1. Introduction
Firmware Over-The-Air (FOTA) is a technology present in SIMCom modules so that you can update firmware remotely without requiring physical access to the device.
In a real application, the module can be programmed to periodically connect to the FTP server and update the firmware itself in a fully automated way.
In this guide we will explain how to compile your SIM7600SA-H application with OpenLinux and update the firmware from an FTP server.
To start testing you will need:
- SIM7600SA-H Module (or other SIMCom CAT4 module)
- SIM7600 QDL (Firmware Update Tool)
- SIM7600SA-H OpenLinux Firmware
- ADB (Android Debug Bridge) Installed
- SIMCom OpenLinux SDK
- Linux operating system installed (can be a virtual machine)
- Functional FTP Server
To get access to the last firmware and OpenLinux SDK, please send an email to support@simcom.com.
2. Updating the Firmware SIM7600SA-HUnzip the firmware and run the QDL Firmware Update Tool.
In the QDL tool click Load, select the folder where firmware was unzipped and click Start. The tool should automatically detect the module and start the update.
The module will restart a few times during the process and will be completed after a few minutes.
The SDK can be installed and run on a Windows computer, but we recommend using Linux for easier installation. If you prefer, you can use a virtual machine to develop and compile the SDK without any problems.
Install Python and Make with the following commands:
sudo apt-get install python
sudo apt-get install make
Send the compacted SDK to the Linux system and run the following command to unzip:
sudo tar xzf sim_open_sdk.tar.gz
The generated folder will be used in the next steps.
4. Compiling ApplicationsEach folder inside sim_open_sdk represents a different part of the OpenLinux system that will be used in the module.
The simcom-demo folder is one that needs to be highlighted, as it contains the demo application that will run on OpenLinux. You can use it as a base to develop your own application.
For this first test with FOTA we will compile all parts of OpenLinux without making any modifications.
First, open the terminal, go to the sim_open_sdk folder and set the system variables using the command:
source sim_crosscompile/sim-crosscompile-env-init
Clean the environment with the make clean command and then individually run the make command followed by the part to compile as follows:
make clean
make aboot
make kernel
make rootfs
make demo
The 4 compiled files will appear in the output folder:
Move the file demo_app to the folder /sim_open_sdk/sim_usrfs
Run the make ota command to read the files that have been compiled and prepare them to be ready to be packaged.
make ota
The compiled files will be organized inside the folder sim_ota/target
Now that the files to be sent to the module have already been organized into the target folder, you need to package them to be read by the module later.
To do this go back to the sim_open_sdk folder and run the command:
bash ota_full.sh
A new file will be generated inside the output folder named update_ota.zip
This file contains the complete module firmware and could already be sent to the module to be installed.
However, when we look at its size, we will see that it is over 38MB, and this can be very much for a cellular connection, and may even end up with your device's data plan.
So how do we update the firmware without ending the data plan?
The answer is simple... Let's use Delta FOTA!
5.2 Delta FOTADelta FOTA consists of analyzing two firmware versions, identifying the differences between them, and sending only code snippets that have been modified to be updated in the module.
This can significantly reduce the size of the file that will be sent to the device.
First let's change the file name update_ota.zip to full_ota.zip
*Note: You can skip to step 5.2.2 if you do not want to change or have already changed the original firmware*
Let's modify the original firmware so we can have a different firmware version.
Open the folder /sim_open_sdk/simcom-demo/src/main.c and edit the file main.c
Add a new line after line 231 with the code snippet below and save the file:
printf("\nHello World! This is the second firmware.\n");
Return to the terminal in the folder sim_open_sdk, initialize the variables using the command source and compile the demo using the command make:
source sim_crosscompile/sim-crosscompile-env-init
make demo
Then move the new demo_app to the folder /sim_open_sdk/sim_usrfs
Delta FOTA analyzes and compares files from two folders inside /sim_open_sdk/sim_ota so you can generate the firmware with only the necessary changes.
- The first one is the source folder (not yet existing) which will be the original firmware code
- The second one is the target folder which will be the new firmware code.
Access the folder /sim_open_sdk/sim_ota through the terminal and copy the folder target changing the name to source through the command:
sudo cp -a target source
Now that we have defined our original firwmare, let's define our new firmware.
Return to /sim_open_sdk folder through the terminal and compile the OTA for the new firmware inside target folder.
make ota
Finally, run the ota.sh script to compare firmwares and package only modified code.
bash ota.sh
You will now see that we have 2 new files inside the output folder, we will use just the update_ota.zip.
*Note that the update_ota.zip file is about 500KB, much smaller than full_ota.zip*
Send the full_ota.zip and **update_ota.zip** files to the Windows computer and we will continue the steps.
Because of the size of Full FOTA, we will send it to the module via USB.
Open the Windows command terminal, browse to the folder where ADB is installed, and use the command below, (replacing the file location with your Full FOTA file)
adb push C:\Workspace\OpenLinux\demo_files\full_ota.zip /cache
Now open the serial terminal and send the command that will update the firmware:
AT+CDELTA="/cache/full_ota.zip"
The module will restart and enter update mode. No action is required, just wait (about 1min).
When ready, the module will boot and the COM port will be available.
Now let's check if the original application is working.
Open windows terminal and run command:
adb shell
Change the permission of the demo application and run it:
chmod a+x /data/demo_app
./data/demo_app
Finally, browse to the /cache folder and delete the full_ota.zip file with the command:
rm /cache/full_ota.zip
7. Delta FOTA via FTPNow we will download Delta FOTA via FTP.
First, upload the update_ota.zip file to your server.
Then access the server with the module through the serial terminal and the command AT+CFTPSLOGIN
AT+NETOPEN
AT+CFTPSSTART
AT+CFTPSSINGLEIP=1
AT+CFTPSLOGIN="YOURIP",PORT,"USER","PASSWORD",0
Browse inside the server using the AT+CFTPSLIST and AT+CFTPSCWD commands to list and switch folders respectively.
AT+CFTPSLIST="/"
AT+CFTPSLIST
AT+CFTPSCWD="OLDemoFirmware"
When you find the file, download it to the module cache using the command below:
AT+CFTPSGETFILE="update_ota.zip",1
If the download is successful, the module should return +CFTPSGETFILE=0
Now let's update the firmware by the new downloaded.
AT+CDELTA="/cache/update_ota.zip"
The module will restart and initialize when completed as previously.
Open the Windows terminal with adb shell and see the new updated application.
chmod a+x /data/demo_app
./data/demo_app
Comments
Please log in or sign up to comment.