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

How to make it run application when there is a bootloader in the nRF52

Hi,

I'm using the bootloader in nRF5_SDK V12.0 with nRF52832. I have some problems want to know:

  1. How to make it run application first after I program softdevice,bootloader and application? I found that it runs the bootloader and broadcast as "DfuTarg". I know it can set m_boot_settings in nRF5_SDK V11.

  2. After I finish the OTA, it can run the application. However, if I just do a little modification in my application and then program it, it would neve run the application,it runs the bootloader. Is it normal?

  3. I want to use AT command received by the UART to make it switch to bootloader instead of using a button. I do that like this: In my application,when received the AT command, I will write a value to the flash(the last page in the flash) using fstorage then do a reset. In the bootloader, I add some code to read the flash to check the value. So my question is I should use the fstorage or do it like flashwrite example in SDK? Which way would you suggest? Thanks.

  • I couldn't find how to add a attachment, the settings page as follow:

    0x0007F000: 5BA4336D 00000001 00000001 00000001   |m3.[............|
    0x0007F010: 00000000 00000000 00005F14 F3CC7A53   |........._..Sz..|
    0x0007F020: 00000001 00000000 00000000 00000000   |................|
    0x0007F030: 00000000 00000000 00000000 00000000   |................|
    0x0007F040: 00000000 00000000 00000000 00000000   |................|
    0x0007F050: 00000000 00000000 00000000 FFFFFFFF   |................|
    0x0007F060: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F070: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F080: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F090: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0A0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0B0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0C0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0D0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0E0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0F0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|`
    

    I set the all version to 1

    Would you see the same problem with GPREGRET register as me?

  • The GPREGRET registers are a part of the POWER peripheral that is restricted when the SoftDevice is enabled, see this page in the S132 v3.0.0 Product Specification. It is therefore important that you use the SoftDevice API, sd_power_gpregret_set, when you want to write to the GPREGRET register and the SoftDevice is enabled. Looking at the bootloader settings I can see that the bank 0 code(@0x7F020) is set to 0x00000001(NRF_DFU_BANK_VALID_APP) and you should reach the

    if (nrf_dfu_app_is_valid())
    

    statment in nrf_dfu_init() in nrf_dfu.c. Have you checked this?

  • Thanks. I have use sd_power_gpregret_set API to do it.

    I have debuged it and found it didn't run to if (nrf_dfu_app_is_valid()) Also the value of enter_bootloader_mode is 0. However,in the if(enter_bootloader_mode != 0 || !nrf_dfu_app_is_valid()) nrf_dfu_app_is_valid returns false, that is the CRC != 0, so it didn't run the application. But I donn't know why the CRC is not 0.

  • The bootloader will calculate the CRC of the application and compare it to the CRC that is stored on the bootloader settings page(@0x7F000) that you created with nrfutil and merged with your bootloader, Softdevice and application hex. The settings page that you attached above shows that nrfutil calculated the CRC to 0x5BA4336D. If you have flashed the same application to your nRF52, then crc32_compute in nrf_dfu_app_is_valid should return the same crc, if it doesn't then its not the same application. Can you set a breakpoint at the if (crc != s_dfu_settings.bank_0.image_crc) statement and see what crc32_compute returns?

  • The settings page as follow:

    0x0007F000: FAD8B19F 00000001 00000001 00000001   |................|
    0x0007F010: 00000000 00000000 00005EA8 5221C273   |.........^..s.!R|
    0x0007F020: 00000001 00000000 00000000 00000000   |................|
    0x0007F030: 00000000 00000000 00000000 00000000   |................|
    0x0007F040: 00000000 00000000 00000000 00000000   |................|
    0x0007F050: 00000000 00000000 00000000 FFFFFFFF   |................|
    0x0007F060: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F070: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F080: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F090: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0A0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0B0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0C0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0D0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0E0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    0x0007F0F0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF   |................|
    

    We can see that the CRC stored on the bootloader settings page is 0x5221C273, then I debug it and set a breakpoint at theif (crc != s_dfu_settings.bank_0.image_crc), the crc is 0xDD2F1460. So it wouldn't run the application. Is there any problem for the crc32_compute function? The SDK I use is nRF5_SDK_12.0.0_12f24da.

    Besides, I found another problem.For example, my application is app.hex and use app.hex to generate the setting page app_setting.hex. Softdevice and bootloader have been flashed to the chip. Then I use app_setting.hex to generate the ZIP and use nRF Toolbox to update the fireware, it failes. The APP reported as completed(just 1% and then 100%,veyy soon), in fact the device is not updated. However, if I use app.hex to generate the ZIP (the same way)and use nRF Toolbox to update the fireware, it's OK. The version of APP is 4.2.0. I use bootloader_secure from the nRF5_SDK_12.1.0_0d23e2a, the problem still exist.

Related