Firmware-over-the-air
Update your MCU's flash code remotely over the web.
What is FOTA?
It's a SW that is used to flash MCU (update MCU code) wirelessly over internet.
Components Used
- stm32f103 MCU
- ESP8266 MCU
- Flask as web server
How to get started?
- Download repo code
git clone "https://github.com/ahmedFarouk2020/Firmware-over-the-air.git"
- Install requirements.txt
pip install -r requirements.txt
- Get HW components mentioned above
Important Features
- 2 Separate Banks (rooms) so if download fails in the middle you can go back to the old code
- Smooth transitions betwen banks
Future Improvements
- Authentication (using username and password provided by author) --> already implemented
- Data Encryption and decryption (security management)
- Data integrity check --> already implemented
First of all, Burn .hex file in FOTA-firmware/Debug on your MCU
Steps to use
- Run app.py using this command
python app.py
the following is displayed - Copy the link to user browser
- Click on "Choose File" button and choose hex file
- click "Submit"
- Reset MCU
Note: The Hex file used with this FOTA has a special format :)
How to create the Hex file
- Create empty .hex file
- Modify the ldscripts/mem.ld file in the project you want to upload to MCU as follows
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
CCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 0
FLASH (rx) : ORIGIN = 0x08002800, LENGTH = 27k
FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0
MEMORY_ARRAY (xrw) : ORIGIN = 0x00000000, LENGTH = 0
}
- Compile
- Copy all the content of the generated hex file from step 3 and paste it in the empty file
- Add '*' in a new line just after the present data
- repeat the steps from 2 to 4 but with this new values
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
CCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 0
FLASH (rx) : ORIGIN = 0x08009400, LENGTH = 27k
FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0
EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0
MEMORY_ARRAY (xrw) : ORIGIN = 0x00000000, LENGTH = 0
}
- Your file is ready to be uploaded I will add a sample file too