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.

  • I just saw that the HW version was not matching. I made it to 0 in my bootloader code and it successfully updated!!

    Below is the command I used:

    Code\nRF_OriginalSDK\nRF5_SDK_15.3.0_59ac345_TRY\BUILDS\190503\dfu>nrfutil dfu serial -pkg dfu_test.zip -p COM5 -b 115200 -fc 1

    Traceback (most recent call last):
    File "C:\Python27\Scripts\nrfutil-script.py", line 9, in <module>
    load_entry_point('nrfutil==5.2.0', 'console_scripts', 'nrfutil')()
    File "c:\python27\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
    File "c:\python27\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
    File "c:\python27\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "c:\python27\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "c:\python27\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File "c:\python27\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
    File "c:\python27\lib\site-packages\nordicsemi\__main__.py", line 1042, in serial
    timeout)
    File "c:\python27\lib\site-packages\nordicsemi\__main__.py", line 956, in do_serial
    dfu.dfu_send_images()
    File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 129, in dfu_send_images
    self._dfu_send_image(self.manifest.application)
    File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 97, in _dfu_send_image
    self.dfu_transport.send_init_packet(data)
    File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 256, in send_init_packet
    self.__execute()
    File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 421, in __execute
    self.__get_response(DfuTransportSerial.OP_CODE['Execute'])
    File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 502, in __get_response
    raise NordicSemiException('Extended Error 0x{:02X}: {}'.format(resp[3], data))
    pc_ble_driver_py.exceptions.NordicSemiException: Extended Error 0x06: The hardware version of the device does not match the required hardware version for the update.

    Code\nRF_OriginalSDK\nRF5_SDK_15.3.0_59ac345_TRY\BUILDS\190503\dfu>nrfutil dfu serial -pkg dfu_test.zip -p COM5 -b 115200 -fc 1
    [####################################] 100%
    Device programmed.

    Tips for those who face similar issues:

    1. The command I used to create package:

    nrfutil pkg generate --hw-version 0 --sd-req 0x00 --application-version 1 --key-file private.key –application blinky_pca10056_mbr_new.hex dfu_test.zip

    2. The command I used to generate the bootloader_settings file:

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

    I have uploaded the updated secure bootloader hex with HW version 0 instead of the default 52 in the sdk_config.h

    secure_bootloader_uart_mbr_pca10056.hex

    3. I installed Python 2.7.11.

        3.7 version should not be installed. nrfutil version was 5.2.0

    4. Connect all UART Pins: RX 8, TX 6, CTS 7, RTS 5, GND and VCC

    5. Don't forget to add MBR and Booloader_settngs file apart from the app and booloader hex. Total 4 files

    6. Use the new nRF Connect-Programmer

  • Also, LEDs 1 and 3 glow indicating the board has entered Bootloader mode

  • 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.

Reply
  • 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.

Children
Related