I have a microcontroller and I have implemented bare-metal code on it like Arduino, stm32f030. Currently I’m on MSP430 and it’s flash is only 16kb. I also have a gsm module sim800l. With my bare-metal code, I can send and receive AT commands using UART interrupts. Now I have a 64kb flash connected. I want to FOTA on my controller. If I can directly put code on the MCU that will be good but then I have to save a backup image too. I have never worked on bootloader so I don’t have idea how to burn code from external flash, I don’t know how to setup server, where to upload hex file and how to read it. Can I get some help?
JareshBeginner
FOTA from scratch
Share
Sure, I can guide you through the process of implementing FOTA (Firmware Over-The-Air) from scratch for your microcontroller. Please note that this is a high-level overview and you might need to dive deeper into certain areas based on your specific requirements. Here’s a step-by-step approach:
Step 1: Bootloader Development
1. Bootloader Code: Create a bootloader code that runs on your microcontroller. This code will be responsible for checking and updating the firmware from the external flash.
2. Memory Mapping: Define memory sections for the application firmware and bootloader in your linker script. Ensure that your bootloader doesn’t overwrite the application firmware.
3. FOTA Mechanism: Implement a mechanism in your bootloader to check for a new firmware version. This could involve periodically querying a server for updates or listening for an update trigger from the GSM module.
4. External Flash Access: Write code in your bootloader to access and program the external flash memory where the firmware updates will be stored.
5. Application Jump: Implement a method to jump from the bootloader to the application firmware once the update is verified and successful.
Step 2: Setting Up a Server
1. Server Hosting: Choose a server or cloud platform to host your firmware files. You can use a simple web server, cloud storage, or dedicated FOTA services.
2. Firmware Storage: Upload your firmware binary (hex) files to the server. Organize these files according to versions for easy retrieval.
3. Version Control: Maintain a mechanism to keep track of the latest firmware version and provide information about available updates.
Step 3: FOTA Process
1. Firmware Check: In your application firmware, periodically or on-demand, query the server to check for a new firmware version. You can use the GSM module and AT commands to establish an internet connection and communicate with the server.
2. Download and Update: If a new version is available, download the firmware file from the server to your external flash memory. Ensure that the new firmware image is correctly written to the flash.
3. Backup Image: To save a backup image, before writing the new firmware, copy the current application firmware to a reserved area in the external flash.
4. Firmware Verification: After writing the new firmware, have a mechanism in place to verify the integrity of the firmware. This could involve checksums, hash functions, or digital signatures.
5. Application Restart: Once the new firmware is successfully verified, trigger a restart to jump to the updated application.
Remember that FOTA involves intricate details and can be quite complex. This outline provides a starting point, but you’ll need to dive into specifics of bootloader programming, flash memory access, GSM communication, and server setup. Be prepared for testing and debugging to ensure a robust FOTA solution.
Additionally, make sure to refer to documentation specific to your microcontroller, external flash, and GSM module to ensure compatibility and proper functioning.
Thanks I will start with bootloader from flash first.
Thanks Alok for sharing your knowledge and experience about FOTA process.
We have also implemented FOTA component and server at our end with secure connection and more checking using which User can do FOTA for Linux based application and RTOS based application as well.
There is one point that I would like to include that we need to make fixed partition where OTA can be stored and can be activated as per rolling mechanism.
Also, We need to allocate one default or factory partition where default firmware can be stored so that if any issue will occur then factory firmware can be activated automatically.
Let me correct if i am wrong at any place.
Regards,
Ritesh Prajapati