How can I add postbuild options to compute a checksum and add it at an address in Flash?

Hi,

Currently I use a custom linker section for my code.

.my_code_section :
{
PROVIDE(__my_code_section_start = .);
KEEP(*(.my_code_section))
PROVIDE(__my_code_section_end = .);
} > FLASH

.my_crc32_data_section :
{
PROVIDE(__my_crc32_data_section_start = .);
KEEP(*(.my_crc32_data_section))
PROVIDE(__my_crc32_data_section_end = .);
} > FLASH

I have to compute a checksum using "__my_code_section_start" during the build and write the computed checksum at "__my_crc32_data_section_start" during the post build phase.

Is there any scripting facility available to do this in Zephyr?

Parents
  • Hi AlphaBeta,

    Zephyr projects build with CMake, so you can use the add_custom_command() CMake command with POST_BUILD.

    Please test this thoroughly though, because a part of the nRF Connect SDK build process is signing images for DFU purpose. If you change the image file, it has to be done before signing, or the signature becomes invalid. If that becomes an issue, you will want to explore manual signing solutions.

    Speaking of signature, our DFU solution already include hashing and signing the image to ensure its integrity. Could this already take care of the goal you are trying to achieve with your checksum?

    Hieu

Reply
  • Hi AlphaBeta,

    Zephyr projects build with CMake, so you can use the add_custom_command() CMake command with POST_BUILD.

    Please test this thoroughly though, because a part of the nRF Connect SDK build process is signing images for DFU purpose. If you change the image file, it has to be done before signing, or the signature becomes invalid. If that becomes an issue, you will want to explore manual signing solutions.

    Speaking of signature, our DFU solution already include hashing and signing the image to ensure its integrity. Could this already take care of the goal you are trying to achieve with your checksum?

    Hieu

Children
No Data
Related