Showing posts with label USB. Show all posts
Showing posts with label USB. Show all posts

Friday, June 20, 2025

nRF52840 Nordic SoC USB Dongle – MDBT50Q-CX-40, Now Supports Zephyr RTOS

[New Taipei City, Taiwan] 

Zephyr RTOS hosted in Linux system has become a leading IoT ecosystem and it has been widely adopted as an open-source , real-time operation system for embedded devices, making it easier for developers to integrate the project smoothly.


Nordic Semiconductor , a main contributor to Zephyr, from the Bluetooth LE controller and USB stack to test tools, DFU frameworks.. and more, is making great effort and strategic decisions to adopt the Zephyr open-source into its nRFConnect(NCS) SDK program.

Raytac Corporation , a hardware-based manufacturer and a comprehensive solution developer with Nordic SoC development for multi-protocol complied wireless modules, now expands support for Zephyr RTOS ecosystem with its nRF52840 USB-C dongle – MDBT50Q-CX-40.

Zephyr support package for MDBT50Q-CX-40: 

https://docs.zephyrproject.org/latest/boards/raytac/mdbt50q_cx_40_dongle/doc/index.html


Reminder: The current Nordic released NCS SDK may NOT upgrade with Zephyr package at the same pace ; It is recommended to get the latest NCS SDK version to access the complete Zephyr support package.

If you’re interested in how Zephyr becomes powerful for a developer to start a project design easier and how the Nordic nRFConnect SDK community brings you to the world of Zephyr RTOS system, never hesitate to save the spot in the upcoming webinar on July 2nd, 2025. How Zephyr became the leading open-source RTOS for IoT (Click on the link to know more)

Resources:
– Begin your journey with Nordic nRFConnect SDK community – nRF Connect SDK Fundamentals
– User Manual of MDBT50Q-CX (nRF52840/nRF52833-based USB-C Dongle)


Edited by Business Development Manager: Ms. Jocelyn Tsai


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)

Thursday, May 29, 2025

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

 is 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 define: 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 over 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)

Thursday, December 26, 2024

How to use Raytac’s MDBT50Q-CX-40 dongle as a BLE sniffer?

 Introduction

Uncertainties in Bluetooth Application Development

Bluetooth’s growing popularity comes with challenges during development. Common issues include hardware instability, software incompatibilities, and environmental interference.
Accurate issue identification and resolution are keys to successful development.

Common Uncertainties
Unstable Connections: Disruptions from wireless signals or physical obstacles.
Pairing Failures: Devices unable to establish connections.
Data Errors: Packet loss or corruption during transmission.
Compatibility Problems: Protocol version mismatches affecting interoperability.

Efficient Bluetooth Issue Analysis
Challenges like transmission speed limitations, data loss, connection failures, or protocol violations can arise. As Bluetooth signals travel wirelessly, precise analysis requires specialized tools.
Nordic offers firmware integrated with Wireshark, flashable onto the Raytac MDBT50Q-CX-40 Dongle, enabling engineers to capture and analyze Bluetooth broadcast signals via USB.
This setup streamlines issue identification and resolution.
Below’s how to configure the Dongle for Wireshark reception.

Flashing Firmware into MDBT50Q-CX-40

Step 1: Download and extract the nRF Sniffer for Bluetooth LE from Nordic:
https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE
Step 2: Locate the file: sniffer_nrf52840dongle_nrf52840_4.1.1.hex
This is the firmware to flash into MDBT50Q-CX-40.


Step 3: Press and hold the button on MDBT50Q-CX-40 and plug it into a PC USB port.
Bootloader mode will be activated after the LED light is turned on.
Then flash the firmware using nRF Programmer.

Step 4: Open the nRF Programmer and follow the below steps:
Select the Device:


The device will appear as the name shown in below:


Add Firmware File:


Load sniffer_nrf52840dongle_nrf52840_4.1.1.hex  into the Programmer:


Press “Write” to flash the firmware.
After flashing, press “Select Device” again.
If the Device name appears as nRF Sniffer for Bluetooth, the flashing is successful.


Set Up Wireshark Software Environment
Step 1: Download & install nRF-Util: https://www.nordicsemi.com/Products/Development-tools/nRF-Util
Step 2: Open MS-DOS and use the command nrfutil list to check if the ble-sniffer item is available.
If not, install it using nrfutil install ble-sniffer.


Step 3: Download and Install Wireshark: https://www.wireshark.org/download.html.
Step 4: Open Wireshark and navigate to: Help → About Wireshark → Folders.
Step 5: Locate the string under Personal Extcap Path for the extcap directory, which will be an empty folder.


Step 6: Copy the files from nrf_sniffer_for_bluetooth_le_4.1.1\extcap (downloaded earlier) into Wireshark\extcap directory.


Step 7: After reopening, you should see an interface with a configurable icon next to the dongle.


Step 8: Edit  Configuration Profiles  Import  From Directory  Navigate to the directory nrf_sniffer_for_bluetooth_le_4.1.1\Profile_nRF_Sniffer_Bluetooth_LE and click “Select Folder”.


Step 9: The profile will be imported. Click OK to confirm.


After all the above is done, the setup shall be completed.



Capturing and analyzing Bluetooth packets
After launching the program, you can see the following devices and Dongle settings.
Double-click to start the packet capture process:


If you want to capture packets with PHY=125K, you can use the following settings:


Packet Analysis Method
In Wireshark, select the device from the “Device” menu to capture and analyze broadcast packets.


User Cases – What sniffer can offer
1. Disconnection when transmitting over 20 bytes between Tablet and Raytac’s AT-Command Module:
Through sniffer analysis, it was discovered that Raytac’s module requested a packet length of 251 bytes, but the tablet’s TX setting was limited to 27 bytes.


2. Broadcast Device Name containing invisible characters:
The device could connect using a mobile app but failed to connect using Central’s code.
From the sniffer interface shown below, the device name length is 11, but the Length field shows 13.
The actual data length (Type length + Device Name) = 1 + 11 = 12, indicating an issue with the program’s broadcast name length.


3. Incorrect parameter settings causing issues with throughput or packet reception:
Improper settings can lead to reduced throughput, incorrect data reception, or disconnections.
The diagram below shows a correct setup with high-volume data transmission. The Protocol Length is 251, and the data transmission intervals are consistent, achieving optimal throughput.


Summary

Mastering hardware and software setups and effectively using packet analysis tools can boost development efficiency and enable high-performance Bluetooth applications.

Resources:
https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE
https://docs.nordicsemi.com/bundle/nrfutil_ble_sniffer_pdf/resource/nRF_Sniffer_BLE_UG_v4.0.0.pdf
https://www.wireshark.org/download.html


Edited by Business Development Manager: Mr. Tony Yin
Technical guidance provided by R&D Manager: Mr. Stanley Huang


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

Bluetooth Specification: BT6.0 ; 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
email: sales@raytac.com
Tel: +886-2-3234-0208