Ameba Arduino: [RTL8195AM] [RTL8710AF] Cloud OTA

Preparation
  • Ameba x 1
  • Apache Web Server
Example
The example illustrates how to use AMEBA to download firmware from Web Server to do remote OTA function. This project is contributed by Maker Rododo. http://www.rododo.farm/
  • Install Web Server
This example needs to install Web Server. Take Apache Web Server installation on Windows as an example, download httpd-2.4.29-Win64-VC15.zip on Apache Lounge website. https://www.apachelounge.com/download/ 1 Complete download and to unzip the file, copy directory Apache24 to C:\ root directory. Open CMD with administrator and key in:
C:\Apache24\bin\httpd -k install
Start Apache:
net start apache2.4
1 Test: Open browser and input:
http://127.0.0.1/
1 The page shows “It works!” if the Apache Web Server starts successfully.
  • Generate OTA firmware
We generate OTA firmware to verify if the download from Web Server is complete. Open Arduino IDE and add a sketch file as below and print “Hello From Ameba!!” on the console every 1 second in the loop() function . 1 Find ota.bin to use for OTA after the compilation and open the directory we install Arduino Ameba SDK. It should be the location shown below if the certain path had not been changed when installing Arduino IDE:
C:\Users\yourname\AppData\Local\Arduino15\packages\realtek\tools\ameba_tools\1.1.0
Copy ota.bin and put it to Apache Web Server htdocs directory (C:\Apache24\htdocs).
  • Generate checksum files
Before remote OTA, we check ota.bin correctness via checksum. We can use the checksum tool provided by Github: https://github.com/ambiot/amb1_arduino/raw/master/Arduino_package/ameba_tools_windows/tools/windows/checksum.exe Download checksum.exe and copy to Apache Web Server htdocs directory (C:\Apache24\htdocs). Open cmd and change to C:\Apache24\htdocs directory. Key in:
Checksum.exe ota.bin
1 203df9 is the checking code generated from checksum. Add a check.txt in C:\Apache24\htdocs after transform the value to Decimal as shown below: 1
  • Example
The libraries we need are: https://github.com/ambiot/amb1_arduino/raw/master/Arduino_libraries/AmebaCloudOTA.zip Refer to Arduino website to install .zip library to Ameba: https://www.arduino.cc/en/Guide/Libraries#toc4 Open “File” -> “Examples” -> “AmebaCloudOTA” -> “ota_cloud”, fill in AP SSID and Password. Remember to fill in Web Server IP Address and Port. 1 Compile and upload to Ameba. Start downloading OTA from Web Server after pushing Reset button. And open the terminal. 1 Run check.txt checking after connecting to the WiFi. 1 Start to download ota.bin 1 Check checksum after the download and start OTA. It restarts and prints ” Hello from Ameba!!!” if the process is successful. 1
Code Reference
int checksum = OTA.gatherOTAinfo(REMOTE_ADDR,"/check.txt", REMOTE_PORT);
if( checksum != -1) Serial.println("info_ok");
In setup(), getting checksum information in check.txt from remote server via OTA.gatherOTAinfo. Remember to fill in web server address and port
Copyrights ©瑞晟微电子(苏州)有限公司 2021. All rights reserved.
Please confirm that QQ communication software is installed