Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created a test case for CNC/Full Sized Rambo #16120

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
70 changes: 45 additions & 25 deletions Marlin/src/HAL/HAL_STM32F1/persistent_store_flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,53 +40,73 @@
#include <EEPROM.h>

// Store settings in the last two pages
// Flash pages must be erased before writing, so keep track.
bool firstWrite = false;
#define EEPROM_SIZE (EEPROM_PAGE_SIZE * 2)
#define ACCESS_FINISHED(TF) do{ FLASH_Lock(); eeprom_dirty = false; return TF; }while(0)

static uint8_t ram_eeprom[EEPROM_SIZE] __attribute__((aligned(4))) = {0};
static bool eeprom_dirty = false;

bool PersistentStore::access_start() {
firstWrite = true;
const uint32_t* source = reinterpret_cast<const uint32_t*>(EEPROM_PAGE0_BASE);
uint32_t* destination = reinterpret_cast<uint32_t*>(ram_eeprom);

static_assert(0 == EEPROM_SIZE % 4, "EEPROM_SIZE is corrupted. (Must be a multiple of 4.)"); // Ensure copying as uint32_t is safe
constexpr size_t eeprom_size_u32 = EEPROM_SIZE / 4;

for (size_t i = 0; i < eeprom_size_u32; ++i, ++destination, ++source)
*destination = *source;

eeprom_dirty = false;
return true;
}

bool PersistentStore::access_finish() {
FLASH_Lock();
firstWrite = false;
return true;
}

bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
FLASH_Status status;
if (eeprom_dirty) {
FLASH_Status status;

if (firstWrite) {
// Instead of erasing all (both) pages, maybe in the loop we check what page we are in, and if the
// data has changed in that page. We then erase the first time we "detect" a change. In theory, if
// nothing changed in a page, we wouldn't need to erase/write it.
// Or, instead of checking at this point, turn eeprom_dirty into an array of bool the size of number
// of pages. Inside write_data, we set the flag to true at that time if something in that
// page changes...either way, something to look at later.
FLASH_Unlock();

status = FLASH_ErasePage(EEPROM_PAGE0_BASE);
if (status != FLASH_COMPLETE) return true;
if (status != FLASH_COMPLETE) ACCESS_FINISHED(true);
status = FLASH_ErasePage(EEPROM_PAGE1_BASE);
if (status != FLASH_COMPLETE) return true;
firstWrite = false;
}
if (status != FLASH_COMPLETE) ACCESS_FINISHED(true);

const uint16_t *source = reinterpret_cast<const uint16_t*>(ram_eeprom);
for (size_t i = 0; i < EEPROM_SIZE; i += 2, ++source) {
if (FLASH_ProgramHalfWord(EEPROM_PAGE0_BASE + i, *source) != FLASH_COMPLETE)
ACCESS_FINISHED(false);
}

for (size_t i = 0; i < size; i++) {
if (FLASH_ProgramHalfWord(EEPROM_PAGE0_BASE + (pos + i) * 2, value[i]) != FLASH_COMPLETE)
return true;
ACCESS_FINISHED(true);
}

return true;
}

bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
for (size_t i = 0; i < size; ++i) ram_eeprom[pos + i] = value[i];
eeprom_dirty = true;
crc16(crc, value, size);
pos += size;
return false;
return false; // return true for any error
}

bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) {
for (size_t i = 0; i < size; i++) {
uint8_t v = *(uint16_t *)(EEPROM_PAGE0_BASE + (pos + i) * 2);
if (writing) value[i] = v;
crc16(crc, &v, 1);
}
const uint8_t * const buff = writing ? &value[0] : &ram_eeprom[pos];
if (writing) for (size_t i = 0; i < size; i++) value[i] = ram_eeprom[pos + i];
crc16(crc, buff, size);
pos += size;
return false;
return false; // return true for any error
}

size_t PersistentStore::capacity() { return size_t(E2END + 1); }
size_t PersistentStore::capacity() { return EEPROM_SIZE; }

#endif // EEPROM_SETTINGS && EEPROM FLASH
#endif // __STM32F1__
2 changes: 1 addition & 1 deletion Marlin/src/inc/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2019-12-02"
#define STRING_DISTRIBUTION_DATE "2019-12-04"
#endif

