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

Secure Buttonless DFU Problem on nRF52832 Soft Device 112

Hello

I am facing problem from many days on buttonless DFU.

Whoever from Nordic approaches kindly give a customized solution rather than other links. I have almost gone through all the links with none exactly matching my issue. I will be really thankful.

I am trying to perform Buttonless DFU on nRF52832 512 kB version on nRF DK. I am using SDK 112 v7 (the latest one) and latest versions of nRF util, etc.. as well. Although I am using SDK 16.

My first act was to convert my application from s132 to S112 on nRF52832 a few months ago as I was using default ble_app_blinky as my base. A kind person from nordic helped me on the issue since the memory mapping on s112 pca10040 example is that of nRF52810

Now for DFU, I am supposed to convert the bootloader s112 example on nRF52810 to nRF52832 by editing the project file for library and memory mapping right?

I used the following links:

1) https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.3.0%2Flib_bootloader.html

2) https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader#h61sjziauupw1j397q9s9ldr01q4j6d5

3) https://devzone.nordicsemi.com/f/nordic-q-a/41386/guide-to-allocate-the-amount-of-ram-rom-i-need

and my project application  + BL + setting + SD oombined well using merge hex. It  went into DFU mode on start up and I started OTA 

OTA package is received successfully and after 100% OTA the DK rebooted and nRF log said bootloader not found:

My guess is something is wrong in my conversions as I am trying to convert from s112 nRF52810 examples to nrf 52832 the following projects:

1) Bootloader S112 example

2) I OTA ble_app_blinky s112 example and change it's memory mapping and nrf52832 libraries as we have to keep the same soft device in OTA

Please note from above screenshot that my OTA is fully complete (100%)

I am using the following memory mapping:

1) Bootloader example: nrf52832 s112

linker_section_placement_macros="FLASH_PH_START=0x0;FLASH_PH_SIZE=0x80000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x10000;FLASH_START=0x78000;FLASH_SIZE=0x6000;RAM_START=0x20005968;RAM_SIZE=0xa698"

linker_section_placements_segments="FLASH RX 0x0 0x80000;RAM RWX 0x20000000 0x10000;uicr_bootloader_start_address RX 0x10001014 0x4;uicr_mbr_params_page RX 0x10001018 0x4;mbr_params_page RX 0x0007E000 0x1000;bootloader_settings_page RX 0x0007F000 0x1000"

2) Base Application FW - nrf52832 s112

linker_section_placement_macros="FLASH_PH_START=0x0;FLASH_PH_SIZE=0x80000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x10000;FLASH_START=0x26000;FLASH_SIZE=0x5a000;RAM_START=0x200022f0;RAM_SIZE=0xdd10"


linker_section_placements_segments="FLASH RX 0x0 0x80000;RAM RWX 0x20000000 0x10000"

3) The OTA package - S112 nRF52832

linker_section_placement_macros="FLASH_PH_START=0x0;FLASH_PH_SIZE=0x80000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x10000;FLASH_START=0x26000;FLASH_SIZE=0x5a000;RAM_START=0x20001ae0;RAM_SIZE=0x4520"

linker_section_placements_segments="FLASH RX 0x0 0x80000;RAM RWX 0x20000000 0x10000"

Here are my nrfutil commands -

1) Bootloader settings and hex merges

BOOTLOADER SETTINGS
nrfutil settings generate --family NRF52 --application E_MCB_Project.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 bootloader_settings.hex


nrfutil settings generate --family NRF52 --application E_MCB_Project.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 --app-boot-validation VALIDATE_GENERATED_CRC --softdevice s112_sd.hex --sd-boot-validation VALIDATE_GENERATED_CRC bootloader_settings.hex


SETTING AND BOOTLOADER MERGE
mergehex -m secure_bootloader.hex bootloader_settings.hex -o bootloaderAndSettings.hex

PACKAGE HEX FROM ABOVE
mergehex -m bootloaderAndSettings.hex s112_sd.hex -o random.hex

PACKAGE HEX FROM ABOVE 2
mergehex -m random.hex E_MCB_Project.hex -o package_EMCB.hex

Here are commands I used for OTA package

echo "## Creating a FW.zip package that can be used to update the FW on the DK"


nrfutil pkg generate --application blinky_112_2.hex --application-version 61 --application-version-string "1.0.61" --hw-version 52 --sd-req 0xCD --sd-id 0xCD --softdevice s112_sd.hex --key-file private.pem fw81_MCB.zip


echo.

sd_112. hex is default  soft devicce 112 I just renamed it rest is self explanatory.

I have provided complete details and I need help on this. Please provide a customized solution and please dont divert me to other links. Its not a huge issue the OTA happens perfectly  but after reboot it cannot find the bootloader

I am assuming its something withbootloader settings or bootloader memory mapping

Regards

Ali

