Nordic 51822 烧录bootloader 后,需要OTA一次,才能启动App解决办法

Nordic 51822 烧录bootloader 后,需要OTA一次,才能启动App解决办法

使用nrfjprog烧写寄存器标志位

nrfjprog  --memwr 0x3FC00 --val 0x01

官网解释说明如下:

E. How do I program the original application via programmer (JLINK), not by DFU ?

After you flash your bootloader, the next step is to program the application via the bootloader DFU mode.

However, doing DFU usually take more time (and hassle) than programming via Jlink programmer, both when developing the firmware and when in mass production. DFU is more for bugs fix and firmware version upgrade on end products.

The reason directly flash the application firmware via JLink programmer won’t work when there is a bootloader is that there is a flag (bank_0 in p_bootloader_settings ) stored in flash ( BOOTLOADER_SETTINGS_ADDRESS = 0x0003FC00) to tell the bootloader if there is a valid application at bank 0 or not. By default it’s 0xFF = BANK_INVALID_APP. We need to set it to BANK_VALID_APP = 0x01.

There are several ways to do it:

  • Use programmer to write directly 0x01 to that address of BOOTLOADER_SETTINGS_ADDRESS (0x0003FC00).

  • Modify the bootloader firmware to write 0x01 to that address using attribute . It’s the same way as we did on writing to NRF_UICR_BOOT_START_ADDRESS the value of BOOTLOADER_REGION_START (see bootloader_setting_arm.c)

  • Combine the a hex that specifically set the byte to 0x01 at BOOTLOADER_SETTINGS_ADDRESS with the hex file of your application. You can also combine the bootloader hex and softdevice file to that combination, to create a single hex file for all of them. This solution is described here. The app_valid_setting_apply.hex is the hex that does the trick. This is very useful when you are doing gang programming.

Very similar to the BANK_VALID_APP flag is the CRC field in the bootloader setting. We also need to tell the bootloader either not to check the CRC or to prepare and write the correct CRC and size of the application image at bank 0. To set the bootloader not to check for CRC, we can simply write 0x00 to bank_0_crc and bank_0_size.

The .hex example on the above link sets the CRC flag to 0x00. You can also use programmer to write directly as how we do it with the BANK_VALID_APP flag. The hex file was created while we use the bootloader in SDK v6.x, in that version in the structure of bootloader_settings_t, each field is 32bit. On SDK v7.x and later, we uncheck the option “Enum Container always int” in C/C++ setting and that cause the enum only occupies 1 byte. It will mix with crc in one word as showed in the figure by testy in the first comment below.

Note that the current implementation of the bootloader on SDK v8.1 doesn’t store CRC of the image it flash on bank 0 to flash, 0x00 is stored in the CRC field, meaning there is no CRC check when the device booting up. It’s up to you to modify the code to store CRC to flash (look for m_image_crc in the code).

参考链接:
1.https://devzone.nordicsemi.com/blogs/685/common-faq-on-dfu/
2.http://www.cnblogs.com/libra13179/p/5787084.html


你可能感兴趣的:(Nordic 51822 烧录bootloader 后,需要OTA一次,才能启动App解决办法)