Is it possible to modify some constant values in .hex file directly for firmware programming without recompiling the codes?

Hello All,

Currently we have a nRF52832 firmware .hex file for mass production.

And we use "nrf connect - programmer" to firmware programming without any problem.

We have a constant datecode value in .hex like "YR2021-12", and we can find it in the .hex file like below:

:10B1B00000005952323032312D31322020203000FF

What i would do is to modify the line to: (2021->2022 & update checksum) and save to a updated .hex file.

:10B1B00000005952323032322D31322020203000FE

Then i flash the updated .hex file but find the nRF52832 always enter DFU mode.

If i erase and write back the old firmware, it can boot up and work normally.

So anyone has any idea on that? Or the way i modify is not acceptable?

Thanks a lot.

  • Hi,

    What i would do is to modify the line to: (2021->2022 & update checksum) and save to a updated .hex file.

    I see you remember the first important point, which is to update the checksum in the intel hex file.

    Then i flash the updated .hex file but find the nRF52832 always enter DFU mode.

    My understanding is that you have a merged hex file including application, bootloader and bootloader settings (and possible SoftDevice). The default configuration of the bootloader does application validation using CRC on boot, and if you modify a number within the application region this will fail, and the bootloader will enter DFU mode. There are a few ways around this:

    • Disable applicating validation on boot, by using the --app-boot-validation option when you generate the BL Settings using nrfjprog settings generate. With this, you can keep the rest of your approach as is.
    • Generate a new bootloader settings hex file after you have modified the application hex file, using the modified hex file as input. This way you can keep CRC validation (or other method) as is.
  • Hello Einar,


    Yes, it is a merged hex file. And let me check it out with your suggestion.

    I will come back to you and update here after tests.

    Thank you very much. 

Related