Make the linker to calculate a checksum over a specific memory area and store the value at a specific memory address.

Hello,

I'd like to have the gcc linker calculate a checksum over a specific address range (defined in .ld file) and store that checksum at a specific address (defined in .ld file).

For that I found an exmaple project that uses the gcc (no nordic project) in which the following was added in the CMakelists.txt:

set (CHECKSUM_OPTIONS "\
  -c sym:__my_section_start,sym:__my_section_stop \
  -d sym:__checksum \
  --crc_polynom 0x104c11db7 --ex-end --crc_init 0x0 --crc_xor 0xffffffff --crc_endianess little -v"
)

target_link_options(app PUBLIC -Wl,--script my_linker.ld ${CHECKSUM_OPTIONS})



In my current noridc project I have a custom_linker.ld file which specifies the sections that I use in the code and I want to have a checksum calculation over.
I use the following call to give the custom_linker.ld file to the toolchain:
zephyr_linker_sources(SECTIONS custom_linker.ld)
Can anyone tell me how I can make the linker calculate the checksum as it is done in the other example project?
Related