Matter Fundamentals – [Lesson 5] – Exercise 2 – Upgrading firmware using Bluetooth LE – v3.3.0-v3.2.0

Exercise steps

1. Open the base code for this exercise.

In Visual Studio Code, in the WELCOME panel, select Open an existing application, navigate to the GitHub repository for the course and open the l5/l5_e2 directory. The application should appear under the APPLICATIONS panel.

This application is a copy of the Matter Lock sample, with added instructions for where to input the code snippets from this exercise.

Note: Any Matter sample can be used, as all the Matter samples in the nRF Connect SDK support OTA Requestor role by default.

2. Enable support for DFU using SMP over Bluetooth LE.

2.1 Add a build configuration and select your board target as usual. Then under Extra CMake arguments, click Add Argument and add the following line to enable support for DFU using SMP over Bluetooth LE (which is by default disabled in Matter samples).

-DCONFIG_CHIP_DFU_OVER_BT_SMP=y
Kconfig

2.2 Click the Generate and Build button, and once the compilation ends, flash the application to your Nordic device.

3. Modify the Matter Lock sample slightly.

To verify that the software update works, it is necessary to introduce modifications in the application and build the binaries again.

3.1 Add a log line to allow easy verification of software update.

In src/app_task.cpp file, in the StartApp() method, add a new log line to allow easy verification that the software update worked.

Add the following line

LOG_INF("================ NEW SOFTWARE IMAGE IS WORKING!!! ===============");
C++

3.2 Modify the VERSION file, by changing the PATCHLEVEL value to any value other one than 0, for example 4.

After the modification, the file should look like this:

VERSION_MAJOR = 3
VERSION_MINOR = 2
PATCHLEVEL = 4
VERSION_TWEAK = 0
EXTRAVERSION =
C++

3.3 Build the sample, but do not flash it again to your DK.

3.4 Open the serial port of your device and make sure that the logs are visible, as it will be needed to verify that the software update succeeded.

Open the serial port of the board, using a VCOM in the CONNECTED DEVICES panel. Click on the Connect to Serial Port icon to the right of the VCOM.

If no logs from the device are visible, click the RESET button on the nRF54L Series DK.

Note

The nRF54L Series DKs enumerate with two serial ports and their numbers can be different on your PC. Select the VCOM with the greater number, for example, if VCOM0 and VCOM1 are available, use VCOM1.

4. Install the nRF Connect Device Manager application on your mobile phone.

4.1 Download and install the nRF Connect Device Manager application on your mobile phone.

4.2 Make sure that the application has permission to use Bluetooth LE on your phone.

4.3 Transfer the software update image from the <path_to_sample>/build/dfu_application.zip directory to your mobile phone.

This can be done in various ways, such as connecting your phone to the PC using a USB cable, transferring with wireless protocols, or sending it via online drive. This depends on the specific model of mobile phone you are using.

5. Perform the software update over Bluetooth LE.

5.1 Press Button 0 on your Nordic DK to start advertising over Bluetooth LE.

5.2 Run the nRF Connect Device Manager application on your mobile phone. The Bluetooth LE scanner should start automatically and find the MatterLock device among the other Bluetooth LE devices nearby.

Click on the MatterLock device.

5.3 Click on the Image button located in the bottom menu, as seen in the picture below:

5.4 Click on the Select File option and point to the dfu_application.zip file location on your mobile phone. Once the file is loaded, the lock.signed.bin file name should be visible in brackets for the Size and Hash fields, as seen below

5.5 Click the Start button, and once asked to Select Mode, choose Confirm only (Recommended). After that, the software transfer process starts and you will be able to see in the application that State is UPLOADING and the progress bar is being updated, as seen below:

Additionally, in your DK logs, there will a lot of messages informing about the update progress, such as below:

I: 386863 [SWU]DFU over SMP progress: 806012/807732 B of image 0
I: 386921 [SWU]DFU over SMP progress: 806164/807732 B of image 0
I: 386979 [SWU]DFU over SMP progress: 806316/807732 B of image 0
I: 386997 [SWU]DFU over SMP progress: 806468/807732 B of image 0
I: 387042 [SWU]DFU over SMP progress: 806620/807732 B of image 0
I: 387103 [SWU]DFU over SMP progress: 806772/807732 B of image 0
I: 387161 [SWU]DFU over SMP progress: 806924/807732 B of image 0
I: 387219 [SWU]DFU over SMP progress: 807076/807732 B of image 0
I: 387227 [SWU]DFU over SMP progress: 807228/807732 B of image 0
Terminal

Once the process ends, your Nordic DK is going to automatically reboot and swap the software image, which may take several seconds. After that, the new software image will be booted and the State in the nRF Connect Device Manager will change its value to UPLOAD COMPLETE.

5.6 Check the logs from the Nordic DK to see whether the software image was updated. The logs should include the following message:

I: 168 [SVR]Server Listening...
I: 171 [DL]Device Configuration:
I: 174 [DL] Serial Number: 11223344556677889900
I: 178 [DL] Vendor Id: 65521 (0xFFF1)
I: 182 [DL] Product Id: 32774 (0x8006)
I: 185 [DL] Product Name: Matter Door Lock
I: 189 [DL] Hardware Version: 0
I: 192 [DL] Setup Pin Code (0 for UNKNOWN/ERROR): 20202021
I: 197 [DL] Setup Discriminator (0xFFFF for UNKNOWN/ERROR): 3840 (0xF00)
I: 204 [DL] Manufacturing Date: 2022-01-01
I: 208 [DL] Device Type: 65535 (0xFFFF)
I: 211 [SVR]SetupQRCode: [MT:8IXS142C00KA0648G00]
I: 216 [SVR]Copy/paste the below URL in a browser to see the QR Code:
I: 222 [SVR]https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A8IXS142C00KA0648G00 
I: 230 [SVR]Manual pairing code: [34970112332]
I: ================ NEW SOFTWARE IMAGE IS WORKING!!! ===============
E: 241 [DL]Long dispatch time: 187 ms, for event type 2
Terminal

The logs show that the software update using SMP over Bluetooth LE was successful.

Switch language?

Progress is tracked separately for each language. Switching will continue from your progress in that language or start fresh if you haven't begun.

Your current progress is saved, and you can switch back anytime.

Register an account
Already have an account? Log in
(All fields are required unless specified optional)

  • 8 or more characters
  • Upper and lower case letters
  • At least one number or special character

Forgot your password?
Enter the email associated with your account, and we will send you a link to reset your password.