MCUboot DFU Guide For Raytac MDBT50Q-DB-40 (Using NCS V2.9.1)

This guide teaches you how to use MCUboot for DFU (Device Firmware Update),
Combined with nRF Connect SDK (NCS) V2.9.1 to upgrade firmware on Raytac’s MDBT50Q series modules.


Table of contents:

  1. Hardware Set Up
  2. Software Kits resource download & install
  3. Compile and load the program
    a. Open VS Code
    b. Project setup
    c. Setup the situation for DFU over UART or DFU over USB
    d. Start compiling your project
    e. Load your compiled program into the MDBT50Q-DB-40 demo board
  4. DFU to MDBT50Q-DB-40 over UART / USB
  5. Execute USB DFU using AuTerm
  6. DFU using your custom keys

1. Hardware setup
– Equip Raytac’s MDBT50Q-DB-40 development board
– Ensure the board is connected via USB to your PC


2.Software Kits resources download & install
– Resources download:
nRF Connect for Desktop – Download nRF Connect for Desktop (Please Click Me)
nRF Command Line Tools – Download nRF Command Line Tools (Please Click Me)
Visual Studio Code – Download Visual Studio Code(Please Click Me)

Install nRF Connect for Desktop ➔ install Programmer and Toolchain Manager.


Open Toolchain Manager and install SDK V2.9.1.


Install Visual Studio Code


3. Compile and load the program
a. Open VS Code(Visual Studio Code)


Note:
If it’s your first time using the software: after installing all the extensions, you should see the same on your screen.


b. Project setup
b.1 Create an example code(In this article: peripheral_uart)
Please refer to the following steps:
Create a new application ➔ Copy a sample ➔ NCS V2.9.1


b.2 Name the Project: peripheral_uart
Input peripheral_uart and the corresponding example program will appear in the options section below.


Note: We named the project peripheral_uart_mcuboot to distinguish it.
This project will create a directory named peripheral_uart_mcuboot.

c. Build an environment for DFU over UART or DFU over USB
– Create a new application ➔ Open

Right click on the project name you just created (peripheral_uart_mcuboot), a pop-up menu will appear. Select the first option “Show in Explorer" from the pop-up menu to display all project files.


Then select New File to create a sysbuild.conf file.


select sysbuild.conf, left-click on it, and a blank box will show.


Input the file name and write: SB_CONFIG_BOOTLOADER_MCUBOOT=y


Parameters and instructions
Add a new file mcuboot.conf, in the sysbuild folder, and input the following parameters into the file. (Add relevant parameters according to UART or USB)
(Note: Please be informed if you want to use DFU over UART in the end, you should use UART when you first create the environment. Similarly, if you want to use DFU over USB, you should create the USB environment at the beginning.)

For DFU over UART
# Enable logging for MCUboot
CONFIG_LOG=y
CONFIG_MCUBOOT_LOG_LEVEL_WRN=y
# Enable Serial Recovery over UART
CONFIG_MCUBOOT_SERIAL=y
# Disable UART, since Serial Recovery uses it
CONFIG_UART_CONSOLE=n
# Configure the bootloader to use two slots
CONFIG_SINGLE_APPLICATION_SLOT=n
# Turn on a LED so we can see when Serial Recovery mode is active
CONFIG_MCUBOOT_INDICATION_LED=y


For DFU over USB
# Enable logging for MCUboot
CONFIG_LOG=y
CONFIG_MCUBOOT_LOG_LEVEL_WRN=y
# Enable Serial Recovery over UART
CONFIG_MCUBOOT_SERIAL=y
# Disable UART, since Serial Recovery uses it
CONFIG_UART_CONSOLE=n
# Configure bootloader to use two slots
CONFIG_SINGLE_APPLICATION_SLOT=n
# Turn on a LED so we can see when Serial Recovery mode is active
CONFIG_MCUBOOT_INDICATION_LED=y
# Configure serial recovery to use CDC_ACM, which by default uses the USB
CONFIG_BOOT_SERIAL_CDC_ACM=y
# Increase flash space for the MCUboot image to fit USB drivers
CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000


Create a new file: mcuboot.overlay and add the following parameters.


