Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Firmware Update over UART Interface

Hello,

Background: I have a custom board that contains nRF52832 module and exposes UART pins (RX, TX, RTS, CTS). I have developed an application using nRF5 SDK v17.0.2. The application does not use any so -called SoftDevice.

Objective: I want to develop a mechanism to update the application firmware of on the nRF52832 module over the UART interface from another micro-controller.

Seeking Help: After searching through the SDK and the forum, it looks like I have to use libraries under Bootloader and DFU modules But I am still confused which components to use and in what order. On the nRF52832 module, do I need to program, as part of my application, routines to receive and process DFU commands/data packets. I am also using the same UART port to exchange application data (from sensors attached sensors )  with the other micro-controller.

I would appreciate any help that can get me started on the right path to achieve the objective.

  • Yes you are correct. After you write to GPREGRET, you just need to trigger a reset to enter bootloader. 

  • Hi Hung,

    I made some progress but not enough.

    - I successfully compiled the secure uart bootloader  nRF5_SDK_17_0_2_d674dde/examples/dfu/secure_bootloader/pca10040_uart by following the exact same procedure as outlined in your tutorial.

    - Adapted my application code such that at the push of a button (on my device) the application set the first bit in GPREGRET and do soft power switching of the nRF52832. I have verified, the setting of bit and power switching are happening as expected.

    I flashed the .hex file of the bootloader and the application using the Programmer tool that is a part of the nRF Connect v3.6.1 application.

    My application works correctly. However, when I push the button to switch to bootloader, the device does not enter into the bootloader (although the application captures the push button event, set the bit and successfully do soft power reset) but again launch the application. I must be doing something wrong, or have missed a critical step. Could you please see.

    Kind regards

  • Please try debugging the bootloader, you can put a breakpoint in dfu_enter_check() in nrf_bootloader.c It's where the bootloader check if it would need to enter DFU mode or not. 

    You may need to compile the bootloader in debug mode (no optimization) to be able to put breakpoint and step in the code of the bootloader. 

    I assume that you have tested the functionality of the bootloader (DFU update) and also know how to create bootloader settting etc. 

    Please also try testing that you can enter the bootloader by holding a button when you reset. 

  • - When I set the optimization level to zero, for debugging the bootloader,  I get the following errors:

    ../SEGGER Embedded Studio for ARM 4.52c/gcc/arm-none-eabi/bin/ld: error: .text is too large to fit in FLASH memory segment
    ../SEGGER Embedded Studio for ARM 4.52c/gcc/arm-none-eabi/bin/ld: error: .dfu_trans is too large to fit in FLASH memory segment
    ../SEGGER Embedded Studio for ARM 4.52c/gcc/arm-none-eabi/bin/ld: error: .nrf_balloc is too large to fit in FLASH memory segment
    ../SEGGER Embedded Studio for ARM 4.52c/gcc/arm-none-eabi/bin/ld: error: .fs_data is too large to fit in FLASH memory segment
    ../SEGGER Embedded Studio for ARM 4.52c/gcc/arm-none-eabi/bin/ld: error: .rodata is too large to fit in FLASH memory segment
    ../SEGGER Embedded Studio for ARM 4.52c/gcc/arm-none-eabi/bin/ld: error: .data is too large to fit in FLASH memory segment
    ../SEGGER Embedded Studio for ARM 4.52c/gcc/arm-none-eabi/bin/ld: error: section .tdata overlaps absolute placed section .mbr_params_page

    For  optimization level > 0, some break points show message no code for breakpoint. Anyway I noticed that the bootloader repeatedly enters and exits the main() function. Not sure if it is normal behavior?

    - From your tutorial, I know how to create the bootloader setttings file. But I must say I still struggling to comprehend the complete sequence to flash the bootloader, and the application.

  • Please try to follow my steps and made sure  you can do a normal DFU udpate. 

    When you change optimization level to 0, the size of the bootloader getting bigger. So it won't fit into the current setting of the flash size and location. 
    You would need to move it down in flash and extend the size of the bootloader. Please have a look at the project configuration to increase the allocated flash for bootloader. 

Related