Go Down

Topic: OTA to ESP to Atmega (Read 212 times) previous topic - next topic

Pinja

I've seen a good number of guides now on OTA updates, but none that quite fits what I want to do.

I have an Arduino Mega as the main MCU in a project, and it has both SPI and UART connections to an ESP12 module. Currently the Arduino does "some stuff", periodically sends a JSON over to the ESP, which sends it out using MQTT over WiFi. The ESP handles all network related stuff.

What I'd like to do is send an Arduino hex to the ESP, store it and verify it on the ESP, then flash the Arduino with it. The ESP currently has custom software running on it, so I was hoping this functionality can be added to it somehow, but I'm not really sure what first steps to take.

I guess I want to reset and trigger the bootloader on the Arduino and then shove the hex over serial or something, but I have no idea the format that needs to take. Any tips?

DrAzzy

The protocol used to upload hex over serial with the arduino bootloader is STK500v2. You can find the specs online if you dig.

I'll bet someone has written code that will upload a .hex file over serial - though I'd wager you'll have a harder time finding one that will do it for the mega vs smaller AVRs that use STK500 (not v2). Some more googling is in order - I'm almost certain I've seen a reference to this. 

To kick off the bootloader, just pulse RESET low, and once the reset pulse ends, the bootloader will be active for a second or so (exact time depends on the specific board - I think the mega gives you a couple of seconds).
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Juraj

#2
Oct 09, 2018, 07:13 am Last Edit: Oct 09, 2018, 07:17 am by Juraj
the ESP8266AVRISP library is a OTA version of "Arduino as ISP".
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

DrAzzy

the ESP8266AVRISP library is a OTA version of "Arduino as ISP".
Which is useful to the OP how?

He wishes to upload via serial using the bootloader, not via ISP using the spi pins.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Juraj

#4
Oct 09, 2018, 09:41 am Last Edit: Oct 09, 2018, 09:42 am by Juraj
Which is useful to the OP how?

He wishes to upload via serial using the bootloader, not via ISP using the spi pins.
"Arduino Mega as the main MCU in a project, and it has both SPI and UART connections to an ESP12 module"
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Pinja

Thanks for the pointers. Some initial googling on both those solutions looks like just what I was after. I will report back once I get something running in case anyone else out there is looking to do something similar.

Juraj

#6
Oct 09, 2018, 11:24 am Last Edit: Oct 09, 2018, 11:25 am by Juraj
for the AVRISP it is important that it can't stk500v2 configured for Mega avrdude network upload in platform.txt. You need the settings from programmers.txt section "Arduino as ISP"
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Go Up