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

Problem about thread OTA

I need to implement using OTA to upgrade the thread.I followed Thread Tutorial: Practical guide for device upgrade OTA provided to complete the upgrade process,but it didn't success.

I have 3 nRF52840 Development Kits.
1 DK will run a Client + Bootloader.
1 DK will run a Server.
1 DK will be used as a packet sniffer.

Here are my steps.

Step 1: nRF Sniffer with Wireshark setup.
I followed the instructions and did.

Step 2: Setup for a bootloader with logging.
I don't need to log, so I didn't do this step.

Step 3: Setup for new Client firmware
I followed the instructions and did.

Step 4: Generating keys
I followed the instructions and did.

nrfutil keys generate priv.pem
nrfutil keys display --key pk --format code priv.pem --out_file dfu_public_key.c

then replace dfu_public_key.c with the <InstallFolder>\examples\dfu\dfu_public_key.c

Step 5: Command line script
I only changed the snr in the script, here is the result of the run.

make -j -C bootloader\pca10056\blank\armgcc
make -j -C Client\pca10056\blank\armgcc
make -j -C Client_test\pca10056\blank\armgcc

nrfutil pkg generate --hw-version 52 --sd-req 0x00 --application-version 2 --application Client_test\pca10056\blank\armgcc\_build\nrf52840_xxaa.hex --key-file priv.pem app_dfu_package.zip

nrfutil settings generate --family NRF52840 --application Client\pca10056\blank\armgcc\_build\nrf52840_xxaa.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 settings.hex

mergehex -m Client\pca10056\blank\armgcc\_build\nrf52840_xxaa.hex settings.hex -o dfu_Client.hex

REM Programming section
REM Board 1
nrfjprog -e --snr 683879203
nrfjprog -f nrf52 --program mbr_nrf52_2.4.1_mbr.hex --chiperase --snr 683879203
nrfjprog -f nrf52 --program bootloader\pca10056\blank\armgcc\_build\nrf52840_xxaa_mbr.hex --snr 683879203
nrfjprog -f nrf52 --program dfu_Client.hex --sectorerase --snr 683879203
nrfjprog -r --snr 683879203
PAUSE

Step 6: Test procedure
1. use nrfutil to flash the Server firmware to the Server DK. From the dfu folder (<InstallFolder>\examples\thread\dfu\) open a command prompt window and run the following command:

nrfutil dfu thread -f -pkg app_dfu_package.zip -p COM6 --channel 11 --panid 43981

2. Power up the client,and run script  create in Step 5.

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>make -j -C bootloader\pca10056\blank\armgcc
make: Entering directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/dfu/bootloader/pca10056/blank/armgcc'
make: *** No rule to make target 'c\:\arm-gcc\lib\gcc\arm-none-eabi\10.2.1\include\stdint.h', needed by '_build/nrf52840_xxaa_mbr/bsp.c.o'.  Stop.
make: Leaving directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/dfu/bootloader/pca10056/blank/armgcc'

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>make -j -C Client\pca10056\blank\armgcc
make: Entering directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/dfu/Client/pca10056/blank/armgcc'
make: *** No rule to make target 'c\:\arm-gcc\lib\gcc\arm-none-eabi\10.2.1\include\stdint.h', needed by '_build/nrf52840_xxaa/bsp.c.o'.  Stop.
make: Leaving directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/dfu/Client/pca10056/blank/armgcc'

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>make -j -C Client_test\pca10056\blank\armgcc
make: Entering directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/dfu/Client_test/pca10056/blank/armgcc'
make: *** No rule to make target 'c\:\arm-gcc\lib\gcc\arm-none-eabi\10.2.1\include\stdint.h', needed by '_build/nrf52840_xxaa/bsp.c.o'.  Stop.
make: Leaving directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/dfu/Client_test/pca10056/blank/armgcc'

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>nrfutil pkg generate --hw-version 52 --sd-req 0x00 --application-version 2 --application Client_test\pca10056\blank\armgcc\_build\nrf52840_xxaa.hex --key-file priv.pem app_dfu_package.zip
Zip created at app_dfu_package.zip

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>nrfutil settings generate --family NRF52840 --application Client\pca10056\blank\armgcc\_build\nrf52840_xxaa.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:                      0xC4963B7D
* Settings Version:         0x00000001 (1)
* App Version:              0x00000001 (1)
* Bootloader Version:       0x00000001 (1)
* Bank Layout:              0x00000000
* Current Bank:             0x00000000
* Application Size:         0x000642E0 (410336 bytes)
* Application CRC:          0x4F829DC2
* 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)


