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
  • Hi,

    The error you are getting indicates that some part of the hex file has data outside of the flash. The first step is to check each hex file before they are merged to see if there are regions outside the range 0x00000000 - 0x00040000 (you may still have data in the UICR region). This online tool can be a suitable way to do this with.

    In addition to the steps you have described I noticed that you need to update the value of BOOTLOADER_START_ADDR and BOOTLOADER_SETTINGS_ADDRESS in the bootloader source code. These defines are used runtime by the MBR and bootloader and have to match the project settings.

    Best regards,
    Rune Holmgren

  • 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,

    This generally seems good.

    The pages from 0x38000 to 0x3D000 are the bootloader.

    The page at 0x3E000 is left empty as it will be used for the MBR settings page.

    The page at 0x3F000 is the bootloader settings page.

    The defines look good at a glance as well.

    I will not dig any deeper into this as your latest message seems to indicate you figured it out.

Reply Children
No Data
Related