Gemalto is now part of the Thales Group, find out more.

You are here

Thales IoT Developer Community

FOTA Example (Firmware Update Over The Air) - EHS5, EHS6, EHS8 modules

Showcase, February 11, 2016 - 4:36pm, 10909 views


The article contains the short description how to update a module’s firmware over the air (not to be confused with userware software which is a separate story).



 Gemalto provides the possibility of performing the firmware update procedure from the file stored in the local file system of the module. The rest of the logic should be implemented in the user application.

An over-the-air firmware update should include the following steps:

•       Downloading the firmware update file to the module's flash file system (FFS)

•       Downloading the JRC MIDlet to the module's flash file system (FFS)

•       Checking the integrity of the downloaded files

•       Stopping and removing of the current JRC MIDlet

•       Starting the actual firmware update

•       Installing the downloaded JRC MIDlet

•       Validating of the update and restoring the normal operation

The above steps can be handled from an external application by means of AT commands issued over the external interface or can be implemented in the Java MIDlet.



Please note that besides the firmware file the application is also updating the JRC MIDlet (Java Remote Control MIDlet Suite) which is a factory MIDlet implementing some of the module’s functionality. There is a dedicated version of JRC released for every firmware release and it MUST be updated together with the firmware.

The versions of the installed firmware and JRC should be verified and compared with the new software to check if the update is really needed and if it was successfull.

The user applications cannot be running during the firmware update process so please consider stopping your other applications to avoid data loss or any other consequences depending on your application's logic.

When the JRC MIDlet is not running the Java code will not be able to receive URC's. So after stopping the JRC this demo application will not be able to receive any SMS messages.



In case of implementation of the update logic in Java such a MIDlet can also be remotely installed with OTAP which is provided by all Java enhanced modules.


Security Issues

The possibility of remote control of the module always includes some risks. So please consider this while developing your solution. 

Here are some (probably not all) issues to take into account:

•       When developing SMS communication, remember to implement some password and/or sender number verification.

•       While using OTAP for remote installation of the MIDlet for remote firmware updating remember also to configure the password for OTAP SMS commands. 

•       Configure the password authentication on the server and use secure connection.

•       The module can be configured to only accept the signed applications (the certicicat must be loaded to the module) to avoid installation of the unwanted application.

•       The MES access can also be blocked for the modules working in the field.

•       Remember that firmware update is a risky operation - if something goes wrong you may loose contact with your device. So prepare your scenario carefully.

Java Example

The attached MIDlet demonstrates how the remote firmware update can be performed. The application can be controlled by SMS commands. Please keep in mind that this is only a demo, the aim of which is to show the possibilities. It is not the complete and fully tested application that could be used as it is in the real system.

About the demo

The demo application downloads the files from the http server mainly because the implementation is simple and does not require any additional API's. But any other protocol that can be implemented in Java could be used here (for example FTP). 

In case of download failure there is some debug information displayed. Some retries and nottifications should be considered in the real application.

Step by step - how to proceed with demo

•       Upload the MIDlet to the module with MES.

•       Make sure that the System.out is configured to one of the interfaces (serial is recommended: asc0 or asc1).
         Set if needed:

•       Install the MIDlet with the following command:

•       Run the MIDlet with:
         or just reset the module (The MIDlet is enabled for autostart)

•       Send SMS to the module with configuration data and start command (see more details below)

•       Watch the results on System.out interface

•       The MIDlet will start with every module reboot, so if it is not needed any more it should be uninstalled



The following configuration parameters and start command can be sent in SMS:

•       FOTA_START – start command

•       APN – Access point number

•       USER – APN user

•       PASS – APN password

•       USF – Firmware file name on HTTP server

•       JRC – JRC MIDlet file name (same for .jar and .jad)

•       PATH – http or https path to the FOTA files

•       JAD_MD5 – Md5 checksum for .jad file

•       JAR_MD5 – Md5 checksum for .jar file

•       USF_MD5 – Md5  checksum for usf file

•       DEBUG – Enable/disable additional debug output (by default it is disabled)


Configuration example




Please find more detail in the attached documents and Eclipse/NetBeans projects.


Download File (zip | 329.13 KB)

Nice article!!!!

I really like it!!



Somewhere over the rainbow!!! Looking for the Oz Land!!!

This is a very good article!
In some cases it may be necessary to be prepared for a FOTA.
For instance, your fleet can be out there for a long time, and it is easier
to maintain if the firmware will be the same in all units.

Antero Markkula
Communication and Mechatronics

Enkom Active Oy –
Upseerinkatu 3 A, 02600 Espoo, Finland
Mobile: +358 400 411368
Office: +358 10 204 0000
Fax: +358 10 204 0010

NES's picture

I ran the FotaMIDlet in the debug **** of the eclipse. However, the debugger always crashes during the file downloads.  Any idea why?

WTK Java Emulator

I'm trying to compile the java example, but the compiler is barking about


Where can I find the this package?

It's a part of standard libraries provided by Gemalto. Maybe you have some very old version...

The example is very good, but I'm with a problem:

When downloading file to the internal memory of module (ffs) the "Logger" return content size of 259 bytes, while the file length is 78Kbytes. The variable of return is long type, then this is not a problem and I'm using a http URL. Any idea for solve the problem ?? 



I'm currently learning concept of FOTA through your showcase example here. It is quite comprehensive and greatly appreciated and received.

Is this the same protocol we would follow if say we needed to send an upgrade of a Midlet app over the air also? Or is this what a FOTA actually does, and I have missed the point?



Bartłomiej Gemalto Moderator's picture
Bartłomiej Gemalto Moderator