D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>mergehex -m Client\pca10056\blank\armgcc\_build\nrf52840_xxaa.hex settings.hex -o dfu_Client.hex
Parsing input files.
Merging file "nrf52840_xxaa.hex" into output.
Merging file "settings.hex" into output.
Storing merged file.

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>REM Programming section

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>REM Board 1

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>nrfjprog -e --snr 683879203
Erasing user available code and UICR flash areas.
Applying system reset.

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>nrfjprog -f nrf52 --program mbr_nrf52_2.4.1_mbr.hex --chiperase --snr 683879203
Parsing image file.
Erasing user available code and UICR flash areas.
Applying system reset.
Checking that the area to write is not protected.
Programming device.

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>nrfjprog -f nrf52 --program bootloader\pca10056\blank\armgcc\_build\nrf52840_xxaa_mbr.hex --snr 683879203
Parsing image file.
Reading flash area to program to guarantee it is erased.
Checking that the area to write is not protected.
Programming device.

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>nrfjprog -f nrf52 --program dfu_Client.hex --sectorerase --snr 683879203
Parsing image file.
Erasing page at address 0x1000.
Erasing page at address 0x2000.
Erasing page at address 0x3000.
Erasing page at address 0x4000.
Erasing page at address 0x5000.
Erasing page at address 0x6000.
Erasing page at address 0x7000.
Erasing page at address 0x8000.
Erasing page at address 0x9000.
Erasing page at address 0xA000.
Erasing page at address 0xB000.
Erasing page at address 0xC000.
Erasing page at address 0xD000.
Erasing page at address 0xE000.
Erasing page at address 0xF000.
Erasing page at address 0x10000.
Erasing page at address 0x11000.
Erasing page at address 0x12000.
Erasing page at address 0x13000.
Erasing page at address 0x14000.
Erasing page at address 0x15000.
Erasing page at address 0x16000.
Erasing page at address 0x17000.
Erasing page at address 0x18000.
Erasing page at address 0x19000.
Erasing page at address 0x1A000.
Erasing page at address 0x1B000.
Erasing page at address 0x1C000.
Erasing page at address 0x1D000.
Erasing page at address 0x1E000.
Erasing page at address 0x1F000.
Erasing page at address 0x20000.
Erasing page at address 0x21000.
Erasing page at address 0x22000.
Erasing page at address 0x23000.
Erasing page at address 0x24000.
Erasing page at address 0x25000.
Erasing page at address 0x26000.
Erasing page at address 0x27000.
Erasing page at address 0x28000.
Erasing page at address 0x29000.
Erasing page at address 0x2A000.
Erasing page at address 0x2B000.
Erasing page at address 0x2C000.
Erasing page at address 0x2D000.
Erasing page at address 0x2E000.
Erasing page at address 0x2F000.
Erasing page at address 0x30000.
Erasing page at address 0x31000.
Erasing page at address 0x32000.
Erasing page at address 0x33000.
Erasing page at address 0x34000.
Erasing page at address 0x35000.
Erasing page at address 0x36000.
Erasing page at address 0x37000.
Erasing page at address 0x38000.
Erasing page at address 0x39000.
Erasing page at address 0x3A000.
Erasing page at address 0x3B000.
Erasing page at address 0x3C000.
Erasing page at address 0x3D000.
Erasing page at address 0x3E000.
Erasing page at address 0x3F000.
Erasing page at address 0x40000.
Erasing page at address 0x41000.
Erasing page at address 0x42000.
Erasing page at address 0x43000.
Erasing page at address 0x44000.
Erasing page at address 0x45000.
Erasing page at address 0x46000.
Erasing page at address 0x47000.
Erasing page at address 0x48000.
Erasing page at address 0x49000.
Erasing page at address 0x4A000.
Erasing page at address 0x4B000.
Erasing page at address 0x4C000.
Erasing page at address 0x4D000.
Erasing page at address 0x4E000.
Erasing page at address 0x4F000.
Erasing page at address 0x50000.
Erasing page at address 0x51000.
Erasing page at address 0x52000.
Erasing page at address 0x53000.
Erasing page at address 0x54000.
Erasing page at address 0x55000.
Erasing page at address 0x56000.
Erasing page at address 0x57000.
Erasing page at address 0x58000.
Erasing page at address 0x59000.
Erasing page at address 0x5A000.
Erasing page at address 0x5B000.
Erasing page at address 0x5C000.
Erasing page at address 0x5D000.
Erasing page at address 0x5E000.
Erasing page at address 0x5F000.
Erasing page at address 0x60000.
Erasing page at address 0x61000.
Erasing page at address 0x62000.
Erasing page at address 0x63000.
Erasing page at address 0x64000.
Erasing page at address 0x65000.
Erasing page at address 0xFE000.
Erasing page at address 0xFF000.
Applying system reset.
Checking that the area to write is not protected.
Programming device.