/**
Expand Down
15 changes: 10 additions & 5 deletions Marlin/src/module/configuration_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,11 +788,16 @@ void MarlinSettings::postprocess() {
_FIELD_TEST(hotendPID);
HOTEND_LOOP() {
PIDCF_t pidcf = {
PID_PARAM(Kp, e),
unscalePID_i(PID_PARAM(Ki, e)),
unscalePID_d(PID_PARAM(Kd, e)),
PID_PARAM(Kc, e),
PID_PARAM(Kf, e)
#if DISABLED(PIDTEMP)
DUMMY_PID_VALUE, DUMMY_PID_VALUE, DUMMY_PID_VALUE,
DUMMY_PID_VALUE, DUMMY_PID_VALUE
#else
PID_PARAM(Kp, e),
unscalePID_i(PID_PARAM(Ki, e)),
unscalePID_d(PID_PARAM(Kd, e)),
PID_PARAM(Kc, e),
PID_PARAM(Kf, e)
#endif
};
EEPROM_WRITE(pidcf);
}
Expand Down
29 changes: 29 additions & 0 deletions buildroot/share/tests/rambo-tests
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,34 @@ opt_set Z_DRIVER_TYPE TMC2130
opt_set E0_DRIVER_TYPE TMC2130
exec_test $1 $2 "Default Configuration"

#
# Full size Rambo Dual Endstop CNC
#
restore_configs
opt_set MOTHERBOARD BOARD_RAMBO
opt_set EXTRUDERS 0
opt_set TEMP_SENSOR_0 999
opt_set DUMMY_THERMISTOR_999_VALUE 170
opt_enable USE_XMAX_PLUG
opt_enable USE_YMAX_PLUG
opt_enable USE_ZMAX_PLUG
opt_enable S_CURVE_ACCELEARATION
opt_disable MIN_SOFTWARE_ENDSTOP_Z
opt_disable MAX_SOFTWARE_ENDSTOPS
opt_enable EEPROM_SETTINGS
opt_enable SD_SUPPORT
opt_enable REVERSE_ENCODER_DIRECTION
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
opt_enable X_DUAL_STEPPER_DRIVERS
opt_enable X_DUAL_ENDSTOPS
opt_enable Y_DUAL_STEPPER_DRIVERS
opt_enable Y_DUAL_ENDSTOPS
opt_enable ADAPTIVE_STEP_SMOOTHING
opt_set DIGIPOT_MOTOR_CURRENT { 120, 120, 120, 120, 120 }
opt_enable CNC_COORDINATE_SYSTEMS
opt_enable GCODE_MOTION_MODES

exec_test $1 $2 "Rambo CNC Configuration"

# clean up
restore_configs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@
*
* View the current statistics with M78.
*/
#define PRINTCOUNTER
//#define PRINTCOUNTER

//=============================================================================
//============================= LCD and SD support ============================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@
*
* View the current statistics with M78.
*/
#define PRINTCOUNTER
//#define PRINTCOUNTER

//=============================================================================
//============================= LCD and SD support ============================
Expand Down
10 changes: 4 additions & 6 deletions config/examples/Wanhao/Duplicator 6/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,7 @@
//
// ULTIPANEL as seen on Thingiverse.
//
#define ULTIPANEL
//#define ULTIPANEL

//
// PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
Expand Down Expand Up @@ -1988,10 +1988,7 @@
//
// SSD1306 OLED full graphics generic display
//
#define U8GLIB_SSD1306
#define LCD_WIDTH 22
#define LCD_HEIGHT 5
#define LCD_RESET_PIN 5
//#define U8GLIB_SSD1306

//
// SAV OLEd LCD module support using either SSD1306 or SH1106 based LCD modules
Expand All @@ -2005,7 +2002,8 @@
//
// TinyBoy2 128x64 OLED / Encoder Panel
//
//#define OLED_PANEL_TINYBOY2
#define OLED_PANEL_TINYBOY2
#define LCD_RESET_PIN 5

//
// MKS OLED 1.3" 128 × 64 FULL GRAPHICS CONTROLLER
Expand Down