New ML support - W25X20CL - update process UI tunning

This commit is contained in:
Robert Pelnar 2018-06-10 00:22:28 +02:00
parent 5de0a6437d
commit f098707021
4 changed files with 21 additions and 10 deletions

View file

@ -1001,7 +1001,7 @@ void erase_eeprom_section(uint16_t offset, uint16_t bytes)
#define LANGBOOT_BLOCKSIZE 0x1000 #define LANGBOOT_BLOCKSIZE 0x1000
#define LANGBOOT_RAMBUFFER 0x0800 #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)) 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; uint32_t src_addr;
if (lang_get_header(lang, &header, &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); fputs_P(PSTR(ESC_H(1,3) "Language update."), lcdout);
delay(1000); for (uint8_t i = 0; i < state; i++) fputc('.', lcdout);
delay(100);
boot_reserved = (state + 1) | (lang << 4); boot_reserved = (state + 1) | (lang << 4);
if ((state * LANGBOOT_BLOCKSIZE) < header.size) 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; uint16_t size = header.size - state * LANGBOOT_BLOCKSIZE;
if (size > LANGBOOT_BLOCKSIZE) size = LANGBOOT_BLOCKSIZE; if (size > LANGBOOT_BLOCKSIZE) size = LANGBOOT_BLOCKSIZE;
w25x20cl_rd_data(src_addr + state * LANGBOOT_BLOCKSIZE, (uint8_t*)LANGBOOT_RAMBUFFER, size); 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); bootapp_ram2flash(LANGBOOT_RAMBUFFER, _SEC_LANG_TABLE + state * LANGBOOT_BLOCKSIZE, size);
} }
else else
{
//TODO - check sec lang data integrity
eeprom_update_byte((unsigned char *)EEPROM_LANG, LANG_ID_SEC); eeprom_update_byte((unsigned char *)EEPROM_LANG, LANG_ID_SEC);
}
} }
} }
boot_app_flags &= ~BOOT_APP_FLG_USER0; boot_app_flags &= ~BOOT_APP_FLG_USER0;
@ -1088,7 +1096,7 @@ void setup()
lcd_splash(); lcd_splash();
if (w25x20cl_init()) if (w25x20cl_init())
upgrade_sec_lang_from_external_flash(); update_sec_lang_from_external_flash();
else else
kill(_i("External SPI flash W25X20CL not responding.")); kill(_i("External SPI flash W25X20CL not responding."));
@ -1118,6 +1126,7 @@ void setup()
SERIAL_ECHO_START; SERIAL_ECHO_START;
printf_P(PSTR(" " FW_VERSION_FULL "\n")); printf_P(PSTR(" " FW_VERSION_FULL "\n"));
#ifdef DEBUG_SEC_LANG
lang_table_header_t header; lang_table_header_t header;
uint32_t src_addr = 0x00000; uint32_t src_addr = 0x00000;
if (lang_get_header(3, &header, &src_addr)) if (lang_get_header(3, &header, &src_addr))
@ -1222,6 +1231,8 @@ void setup()
SERIAL_ECHOLN("Reading eeprom from 0 to 100: done"); SERIAL_ECHOLN("Reading eeprom from 0 to 100: done");
#endif #endif
#endif //DEBUG_SEC_LANG
// Check startup - does nothing if bootloader sets MCUSR to 0 // Check startup - does nothing if bootloader sets MCUSR to 0
byte mcu = MCUSR; byte mcu = MCUSR;
/* if (mcu & 1) SERIAL_ECHOLNRPGM(_T(MSG_POWERUP)); /* if (mcu & 1) SERIAL_ECHOLNRPGM(_T(MSG_POWERUP));
@ -1486,14 +1497,14 @@ void setup()
lang_select(eeprom_read_byte((uint8_t*)EEPROM_LANG)); 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 sec_lang_code = lang_get_code(1);
uint16_t ui = _SEC_LANG_TABLE; //table pointer 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); 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); // lang_print_sec_lang(uartout);
//#endif //DEBUG_SEC_LANG #endif //DEBUG_SEC_LANG
if (eeprom_read_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE) == 255) { if (eeprom_read_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE) == 255) {
eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0); eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0);

View file

@ -197,7 +197,7 @@ uint16_t lang_print_sec_lang(FILE* out)
#endif //(LANG_MODE == 0) #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(); uint8_t cnt = lang_get_count();
if ((lang < 2) || (lang > cnt)) return; //only languages from xflash can be selected if ((lang < 2) || (lang > cnt)) return; //only languages from xflash can be selected

View file

@ -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); extern uint16_t lang_print_sec_lang(FILE* out);
#endif //DEBUG_SEC_LANG #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) #if defined(__cplusplus)
} }

View file

@ -3690,7 +3690,7 @@ static void lcd_set_lang(unsigned char lang)
lcd_update_enable(true); lcd_update_enable(true);
return; return;
} }
lang_boot_upgrade_start(lang); lang_boot_update_start(lang);
} }
if (lang_select(lang)) if (lang_select(lang))
eeprom_update_byte((unsigned char*)EEPROM_LANG, lang); eeprom_update_byte((unsigned char*)EEPROM_LANG, lang);
@ -5432,7 +5432,7 @@ void lcd_confirm_print()
static void lcd_test_menu() static void lcd_test_menu()
{ {
lang_boot_upgrade_start(3); lang_boot_update_start(3);
lcd_update_enable(true); lcd_update_enable(true);
lcd_return_to_status(); lcd_return_to_status();
} }