When it comes to IoT device management, over-the-air (OTA) firmware updates play a key role.
OTA enables product manufacturers to remotely update connected devices with bug fixes, feature enhancements and security patches.
If you are evaluating one of our EFM32 32-bit MCUs such as the one onboard the Giant Gecko GG11 Starter Kit (SLSTK3701A) and want to learn a simple way to enable OTA firmware updates then this blog will get you started by presenting the example illustrated in the following diagram:
There are several criteria for the firmware update image to be flashed:
The bootloader storage area will be erased, and the embedded application will try to establish a new HTTP/HTTPS connection, if:
1. Order an EFM32 Giant Gecko GG11 Starter Kit SLSTK3701A from our website
2. Install Simplicity Studio
3. Connect the board as shown in the image below:
4. Open Simplicity Studio, from the Launcher perspective, select the example named SLSTK3701A_micriumos_httpcloader as shown below:
5. Open the file httpclient.c located in the /src folder in the Project Explorer and enter the full URL where you plan to host the firmware upgrade image:
#define FULL_URL "http://mywebserver.com/myupgrade.gbl"
If your webserver is secured (i.e. https) then this demo includes mbedTLS. Simply make sure that the certificate required by your website is defined in SSL_ROOT_CA in the file ssl_certificates.c located in the /src folder of the Project Explorer.
You may also have to tweak the number of bits and bytes that match your website's certificates by setting the proper sizes in MBEDTLS_ECP_MAX_BITS and MBEDTLS_MPI_MAX_SIZE in the configuration file config-ssl-
httpcloader.h located in C:\SiliconLabs\SimplicityStudio\v4\developer\sdks\gecko_sdk_suite\v2.5\app\mcu_example\SLSTK3701A_EFM32GG11\micriumos_httpcloader\config-ssl-httpcloader.h
#define MBEDTLS_MPI_MAX_SIZE 256 #define MBEDTLS_ECP_MAX_BITS 384
6. Open the file application_properties.c in the /src folder of the Project Explorer and set the version number of the embedded application to 2 to simulate a firmware upgrade:
#define APP_PROPERTIES_VERSION 2
7. Build the project
8. Generate the firmware upgrade file myupgrade.gbl by opening the utility Simplicity Commander located at C:\SiliconLabs\SimplicityStudio\v4\developer\adapter_packs\commander and by providing the path to your binary file .s37 to a command line similar to this:
commander.exe gbl create myupgrade.gbl --app "C:\Users\[YourUsername]\SimplicityStudio\v4_workspace\SLSTK3701A_micriumos_httpcloader\GNU ARM v7.2.1 - Debug\SLSTK3701A_micriumos_httpcloader.s37"
9. Upload the file myupgrade.gbl to your web server
10. Open the file application_properties.c in the /src folder of the Project Explorer and set the version number of the embedded application back to 1:
#define APP_PROPERTIES_VERSION 1
11. Build the project again
12. Connect the starter kit as previously shown in Figure 2
13. Open Device Manager in Windows to find out the COM Port number of the USB device listed as J-Link CDC UART Port
14. Open a Serial Console application such as PuTTY to see the debug messages during run time
15. Select the item J-Link Silicon Labs from the list of Debug Adapters, right-click to open the context menu and select the option Upload Application... as shown below:
16. In the field Application Image Path, select the file SLSTK3701A_micriumos_httpcloader.s37 that you just built by browsing to the workspace folder where you have your project, a path similar to the following:
C:\Users\[YourUsername]\SimplicityStudio\v4_workspace\SLSTK3701A_micriumos_httpcloader\GNU ARM v7.2.1 - Debug\SLSTK3701A_micriumos_httpcloader.s37
Tick the checkbox to Upload a Bootloader image and select the bootloader that comes with the example by browsing to the file bootloader-storage-internal-single-combined.s37 in a path similar to this:
17. Press the button Ok to flash both images. The bootloader image will be flashed in a reserved area of Flash and from this point forward you can simply Launch a Debug Session from Simplicity Studio to program the device with a different application image as the bootloader image will be stored in a reserved area of Flash that won't be deleted unless you overwrite it with this tool or from the command line with Simplicity Commander.
18. Watch the serial terminal as the embedded application starts the Ethernet interface, connects to your website to download the file myupgrade.gbl and reboots on the new upgraded embedded application.
The firmware update situation described in this example assume no authentication and no encryption of the firmware update file. However, these features along with secure boot are supported by our system but it is beyond the scope of this blog.
To sign and encrypt a firmware update file, you can use Simplicity Commander as follows:
commander.exe gbl create --app --bootloader --metadata --compress --encrypt --sign --force
For more information on how to use Simplicity Commander see the section GBL Commands on Page 34 of the following document:
For more information on the Gecko Bootloader see the following documents: