kopia lustrzana https://github.com/solokeys/solo1
Initial modification to move bootloader data after the application
rodzic
efddd2f3a8
commit
35e52f4968
|
@ -62,11 +62,6 @@ static void erase_application()
|
|||
}
|
||||
}
|
||||
|
||||
#define LAST_ADDR (APPLICATION_END_ADDR-2048 + 8)
|
||||
#define VERSION_ADDR (AUTH_WORD_ADDR-8)
|
||||
#define BOOT_VERSION_PAGE (APPLICATION_START_PAGE-1)
|
||||
#define BOOT_VERSION_ADDR (0x08000000 + BOOT_VERSION_PAGE*FLASH_PAGE_SIZE)
|
||||
#define LAST_PAGE (APPLICATION_END_PAGE-1)
|
||||
static void disable_bootloader()
|
||||
{
|
||||
// Clear last 4 bytes of the last application page-1, which is 108th
|
||||
|
|
|
@ -14,15 +14,15 @@ _MIN_STACK_SIZE = 0x400;
|
|||
|
||||
/*
|
||||
flash2 is for storing bootloader data, like last used firmware version.
|
||||
_bconfig_start should be equal to (APPLICATION_START_PAGE-1) page address, from targets/stm32l432/src/memory_layout.h:30; and equal to flash2 origin
|
||||
_bconfig_start should be equal to (APPLICATION_END_PAGE) page address, from targets/stm32l432/src/memory_layout.h:30; and equal to flash2 origin
|
||||
*/
|
||||
|
||||
_bconfig_start = 0x08000000 + 10*2048;
|
||||
_bconfig_start = 0x08000000 + 216*1024;
|
||||
|
||||
MEMORY
|
||||
{
|
||||
flash (rx) : ORIGIN = 0x08000000, LENGTH = 20K
|
||||
flash2 (rx) : ORIGIN = 0x08000000 + 10*2048, LENGTH = 2K
|
||||
flash2 (rx) : ORIGIN = 0x08000000 + 216*1024, LENGTH = 2K
|
||||
ram (xrw) : ORIGIN = 0x20000000, LENGTH = 48K
|
||||
sram2 (rw) : ORIGIN = 0x10000000, LENGTH = 16K
|
||||
}
|
||||
|
|
|
@ -16,21 +16,27 @@ _MIN_STACK_SIZE = 0x400;
|
|||
Memory layout of device:
|
||||
20+2 KB 198KB-2KB -8 38 KB
|
||||
| bootloader | application | secrets/data |
|
||||
----------->
|
||||
len | 20 KB/10p| 196KB-8-8/98p | 8B | 2kB/1p | 38 KB/19p |
|
||||
pos | 0->20 KB | 20->216KB-8-8 | 216KB-8-8->216KB-8 | 216kB -> 218 kB | 218->256 KB |
|
||||
posp | 0-10 | 10-113 | 113-113 | 113-114 | 113-128 |
|
||||
desc | bootloader | application | firmware version | bootloader data | secrets/data |
|
||||
|
||||
Last 8 bytes in application space are occupied by bootloader flags - app
|
||||
authorization and bootloader activation flag.
|
||||
Previous 8 bytes are application version.
|
||||
*/
|
||||
|
||||
/* Current firmware version number
|
||||
Should be equal to (APPLICATION_END_ADDR-8) from targets/stm32l432/src/memory_layout.h:40 */
|
||||
_version_start = 0x08000000 + (128-19)*2048-8-8;
|
||||
_version_start = 0x08000000 + 216*1024-8-8;
|
||||
|
||||
/* flash length is (APPLICATION_END_PAGE-20*1024), where 20K is bootloader */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
flash (rx) : ORIGIN = 0x08005000 + 2K, LENGTH = 198K - 8 - 8 - 2K
|
||||
flash_v (rx) : ORIGIN = 0x08000000 + (128-19)*2048 - 8 - 8, LENGTH = 8
|
||||
flash (rx) : ORIGIN = 0x08000000 + 20K, LENGTH = 196K - 8 - 8
|
||||
flash_v (r) : ORIGIN = 0x08000000 + 196K - 8 - 8, LENGTH = 8
|
||||
ram (xrw) : ORIGIN = 0x20000000, LENGTH = 48K
|
||||
sram2 (rw) : ORIGIN = 0x10000000, LENGTH = 16K
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
// Start of application code
|
||||
#ifndef APPLICATION_START_PAGE
|
||||
#define APPLICATION_START_PAGE (11)
|
||||
#define APPLICATION_START_PAGE (10)
|
||||
#endif
|
||||
#define APPLICATION_START_ADDR (0x08000000 + ((APPLICATION_START_PAGE)*PAGE_SIZE))
|
||||
|
||||
|
@ -37,10 +37,31 @@
|
|||
|
||||
// End of application code. Leave some extra room for future data storage.
|
||||
// NOT included in application
|
||||
#define APPLICATION_END_PAGE ((PAGES - 19))
|
||||
#define APPLICATION_END_PAGE ((PAGES - 20))
|
||||
#define APPLICATION_END_ADDR ((0x08000000 + ((APPLICATION_END_PAGE)*PAGE_SIZE))-8)
|
||||
|
||||
// Bootloader state.
|
||||
#define AUTH_WORD_ADDR (APPLICATION_END_ADDR)
|
||||
|
||||
#define LAST_ADDR (APPLICATION_END_ADDR-2048 + 8)
|
||||
#define VERSION_ADDR (AUTH_WORD_ADDR-8)
|
||||
#define BOOT_VERSION_PAGE (APPLICATION_END_PAGE)
|
||||
#define BOOT_VERSION_ADDR (0x08000000 + BOOT_VERSION_PAGE*FLASH_PAGE_SIZE)
|
||||
#define LAST_PAGE (APPLICATION_END_PAGE-1)
|
||||
|
||||
|
||||
struct flash_memory_st{
|
||||
uint8_t bootloader[20*1024];
|
||||
uint8_t application[196*1024-16];
|
||||
uint8_t app_version[8];
|
||||
uint8_t auth_word[8];
|
||||
uint8_t bootloader_data[2*1024];
|
||||
uint8_t user_data[38*1024];
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef struct flash_memory_st flash_memory_st;
|
||||
|
||||
static_assert(sizeof(flash_memory_st) == 256*1024, "Data structure doesn't match flash size");
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue