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

not able to enter DFU Mode with secure bootloader example

I am not able to enter DFU Mode with secure bootloader example.

I use IAR and NRF Connect with Programmer to flash

Following are the steps I followed

1. Build Secure bootloader for serial UART ( enabled NRF_DFU_DEBUG_VERSION to remove link error)

2. Build blinky with MBR

3. Create settings file for blinky with MBR using the following command:

nrfutil settings generate --family NRF52840 --application blinky_pca10056_mbr.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 settings.hex

Note: Generating a DFU settings page with backup page included.
This is only required for bootloaders from nRF5 SDK 15.1 and newer.
If you want to skip backup page generation, use --no-backup option.

Generated Bootloader DFU settings .hex file and stored it in: settings.hex

Bootloader DFU Settings:
* File: settings.hex
* Family: NRF52840
* Start Address: 0x000FF000
* CRC: 0x5BBAFFAB
* Settings Version: 0x00000001 (1)
* App Version: 0x00000001 (1)
* Bootloader Version: 0x00000001 (1)
* Bank Layout: 0x00000000
* Current Bank: 0x00000000
* Application Size: 0x00000608 (1544 bytes)
* Application CRC: 0xA6B0AE53
* Bank0 Bank Code: 0x00000001
* Softdevice Size: 0x00000000 (0 bytes)
* Boot Validation CRC: 0x00000000
* SD Boot Validation Type: 0x00000000 (0)
* App Boot Validation Type: 0x00000000 (0)

4. I then used the NRF Connect to program 4 files: settings, blinky_mbr, secure bootloader and mbr(mbr taken from test image folder)

Observation:
1. The blinky app runs normally
2. If I hold down button 4 and power-cycle, LEDs 1 and 3 are lit.After sometime, normal mode where app runs is entered and the app runs

I guess there is a hardfault and DFU mode is not entered. Instead after some time, maybe due to watchdog reset, normal app runs. I am unable to understand what I am missing here


Queries:
1. How to enter DFU mode?
2. Is it OK to use nrf Connect programmer to program all at once
3. How to enable RTT / UART logs on IAR? In the sdk_config file, I only see NRF_LOG_ENABLED. No macros related to UART / RTT

Note that I just want to check getting into bootloader mode as a first step and it is not working. Hence not getting into creating my own private -public key-pair

Parents
  • Hi,

    You have not specified clearly which bootloader example and transport layer you use for DFU. Can you clarify? If you use the BLE bootloader, then you must also program the SoftDevice, which is used to handle BLE communication.

  • Aadishri GS said:
    I use Secure bootloader and UART

    Oh, yes. I don't know how I failed to see that. In that case it should not be any problem.

    If I hold down button 4 and power-cycle, LEDs 1 and 3 are lit.After sometime, normal mode where app runs is entered and the app runs

    How long is that time? The bootloader has an inactivity timeout and will reset and start the application if nothing happens for the specified duration of time. This is configured by NRF_BL_DFU_INACTIVITY_TIMEOUT_MS in the bootloaders sdk_config.h, and the default value is 120000 ms (two minutes).

    1. How to enter DFU mode?

    You can enter DFU mode by asserting a GPIO pin while resetting the device. You select which pin by setting NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN to the GPIO number you want in the bootloaders sdk_config.h. For the PCA10056 (nRF52840 DK) project, this is GPIO pin 25, which is connected to button 4.

    2. Is it OK to use nrf Connect programmer to program all at once

     Yes.

    3. How to enable RTT / UART logs on IAR? In the sdk_config file, I only see NRF_LOG_ENABLED. No macros related to UART / RTT

    You should use the debug bootloader project which has RTT logging enabled by default. You can find it under <SDK>\examples\dfu\secure_bootloader\pca10056_uart_debug\. You cannot view the RTT log from IAR, but you can still build the project with IAR, and view the logs using J-Link RTT Viewer.

Reply
  • Aadishri GS said:
    I use Secure bootloader and UART

    Oh, yes. I don't know how I failed to see that. In that case it should not be any problem.

    If I hold down button 4 and power-cycle, LEDs 1 and 3 are lit.After sometime, normal mode where app runs is entered and the app runs

    How long is that time? The bootloader has an inactivity timeout and will reset and start the application if nothing happens for the specified duration of time. This is configured by NRF_BL_DFU_INACTIVITY_TIMEOUT_MS in the bootloaders sdk_config.h, and the default value is 120000 ms (two minutes).

    1. How to enter DFU mode?

    You can enter DFU mode by asserting a GPIO pin while resetting the device. You select which pin by setting NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN to the GPIO number you want in the bootloaders sdk_config.h. For the PCA10056 (nRF52840 DK) project, this is GPIO pin 25, which is connected to button 4.

    2. Is it OK to use nrf Connect programmer to program all at once

     Yes.

    3. How to enable RTT / UART logs on IAR? In the sdk_config file, I only see NRF_LOG_ENABLED. No macros related to UART / RTT

    You should use the debug bootloader project which has RTT logging enabled by default. You can find it under <SDK>\examples\dfu\secure_bootloader\pca10056_uart_debug\. You cannot view the RTT log from IAR, but you can still build the project with IAR, and view the logs using J-Link RTT Viewer.

Children
  • debug bootloader project

    Can I debug with Step-into/over the code with this debug bootloader code?

    1. Can you kindly elaborate the steps? I cannot see these debug buttons enabled on IAR.

    2. Also, can I see the DFU in action with this code running in debug mode?

  • 1. The difference between the debug bootloader and the "normal" is that is has RTT logging enabled, which increases the size. There are no additional steps for using this. You build and program it like the "normal" bootloader, but you can view the RTT log if you want to see what is going on. It is not related to debugging via a debugger. You can break in the bootloader if you like, but then you probably want to disable optimization. (In that case, you also have to move the start address of the bootloader as the size will increase.)

    2. I don't know exactly what you mean by seeing DFU in action, but here will be extensive logging RTT through the DFU procedure when you use the debug bootloader. This gives a good understanding about what is happening, and can be used to track down most bootloader issues quite fast.

  • I don't know exactly what you mean by seeing DFU in action

    I meant going through the code while DFU is happening live (packet transfer etc). Is it possible? Like how we debug regular application...

    If you dont mind, I had a few more queries about logging and DFU

    1. If I enable UART logging, where will I see the logs? Coz, we already have the UART being used for DFU??

    2. I could not enable USB interface (port labelled nRF USB next to Reset button on nRF52840 DK) for DFU. I tried both Win 7 and Win 10 PCs. The USB port is not even seen in Device manager. Any inputs?

    Thanks so much for your time

  • Hi,

    1. The debug bootloader projects support logging via RTT, so there is no conflict with UART. RTT logging requires you to use a J-Link debugger, such as the on-board debugger on the DK. The logs are automatically on when you use the debug bootloader, so you just need to start and connect the J-Link RTT Viewer application.

    2. The nRF52840 does not enable the USB automatically. It is like any other peripheral (such as UART) in the way that it has to be configured and enabled. It is always disabled by default. If you want to use it for DFU you need a USB bootloader that does this, for instance <SDK15.3>\\examples\dfu\secure_bootloader\pca10056_usb_debug\.

  • I could not enable USB interface

    The USB interface is seen only during Bootloader mode

Related