For DFU over UART
/* Configure button and LED for Serial Recovery */
/ {
    aliases {
          mcuboot-button0 = &button0;
          mcuboot-led0 = &led0;
    };
  };


For DFU over USB
/* Configure button and LED for Serial Recovery */
/ {
    aliases {
          mcuboot-button0 = &button0;
          mcuboot-led0 = &led0;
    };
  };
/* Configure CDC ACM */
&zephyr_udc0 {
            cdc_acm_uart0: cdc_acm_uart0 {
                        compatible = “zephyr,cdc-acm-uart";
            };
};


Note: if you use DFU over USB, please enable the USB subsystem in prj.conf.


After all the setup is completed, you can start compiling your project.


d. Start compiling your project
Add Build Configuration ➔ Select target board ➔ In this example, choose raytac_mdbt50q_db_40/nrf52840.


Start compiling by clicking “Generate and Build" at the bottom-right corner.


e. Load your compiled program into the MDBT50Q-DB-40 demo board
After compiling without error, select the flash function to load your program into the MDBT50Q-DB-40 demo board.


If the below is shown, it means that you have successfully loaded your program into the demo board.


4. DFU to MDBT50Q-DB-40 through UART / USB
DFU over UART
Hold the SW2 button then plug the power into the USB connector.
The system will enter the bootloader mode.
You can then DFU the new firmware via the UART.


DFU over USB
If you update your firmware through USB, please also hold the SW2 button and connect the USB cable.


5. Execute USB DFU using AuTerm
AuTerm is a free-for-download PC software on Windows.
It allows you to update your new firmware on the MDBT50Q-DB-40 demo board.
Download link:
https://github.com/thedjnK/AuTerm/releases/download/v0.35a-pre/AuTerm_test_Win_x64_v0.35a.7z

Steps:
Select the tab Config to set the correct COM port.


Follow the sequences in the below screenshot.


You can use the file peripheral_uart_mcuboot.signed.bin for testing.
It is located in peripheral_uart_mcuboot/build.
Then follow the sequences in the below screenshot.
DFU will be completed when the progress reaches 100%.


6. DFU using your custom keys
When you compile the code, you will see the below warning.
Reason: It’s required to have your own private key to ensure your product’s security.
Following are the steps to enable security features.


Step 1. Create the key
First, install the imgtool program using pip.


Then use the following command to generate your private key in your project folder.
After the private key is generated, you can access it in your directory.


Step 2. Configure the project to use this key in sysbuild.conf

# Add MCUboot
SB_CONFIG_BOOTLOADER_MCUBOOT=y
#Add private key for MCUboot
SB_CONFIG_BOOT_SIGNATURE_KEY_FILE="\${APP_DIR}/private_key.pem"
# Configure key type
SB_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y


Step 3. Build and flash the project again. Your firmware will have security features.


Edited by Account Manager: Mr. Welson Kuo


Raytac Corporation 勁達國際電子股份有限公司 / Raytac Corporation (USA)
A Bluetooth, Wi-Fi, and LoRa Module Maker/ODM & OEM Manufacturer based on
Nordic nRF54; nRF53: nRF52; nRF51; nRF7002
Semtech Specification: SX1262


Bluetooth Specification: BT6.1 ; BT6 ; BT5.4 ; BT5.3 ; BT5.2.
Wi-Fi Specification: Wi-Fi 6
LoRa Specification: LoRaWAN


All products are FCC/IC/CE/Telec/KC/RCM/SRRC/NCC/WPC Pre-Certified.
http://www.raytac.com
https://www.raytac.com/contact/
email: sales@raytac.com
Tel: +886-2-3234-0208(TW)/+1-626-217-3139(USA)


Tips for Nordic’s nRF52840 DK to successfully detect Raytac’s MDBT50Q-DB-40 Demo Board

WHY Nordic’s DK cannot DETECT Raytac’s modules?

Some tips to fix this problem

Nordic’S board no : PCA10056 (nRF52840)

Raytac’s board no : MDBT50Q-DB-40 (nRF52840)


1. Update the version of nRF Command Line Tools from below link
https://www.nordicsemi.com/Products/Development-tools/nRF-Command-Line-Tools/Download?lang=en#infotabs

2. Update the version of jlink driver from below link.
https://www.segger.com/downloads/jlink/JLink_Windows_V780c_x86_64.exe


