File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -313,11 +313,13 @@ else
313313 $(Q)$(DFU_UTIL) -a 0 -d $(DEVICE) -D $<
314314endif
315315
316+ TEXT_ADDR ?= 0x08020000
317+
316318deploy-stlink : $(BUILD ) /firmware.dfu
317319 $(ECHO ) " Writing $( BUILD) /firmware0.bin to the board via ST-LINK"
318320 $(Q )$(STFLASH ) write $(BUILD ) /firmware0.bin 0x08000000
319321 $(ECHO ) " Writing $( BUILD) /firmware1.bin to the board via ST-LINK"
320- $(Q )$(STFLASH ) --reset write $(BUILD ) /firmware1.bin 0x08020000
322+ $(Q )$(STFLASH ) --reset write $(BUILD ) /firmware1.bin $( TEXT_ADDR )
321323
322324deploy-openocd : $(BUILD ) /firmware.dfu
323325 $(ECHO ) " Writing $( BUILD) /firmware{0,1}.bin to the board via ST-LINK using OpenOCD"
@@ -327,7 +329,7 @@ $(BUILD)/firmware.dfu: $(BUILD)/firmware.elf
327329 $(ECHO ) " Create $@ "
328330 $(Q )$(OBJCOPY ) -O binary -j .isr_vector $^ $(BUILD ) /firmware0.bin
329331 $(Q )$(OBJCOPY ) -O binary -j .text -j .data $^ $(BUILD ) /firmware1.bin
330- $(Q )$(PYTHON ) $(DFU ) -b 0x08000000:$(BUILD ) /firmware0.bin -b 0x08020000 :$(BUILD ) /firmware1.bin $@
332+ $(Q )$(PYTHON ) $(DFU ) -b 0x08000000:$(BUILD ) /firmware0.bin -b $( TEXT_ADDR ) :$(BUILD ) /firmware1.bin $@
331333
332334$(BUILD ) /firmware.hex : $(BUILD ) /firmware.elf
333335 $(ECHO ) " Create $@ "
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ MCU_SERIES = l4
22CMSIS_MCU = STM32L476xx
33AF_FILE = boards/stm32l476_af.csv
44LD_FILE = boards/stm32l476xe.ld
5+ TEXT_ADDR = 0x08004000
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ MCU_SERIES = l4
22CMSIS_MCU = STM32L476xx
33AF_FILE = boards/stm32l476_af.csv
44LD_FILE = boards/stm32l476xg.ld
5+ TEXT_ADDR = 0x08004000
Original file line number Diff line number Diff line change 66MEMORY
77{
88 FLASH (rx) : ORIGIN = 0x08000000 , LENGTH = 512K
9- FLASH_ISR (rx) : ORIGIN = 0x08000000 , LENGTH = 0x0000800 /* sector 0, 2 KiB */
10- FLASH_FS ( r) : ORIGIN = 0x08000800 , LENGTH = 0x001F800 /* sectors 1-63 (2K each = 126 KiB) */
11- FLASH_TEXT ( rx) : ORIGIN = 0x08020000 , LENGTH = 0x0060000 /* Sector starting @ 64 */
9+ FLASH_ISR (rx) : ORIGIN = 0x08000000 , LENGTH = 0x0004000 /* sectors 0-7, 16 KiB */
10+ FLASH_TEXT ( rx) : ORIGIN = 0x08004000 , LENGTH = 0x005C000 /* sectors 8-191, 368 KiB */
11+ FLASH_FS ( r) : ORIGIN = 0x08060000 , LENGTH = 0x0020000 /* sectors 192-255, 128 KiB */
1212 RAM (xrw) : ORIGIN = 0x20000000 , LENGTH = 96K
1313 SRAM2 (xrw) : ORIGIN = 0x10000000 , LENGTH = 32K
1414}
@@ -30,3 +30,6 @@ _ram_start = ORIGIN(RAM);
3030_ram_end = ORIGIN (RAM ) + LENGTH (RAM );
3131_heap_start = _ebss; /* heap starts just after statically allocated memory */
3232_heap_end = 0x20014000 ; /* tunable */
33+
34+ _flash_fs_start = ORIGIN (FLASH_FS );
35+ _flash_fs_end = ORIGIN (FLASH_FS ) + LENGTH (FLASH_FS );
Original file line number Diff line number Diff line change 66MEMORY
77{
88 FLASH (rx) : ORIGIN = 0x08000000 , LENGTH = 1024K
9- FLASH_ISR (rx) : ORIGIN = 0x08000000 , LENGTH = 0x0000800 /* sector 0, 2 KiB */
10- FLASH_FS ( r) : ORIGIN = 0x08000800 , LENGTH = 0x001F800 /* sectors 1-63 (2K each = 126 KiB) */
11- FLASH_TEXT ( rx) : ORIGIN = 0x08020000 , LENGTH = 0x0080000 /* Sector starting @ 64 */
9+ FLASH_ISR (rx) : ORIGIN = 0x08000000 , LENGTH = 0x0004000 /* sectors 0-7, 16 KiB */
10+ FLASH_TEXT ( rx) : ORIGIN = 0x08004000 , LENGTH = 0x007C000 /* sectors 8-255, 496 KiB */
11+ FLASH_FS ( r) : ORIGIN = 0x08080000 , LENGTH = 0x0080000 /* sectors 256-511 512 KiB */
1212 RAM (xrw) : ORIGIN = 0x20000000 , LENGTH = 96K
1313 SRAM2 (xrw) : ORIGIN = 0x10000000 , LENGTH = 32K
1414}
@@ -32,3 +32,6 @@ _ram_start = ORIGIN(RAM);
3232_ram_end = ORIGIN (RAM ) + LENGTH (RAM );
3333_heap_start = _ebss; /* heap starts just after statically allocated memory */
3434_heap_end = 0x20014000 ; /* tunable */
35+
36+ _flash_fs_start = ORIGIN (FLASH_FS );
37+ _flash_fs_end = ORIGIN (FLASH_FS ) + LENGTH (FLASH_FS );
Original file line number Diff line number Diff line change @@ -86,11 +86,14 @@ STATIC byte flash_cache_mem[0x4000] __attribute__((aligned(4))); // 16k
8686
8787#elif defined(STM32L476xx )
8888
89+ extern uint8_t _flash_fs_start ;
90+ extern uint8_t _flash_fs_end ;
91+
8992// The STM32L476 doesn't have CCRAM, so we use the 32K SRAM2 for this.
9093#define CACHE_MEM_START_ADDR (0x10000000) // SRAM2 data RAM, 32k
9194#define FLASH_SECTOR_SIZE_MAX (0x00800) // 2k max
92- #define FLASH_MEM_SEG1_START_ADDR (0x08000800) // sector 1
93- #define FLASH_MEM_SEG1_NUM_BLOCKS (252) // 1 Block= 512 Bytes Reserve 126 kBytes
95+ #define FLASH_MEM_SEG1_START_ADDR ((long)&_flash_fs_start)
96+ #define FLASH_MEM_SEG1_NUM_BLOCKS ((&_flash_fs_end - &_flash_fs_start) / 512)
9497
9598#else
9699#error "no storage support for this MCU"
You can’t perform that action at this time.
0 commit comments