Parents
  • Hello,

    Try to use only --application-version 61. You are not supposed to use both --application-version and --application-version-string in the same packet. So try to use just one of them.

    You can't update a major softdevice version without updating the bootloader. You should actually probably always update the bootloader when you update the softdevice, so that you are 100% sure that you have a working pair. The bootloader depends on a compatible softdevice to be able to advertise and receive packets for the new application.

    Does it work to update the application only? (to another application using the same version of the softdevice)

    When you try to do SD+BL+APP, what was the old present softdevice version, what is the new one, and what command do you use to generate the DFU image?

    BR,

    Edvin

  • Hello Edvin

    I will try without application version string.

    Oh so you mean to say we cant do APP + SD we need to do APP + SD + BL always. That makes sense why it wasn't working with APP + SD

    Yes it does work when I OTA application only; and yes the soft device versions were same of both - S112

    I wanted to know if the steps were right. I changed linker addresses according to S112 on nRF52832 using info center links in the post. Please tell me if this was corrrect.

    On SD + BL + APP it seemed to send the TWO zip packages around 2-3 times (It said uploading 1 0f 2 and then 2 of 2) and then repeat.

    The old soft device was S112 and new one was S132 (OTA package). It worked on S132 SD + BL + APP with repetitions like I said but it didn't work at all with S112 in OTA package.

    The command was this:

    nrfutil pkg generate --application E_MCB_Project_CRC.hex --application-version 61 --application-version-string "1.0.61" --bootloader secure_bootloader.hex --bootloader-version 1 --hw-version 52 --sd-req 0xCD --sd-id 0xCD --softdevice s112_132.hex --key-file private.pem fw87_BL_SD_APP.zip

    secure_bootloader. hex is s112 project with all changes and details in original post please and the soft device is S132 default hex file.

    The code on the DK had S112

    Ali

  • SD updates are not supported on the nRF52810, because there is no room for 2xsoftdevice in the flash.

    What chip are you running this on?

    It is not strictly necessary to update the bootloader when you update the softdevice. But you need to make sure that the softdevice that the bootloader and the application is using is the same version, because they use the same physical softdevice. 

    I am not catching exactly what is not working. Is it nRF52810 + S112 + softdevice OTA update?

Reply
  • SD updates are not supported on the nRF52810, because there is no room for 2xsoftdevice in the flash.

    What chip are you running this on?

    It is not strictly necessary to update the bootloader when you update the softdevice. But you need to make sure that the softdevice that the bootloader and the application is using is the same version, because they use the same physical softdevice. 

    I am not catching exactly what is not working. Is it nRF52810 + S112 + softdevice OTA update?

Children
  • I am really disappointed with the help here Edvin. I am sorry to say..

    I clearly explained everything in OP and requested to please not drag this conversation. 

    Anyways i clearly mentioned i have nRF52832 DK with custom firmware. But it is on S112 and not S132
    got it???

    I clearly mentioned i am not using nRF52810, please read OP i clearly mentioned, then why are you mentioning it in reply days later?

  • Anyways coming back to your reply that bootloader and application are using same version? what does that mean
    during nrfutil where I input application versions in the pkg generation?

    and what is not working is nrf52832 + S112 (base application). i simply want to OTA another application

    Once again i request you to read OP I tried to explain everything very clearly anyone would understand it

    OP means original Post btw

    Ali

  • Hi Muhammad, 

    Edvin is on vacation so I will take over this case. 

    I'm sorry for the misunderstanding I will try to summarize the issue here.

    So you develop your application on a NRF52832 and it should run S112 softdevice. 
    You want to do DFU update on it. So you modified the bootloader to run on nRF52832 and S112 softdevice. Same with the application. 
    Now the application works fine with and without the bootloader and you can do DFU update the application with no issue. You can update the same application or new version of application. 

    The issue you have now is to update the SD+APP or SD+APP+BL. Note that SD+APP only works if it's the same SD or they are same major version (for example same v7.x ).

    We would need to gather debug information to really tell what went wrong when you update SD+APP or SD+BL+APP. This includes the bootloader logs, the DFU master log and you may need to step into the code to see why it didn't run the application. 


    However I spotted one issue with your script. In your base application you have FLASH_START=0x26000;. 

    This is not correct, this is the start address for S132 not the start address for S112 which is 0x19000. 

    As you may already know, the only difference between using S132 and S112 is the size of the softdevice, it's changed from 152kB on S132 down to 100kB on the S112 v.7 (and the difference in the header files of course).

    This result in that your application has to change the start address from 0x26000 to 0x19000. because the application is always located right after the softdevice. Failed to do this may cause the application not to operate normally when it's updated to a device running on S112. 

    However this doesn't apply for the bootloader as the bootloader location is fixed at the bottom area of the flash, regardless the size of the softdevice. 

    I would suggest you to test only the softdevice and bootloader first. And then do a SD+BL update. Doing that we can exclude the application from the picture and can rule out any issue with the application and can focus on the bootloader if it can do a SD+BL update or not. 
    Please also state clearly the SD in the old version and new version when you update. 

  • Hi Hung

    Thank you so much for the great reply. Looks like you went well into my problem. I hope we can solve this together.

    I just want to confirm whether it was the right decision to modify the bootloader addresses right? Because memory map of nrf52832 is differet.

    Okay I will change it to 0x19000 and also do the SD+BL update and let you know.

    However i would be grateful if you could clear my concept on this

    I set it to 0x26000 because of this memory map:

    I thought that the soft device reserved space in nrf52832 is maximum (that of s132) but i didnt know the soft device region ends and application region starts according to the soft device.\

    But the flash of nrf52832 is greater than that of nrf52810 right? Then where does the extra space go. Does application area get that extra space? and bootloader starts late??

    Please clarify these doubts for me because I changed bootloader project settings according to this as well. It was s112 project but for nrf52810 so I started the bootloader from 0x78000

  • Another thingI want to ask you is that with the project settings in OP, I managed to update the application only. But there was a weird thing I saw. After using merge hex to compile settings and bootloader and application and soft device; I noticed advertisement on nRF connect as DFU targ and not buttonless DFU. 

    It means device is going directly into DFU Mode?
    Could you please shed some light on this whole situation?

    once again thanks in advance

    Ali

Related