Dear all, I am doing a project on my filed experiments, with about 100 mega2560 used in the project. Each mega2560 control a tank (turn on/off heating, reading temperature and so on). The sketch (user APP) in the mega2560 is the same for all of them. Each mega2560 communicate with the server (a PC with self-written software by VB.net) by ESP32 S3. (Do not ask me why two chips used )
Here is what I used: Serial port 3 of mega2560 was connected with Serial port 2 of ESP32. The pin 18 of ESP32 was connected to RESET pin of mega2560, then ESP32 can reset mega2560 if needed. Both of the Serial port 0 for mega2560 and ESP32 were retained for sketch downloading by USB cable.
What I am going to do is that: I will update user APP for mega2560 since the project is still going on, and wish to update all of them wireless (something like by OTA), not by a USB cable which I used now.
There was a idea in my mind which I think that I do not need to change anything physically, but not know how to make it become true.
First, I will update my code in Arduino IDE, and export hex file.
Second, may be I can read the hex file line by line, and send it to ESP32 by virtual serial port line by line. (It seems that hex file was consist with many lines begin with ":", so I think I can read it by the software developed by VB.net, and send it to ESP32 by wifi)
When the ESP32 got data from server, and know I am going to update the user APP (may be I can add some code before each line), the data will be send to mega2560 directly.
When mega2560 got data from ESP32, and know I am going to update the user APP, then the data will be write to flash. (How can I write a hex file in flash in mega2560?). Only can find examples for writing data, not a file.
When the whole hex file was transferred, I can use CRC to make they are write. The server can let ESP32 to reset the mega2560. Then mega2560 will find new sketch was loaded and updated it. I think here I need to modify the default BOOTLOADER of mega2560, right?
The bold sentences are my major questions, thanks in advance! Any help and comments are welcome, and if there is some codes are even more great, since I am not a coding boy, but just doing control experiments and like doing some coding