Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts

Friday, February 7, 2020

Firmware Coding & DFU onto MDBT50Q-RX

Hi there, 

Here introduce the firmware perspective about how to program your code onto MDBT50Q-RX dongle.

Believed all readers have done the hardware setting and now has well prepared to load the code onto the dongle. (If not yet done the hardware setting, pls find it here)

In this blog, we will introduce the procedure based on below 2 scenarios
  • First time to load the code
  • DFU Firmware update by USB or OTA (through Bluetooth over the air)

First time to load the code:

1. Generate Public Key

For security reason, Public Key is the first step to proceed (DOS Environment MUST)
   Command to produce Public Key is in below:

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

2. Edit Bootloader (Use Keil C as the example)
    2.1 Open a project

\nRF5_SDK_15.3.0_59ac345\examples\dfu\secure_bootloader\pca10056_ble

    2.2 Paste the Public Key produced from step 1 in the red square.

    2.3 Set up Button behavior to trigger the Bootloader function start
    2.3.1 Activate to enter the Bootloader function by using button pressed. (Developers may change to others if don't like this way. Just enter "secure_bootloader" project and modify "sdk_config.h")


    2.3.2 Modify button pin no. (Developers can modify "sdk_config.h" in "secure_bootloader" project)


    2.3.3 Modify LED pin no. (Developers can modify "pca10056.h" in "secure_bootloader" project)


3. Edit Application
   Open and edit the project

\nRF5_SDK_15.3.0_59ac345\examples\peripheral\usbd_ble_uart\pca10056\s140\arm5_no_packs

4. Generate bootloader_settings.hex file

nrfutil.exe settings generate --family NRF52840 --application USBD_TO_UART.hex --application-version 3 --bootloader-version 2 --bl-settings-version 1 bootloader_settings.hex

5. Merge files
1Bootloader.hex
2bootloader_settings.hex
3s140_nrf52_6.1.1_softdevice.hex
4USBD_TO_UART.hex
mergehex.exe -m Bootloader.hex bootloader_settings.hex -o Combind0.hex
mergehex.exe -m Combind0.hex s140_nrf52_6.1.1_softdevice.hex -o Combind1.hex
mergehex.exe -m Combind1.hex USBD_TO_UART.hex x -o USBD_TO_UART_BT_SD_APP.hex



6. Use nRFconnect to burn the merged code onto dongle (nRF52840 IC)
Launch the programmer

Load the merged .hex file
Program the .hex file



Right here, the code should be loaded onto dongle successfully.
Hope all you guys enjoy the journey and completed the setup.

In case you are not happy about the code you just loaded?
No worry, we now introduce DFU process in below to retrieve your happiness.


Tuesday, December 18, 2018

Bluetooth Project: How to program your firmware to module

After setup been done, here comes the next question: How to program the firmware in to the module. We are using some simple instruction in below for reader's quick reference.

Hardware
You will need a Nordic nRF5X DK or a Segger J-link as programmer to load the firmware. To use Nordic nRF5X DK to debug the SoC as well, you will need to order corresponding nRF5X DK to match the SoC number. For example, order nRF52840 DK to debug nRF52840 SoC or order nRF52 DK to debug nRF52832/52810 SoC. But if you are only using it as programmer, any version of nRF5X DK will work as we only use the J-link on this board.

Software
Please download Nordic nRFGo Studio or Nordic nRF Connect for Desktop for programming. Remember to install nRF5X Command Line Tools if the board was not detected by nRFGo Studio. Once they are all connected, you can then start programming. Please make sure to “erase all” every time before programming.


For more tutorials and demo of sample code, please visit Nordic’s DevZone and Infocenter where have ample resources to utilize. 

Programing 
Case A. SoftDevice + Application

1. If Softdevice and Application code separately
Erase all first. Then program Softdevice and follow by Application code.
   
2. If Softdevice and Application combined code is available (Recommend)
Erase all first. Then program the combined code
   
 **Raytac module comes with testing code programmed. Please erase the testing code as the first step and then start the programming.

Case B. SoftDevice + Bootloader+ Application

1. Softdevice+Bootloader 
Erase all first. Program the Softdevice and follow by Bootloader. Then use DFU to update the application code.

2. Softdevice+Application+Bootloader combined code is available (Recommend)
Erase all First and follow by programming the combined code.

 **Raytac module comes with testing code programmed. Please erase the testing code as the first step and then start the programming.

*Remark
Bootloader is needed for DFU (OTA) Function.
SDK 11 (included) and before - a legacy DFU method, which is simple but less security
SDK 12 (Included) and after - a latest DFU method, which has higher security.



To easy customer's IoT device mass production, Raytac provide code pre-program service into module before shipment.  There are requirements listed in below for customers who need the service!

1. A single, combined hex file is required. Please combine softdevice and application or/and bootloader (depending on your firmware design) together before programming. This will shorten programming time and help to manage your code easier.
2. Need a simple method to check programming status. The easiest way is to check the device name if device will broadcast device name after programming is done; or use I/O to trigger LED and its behavior. This does not aim to test any or full function of your device, only a simple method for the operator to know programming status.


Raytac Corporation 勁達國際電子有限公司
A BT5 & BT 4.2 & BTv4.1 module maker based on Nordic nRF51 & nRF52 solution 
(nRF51822 & nRF51422 & nRF52832 & nRF52810 & nRF52840)
www.raytac.com          email: cs@raytac.com          Tel: +886.2.3234.0208