Hi,
I'm working with a nRF54L15 within the nRF Connect SDK on Zephyr. I need an array which retains its content through soft resets, so in another RAM section than the usual bss/data. I'm familiar with doing this on projects where I have full control over linker scripts and the likes and used to do this on nRF52 without any issue, but I'm new to Zephyr.
I found this Q/A and the appropriate zephyr macro to achieve this, and it works well. The issue is that my array not only takes up RAM, but also Flash, which doesn't make sense as it's just a static array with no initialization values.
Here's how it's declared:
#include <zephyr/linker/section_tags.h> #include <zephyr/toolchain.h> #include <stdint.h> static __noinit uint8_t persistent_array[24*1024]; static __noinit uint32_t persistent_crc32; // .. some functions to read/write in this array
And here's the output of `size -A zephyr.elf`:
build/zephyr/zephyr.elf : section size addr rom_start 1148 0 text 155692 1152 .ARM.exidx 8 156844 initlevel 168 156852 device_area 160 157020 sw_isr_table 2168 157180 _static_thread_data_area 48 159352 bt_l2cap_fixed_chan_area 36 159400 bt_conn_cb_area 32 159436 bt_gatt_service_static_area 48 159468 settings_handler_static_area 120 159516 tbss 8 159636 rodata 12600 159648 .ramfunc 0 536870912 datas 2332 536870912 device_states 16 536873244 k_mem_slab_area 84 536873260 k_mutex_area 120 536873344 k_msgq_area 48 536873464 k_sem_area 24 536873512 k_event_area 24 536873536 k_fifo_area 24 536873560 net_buf_pool_area 308 536873584 ._NOINIT_SECTION_NAME."CMAKE_SOURCE_DIR/src/dummy/dummy_array.c".1 4 536873892 ._NOINIT_SECTION_NAME."CMAKE_SOURCE_DIR/src/dummy/dummy_array.c".0 24576 536873896 bss 13697 536898472 noinit 22624 536912176 .comment 64 0 .debug_aranges 17648 0 .debug_info 2255551 0 .debug_abbrev 133539 0 .debug_line 368703 0 .debug_frame 48492 0 .debug_str 157143 0 .debug_loc 434689 0 .debug_ranges 57856 0 .ARM.attributes 56 0 .last_section 4 199808 Total 3709862
And the linker summary after building:
Memory region Used Size Region Size %age Used FLASH: 199812 B 1524 KB 12.80% RAM: 63888 B 256 KB 24.37% IDT_LIST: 0 GB 32 KB 0.00%
For comparison, if I set the array size to 4:
Memory region Used Size Region Size %age Used FLASH: 175224 B 1524 KB 11.23% RAM: 39320 B 256 KB 15.00% IDT_LIST: 0 GB 32 KB 0.00%
Is there a way through Zephyr to have such a persistent linker section which only takes up RAM and not Flash ? I don't care what the initial data is, if it wasn't persistent it would just go to .bss.
edit: Forgot to add that this is a fresh new project, so close to nothing changed compared to the base example project following Nordic's tutorial.
Thanks for any help you can provide