From f098707021c05f437a80cd2a01d709ed01fb1b5c Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Sun, 10 Jun 2018 00:22:28 +0200 Subject: [PATCH] New ML support - W25X20CL - update process UI tunning --- Firmware/Marlin_main.cpp | 23 +++++++++++++++++------ Firmware/language.c | 2 +- Firmware/language.h | 2 +- Firmware/ultralcd.cpp | 4 ++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index a90c699f..742c4e65 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1001,7 +1001,7 @@ void erase_eeprom_section(uint16_t offset, uint16_t bytes) #define LANGBOOT_BLOCKSIZE 0x1000 #define LANGBOOT_RAMBUFFER 0x0800 -void upgrade_sec_lang_from_external_flash() +void update_sec_lang_from_external_flash() { if ((boot_app_magic == BOOT_APP_MAGIC) && (boot_app_flags & BOOT_APP_FLG_USER0)) { @@ -1011,8 +1011,9 @@ void upgrade_sec_lang_from_external_flash() uint32_t src_addr; if (lang_get_header(lang, &header, &src_addr)) { - fprintf_P(lcdout, PSTR(ESC_H(1,3) "l=%1hhd s=%1hhx %04x %04x"), lang, state, src_addr, header.size); - delay(1000); + fputs_P(PSTR(ESC_H(1,3) "Language update."), lcdout); + for (uint8_t i = 0; i < state; i++) fputc('.', lcdout); + delay(100); boot_reserved = (state + 1) | (lang << 4); if ((state * LANGBOOT_BLOCKSIZE) < header.size) { @@ -1020,10 +1021,17 @@ void upgrade_sec_lang_from_external_flash() uint16_t size = header.size - state * LANGBOOT_BLOCKSIZE; if (size > LANGBOOT_BLOCKSIZE) size = LANGBOOT_BLOCKSIZE; w25x20cl_rd_data(src_addr + state * LANGBOOT_BLOCKSIZE, (uint8_t*)LANGBOOT_RAMBUFFER, size); + if (state == 0) + { + //TODO - check header integrity + } bootapp_ram2flash(LANGBOOT_RAMBUFFER, _SEC_LANG_TABLE + state * LANGBOOT_BLOCKSIZE, size); } else + { + //TODO - check sec lang data integrity eeprom_update_byte((unsigned char *)EEPROM_LANG, LANG_ID_SEC); + } } } boot_app_flags &= ~BOOT_APP_FLG_USER0; @@ -1088,7 +1096,7 @@ void setup() lcd_splash(); if (w25x20cl_init()) - upgrade_sec_lang_from_external_flash(); + update_sec_lang_from_external_flash(); else kill(_i("External SPI flash W25X20CL not responding.")); @@ -1118,6 +1126,7 @@ void setup() SERIAL_ECHO_START; printf_P(PSTR(" " FW_VERSION_FULL "\n")); +#ifdef DEBUG_SEC_LANG lang_table_header_t header; uint32_t src_addr = 0x00000; if (lang_get_header(3, &header, &src_addr)) @@ -1222,6 +1231,8 @@ void setup() SERIAL_ECHOLN("Reading eeprom from 0 to 100: done"); #endif +#endif //DEBUG_SEC_LANG + // Check startup - does nothing if bootloader sets MCUSR to 0 byte mcu = MCUSR; /* if (mcu & 1) SERIAL_ECHOLNRPGM(_T(MSG_POWERUP)); @@ -1486,14 +1497,14 @@ void setup() lang_select(eeprom_read_byte((uint8_t*)EEPROM_LANG)); -//#ifdef DEBUG_SEC_LANG +#ifdef DEBUG_SEC_LANG uint16_t sec_lang_code = lang_get_code(1); uint16_t ui = _SEC_LANG_TABLE; //table pointer printf_P(_n("lang_selected=%d\nlang_table=0x%04x\nSEC_LANG_CODE=0x%04x (%c%c)\n"), lang_selected, ui, sec_lang_code, sec_lang_code >> 8, sec_lang_code & 0xff); // lang_print_sec_lang(uartout); -//#endif //DEBUG_SEC_LANG +#endif //DEBUG_SEC_LANG if (eeprom_read_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE) == 255) { eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0); diff --git a/Firmware/language.c b/Firmware/language.c index fdf42d41..bca123d8 100644 --- a/Firmware/language.c +++ b/Firmware/language.c @@ -197,7 +197,7 @@ uint16_t lang_print_sec_lang(FILE* out) #endif //(LANG_MODE == 0) -void lang_boot_upgrade_start(uint8_t lang) +void lang_boot_update_start(uint8_t lang) { uint8_t cnt = lang_get_count(); if ((lang < 2) || (lang > cnt)) return; //only languages from xflash can be selected diff --git a/Firmware/language.h b/Firmware/language.h index b671388f..5204327d 100644 --- a/Firmware/language.h +++ b/Firmware/language.h @@ -114,7 +114,7 @@ extern const char* lang_get_sec_lang_str_by_id(uint16_t id); extern uint16_t lang_print_sec_lang(FILE* out); #endif //DEBUG_SEC_LANG -extern void lang_boot_upgrade_start(uint8_t lang); +extern void lang_boot_update_start(uint8_t lang); #if defined(__cplusplus) } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index f3af4b95..a51c56c7 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3690,7 +3690,7 @@ static void lcd_set_lang(unsigned char lang) lcd_update_enable(true); return; } - lang_boot_upgrade_start(lang); + lang_boot_update_start(lang); } if (lang_select(lang)) eeprom_update_byte((unsigned char*)EEPROM_LANG, lang); @@ -5432,7 +5432,7 @@ void lcd_confirm_print() static void lcd_test_menu() { - lang_boot_upgrade_start(3); + lang_boot_update_start(3); lcd_update_enable(true); lcd_return_to_status(); }