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

Error while programming bootloader on nRF52832 QFAB IC using nrfjprog

I have a custom board of nRF52832-QFAB-B0 on which my application works well with SDK15.0.0 & SD132 v6.0.0 

To perform DFU,

1. I copied the relevant parts of ble_app_buttonless_dfu example,

2. Increased the vendor specific uuid count to 2 in the sdk_config, now that I have two services - custom service & DFU service.

3. Included the required libraries and headers into my project as prompted by the error messages in SEGGER embedded studio and ran.

4. Got the following error in my log: "missing bootloader"

To program bootloader, I followed the steps in infocenter:

1. Cleared the flash

nrfjprog wipe

2. Programmed the softdevice SD132 v6.0.0 

nrfjprog program -d nrf52 -c ../../SDK_15.0.0/components/softdevice/s132/hex/s132_nrf52_6.0.0_softdevice.hex

3. Modified the secure_bootloader with the following settings in memory segments & linker. Memory map changed since my IC variant is nRF52832 QFAB-B0 with 256kB Flash & 32kB RAM

Common Linker -> Section Placement macros:

FLASH_PH_START=0x0

FLASH_PH_SIZE=0x40000

RAM_PH_START=0x20000000

RAM_PH_SIZE=0x8000

FLASH_START=0x38000

FLASH_SIZE=0x6000

RAM_START=0x200057b8

RAM_SIZE=0x2848

Common Build->Memory segments:

FLASH RX 0x0 0x40000

RAM RWX 0x20000000 0x8000

uicr_mbr_params_page RX 0x10001018 0x4

mbr_params_page RX 0x0003E000 0x1000

bootloader_settings_page RX 0x0003F000 0x1000

uicr_bootloader_start_address RX 0x10001014 0x4

4. Generated the Bootloader settings hex file with the following command:

nrfutil settings generate --family NRF52QFAB --application pca10040/s132/ses/Output/Debug/Exe/ble_app_template_pca10040_s132.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 settings.hex

5. Merged bootloader and settings file using mergehex

mergehex -m bootloader.hex settings.hex -o bootloader_settings.hex

6. Now to program the bootloader I use nrfjprog

./nrfjprog --reset --program ../mergehex/glo_bootloader_settings.hex --family NRF52 --sectoranduicrerase

which throws an error:

Parsing hex file.

ERROR: The file specified is not a valid hex file, has data outside valid areas

ERROR: or does not have data in valid areas.

Parents Reply Children
  • Thanks for the online tool. Quite helpful.

    I got the nrjprog to program correctly now. But the board still doesn't advertise as "DfuTarg". I no longer get the error message while programming, but instead get the following result:

    ./nrfjprog --reset --program ../mergehex/glo_bootloader_settings.hex --family NRF52 --sectoranduicrerase

    Parsing hex file.

    Erasing page at address 0x38000.

    Erasing page at address 0x39000.

    Erasing page at address 0x3A000.

    Erasing page at address 0x3B000.

    Erasing page at address 0x3C000.

    Erasing page at address 0x3D000.

    Erasing page at address 0x3F000.

    Erasing UICR flash area.

    Applying system reset.

    Checking that the area to write is not protected.

    Programing device.

    Applying system reset.

    Run.


    But the board is still not advertising as "DfuTarg". Works in DK. I have modified the following also in the bootloader project (it changes for the whole SDK I guess since these variables are in nrf_dfu_types.h and in bootloader_info.h):

    #define BOOTLOADER_START_ADDR (0x00038000UL)
    #define BOOTLOADER_SETTINGS_ADDRESS (0x0003F000UL)
    #define NRF_MBR_PARAMS_PAGE_ADDRESS (0x0003E000UL)


    Using the online tool on the merged settings & bootloader file, I get this:
    Block starting at 229376 (0x38000), 23209 (0x5aa9) bytes long
    Block starting at 258048 (0x3f000), 92 (0x5c) bytes long
    Block starting at 268439572 (0x10001014), 8 (0x8) bytes long

  • Hi, Any update? Anything wrong in what I am doing here? Is there an example where DFU works in nRF52832 QFAB version?

  • Is it necessary to have an application in flash for bootloader to work? Or can we load the first application itself via DFU?

  • I tried the whole sequence from start again. The advertising works on QFAB board now. But when I connect using nrfConnect, it disconnects before service discovery.  Again, works well on DK - meaning I am able to send an application on DK via ble and on restart, the application runs.

    This time I made sure that the bootloader start address is correctly written on flash using a readback.

    ./nrfjprog --memrd 0x10001014

    0x10001014: 00038000

    ./nrfjprog --memrd 0x10001018

    0x10001018: 0003E000

    Could this have anything to do with my application size? It's pretty big (70KB after optimising for size. So 222KB taken for SD+App) and Softdevice+App takes 30.3KB of RAM according to SES compilation results.

  • Hi, I finally figured out.

    Apart from setting the BOOTLOADER_SETTINGS_ADDRESS, NRF_MBR_PARAMS_PAGE_ADDRESS, I had to make another change in sdk_config.h ( I didn't have to change BOOTLOADER_START_ADDR btw in SES project. It was pointing to CODE_START which I didn't have to change)

    There was one more difference between DK and my board apart from QFAA & QFAB. It's that my board did not have a 32KHz crystal.  Silly of me to not think about this.

    So I had to change the clock parameters of the sdk_config.h file.

    #define NRF_SDH_CLOCK_LF_SRC 0
    #define NRF_SDH_CLOCK_LF_RC_CTIV 16
    #define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
    #define NRF_SDH_CLOCK_LF_ACCURACY 7 //20_PPM


    Please let me know if these values are good.

Related