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

DFU_APP_DATA_RESERVED not working

nrf51822_AA rev3, SDK8.0.0, S110 8.0.0

My application has the max number of bonds set to 24 with a size of 128bytes each. So that's 3 pages. Plus one page for saving user/state information. So, I'd like to save a total of 4 pages when DFUing.

I set DFU_APP_DATA_RESERVED to 0x1000, but it has no effect.

I printf'ed a bunch of defines to try to figure out the problem, but I think everything looks right:

NRF_UICR_BOOT_START_ADDRESS = 0x10001014
CODE_REGION_1_START = 0x00018000
SOFTDEVICE_REGION_START = 0x00001000
BOOTLOADER_REGION_START = 0x0003C000
BOOTLOADER_SETTINGS_ADDRESS = 0x0003FC00
DFU_REGION_TOTAL_SIZE = 0x00024000
DFU_APP_DATA_RESERVED = 0x00001000
DFU_BANK_PADDING = 0x00000000
DFU_IMAGE_MAX_SIZE_FULL = 0x00023000
DFU_IMAGE_MAX_SIZE_BANKED = 0x00011800
DFU_BL_IMAGE_MAX_SIZE = 0x00003C00
DFU_BANK_0_REGION_START = 0x00018000
DFU_BANK_1_REGION_START = 0x00029800

PSTORAGE_DATA_START_ADDR = 0x0003AC00
PSTORAGE_DATA_END_ADDR = 0x0003BC00

I can read back the memory using "nrfjprog.exe --memrd 0x0003AC00 --n 4096" and I can see the bond and state information, but after DFUing it's all gone.

bootloader flash settings:
IROM1: 0x3C000 / 0x3C00
IRAM1: 0x20002000 / 0x1F80
IRAM2: 0x20003F80 / 0X80 (no init)

application flash settings:
IROM1: 0x18000 / 0x28000
IRAM1: 0x20002000 / 0x2000

Help...thanks!

Parents
  • I figured it out. I was storing the user state in the reset_prepare function, but not waiting for it to finish. So, I guess the application data was corrupted before it even reset into the bootloader. Once I removed the storing, everything worked.

    The bonds were not being saved because I was short a page like you said.

    This should probably be a separate question: Since pstorage uses its own event handler, what is the best way to 'wait' for it to finish before continuing? I am not using a scheduler.

  • @Chris: You should register a callback handler when calling pstorage_register() and wait for the callback even (with PSTORAGE_STORE_OP_CODE for example) and check the result. You can set a flag in the callback handler and wait for that flag in the main code be for proceed.

Reply Children
No Data
Related