Skip to content

Commit

Permalink
Merge pull request #950 from pennam/pico-rand-fix
Browse files Browse the repository at this point in the history
RP2040: fix OTA and binary size computation
  • Loading branch information
pennam authored Oct 2, 2024
2 parents 931f0bb + b1cde79 commit b7b114e
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 25 deletions.
12 changes: 0 additions & 12 deletions mbed-os-to-arduino
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
Expand Down
12 changes: 0 additions & 12 deletions mbed-os-to-arduino-macos
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 9819fef4bdb417e3ff9aee08266264b6ec23e075 Mon Sep 17 00:00:00 2001
From: pennam <[email protected]>
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

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From 35b0d95199cb5b9cda593ce4b4029c4306906ccd Mon Sep 17 00:00:00 2001
From: pennam <[email protected]>
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

2 changes: 1 addition & 1 deletion variants/NANO_RP2040_CONNECT/conf/mbed_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b7b114e

Please sign in to comment.