3. Update the version of nRF Connect for desktop.
nRF connect for desktop V4.1.2
Programmer V3.0.9


4. Add jumper wire for GND shown as the below red arrow to avoid the different power reference between these 2 boards.


5. Make sure that IDE cable connects correctly. Red edge of IDE cable should connect to PIN 1 of both boards.

6. Supply power to VDD of Raytac’s demo board before flashing.



Edited by Sales Manager: Ms. Gracie Chuang

Raytac Corporation 勁達國際電子股份有限公司

Bluetooth & WiFi module maker based on Nordic nRF54, nRF53, nRF52, nRF7002 solution
BT5.4 &BT5.3 & BT5.2 & BT5.1 Qualified, FCC/IC/CE/Telec/KC/RCM/SRRC/NCC Pre-Certified.
Bluetooth Solution: nRF54, nRF5340, nRF52840, nRF52833, nRF52832, nRF52820, nRF52811, nRF52810, nRF52805, nRF51822 WiFi Solution: nRF7002
https://www.raytac.com
email:service@raytac.com
Tel: +886.2.3234.0208

How To Use nRF52840/nRF52833 module DevKit(MDBT50Q series) – 2024 Update – Applied to nRF5 SDK

Preface:
Here provides an easy introduction of How to set up of nRF52840 & nRF52833 Module Demo board MDBT50Q-DB-40 (for nRF52840) & MDBT50Q-DB-33 (for nRF52833)

 
 
MDBT50Q-DB-40  is a Demo Board built by Raytac’s MDBT50Q-1MV2  with Red PCBA deployed nRF52840 SoC with Bluetooth 5 & Thread Combo, with 1MB Flash Memory and 256KB RAM and Chip Antenna.
 
MDBT50Q-DB-33 is a Demo Board built by Raytac’s MDBT50Q-512K with Green PCBA deployed nRF52833 SoC with Bluetooth 5 & Thread Combo, with 512KB Flash Memory and 128KB RAM and Chip Antenna.
 
Both demo boards are Bluetooth BT5.4 qualified and FCC, IC, CE, Telec, KC, SRRC, RCM, NCC, WPC pre-certified.

Table of contents:

1.1 Hardware Set Up

1.2 Software Kits resources & preparations

1.3 Flash the ready firmware into Raytac’s module

1.4 DFU to MDBT50Q-DB-XX through USB interface 


1.1 Hardware Set Up
 
MDBT50Q-DB-XX package contains:
  • 1 x MDBT50Q-DB-40/MDBT50Q-DB-33
  • 1 x IDC Wire
  • 1 x Data/Power Mini USB Wire(for data transferring)

Where to buy MDBT50Q-DB-XX?

MDBT50Q-DB-40 (nRF52840 Solution)

MDBT50Q-DB-33 (nRF52833 Solution)
Connect Nordic NRF52-DK/NRF52840-DK Connect with MDBT50Q-DB-40 by IDC Wire

※Note: PCA10056 (NRF52840-DK) / PCA10040 (NRF52832-DK) / PCA10100(NRF52833-DK)

Power up MDBT50Q-DB-XX using Mini USB

IMG_0064.jpg
MDBT50Q-DB-40

MDBT50Q-DB-40 Schematic:

MDBT50Q Demo Board Schematic-V2.jpg

MDBT50Q-DB-33 Schematic:

MDBT50Q-DB-33 Schematic


1.2 Software kits resources & preparations

Resources:

Download nRF Connect For Desktop (Please Click Me)

Download nRF Command Line Tools (Please Click Me)

Download NRF5 SDK (The latest V17.1.0) (Please Click Me)

Download Visal Studio Code(Please Click Me)

Preparations:

Option 1.  NRF5 SDK (The latest version V17.1.0)

  1. 1.0_ddde560\components\softdevice\s140\hex\ s140_nrf52_7.2.0_softdevice.hex
  2. 1.0_ddde560\examples\ble_peripheral\ble_app_uart\pca10056\s140\arm5_no_packs\_build\ nrf52840_xxaa.hex

*Tips: If you go with nRF5 SDK option, please consider to add a bootloader hex file if you’re going to make DFU requests in the future.