D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu>nrfjprog -r --snr 683879203
Applying system reset.
Run.

Then the server never had the client upgrade prompt.I have attached the package that my sniffer caught, please help to see why it is not upgraded.

OTA.rar

Parents Reply Children
  • I ran the dfu2 file you gave me, here is the output from the terminal, the output just keeps pausing at "Thread DFU server is running... Press <Ctrl + D> to stop. "this line.

    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>set DFU_SERVER_COM_PORT=COM6
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>set DFU_SERVER_DK=683193868
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>set CLIENT_DK_SNR=683571084
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>make -j9 -C bootloader\pca10056\blank\armgcc
    make: Entering directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/dfu2/bootloader/pca10056/blank/armgcc'
    make: *** No rule to make target 'c\:\arm-gcc\lib\gcc\arm-none-eabi\10.2.1\include\stdint.h', needed by '_build/nrf52840_xxaa_mbr/bsp.c.o'.  Stop.
    make: Leaving directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/dfu2/bootloader/pca10056/blank/armgcc'
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>make -j9 -C client\pca10056\blank\armgcc
    make: Entering directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/dfu2/client/pca10056/blank/armgcc'
    make: *** No rule to make target 'c\:\arm-gcc\lib\gcc\arm-none-eabi\10.2.1\include\stdint.h', needed by '_build/nrf52840_xxaa/bsp.c.o'.  Stop.
    make: Leaving directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/dfu2/client/pca10056/blank/armgcc'
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>make -j9 -C ..\ncp\ftd\uart\pca10056\blank\armgcc\
    make: Entering directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/ncp/ftd/uart/pca10056/blank/armgcc'
    make: *** No rule to make target 'c\:\arm-gcc\lib\gcc\arm-none-eabi\10.2.1\include\stdint.h', needed by '_build/nrf52840_xxaa/boards.c.o'.  Stop.
    make: Leaving directory 'D:/widic/nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8/examples/thread/ncp/ftd/uart/pca10056/blank/armgcc'
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>del files\settings.hex
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>nrfutil settings generate --family NRF52840 --application client\pca10056\blank\armgcc\_build\nrf52840_xxaa.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 files\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: files\settings.hex
    
    Bootloader DFU Settings:
    * File:                     files\settings.hex
    * Family:                   NRF52840
    * Start Address:            0x000FF000
    * CRC:                      0x8736CF1A
    * Settings Version:         0x00000002 (2)
    * App Version:              0x00000001 (1)
    * Bootloader Version:       0x00000001 (1)
    * Bank Layout:              0x00000000
    * Current Bank:             0x00000000
    * Application Size:         0x000642E0 (410336 bytes)
    * Application CRC:          0xDA4F70D9
    * Bank0 Bank Code:          0x00000001
    * Softdevice Size:          0x00000000 (0 bytes)
    * Boot Validation CRC:      0xAFFD6110
    * SD Boot Validation Type:  0x00000000 (0)
    * App Boot Validation Type: 0x00000001 (1)
    
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>del files\dfu_client.hex
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>mergehex -m client\pca10056\blank\armgcc\_build\nrf52840_xxaa.hex files\settings.hex -o files\dfu_client.hex
    Parsing input files.
    Merging file "nrf52840_xxaa.hex" into output.
    Merging file "settings.hex" into output.
    Storing merged file.
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>nrfjprog -e --snr 683571084
    Erasing user available code and UICR flash areas.
    Applying system reset.
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>nrfjprog -e --snr 683193868
    Erasing user available code and UICR flash areas.
    Applying system reset.
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>nrfjprog --program ..\..\..\components\softdevice\mbr\hex\mbr_nrf52_2.4.1_mbr.hex --verify --snr 683571084
    Parsing image file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    Verifying programming.
    Verified OK.
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>nrfjprog --program bootloader\pca10056\blank\armgcc\_build\nrf52840_xxaa_mbr.hex --verify --snr 683571084
    Parsing image file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    Verifying programming.
    Verified OK.
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>nrfjprog --program files\dfu_client.hex --verify --snr 683571084
    Parsing image file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    Verifying programming.
    Verified OK.
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>nrfjprog --reset --snr 683571084
    Applying system reset.
    Run.
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>del files\app_dfu_package.zip
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>nrfutil pkg generate --hw-version 52 --sd-req 0x00 --application-version 2 --application files\app_3.hex --key-file ..\..\dfu\private.pem files\app_dfu_package.zip
    Zip created at files\app_dfu_package.zip
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>nrfjprog --program ..\ncp\ftd\uart\pca10056\blank\armgcc\_build\nrf52840_xxaa.hex --verify --snr 683193868
    Parsing image file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    Verifying programming.
    Verified OK.
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>nrfjprog --reset --snr 683193868
    Applying system reset.
    Run.
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>TIMEOUT 5
    
    等待 0 秒,按一个键继续 ...
    
    D:\widic\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\examples\thread\dfu2>nrfutil dfu thread -pkg files\app_dfu_package.zip -p COM6 --channel 12 --panid 43981
    Address not specified. Using ff03::1 (all Thread nodes)
    Using connectivity board at serial port: COM6
    Waiting for NCP to promote to a router...
    Thread DFU server is running... Press <Ctrl + D> to stop.
    
    
    
    

  • So that means that it is working? Did the LED4 turn on on the client DK after a while? (NB: It takes a while). If not, can you open an RTT viewer to monitor the log from the client DK? Also, make sure that the Thread channel used on the client DK is 12. It should be set in sdk_config.h in the dfu2 folder I sent you, in the client\pca10056\blank\config\sdk_config:

    #define THREAD_CHANNEL 12

    I don't know if it makes a difference, but please set this in the NCP example as well:

    sdk\examples\thread\ncp\ftd\uart\pca10056\blank\config\sdk_config.h.

    If it doesn't work, please let me know what the RTT log of the client DK says.

    Best regards,

    Edvin

  • Hi Edvin,

    It worked successfully.Thanks.

    I have one more question. I actually want to implement DFU on  NEC v1.4.99-dev1, is there any example?

    Best regards,

    winik

  • What is NEC v1.4.99-dev1?

    If you are talking about NCS (nRF Connect SDK), then that is a different story. I am not too experienced with NCS yet, but there is something called mcu_boot. Zephyr has it's own implementation of bootloaders and DFU, and it is not related to the bootloader in the nRF5 SDK. If you are interested in that, I suggest you open a new ticket regarding the NCS bootloader and MCU boot, as it is a different topic than this. 

    Best regards,

    Edvin

Related