This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Generating bootloader settings

While exploring documentaion and trying to learn more about the DFU (and bootloader settings), I found info on how to generate the bootloader settings, which also explains why the bootloader example was booting to dfu mode the first time, and then to my app, after I used dfu to update it (because that is what happens when there is no bootloader settings present).

So, by running:

nrfutil settings generate --family NRF51 --application-version 1 --application my_app_nrf51822.hex --bootloader-version 2 --bl-settings-version 1 --no-backup settings.hex

It generates the settings.hex:

Generated Bootloader DFU settings .hex file and stored it in: settings.hex

Bootloader DFU Settings:
* File:                     settings.hex
* Family:                   nRF51
* Start Address:            0x0003FC00
* CRC:                      0x78F3C691
* Settings Version:         0x00000001 (1)
* App Version:              0x00000001 (1)
* Bootloader Version:       0x00000002 (2)
* Bank Layout:              0x00000000
* Current Bank:             0x00000000
* Application Size:         0x0000B9F4 (47604 bytes)
* Application CRC:          0x78A6D951
* Bank0 Bank Code:          0x00000001
* Softdevice Size:          0x00000000 (0 bytes)
* Boot Validation CRC:      0x00000000
* SD Boot Validation Type:  0x00000000 (0)
* App Boot Validation Type: 0x00000000 (0)

Thought this info to be relevant for defining the correct values for flash size (the app is currently 47604 bytes, but will probably still grow slightly).

More questions:

- how to flash this settings.hex together with the app, bootloader, softdevice, etc?

- how can I set the "Softdevice Size" to the correct value?

- Shouldn't we also set the "Boot Validation CRC" value?

Best regards,

Ricardo

Parents
  • Hello Ricardo,

     

    Thought this info to be relevant for defining the correct values for flash size (the app is currently 47604 bytes, but will probably still grow slightly).

     Do you refer to the application size 47604 bytes from the bootloader settings print/log? If so, this only refers to the current application. It does not mean that all future applications must have the same size. They can be smaller or larger. The bootloader settings file is specific for this application only. Whenever you run a DFU in the future, these settings will be replaced. 

     

    how to flash this settings.hex together with the app, bootloader, softdevice, etc?

     You can e.g. use mergehex (part of nrfjprog). 

    Currently (but this may be updated only a couple of days ago. I am not sure) you can merge maximum two .hex files in one operation, so to merge the softdevice (SD), bootloader(BL), application(APP) and bootloader settings (BLS), you can use the following commands:

    mergehex --merge SD.hex BL.hex --output temp1.hex
    mergehex --merge temp1.hex APP.hex --output temp2.hex
    mergehex --merge temp2.hex BLS.hex --output merged_file.hex

    And all the hex files for the BL, APP, SD and BLS will be merged into merged_file.hex.

     

    - how can I set the "Softdevice Size" to the correct value?

     Look up "nrfutil settings generate --help" and look at the "--softdevice" parameter. This is not something you need. Test without this first. 

     

    - Shouldn't we also set the "Boot Validation CRC" value?

     no.

    The file you have looks good. Try it together with your application. It is not necessary to merge the files either before testing. Just use nrfjprog to program your files.

    nrfjprog --eraseall
    nrfjprog --program BL.hex --verify
    nrfjprog --program SD.hex --verify
    nrfjprog --program APP.hex --verify
    nrfjprog --program BLS.hex --verify
    nrfjprog --reset

    Testing like this may lead to a lot of typing. Try to save the content of this last snippet to a .bat file, e.g. create a file called test.bat. Then copy this text into that .bat file, and call "test.bat" from your command terminal.

  • Hi Edvin,

    In between I was also experimenting and had actually already tested using mergehex to merge both my app and the bootloader settings, but was testing the flashing with nrfconnect programmer.

    This nrfjprog tool is much easier, and I have already placed all of this inside a nice Makefile as you suggested.

    I also changed the --bootloader-version from 2 to 1, as I am using SDK 12.

    It looks like the bootloader settings file is now correct, or you have any other suggestion?

    Best regards,

    Ricardo

Reply
  • Hi Edvin,

    In between I was also experimenting and had actually already tested using mergehex to merge both my app and the bootloader settings, but was testing the flashing with nrfconnect programmer.

    This nrfjprog tool is much easier, and I have already placed all of this inside a nice Makefile as you suggested.

    I also changed the --bootloader-version from 2 to 1, as I am using SDK 12.

    It looks like the bootloader settings file is now correct, or you have any other suggestion?

    Best regards,

    Ricardo

Children
No Data
Related