KBA_BT_0806: Using BLED112 to do Over-the-Air update of BGMxxx
01/13/2017 | 02:24 PM
Introduction
The example code provided at the end of this article shows how to use the BLED112 dongle as OTA client to update Bluetooth applications running on BGMxxx (or EFR32BG).
NOTE: when testing OTA updates, make sure you first test with a target device that can be easily accessed with J-Link debugger in case something unexpected happens.
This example application is only for experimental use. It has not been extensively tested and it is not intended for production use.
The target device must be based on BGMxxx module or EFR32BG SoC. This application is NOT suitable to update any BLExxx devices.
Target device must be running application built with SDK 2.0.0 or later and the application must have OTA enabled as specified in AN1045. Recommended minimum SDK version: 2.0.3 or 2.1.1.
BLED112 dongle is needed. The Bluetooth Smart SDK for BLE product family is not necessary.
What the example does?
The example code provided here is basically the "OTA host example" from the Bluetooth Smart SDK that has been ported to BLED112 dongle. This host example is explained in more detail in AN1045.
Running the example
The attached zip includes a makefile for building the project. This has been tested on Windows using Cygwin but it should work on other platforms as well.
Before running the example, you need to have the EBL file(s) that are suitable for updating your target device.
If you run the example without any parameters it shows the possible usage options as follows:
--- Usage: ----
./OTA list => check COM port number of BLED112
./OTA <COMx> scan => scan for BLE devices (stops automatically after 5 seconds)
./OTA <COMx> <address> <EBL file> => run OTA update
By running the program with option list you can easily check what is the COM port number associated with your BLED112 dongle.
The second option allows you to scan for BLE devices. This is convenient if you don't already know the Bluetooth address of the target device. You can also use it to make sure that the target device is advertising. When lauched with the scan option the program listens for advertisements and then automatically stops after 5 seconds has passed.
Finally, to run the OTA update you need to pass three parameters:
- COM port number
- Bluetooth address of the target device
- name of the EBL file
The attached file named example_run.txt shows example usage of the program (copied from Cygwin console).
is it possible to program multiple BGM121 devices at same time from single BLED112 dongle via OTA? may we modify OTA_UPDATER_BLED112_v01 for that? is ble dongle capable of that? is there any more appropriate way to achieve this goal? we have to program like 1000 bgm121 devices using OTA and one programmer device should be able to load ebl to multiple devices at same time.
0
is it possible to program multiple BGM121 devices at same time from single BLED112 dongle via OTA?
No, this is not possible. The new firmware image is uploaded over a Bluetooth connection which is point-to-point.
If you want to run multiple updates in parallel then you can of course use multiple BLED112 dongles and run several instances of the update program.
0
when I try to compile this program, get these errors, how can fix?
0
we are able to compile and get ota.exe file, after connection, BLED112 sends ebl file even when target device don't go to DFU mode, how can fix this issue?
0
Hello @farrukh,
sorry for the delayed reply. This example has not been updated to match the changes in our OTA protocol, I will add an updated version later today or tomorrow.
EDIT: updated codes attached to this message (OTA_UPDATER_BLED112_v02.zip )
I have the following problem " service not found",
it gets connected, but no update is possible, but with the wstk it works. the OTA service has the same UUID
OTA.exe COM17 00:0b:57:XX:XX:XX app.ebl
trying to open EBL file app.ebl
Bytes to send:77696
SDK version: 2.6.0
image type: APP
Trying to connect
Connected (handle 0)
Connection interval: 25600 units = 32000.00 ms
timeout: 0 units = 0 ms
ble_rsp_connection_update: conn 0,result 4300
service not found
0
the connection interval seems to be very high and the timeout very low, any ideas what goes wrong, just compiled with mingw an ran under windows 7.
Any Ideas?
I have the following problem " service not found",
it gets connected, but no update is possible, but with the wstk it works. the OTA service has the same UUID
OTA.exe COM17 00:0b:57:XX:XX:XX app.ebl
trying to open EBL file app.ebl
Bytes to send:77696
SDK version: 2.6.0
image type: APP
Trying to connect
Connected (handle 0)
Connection interval: 25600 units = 32000.00 ms
timeout: 0 units = 0 ms
ble_rsp_connection_update: conn 0,result 4300
service not found
0
There seems to be some mismatch in processing events from the BLED112, because 32 seconds is not a valid connection interval (4 secs is the maximum). On the other hand, 32 seconds is the maximum for supervision timeout but in your log it is shown as the value for connection interval.
Are you using 32-bit or 64-bit version of MinGW? I have the 32-bit version and I build the program with command mingw32-make.
Typically I run the OTA host example on Cygwin, you might want to try that , too.
0
I'm using 32.bit version of MinGW,
tried two different version (4.9.2, 5.3.0),
tried also the OTA_UPDATER_BLED112_v01,
and now downloaded and installed cygwin, and ran make, everywhere the same problem (win7 64bit)
That is the cygwin output (gcc-Version 7.3.0 (GCC), GNU Make 4.2.1)
/OTA_UPDATE R_BLED112_v02
$ make
gcc -O3 -Wall -c -fmessage-length=0 -DPLATFORM_WIN -MMD -MP -MF"main.d" -MT"main .d" -o"main.o" "main.c"
main.c: In Funktion »send_ebl_data«:
main.c:190:53: Warnung: Format »%d« erwartet Argumenttyp »int«, aber Argument 4 hat Typ »size_t {alias long unsigned int}« [-Wformat=]
printf("send_ebl_data %d, retry = %d, bytes_left: %d\n", ++num_calls, retry, d fu_toload);
~^
%ld
main.c: In Funktion »ble_evt_attclient_attribute_value«:
main.c:654:38: Warnung: Format »%x« erwartet Argumenttyp »unsigned int«, aber Ar gument 2 hat Typ »uint32 {alias long unsigned int}« [-Wformat=]
printf("Application version: 0x%4.4x\n", appVersion);
~~~~^
%4.4lx
main.c:614:6: Warnung: Variable »i« wird nicht verwendet [-Wunused-variable]
int i;
^
gcc -O3 -Wall -c -fmessage-length=0 -DPLATFORM_WIN -MMD -MP -MF"uart.d" -MT"uart .d" -o"uart.o" "uart.c"
gcc -O3 -Wall -c -fmessage-length=0 -DPLATFORM_WIN -MMD -MP -MF"cmd_def.d" -MT"c md_def.d" -o"cmd_def.o" "cmd_def.c"
gcc -O3 -Wall -c -fmessage-length=0 -DPLATFORM_WIN -MMD -MP -MF"stubs.d" -MT"stu bs.d" -o"stubs.o" "stubs.c"
gcc -O3 -Wall -c -fmessage-length=0 -DPLATFORM_WIN -MMD -MP -MF"ebl_utils.d" -MT "ebl_utils.d" -o"ebl_utils.o" "ebl_utils.c"
ebl_utils.c: In Funktion »find_app_properties«:
ebl_utils.c:25:45: Warnung: Format »%d« erwartet Argumenttyp »int«, aber Argumen t 2 hat Typ »size_t {alias long unsigned int}« [-Wformat=]
printf("could not find app properties! (%d)\n", ret);
~^
%ld
ebl_utils.c:29:6: Warnung: Implizite Deklaration der Funktion »memcmp« [-Wimplic it-function-declaration]
if(memcmp(magic, buf, 4) == 0)
^~~~~~
ebl_utils.c:36:46: Warnung: Format »%d« erwartet Argumenttyp »int«, aber Argumen t 2 hat Typ »size_t {alias long unsigned int}« [-Wformat=]
printf("could not find app properties! (%d)\n", ret);
~^
%ld
ebl_utils.c:15:6: Warnung: Variable »retval« wird nicht verwendet [-Wunused-vari able]
int retval = -1;
^~~~~~
Building target: OTA
gcc -o"OTA" main.o uart.o cmd_def.o stubs.o ebl_utils.o -lm -lsetupapi
Finished building target: OTA
OTA.exe COM17 00:0b:57:XX:XX:XX app.ebl
trying to open EBL file app.ebl
Bytes to send:77952
Trying to connect
Connected (handle 0)
Connection interval: 25600 units = 32000.00 ms
service not found
EDIT: OK, on the Cygwin Terminal it works, but not from the windows cmd.exe, is there a way to get working out-of-the-box, not having to install cygwin first.
I would like to pass on an easy solution to users, that could run on any windows pc.
0
OK, good to hear it works on Cygwin. That's what I'm using personally for any OTA related tests. I need to try and see what might cause this to fail with MinGW, but it may take some time until I have suitable time slot to do this.
If you want to distribute a standalone Cygwin program then I'm not 100% sure how it works. See the Cygwin FAQ for more info:
KBA_BT_0806: Using BLED112 to do Over-the-Air update of BGMxxx
Introduction
The example code provided at the end of this article shows how to use the BLED112 dongle as OTA client to update Bluetooth applications running on BGMxxx (or EFR32BG).
NOTE: when testing OTA updates, make sure you first test with a target device that can be easily accessed with J-Link debugger in case something unexpected happens.
This example application is only for experimental use. It has not been extensively tested and it is not intended for production use.
Prerequisites
OTA updates are explained in detail in the following application note:
AN1045: Bluetooth® Over-the-Air Device Firmware Update
The target device must be based on BGMxxx module or EFR32BG SoC. This application is NOT suitable to update any BLExxx devices.
Target device must be running application built with SDK 2.0.0 or later and the application must have OTA enabled as specified in AN1045. Recommended minimum SDK version: 2.0.3 or 2.1.1.
BLED112 dongle is needed. The Bluetooth Smart SDK for BLE product family is not necessary.
What the example does?
The example code provided here is basically the "OTA host example" from the Bluetooth Smart SDK that has been ported to BLED112 dongle. This host example is explained in more detail in AN1045.
Running the example
The attached zip includes a makefile for building the project. This has been tested on Windows using Cygwin but it should work on other platforms as well.
Before running the example, you need to have the EBL file(s) that are suitable for updating your target device.
If you run the example without any parameters it shows the possible usage options as follows:
By running the program with option list you can easily check what is the COM port number associated with your BLED112 dongle.
The second option allows you to scan for BLE devices. This is convenient if you don't already know the Bluetooth address of the target device. You can also use it to make sure that the target device is advertising. When lauched with the scan option the program listens for advertisements and then automatically stops after 5 seconds has passed.
Finally, to run the OTA update you need to pass three parameters:
- COM port number
- Bluetooth address of the target device
- name of the EBL file
The attached file named example_run.txt shows example usage of the program (copied from Cygwin console).
No, this is not possible. The new firmware image is uploaded over a Bluetooth connection which is point-to-point.
If you want to run multiple updates in parallel then you can of course use multiple BLED112 dongles and run several instances of the update program.
when I try to compile this program, get these errors, how can fix?
Hello @farrukh,
sorry for the delayed reply. This example has not been updated to match the changes in our OTA protocol, I will add an updated version later today or tomorrow.
EDIT: updated codes attached to this message (OTA_UPDATER_BLED112_v02.zip )
Hello,
I have the following problem " service not found",
it gets connected, but no update is possible, but with the wstk it works. the OTA service has the same UUID
the connection interval seems to be very high and the timeout very low, any ideas what goes wrong, just compiled with mingw an ran under windows 7.
Any Ideas?
There seems to be some mismatch in processing events from the BLED112, because 32 seconds is not a valid connection interval (4 secs is the maximum). On the other hand, 32 seconds is the maximum for supervision timeout but in your log it is shown as the value for connection interval.
Are you using 32-bit or 64-bit version of MinGW? I have the 32-bit version and I build the program with command mingw32-make.
Typically I run the OTA host example on Cygwin, you might want to try that , too.
I'm using 32.bit version of MinGW,
tried two different version (4.9.2, 5.3.0),
tried also the OTA_UPDATER_BLED112_v01,
and now downloaded and installed cygwin, and ran make, everywhere the same problem (win7 64bit)
That is the cygwin output (gcc-Version 7.3.0 (GCC), GNU Make 4.2.1)
EDIT: OK, on the Cygwin Terminal it works, but not from the windows cmd.exe, is there a way to get working out-of-the-box, not having to install cygwin first.
I would like to pass on an easy solution to users, that could run on any windows pc.
OK, good to hear it works on Cygwin. That's what I'm using personally for any OTA related tests. I need to try and see what might cause this to fail with MinGW, but it may take some time until I have suitable time slot to do this.
If you want to distribute a standalone Cygwin program then I'm not 100% sure how it works. See the Cygwin FAQ for more info:
https://cygwin.com/faq.html
Points 6.13 and 6.14 seem to be related to running Cygwin programs without having complete Cygwin setup installed on your PC.