Add dump firmware option

pull/52/head
DiSlord Live 3 years ago
parent d31a599b1d
commit 5d22b2fcce

@ -91,6 +91,7 @@
#define __USE_RTC__ // Enable RTC clock
#define __USE_SD_CARD__ // Enable SD card support
#define __SD_CARD_LOAD__ // Allow run commands from SD card (config.ini in root)
#define __SD_CARD_DUMP_FIRMWARE__ // Allow dump firmware to SD card
#define __LCD_BRIGHTNESS__ // LCD or hardware allow change brightness, add menu item for this
#define __HARMONIC__
#define __NOISE_FIGURE__
@ -1274,6 +1275,7 @@ extern int linear_averaging;
#else
#define SAVEAREA_MAX 5
#endif
// STM32 minimum page size for write
#define FLASH_PAGESIZE 0x800
// config save area (flash7 addr)
@ -1281,12 +1283,16 @@ extern int linear_averaging;
#define SAVE_CONFIG_ADDR 0x0801D000
#define SAVE_CONFIG_SIZE FLASH_PAGESIZE
#define FLASH_END 0x08020000
#define FLASH_START_ADDRESS 0x08000000
#define FLASH_TOTAL_SIZE (128*1024)
#endif
#ifdef TINYSA4
#define SAVE_CONFIG_ADDR 0x0803C000
#define SAVE_CONFIG_SIZE FLASH_PAGESIZE*2
#define FLASH_END 0x08040000
#define FLASH_START_ADDRESS 0x08000000
#define FLASH_TOTAL_SIZE (256*1024)
#endif
typedef char assert_config[sizeof(config_t)> SAVE_CONFIG_SIZE ? -1 : 1]; // Check config size

91
ui.c

@ -3501,6 +3501,40 @@ static UI_FUNCTION_ADV_CALLBACK(menu_connection_acb)
shell_reset_console();
}
#endif
#ifdef __USE_SD_CARD__
static uint16_t file_mask;
// Save format enum
enum {
FMT_BMP_FILE, FMT_CSV_FILE,
#ifdef __SD_CARD_DUMP_FIRMWARE__
FMT_BIN_FILE,
#endif
//#ifdef __SD_CARD_LOAD__
// FMT_CMD_FILE,
//#endif
};
// Save file extension
static const char *file_ext[] = {
[FMT_BMP_FILE] = "bmp",
[FMT_CSV_FILE] = "csv",
#ifdef __SD_CARD_DUMP_FIRMWARE__
[FMT_BIN_FILE] = "bin",
#endif
//#ifdef __SD_CARD_LOAD__
// [FMT_CMD_FILE] = "cmd",
//#endif
};
static void sa_save_file(char *name, uint8_t format);
static UI_FUNCTION_CALLBACK(menu_sdcard_cb) {
(void)item;
sa_save_file(0, data);
}
#endif
// ===[MENU DEFINITION]=========================================================
// Back button submenu list
@ -3988,6 +4022,9 @@ static const menuitem_t menu_settings[] =
{ MT_CALLBACK, 0 , "LOAD\nCONFIG.INI", menu_load_config_cb},
// { MT_CALLBACK, 1 , "LOAD\nSETTING.INI", menu_load_config_cb},
#endif
#ifdef __SD_CARD_DUMP_FIRMWARE__
{ MT_CALLBACK, FMT_BIN_FILE, "DUMP\nFIRMWARE", menu_sdcard_cb},
#endif
#ifdef TINYSA4
{ MT_ADV_CALLBACK, 0, "INTERNALS", menu_internals_acb},
#endif
@ -6518,31 +6555,6 @@ static int touch_quick_menu(int touch_x, int touch_y)
}
#ifdef __USE_SD_CARD__
static uint16_t file_mask;
// Save format enum
enum {
FMT_BMP_FILE, FMT_CSV_FILE,
//#ifdef __SD_CARD_DUMP_FIRMWARE__
// FMT_BIN_FILE,
//#endif
//#ifdef __SD_CARD_LOAD__
// FMT_CMD_FILE,
//#endif
};
// Save file extension
static const char *file_ext[] = {
[FMT_BMP_FILE] = "bmp",
[FMT_CSV_FILE] = "csv",
//#ifdef __SD_CARD_DUMP_FIRMWARE__
// [FMT_BIN_FILE] = "bin",
//#endif
//#ifdef __SD_CARD_LOAD__
// [FMT_CMD_FILE] = "cmd",
//#endif
};
//*******************************************************************************************
// Bitmap file header for LCD_WIDTH x LCD_HEIGHT image 16bpp (v4 format allow set RGB mask)
//*******************************************************************************************
@ -6674,18 +6686,18 @@ static void sa_save_file(char *name, uint8_t format) {
res = f_write(fs_file, (char *)spi_buffer, buf - (char *)spi_buffer, &size);
}
break;
//#ifdef __SD_CARD_DUMP_FIRMWARE__
// /*
// * Dump firmware to SD card as bin file image
// */
// case FMT_BIN_FILE:
// {
// const char *src = (const char*)FLASH_START_ADDRESS;
// const uint32_t total = FLASH_TOTAL_SIZE;
// res = f_write(fs_file, src, total, &size);
// }
// break;
//#endif
#ifdef __SD_CARD_DUMP_FIRMWARE__
/*
* Dump firmware to SD card as bin file image
*/
case FMT_BIN_FILE:
{
const char *src = (const char*)FLASH_START_ADDRESS;
const uint32_t total = FLASH_TOTAL_SIZE;
res = f_write(fs_file, src, total, &size);
}
break;
#endif
}
f_close(fs_file);
// shell_printf("Close = %d\r\n", res);
@ -6699,11 +6711,6 @@ static void sa_save_file(char *name, uint8_t format) {
ui_mode_normal();
}
static UI_FUNCTION_CALLBACK(menu_sdcard_cb) {
(void)item;
sa_save_file(0, data);
}
static void save_csv(uint8_t mask) {
file_mask = mask;
menu_sdcard_cb(0, FMT_CSV_FILE);

Loading…
Cancel
Save

Powered by TurnKey Linux.