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

nRF52810 DFU attempt #2

I'm trying to set up DFU for a custom board with a nRF52810 module (Rigado BMD-330).  I created the secure bootloader from the recent project for SDK 15 posted by Vidar Berg.  All seems to be working and I can connect to the DFUTARG.  The DFU download works .... once.  I discovered I need to add the buttonless DFU service to my application in order to  switch from the application back to the bootloader if I want to support multiple DFUs.

I started this task using the guidelines on the infocenter and with the buttonless DFU example, only to find I'm getting compile errors from nrf_dfu_types.h.  This is looking for  NRF52 defined or I get: #error "Architecture not set."  However, my application followed the PCA10040e path and does not use the NRF52 flag and also uses gcc_startup_nrf52810.S and system_nrf52810.c versus gcc_startup_nrf52.S and system_nrf52.c ..... which seems the right thing to do for nRF52810 development and the app without DFU service is running nicely.   I attempted to add the NRF52 flag and as you might expect that resulted in linker errors.

I don't know how to resolve this ..... if it even can be resolved.  It seems rather ugly at this point. 

Any suggestions?  I know there's working example of nRF52810_S112 buttonless DFU service for SDK 14.2 but I'd like to stick with SDK 15 if possible.  I'd be happy to beta test a SDK 15 buttonless DFU service for the nRF52810. 

Thanks,  Max

 

Parents
  • Hi Max,

    I saw the same problem when I made the bootloader project. The pre-processor check in dfu_types.h does not include check for NRF52810_XXA, which is why you get the "Architecture not set." error. 

    Here is the change I made: 

    diff --git a/components/libraries/bootloader/dfu/nrf_dfu_types.h b/components/libraries/bootloader/dfu/nrf_dfu_types.h
    index 5ccd290..db6b918 100644
    --- a/components/libraries/bootloader/dfu/nrf_dfu_types.h
    +++ b/components/libraries/bootloader/dfu/nrf_dfu_types.h
    @@ -72,7 +72,7 @@ extern "C" {
      */
     #if defined(NRF51)
         #define CODE_PAGE_SIZE            (PAGE_SIZE_IN_WORDS * sizeof(uint32_t))
    -#elif defined(NRF52) || defined(NRF52840_XXAA)
    +#elif defined(NRF52) || defined(NRF52840_XXAA) || defined(NRF52810_XXAA)
         #define CODE_PAGE_SIZE            (MBR_PAGE_SIZE_IN_WORDS * sizeof(uint32_t))
     #else
         #error "Architecture not set."
    diff --git a/components/libraries/bootloader/nrf_bootloader_app_start_final.c b/components/libraries/bootloader/nrf_bootloader_app_start_final.c
    index a818322..dde759b 100644

  • I made the changes Vidar suggested and the application compiled with my GCC Makefile.  The other files in the link I referenced were for SDK 14 and didn't apply to my environment.

    Unfortunately, the application with the Buttonless DFU Service added does not appear to initialize on my custom nRF52810 board and I have to figure some way to debug it.  Since I have no visibility to my custom board, I'm going to try and go back to developing for nRF52810 in the nRF52 DK board and review the log information displayed.  This involves redefining some GPIO, but not too difficult.  Hopefully this will give some clues where it's failing via the log messages.

    I found the application with the Buttonless DFU Service will not run without a valid bootloader present so I'd like to set up the bootloader + bootloader settings to run with a valid application so I can load everything into flash and execute the application.  I'm not clear on the details of how to set the bootloader settings to do this, so some specific how-to information would be helpful.

    I'm also not sure the nRF5810 bootloader will run on the nRF52832 on the nRF52 DK board.  Should I be using a nRF52832 bootloader instead?  

    Later .........

    Max

      

  • I did not enable debug logging in the bootloader port I provided earlier as it would significantly increase the code size. If you wish to enable it you first need to adjust the bootloader start address downwards in order to allocate more flash space, like we have done for the bootloader *_debug projects. Start address is set in the linker script (*.ld file adjacent to Makefile). Once you have adjusted the start address you can enable the logger module in sdk_config.h and rebuild the bootloader. 

    "I found the application with the Buttonless DFU Service will not run without a valid bootloader present so I'd like to set up the bootloader + bootloader settings to run with a valid application so I can load everything into flash and execute the application.  I'm not clear on the details of how to set the bootloader settings to do this, so some specific how-to information would be helpful."

    The buttonless service requires the bootloader to be present in order to set up the supervisor call interface between application and bootlaoder.  The settings page can be generated with nrfutil as explained here: http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.tools/dita/tools/nrfutil/nrfutil_settings_generate_display.html?cp=5_5_6 

    E.g., Generate and upload settings page

    nrfutil settings generate --family NRF52810 --application <app.hex> --application-version <version number> --bootloader-version <version number>
    --bl-settings-version 1 settings.hex && nrfjprog --program settings.hex --sectorerase -r

    You can run the 52810 bootloader on a 52832 IC.
  • Vidar,

    Thanks so much!  Great helpful information.

    I'm working my way through it and we'll see how I make out.

    I did try to generate a bootloader settings file and merge it with the bootloader.  I noticed in the info displayed it reports:

    Bank0 Bank Code: 0x00000001

    Is this the code that indicates a valid application?

    Max

  • Hi Max,

    Glad you found it helpful. You may also want to have a look at this blog post by Hung Bui here. Merging of settings page is explained in Appendix 1.

    Yes, Bank 0 code 0x1 indicates a valid application. Here is the settings structure for reference: http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/structnrf__dfu__settings__t.html   

Reply Children
  • I got everything working, but it wasn't easy.  I'll outline the steps below for anyone else struggling with this and maybe it will help.  The most significant hurdle was to eliminate the application preserve pages.  I do not think Nordic should have 3 pages of flash reserved for a nRF52810.  My final application size was around 55 KB using GCC and there was only 60 KB of flash left after loading the SoftDevice and the bootloader.

    Good work on the nRF52810 bootloader!  It seems to be running well.

    Development/Debug steps:

    1. Set up the existing application program to run on nRF52832 and the nRF52 DK.  For me, this required reconfiguring LEDs and an ADC channel.

    2. Merge the Buttonless DFU Service into the application.  Run with nRF52832 bootloader and S132 SoftDevice.  Use ble_app_buttonless_dfu SDK example for guidance on what to include in the program as well as how to set up the project or GCC Makefile.  Verify operation of everything (application and DFU Service) from nRF Connect.

    3. Migrate the project to a nRF52810 using the PCA10040e setup.  Run on the nRF52 DK with the nRF52810 bootloader and S112 SoftDevice.  Note that this will reduce the flash available significantly.  I found I had to set the application preserve pages in nrf_dfu_types.h to 0 using: #define DFU_APP_DATA_RESERVED               (CODE_PAGE_SIZE * 0).  Again, verify operation of everything (application and DFU Service) from nRF Connect.

    4. Migrate the project to the nRF52810 board.  Reconfigure peripherals and GPIO as required.  Use the PCA10040e config or Makefile to not have the DEVELOP_IN_NRF52832 setting.   Verify operation of everything (application and DFU Service) from nRF Connect.

    So far I've been using DFU to load the application.  I still have to figure out how to load the application directly to flash from either nRFgo Studio or nrfjprog, but I'm confident I can do that now that I have a working application.

    Thanks for the outstanding support with this.  I'll mark this as answered.  Much more testing to be done!

    Max

  • Thanks for the update. I agree, we shouldn't reserve 3 pages on the 52810, glad you noticed it.

    Vidar

Related