Option 2.  NCS (Recommended version V2.6.0)

螢幕擷取畫面 2024-06-04 161138

2A.  Find “Toolchain Manager” in app nRFConnect for Desktop

螢幕擷取畫面 2024-06-04 161251

2B.  Install nRFConnect SDK V2.6.0 to your working site.

螢幕擷取畫面 2024-06-04 161333

2C. Prepared with the latest version of nRF Command Line Tools
螢幕擷取畫面 2024-06-04 161627
 
**Note: SEGGER J-LINK Upgrade message might pop up while you’re doing above download.
螢幕擷取畫面 2024-06-04 161724
 
2D. Locate all the necessary kits for programming in PC

螢幕擷取畫面 2024-06-04 161810


1.3 Flash the ready firmware into Raytac’s module

Intro:

With the ready built code of zephyr.hex (Made through NCS) or nrf52840_xxaa.hex & s140_nrf52_7.2.0_softdevice.hex (Made through nRF5-SDK) file for application, we would like to move onto  flashing code into the MDBT50Q BLE module(mounted on MDBT50Q-DB-XX demo board).

Step1.  

Execute nRF Connect >>  Programmer  > > Open

螢幕擷取畫面 2024-06-04 161858

Step2.

Click “SELECT DEVICE” >> Find icon “nRF52840 DK” which is detected by the programmer app

螢幕擷取畫面 2024-06-04 162005

Step3.

Click “nRF52840 DK”>> “Erase All” to remove flash memory inside MDBT50Q BLE Module

螢幕擷取畫面 2024-06-04 162106

Step4.

Click “Add File” to load application zephyr.hex into programmer

螢幕擷取畫面 2024-06-04 162202

!! Important Tips:!!

 

  • If you’re using nRF Connect SDK for code compiling as above, Program the hex file to MDBT50Q BLE module on the MDBT50Q-DB Demo board:
    – C:\ncs\v2.6.0\nrf\samples\bluetooth\peripheral_uart\build\zephyr\zephyr.hex
  • If you’re using NRF5 SDK for code compiling, do make the 4-in-1 hex file (merged ready) before programming it to MDBT50Q BLE module.  It includes the 4 hex files below:

(1) bootloader.hex

(2) bootloader_setting_file.hex

(3) s140_nrf52_7.2.0_softdevice.hex

(4) nrf52840_xxaa.hex

螢幕擷取畫面 2024-06-04 162300


1.4 DFU to MDBT50Q-DB-XX through USB interface

Intro : Before DFU implement , Please make sure the bootloader file has been installed in your MDBT50Q BLE module.

※Note: NRF52840 SoC supports USB interface to utilize Device Firmware Update (DFU).

How do I prepare the software??

  • Download nrfutil.exe file from Nordic website .
  • It is workable to do List, Program, Recover, Erase, and operations with nRFutil device command to Nordic device.
  • Open DOS mode to install device command type: nrfutil install device

(Jocelyn) How To Use NRF52840 NRF52833 module Dev Kit (MDBT50Q Series) 2024 version - Release file

How do I setup the hardware??

  1. Press Switch 4 and hold
  2. Power up Demo Board
  3. Blue LED Lights on
  4. Demo Board successfully enters into USB DFU Mode

螢幕擷取畫面 2024-06-04 162504

How do I prepare the firmware??

**USB DFU works only in DOS mode.

**USB DFU only works when USB Bootloader installed in current loaded firmware (inside BLE Module)

A single, merged 4-in-1 hex file is required, which includes:

Bootloader, Bootloader setting, Softdevice, and Application.

Firmware DFU requires a .zip file.

USB DFU Execution Steps:

Step 1. When Blue LED Lights on with MDBT50Q-DB (Ready to enter USB DFU Mode)

Step 2. Find out Com Port No. “nRF52 SDFU USB(COMxx)”

螢幕擷取畫面 2024-06-04 162542


Step 3. Execute USB DFU

Option 1. Using device program command:

(1) List the devices with a DFU trigger interface by running:

nrfutil device list –traits nordicDfu

Option1-1

(2) Program new firmware to a device identified by its serial number by running:

nrfutil device program –firmware .zip nrf52840_xxaa.zip –serial-number XXXXXXXXXXXX

Option1-2