From d47662c4487ee388f8e47a283c2b7db7d60239fe Mon Sep 17 00:00:00 2001 From: KurtE Date: Mon, 23 May 2022 17:29:46 -0700 Subject: [PATCH] Teensy Builds retain Filesystem Changed a few things in the link step that satisfies the teensy loader apps, both the teensy.exe as well as the teensy_loader_cli such that when you program the board again it should retain the file sytem that is stored in the upper area of the Flash --- .../boards/sparkfun_teensy_micromod/flash_config.c | 6 ++++-- ports/mimxrt10xx/boards/teensy40/flash_config.c | 6 ++++-- ports/mimxrt10xx/boards/teensy41/flash_config.c | 6 ++++-- ports/mimxrt10xx/linking/common.ld | 3 ++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ports/mimxrt10xx/boards/sparkfun_teensy_micromod/flash_config.c b/ports/mimxrt10xx/boards/sparkfun_teensy_micromod/flash_config.c index 09886dece6..e0f5a5bd7d 100644 --- a/ports/mimxrt10xx/boards/sparkfun_teensy_micromod/flash_config.c +++ b/ports/mimxrt10xx/boards/sparkfun_teensy_micromod/flash_config.c @@ -15,7 +15,7 @@ __attribute__((section(".boot_hdr.ivt"))) * IVT Data *************************************/ const ivt image_vector_table = { - IVT_HEADER, /* IVT Header */ + 0x432000D1, /* Teensy bootloader looks for this value*/ IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ IVT_RSVD, /* Reserved = 0 */ (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ @@ -25,13 +25,15 @@ const ivt image_vector_table = { IVT_RSVD /* Reserved = 0 */ }; +extern unsigned long _flashimagelen; + __attribute__((section(".boot_hdr.boot_data"))) /************************************* * Boot Data *************************************/ const BOOT_DATA_T boot_data = { FLASH_BASE, /* boot start location */ - FLASH_SIZE, /* size */ + (uint32_t)&_flashimagelen, /* actual size of image */ PLUGIN_FLAG, /* Plugin flag*/ 0xFFFFFFFF /* empty - extra data word */ }; diff --git a/ports/mimxrt10xx/boards/teensy40/flash_config.c b/ports/mimxrt10xx/boards/teensy40/flash_config.c index 3f4ab0271d..d878124b40 100644 --- a/ports/mimxrt10xx/boards/teensy40/flash_config.c +++ b/ports/mimxrt10xx/boards/teensy40/flash_config.c @@ -15,7 +15,7 @@ __attribute__((section(".boot_hdr.ivt"))) * IVT Data *************************************/ const ivt image_vector_table = { - IVT_HEADER, /* IVT Header */ + 0x432000D1, /* Teensy bootloader looks for this value*/ IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ IVT_RSVD, /* Reserved = 0 */ (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ @@ -25,13 +25,15 @@ const ivt image_vector_table = { IVT_RSVD /* Reserved = 0 */ }; +extern unsigned long _flashimagelen; + __attribute__((section(".boot_hdr.boot_data"))) /************************************* * Boot Data *************************************/ const BOOT_DATA_T boot_data = { FLASH_BASE, /* boot start location */ - FLASH_SIZE, /* size */ + (uint32_t)&_flashimagelen, /* actual size of image */ PLUGIN_FLAG, /* Plugin flag*/ 0xFFFFFFFF /* empty - extra data word */ }; diff --git a/ports/mimxrt10xx/boards/teensy41/flash_config.c b/ports/mimxrt10xx/boards/teensy41/flash_config.c index 09886dece6..e0f5a5bd7d 100644 --- a/ports/mimxrt10xx/boards/teensy41/flash_config.c +++ b/ports/mimxrt10xx/boards/teensy41/flash_config.c @@ -15,7 +15,7 @@ __attribute__((section(".boot_hdr.ivt"))) * IVT Data *************************************/ const ivt image_vector_table = { - IVT_HEADER, /* IVT Header */ + 0x432000D1, /* Teensy bootloader looks for this value*/ IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ IVT_RSVD, /* Reserved = 0 */ (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ @@ -25,13 +25,15 @@ const ivt image_vector_table = { IVT_RSVD /* Reserved = 0 */ }; +extern unsigned long _flashimagelen; + __attribute__((section(".boot_hdr.boot_data"))) /************************************* * Boot Data *************************************/ const BOOT_DATA_T boot_data = { FLASH_BASE, /* boot start location */ - FLASH_SIZE, /* size */ + (uint32_t)&_flashimagelen, /* actual size of image */ PLUGIN_FLAG, /* Plugin flag*/ 0xFFFFFFFF /* empty - extra data word */ }; diff --git a/ports/mimxrt10xx/linking/common.ld b/ports/mimxrt10xx/linking/common.ld index 44e8d537c4..b6f1acc8d0 100644 --- a/ports/mimxrt10xx/linking/common.ld +++ b/ports/mimxrt10xx/linking/common.ld @@ -74,7 +74,6 @@ SECTIONS _etext = .; /* define a global symbol at end of code */ __etext = .; /* define a global symbol at end of code */ } > FLASH_FIRMWARE - _ld_filesystem_start = ORIGIN(FLASH_FATFS); _ld_filesystem_end = _ld_filesystem_start + LENGTH(FLASH_FATFS); @@ -127,6 +126,8 @@ SECTIONS _ld_dtcm_data_flash_copy = LOADADDR(.dtcm_data); _ld_dtcm_data_size = SIZEOF(.dtcm_data); + _flashimagelen = _ld_dtcm_data_flash_copy + _ld_dtcm_data_size - flash_config_location; + .dtcm_bss : { . = ALIGN(4);