Skip to content

Commit f85b638

Browse files
committed
Fix mbed-os-to-arduino for PortentaH7
dtcm section added too; can be used with int testdtcm __attribute__((section (".dtcm"))) = 42; /* copy *dtcm from flash to DTCM */ extern uintptr_t _dtcm_lma; extern uintptr_t _sdtcm; extern uintptr_t _edtcm; volatile uint8_t *dst = (volatile uint8_t *)&_sdtcm; volatile uint8_t *src = (volatile uint8_t *)&_dtcm_lma; while ((uintptr_t)dst < (uintptr_t)&_edtcm) { *dst++ = *src++; } Serial.println(testdtcm); // will print 42 Serial.println((uintptr_t)&testdtcm, HEX); // will print somethin in rang 0x20000000
1 parent 4cf572f commit f85b638

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

mbed-os-to-arduino

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,21 @@ generate_flags () {
198198
.pdm_section (NOLOAD) : {\n \
199199
. = ABSOLUTE(0x3800FC00);\n \
200200
*(.pdm_buffer)\n \
201-
} > RAM_D3"
201+
} > RAM_D3\n \
202+
_dtcm_lma = __etext + SIZEOF(.data);\n \
203+
.dtcm : AT(_dtcm_lma) {\n \
204+
_sdtcm = .;\n \
205+
*(.dtcm*)\n \
206+
_edtcm = .;\n \
207+
} > DTCMRAM"
202208
sed -i "s?.heap (COPY):?${OPENAMP_SECTION}\n .heap (COPY):?g" $ARDUINOVARIANT/linker_script.ld
203209
OPENAMP_REGIONS="__OPENAMP_region_start__ = 0x38000400;\n__OPENAMP_region_end__ = 0x38000400 + LENGTH(RAM_D3) - 1K;"
204210
sed -i "s?ENTRY(Reset_Handler)?${OPENAMP_REGIONS}\nENTRY(Reset_Handler)?g" $ARDUINOVARIANT/linker_script.ld
205211
fi
206212
echo "Patching linker scripts"
207213
sed -i 's/0x8100000/CM4_BINARY_START/g' "$ARDUINOVARIANT"/linker_script.ld
208-
sed -i 's/LENGTH = 0x100000/LENGTH = CM4_BINARY_END - CM4_BINARY_START/g' "$ARDUINOVARIANT"/linker_script.ld
209-
sed -i 's/LENGTH = 0xc0000/LENGTH = CM4_BINARY_START - 0x8040000/g' "$ARDUINOVARIANT"/linker_script.ld
214+
sed -i 's/LENGTH = 0x200000/LENGTH = CM4_BINARY_END - CM4_BINARY_START/g' "$ARDUINOVARIANT"/linker_script.ld
215+
sed -i 's/LENGTH = 0x1c0000/LENGTH = CM4_BINARY_START - 0x8040000/g' "$ARDUINOVARIANT"/linker_script.ld
210216
fi
211217
if [[ $ARDUINOVARIANT == *NANO_RP2040* ]]; then
212218
set +e

0 commit comments

Comments
 (0)