nRF52840 UART bootload issue

Hi,

I developed a firmware without softdevice for a custom board with nRF52840

I recently decided to add a bootloader to my application and I based my bootloader code from the example : secure bootloader pca10056 uart

In the bootloader code I changed main to :

int main(void)
{
	gpio_setup();
	LED_GREEN();
	nrf_bootloader_init(dfu_observer);
}

As I intend to stay in bootloader using retention register, I set in sdk_config.h :

#ifndef NRF_BL_DFU_ENTER_METHOD_GPREGRET
#define NRF_BL_DFU_ENTER_METHOD_GPREGRET 1
#endif

Here are my steps regarding how I flash my device/prepare my files :

1 - From my app hex I generate a bootloadable app zip

nrfutil --verbose pkg generate --hw-version 52 --application-version 1 --application app.hex --key-file private.key --sd-req 0 app.zip

2 - I generate bootloader settings for my app

nrfutil --verbose settings generate --family NRF52840 --application app.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 btl_settings.hex

3 - I merge the bootloader hex and the bootloader settings to a bundle hex

mergehex --merge btl_settings.hex btl.hex --output bundle.hex

4 - I erase my whole chip to make sure to start clean

nrfjprog -f nrf52 --eraseall

5 - I flash the mbr hex I found in "nRF5_SDK_17.1.0_ddde560\examples\dfu\secure_dfu_test_images\uart\nrf52840\mbr.hex"

nrfjprog -f nrf52 --program mbr.hex --sectorerase --verify

6 - I flash the bundle generated in step 3

nrfjprog -f nrf52 --program bundle.hex --sectorerase --verify

7 - I flash the app

nrfjprog -f nrf52 --program app.hex --sectorerase --verify

8 - hard reset my device

Output :

I can clearly see that bootloader is exited shortly after power on with the green led but it doesn't look like my app is started after the bootloader exited

Why doesn't my app start and how can I fix this issue ?

I am working with :

- SDK 17.1.0

- Latest nrf command line tools

- Latest nrfutil

  • Hi Gabriel, 

    Before testing with bundling the hex files together, have you tried to flash them one by one ? 
    I would suggest to try : 

    1. Flash MBR -> Flash bootloader -> Flash bootloader setting -> flash application 

    It this doesn't work, continue with: 

    2. Flash MBR -> Flash bootloader.  -> Do DFU update of your application image , check if the application work. 

    3. If 2 works, you can try to do a hex dump of what in the flash using nrfjprog --readcode and then compare with what you have at step 1. 

    If 2 doesn't work, there must be something wrong with the bootloader. Please double check that the way to enter DFU mode using a button is disabled. It's in case that you have the GPIO hardware differently from the Dev Kit and the bootloader takes it as the button is pressed and won't enter application but enter DFU instead. 

  • Hello,

    I tried 

    1. Flash MBR -> Flash bootloader -> Flash bootloader setting -> flash application 

    It looks like I stay in the bootloader

    I then tried 

    2. Flash MBR -> Flash bootloader.  -> Do DFU update of your application image , check if the application work. 

    nrfutil dfu serial -pkg app.zip -p COM4 -fc false -b 115200

    But it stays at 0%

    I made a "custom_board.h", can you check if its correct ?

    #include "nrf_gpio.h"
    
    #define LEDS_NUMBER    0
    #define LED_1          NRF_GPIO_PIN_MAP(1,13) // R
    #define LED_2          NRF_GPIO_PIN_MAP(1,0)	// G
    #define LED_3          NRF_GPIO_PIN_MAP(1,1)	// B
    #define LEDS_ACTIVE_STATE 0
    #define LEDS_LIST { LED_1, LED_2, LED_3 }
    
    #define BUTTONS_NUMBER 0
    #define BUTTONS_ACTIVE_STATE 0
    
    #define RX_PIN_NUMBER  NRF_GPIO_PIN_MAP(1,9)
    #define TX_PIN_NUMBER  NRF_GPIO_PIN_MAP(1,7)
    #define CTS_PIN_NUMBER 11
    #define RTS_PIN_NUMBER NRF_GPIO_PIN_MAP(1,2)
    #define HWFC           false

  • Also I changed this in "sdk_config.h"

    #define NRF_BL_DFU_ENTER_METHOD_BUTTON 0
    #define NRF_BL_DFU_ENTER_METHOD_GPREGRET 1
    #define NRF_BL_DFU_ENTER_METHOD_BUTTONLESS 1
    #define NRF_CRYPTO_ALLOCATOR 2
    #define NRF_DFU_APP_ACCEPT_SAME_VERSION 1
    #define NRF_DFU_APP_DOWNGRADE_PREVENTION 0

  • Hi Gabriel, 


    We would need to verify that the bootloader can actually receive the UART command from the PC. 

    Have you tried to test your board with an UART example and verify that you can communicate with the PC via UART ? 

    Could you try to debug the bootloader and check if it receives any command ? You may want to use debug version of the bootloader. 

  • We tested UART at 100k baudrate and its working fine. Somehow our bootloader is not seing the PC messages, I need to try to change the baudrate

Related