diff --git a/mbed-os-to-arduino b/mbed-os-to-arduino index 87143d3ce..d919715ee 100755 --- a/mbed-os-to-arduino +++ b/mbed-os-to-arduino @@ -227,18 +227,6 @@ generate_flags () { sed -i 's/LENGTH = 0x200000/LENGTH = CM4_BINARY_END - CM4_BINARY_START/g' "$ARDUINOVARIANT"/linker_script.ld sed -i 's/LENGTH = 0x1c0000/LENGTH = CM4_BINARY_START - 0x8040000/g' "$ARDUINOVARIANT"/linker_script.ld fi - if [[ $ARDUINOVARIANT == *NANO_RP2040* ]]; then - set +e - HAS_2NDSTAGE_SECTION=`grep second_stage_ota "$ARDUINOVARIANT"/linker_script.ld` - set -e - if [ x"$HAS_2NDSTAGE_SECTION" == x ]; then - echo "Adding second stage bootloader section to Nano RP2040 Connect" - SECOND_STAGE_SECTION=".second_stage_ota : {\n \ - KEEP (*(.second_stage_ota))\n \ - } > FLASH" - sed -i "s?.flash_begin?${SECOND_STAGE_SECTION}\n .flash_begin?g" $ARDUINOVARIANT/linker_script.ld - fi - fi done echo " done." } diff --git a/mbed-os-to-arduino-macos b/mbed-os-to-arduino-macos index 077a4d7d0..bd745a976 100755 --- a/mbed-os-to-arduino-macos +++ b/mbed-os-to-arduino-macos @@ -253,18 +253,6 @@ generate_flags () { gsed -i 's/LENGTH = 0x200000/LENGTH = CM4_BINARY_END - CM4_BINARY_START/g' "$ARDUINOVARIANT"/linker_script.ld gsed -i 's/LENGTH = 0x1c0000/LENGTH = CM4_BINARY_START - 0x8040000/g' "$ARDUINOVARIANT"/linker_script.ld fi - if [[ $ARDUINOVARIANT == *NANO_RP2040* ]]; then - set +e - HAS_2NDSTAGE_SECTION=`grep second_stage_ota "$ARDUINOVARIANT"/linker_script.ld` - set -e - if [ x"$HAS_2NDSTAGE_SECTION" == x ]; then - echo "Adding second stage bootloader section to Nano RP2040 Connect" - SECOND_STAGE_SECTION=".second_stage_ota : {\n \ - KEEP (*(.second_stage_ota))\n \ - } > FLASH" - gsed -i "s?.flash_begin?${SECOND_STAGE_SECTION}\n .flash_begin?g" $ARDUINOVARIANT/linker_script.ld - fi - fi done echo " done." } diff --git a/patches/0235-RP2040-add-second_stage_ota-section-to-linker-script.patch b/patches/0235-RP2040-add-second_stage_ota-section-to-linker-script.patch new file mode 100644 index 000000000..875ba721b --- /dev/null +++ b/patches/0235-RP2040-add-second_stage_ota-section-to-linker-script.patch @@ -0,0 +1,28 @@ +From 9819fef4bdb417e3ff9aee08266264b6ec23e075 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Wed, 11 Sep 2024 12:24:01 +0200 +Subject: [PATCH 235/236] RP2040: add second_stage_ota section to linker script + + - This was previously done inside mbed-os-to-arduino script +--- + .../TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld +index ec8bac7e40..8295f3269d 100644 +--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld ++++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld +@@ -54,6 +54,10 @@ SECTIONS + __flash_binary_start = .; + } > FLASH + ++ .second_stage_ota : { ++ KEEP (*(.second_stage_ota)) ++ } > FLASH ++ + .boot2 : { + __boot2_start__ = .; + KEEP (*(.boot2)) +-- +2.45.2 + diff --git a/patches/0236-RP2040-add-simbols-to-linker-script-to-compute-.unin.patch b/patches/0236-RP2040-add-simbols-to-linker-script-to-compute-.unin.patch new file mode 100644 index 000000000..df9c8a642 --- /dev/null +++ b/patches/0236-RP2040-add-simbols-to-linker-script-to-compute-.unin.patch @@ -0,0 +1,27 @@ +From 35b0d95199cb5b9cda593ce4b4029c4306906ccd Mon Sep 17 00:00:00 2001 +From: pennam +Date: Wed, 11 Sep 2024 12:27:03 +0200 +Subject: [PATCH 236/236] RP2040: add simbols to linker script to compute + .uninitialized_data section size + +--- + .../TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld +index 8295f3269d..b748bab5fa 100644 +--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld ++++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld +@@ -183,7 +183,9 @@ SECTIONS + + .uninitialized_data (COPY): { + . = ALIGN(4); ++ __uninitialized_data_start__ = .; + *(.uninitialized_data*) ++ __uninitialized_data_end__ = .; + } > RAM + + /* Start and end symbols must be word-aligned */ +-- +2.45.2 + diff --git a/variants/NANO_RP2040_CONNECT/conf/mbed_app.json b/variants/NANO_RP2040_CONNECT/conf/mbed_app.json index 839285b81..8cd4676b8 100644 --- a/variants/NANO_RP2040_CONNECT/conf/mbed_app.json +++ b/variants/NANO_RP2040_CONNECT/conf/mbed_app.json @@ -2,7 +2,7 @@ "target_overrides": { "*": { "target.printf_lib": "std", - "target.macros_add": [ "MBEDTLS_ENTROPY_NV_SEED" ], + "target.macros_add": [ "MBEDTLS_ENTROPY_NV_SEED", "UNINITIALIZED_DATA_SECTION=1" ], "platform.stdio-buffered-serial": false, "platform.stdio-baud-rate": 115200, "platform.default-serial-baud-rate": 115200,