pico_set_persistent_data_loc causes incorrect RAM usage calculation in memory report (SDK 2.3.0 & 2.3.1) #3184
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#3184
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Issue
When using
__persistent_dataand overriding its placement viapico_set_persistent_data_loc(), the generated build memory report incorrectly calculates total RAM usage.0x20040000) causes the memory reporter script/tool to include the memory gap into the total used RAM, artificially inflating the reported usage.__persistent_dataare completely excluded/ignored from theRAMused size calculation, reporting lower memory usage than actual.To Reproduce
__persistent_data:CMakeLists.txt:Expected behavior
The memory report should accurately account for the 16 KB allocated in RAM under the
RAMrow (or a dedicatedPERSISTENTmemory region row), without inflating usage due to section gaps or omitting the section entirely.Build Output Logs
Baseline (without
__persistent_data):SDK 2.3.1 Output (Omits persistent data from RAM calculation):
RAMreported drops from 102520 B to 86136 B (102520 B - 16384 B = 86136 B), completely ignoring the 16 KB array.SDK 2.3.0 Output (Includes offset gap into RAM calculation):
RAMreported jumps to 280600 B due to the absolute address offset.Environment Information
"the generated build memory report incorrectly calculates total RAM usage"
What report is this? What script is generating this?
It's the
--print-memory-usagereport from the linkerI believe this is caused by https://github.com/raspberrypi/pico-sdk/pull/3109 - in SDK 2.3.0 the heap was being placed above persistent data in this circumstance(which was incorrect), causing all of that
RAMto be counted as used. With that PR, the heap is correctly placed before persistent data, so theRAMis showing as unused above the heap.I'm not sure why the
.persistent_datasection isn't appearing in--print-memory-usage- my guess would be it's because the location counter gets moved backwards after it was placed, which causes--print-memory-usageto miss it. This doesn't occur for.persistent_dataplaced at a fixed address in XIP SRAM.It looks like this might not be possible to fix -
--print-memory-usagelooks at the final value of the location counter, so will treat the holes that placing.persistent_datacreates as used space if the heap is above it (sram0 case), or will not include.persistent_dataif the heap is below it (sram1 case, as the final value of the location counter has been moved back).It might be possible to revert it to the 2.3.0 behaviour with some extra linker bits, but I don’t think that is worth it, given the current memory usage printout is a more realistic view of the situation. Instead, I think I will add some docs to
pico_set_persistent_data_locto describe this behaviour.@JoaoBortolace I've opened #3191 to fix the docs here