Firmware update of ATmega 324pb using esp8266

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there a way to update the latest firmware to ATmega Through OTA using ESP module. If so by which reliable communication can be used SPI/USART/ I2C etc.

Last Edited: Mon. Jul 8, 2019 - 05:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AVRs can update their own code using SPM (self program Memory). To do that you need a "bootloader" which is code in the upper part of the flash. After that the only challenge is how to deliver the data to the AVR during the reprogramming process. Most AVR bootloaders are written to use UART so if you can deliver the new program code to the AVR from the ESP via the UART you should be good to go.

 

An alternative is to have the programming done "outside" the AVR - reprogram it using ISP and have the ESP module wiggle the wires in the right pattern to accomplish this. I'd suggest, however, this is more complex than having the AVR reprogram itself (given that so many pre-written bootloaders exist to choose from).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

samYU wrote:
Is there a way to update the latest firmware to ATmega Through OTA using ESP module.
Yes

FOTA is a feature of ESP8266 Zerynth; mega324PB's load is another file via the network.

A loader to communicate with the mega324PB's bootloader may be simple though may be several pages of Python.

An alternative method is a WebSocket server on the ESP8266 plus an AVR loader.

 

fyi, Arduino Uno WiFi rev 2 is ESP32 to mega4809 with a UPDI option (mega4809 is a mega324PB follow-on)

There are WebSocket servers in Python; pyupdi to a megaAVR 0-series.

 


Zerynth Supported Devices

Embedded WebSocket Server - Real Time Logic

ARDUINO UNO WiFi REV2

MicroWebSrv is a micro HTTP Web server that supports WebSockets, html/python language templating and routing handlers, for MicroPython (principally used on ESP32 and Pycom modules) | MicroWebSrv

GitHub - mraardvark/pyupdi: Python UPDI driver for programming "new" tinyAVR and megaAVR devices

ATmega324PB - 8-bit PIC Microcontrollers

ATMEGA4809 - 8-bit AVR Microcontrollers - Microcontrollers and Processors

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you @clawson am using ATmega 324pb, guess will go with the bootloader method

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does ATmega 324pb support FOTA feature ? if  so what are the ways using esp8266?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

samYU wrote:
Does ATmega 324pb support FOTA feature ?
Not directly as it's not a part of SerialBootloader though could implement that method (wireless stack, external EEPROM stores the load, bootloader programs the load)

AN_8390 AVR2054: SerialBootloader User Guide

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@gchapman Thank you for the reply am just a newbie,  could just explain about the following methods suggested by you. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Zerynth FOTA - no idea how that's done for the ESP8266 though Python has file I/O and the complexity of the Python for an AVR loader likely matches the AVR bootloader's complexity (low)

 

WebSocket

  1. Operator selects the URL for the AVR load (a file) or copies the AVR load onto their device
  2. Operator presses the OTAU button on the web page displayed by their device's web browser
  3. OTAU event to ESP8266's WebSocket server then AVR loader resets the AVR
  4. AVR load is streamed to the WebSocket server which streams that to the AVR loader which streams to the AVR bootloader
  5. AVR loader sends reboot to AVR bootloader

 

Arduino Uno WiFi rev 2 -

ESP32 is connected to mega4809 UPDI though couldn't quickly locate the ESP32 AVR UPDI code.

mega4809 does have a bootloader :

ArduinoCore-megaavr/bootloaders at master · arduino/ArduinoCore-megaavr · GitHub

 

SerialBootloader -

via AN_8390 AVR2054: SerialBootloader User Guide

 

"Dare to be naïve." - Buckminster Fuller