Program your AVR MCU Over-the-Air using ESP32
View Code
·
Report Bug
·
Request Feature
·
Create a Pull Request
The project aims at enabling firmware update of AVR-powered boards Over-the-Air using ESP32.
Testing was done with ESP32-DevKitC v4 board and Arduino UNO, Leonardo and MEGA. You can try with any other AVR-powered board and let me know how it worked out.
/esp_avr_flash
-> Basic flashing utility, requires path of the .bin file which has been already uploaded in SPIFFS
/file_serving_avr
-> OTA demo, with HTTP File Server with embedded flash link
/references
-> Python scripts for understanding the flashing protocol commands and verification
To run the OTA demo, you need an ESP32 dev board (e.g. ESP32-WROVER Kit) or ESP32 core board (e.g. ESP32-DevKitC). For the AVR MCU, you can use an Arduino UNO, Leonardo or MEGA.
-
ESP-IDF v4.0 and above
You can visit the ESP-IDF Programmming Guide for the installation steps.
-
Arduino IDE
Not a mandatory requirement, although it is an easy way to generate the .hex files for your AVR MCU code.
-
Wire your AVR MCU (e.g. Arduino UNO, Leonardo, Mega, etc.) to the ESP32. All the following connections should be made through a Bi-Directional Logic Level Converter (LLC -> 5V - 3.3V).
ESP32 LLC (L) LLC (H) AVR 3.3V 3.3V - - - - 5V 5V GND GND GND GND GPIO4 (TX) L1 H1 RX GPIO5 (RX) L2 H2 TX GPIO19 L3 H3 RESET -
Generate a .hex file for the AVR MCU code you want to flash. You can follow this link for instructions.
-
Open the project configuration menu (
idf.py menuconfig
) go toExample Connection Configuration
->- WiFi SSID: WiFi network to which your PC is also connected to.
- WiFi Password: WiFi password
-
In order to test the OTA demo ->
/file_serving_avr
:- Compile and burn the firmware
idf.py -p PORT -b BAUD flash
- Run
idf.py -p PORT monitor
and note down the IP assigned to your ESP module. The default port is 80. - Test the example interactively on a web browser (assuming IP is 192.168.43.82):
- Open path
http://192.168.43.82/
to see an HTML web page with list of files on the server (initially empty) - Use the file upload form on the webpage to select and upload a .hex file to the server
- Click a file link to download / open the file on browser (if supported)
- Click the delete link visible next to each file entry to delete them
- Click on the flash link to flash the .hex code file uploaded to the connected AVR MCU.
- Open path
- Compile and burn the firmware
-
After clicking the flash link, you should get the following results -
-
Voila! Your AVR MCU is now running the code you uploaded Over-the-Air!
- Check your wiring. Make sure that the ESP32 and AVR MCU are powered separately. Don't power one MCU using the other.
- Do not connect ESP32 pins directly to the AVR-MCU pins, as ESP32 pins are not 5V tolerant. Use a logic level convertor.
- Verify your WiFi SSID and password. It is a known bug that ESP32 does not connect to WiFi stations with 'space' character in the SSID or password.
- Check your AVR MCU code, which generated the .hex file, for any 'logical' errors.
- For any other bugs or errors, you can always raise issues.
For OTA updates for STM32Fxx MCUs, you can follow this project.
-
GitHub Project: esp_avr_programmer by rene-win
-
STK500 Protocol: Documentation
-
Arduino StackExchange answer by Peter
Distributed under the MIT License. See LICENSE
for more information.