An ota example for esp8266 using non-os SDK and rboot
The project is aimed at making life of esp8266 enthusiasts simple by providing
a step by step guide to enable firmware over the air feature. The code for the
project has been borrowed from:
Although the project is fully functional. It is aimed as a example for OTA
feature and developers can add their custom modules to it. Following is the
major differences compared to the original project:
The bootloader used in the project is rboot developed by Richard Burton. The frimware sends a GET request periodically(configured in user_config.c) to the
specified HTTP server and upgrades itself. The entire program flash is divided
into two 512 KB partitions. One partiton is used to run the current program and
another partition is used to load a newer firmware. If the current program is running from partition 1 then the new program will be loaded into partition 2.
Once the newer firmware is loaded, the module resets to boot from the new program.
Simliarly if the current program is running from partition 2 partition 1 will be
used for loading the newer firmware. This means that the esp needs to atleast have 1MB of flash. Building the project yields to binaries. Both the binaries are almost the same except the way they are linked using the linker. One of them is linked so that they can lie on 0x02000 and another is linked so that it can lie on 0x82000 of the program flash. For any firmware both these binaries needs to be generated. More about the internal working of the bootloader can be found at:
Most of the configuration needs to be done in user/user_config.h. Following are the configurations:
Keep the other configurations intact
Following configurations needs to be updated in the makefile:
For the purpose of testing I used the default python http server called the
simpleHTTPServer. The module comes by default in python 2.7. Running SimpleHTTPServer from a directory hosts all the files in the directory on to
the network. The firmware files can be hosted by running the server on the
firmware directory using the below command:
python -m SimpleHTTPServer 3000
You can check the weather the files are hosted by accessing your ip on the browser:
ex: 192.168.1.4:3000
It should list the files in the firmware folder.
Please note that the server might not be accessible over the public IP due
to firewall.
To add any new module to the project the USER_MODULES variable in the makefile
needs to be updated. The USER_MODULES specifies a list of folders that would
be searched to find the files that need to be compiled.