This code example has a related User's Guide, here: Uploading Firmware Images Using OTA DFU
The article referred in the Background section discusses two methods of performing OTA:
-
Using Apploader
-
Using user application
This code example demonstrates the second method. See the article Uploading Firmware Images Using OTA DFU for conceptual details.
The code sample provided in AN1086: Using the Gecko Bootloader with the Silicon Labs Bluetooth® Applications is simplified to fit in one page. The full example provided here includes some additional debug prints and features, such as printing the estimated data transfer rate.
The main functional difference is related to erasing the download area. In the simplified code, the download area is erased when the remote OTA client starts the OTA process (writing value 0 to ota_control). In this example, the download area is erased at startup. The code also reads the content of the download area and does an erase only if needed (i.e., if the download area is not already blank) to avoid dropping the connection because of the supervision timeout. Erasing the whole download area (256k or more) will take several seconds (it is a blocking function call) and this can lead to supervision timeout unless the connection parameters are specifically adjusted to prevent it.
This project aims to implement the firmware upgrade method used in SoC-mode Bluetooth applications. A Gecko Bootloader(GBL) image containing the new firmware is sent to the target device via a Bluetooth connection.
- GSDK v4.4.0
- Silicon Labs EFR32 Development Kit
NOTE: Tested boards for working with this example:
Board ID | Description |
---|---|
BRD2704A | SparkFun Thing Plus Matter - MGM240P - BRD2704A |
BRD2601B | EFR32xG24 Dev Kit - xG24-DK2601B |
BRD2703A | EFR32xG24 Explorer Kit - XG24-EK2703A |
BRD4108A | BG22 Bluetooth SoC Explorer Kit - BG22-EK4108A |
BRD4314A | BGM220 Bluetooth Module Explorer Kit - BGM220-EK4314A |
- Connect the Bluetooth Development Kits to the PC through a compatible-cable. For example, a micro USB cable for the BGM220 Bluetooth Module Explorer Kit.
To test this application, you can either create a project based on an example project or start with a "Bluetooth - SoC Empty" project based on your hardware.
-
From the Launcher Home, add your hardware to MyProducts, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project with filter "ota".
-
Click Create button on the Bluetooth - OTA Firmware Update in User Application examples. Example project creation dialog pops up -> click Create and Finish and Project should be generated.
-
Build and flash this example to the board.
-
Create a Bluetooth - SoC Empty project for your hardware using Simplicity Studio 5.
-
Since in this project, we do not use Apploader for firmware upgrade, remove Apploader from your application
-
Open the Project Configurator (that is, open the .slcp file in your project and select the Software Components tab)
-
Find the OTA DFU software component (Bluetooth > Utility > In-Place OTA DFU), and uninstall it
-
-
Import the attached GATT configuration file into the project.
-
Open the .slcp file in the project.
-
Select the CONFIGURATION TOOLS tab and open the Bluetooth GATT Configurator.
-
Find the Import button and import the attached config/btconf/gatt_configuration.btconf file.
-
Save the GATT configuration (ctrl-s).
-
-
Open the .slcp file. Select the SOFTWARE COMPONENTS tab and install the software components:
- [Services] → [IO Stream] → [IO Stream: EUSART] → default instance name: vcom
- [Application] → [Utility] → [Log]
- If using WSTK, navigate to the Platform > Board > Board Control software component, open its configurator and Enable Virtual COM UART
-
Copy all attached files in inc and src folders into the project root folder (overwriting existing files).
-
Build the project and flash it to your target.
NOTE:
-
Make sure that this repository is added to Preferences > Simplicity Studio > External Repos.
-
Do not forget to flash a bootloader to your board, see Bootloader for more information
You can generate OTA files by running the create_bl_files script in your project (Note: you may need to set up some environmental variables first as described in section 3.10 of AN1086: Using the Gecko Bootloader with the Silicon Labs Bluetooth® Applications).
Once you generated the upgrade files
- Copy them to your smartphone
- Open EFR Connect on your phone
- Find your device (advertising as Application OTA) in the Bluetooth Browser and connect to it
- In the context menu select OTA
- Try OTA using the application.gbl file(make sure the size of this file is less than size of download area).
You can check the debug prints to make sure that the application can detect the bootloader version and download area information correctly as the first test before trying any updates. Below is a sample of the debug prints when running on a BGM220 Bluetooth Module Explorer Kit(with 512k flash):