Programming an AVR from an AVR

A Master with Multiple Slaves.

nwrightson
Benutzer
Avatar
Gender:
Location: Newcastle
Age: 63
Homepage: nweha.homeserver.c…
Posts: 362
Registered: 08 / 2003
Subject:

Programming an AVR from an AVR

 · 
Posted: 15.10.2017 - 22:31  ·  #1
Hi All,

I'm looking at putting together a system that will have multiple AVR's/XMega's. One will act as a Master with multiple slaves. I'm thinking of having three SPI ports on the Master. Each SPI port on the Master will have multiple slaves. ie Master_SPI1 will have 6 SPI slaves, Master_SPI2 will have 2 SPI slaves, and Master_SPI3 will have 4 SPI slaves. The Master Micro will have an SD card for data storage.

Over a serial link, I would like to be able to download a new firmware image and store it on the SD card for the Master and be able to reprogram the Master from this image. Similar to updating the firmware on your ADSL modem or phone.

In addition, I would like to download new firmware onto the SD card for the slave micros on the SPI networks.
The Master would then use these images to update the firmware in the Slave devices.

Does anyone have code to share on programming of an AVR via an AVR using the SPI interface?

Looking forward to general comments and any help in this project.

Kind regards,
Neil.
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: Programming an AVR from an AVR

 · 
Posted: 15.10.2017 - 23:11  ·  #2
Hi Neil.

The hardest bit is programming from the SD card, and for that you need an XMEGA. I believe Miparo produced a flash loader that does this exact job and is part of AVRCo. I would personally use UARTs rather than SPI for the slaves. They are less sensitive to speed. It it possible to set AVRs as SPI slaves, but it is harder than you might imagine.
nwrightson
Benutzer
Avatar
Gender:
Location: Newcastle
Age: 63
Homepage: nweha.homeserver.c…
Posts: 362
Registered: 08 / 2003
Subject:

Re: Programming an AVR from an AVR

 · 
Posted: 15.10.2017 - 23:41  ·  #3
Hi Merlin,

Quote by Merlin

The hardest bit is programming from the SD card, and for that you need an XMEGA. I believe Miparo produced a flash loader that does this exact job and is part of AVRCo.

I have not updated my compiler version for a while, so do not think I have this version. If need be, I will update. To be honest, I have not used AVRCo for > 5 years.
I'm a bit confused about your above comment. Is this for the master to program itself with new firmware that is on the SD card? Why does the master specifically need to be a XMEGA? I have no aversion to the XMEGA, just trying to understand the issue.

Quote by Merlin

I would personally use UARTs rather than SPI for the slaves. They are less sensitive to speed. It it possible to set AVRs as SPI slaves, but it is harder than you might imagine.

Given that I will need to have the SPI connections for the flashing of the slaves, that is why I was looking to use the SPI bus for the normal system comms as well.
Because I need to have slaves on a shared bus, these will need to be multi dropped ie RS485.

Thanks,
Neil.
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: Programming an AVR from an AVR

 · 
Posted: 16.10.2017 - 14:04  ·  #4
Hi Neil.

For your first question there is limited space in any AVR boot area to store the functions needed to update the flash. For reading from a flash drive these function are fairly large and Miparo produced a stripped down version that could be used in an XMEGA boot area, but it will only work with XMEGAs. A complete bootloader from flash drive was produced.

As far as SPI is concerned, the problem with it is that the slave must keep up with the master. For normal chips this is not an issue but for CPUs it definitely is. A timer interrupt at the wrong moment for example will screw things up. There are things you can do to mitigate the issue, but then you could make life difficult for your other peripherals. For this reason, AVRCo does not support SPI slaves in its drivers, so you would have to write your own.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Programming an AVR from an AVR

 · 
Posted: 16.10.2017 - 20:41  ·  #5
Hello Neil,

directly SPI programming of connected slave AVRs don't make sense.
Too difficult, think of PDI with XMegas.
Build an RS485 network without line drivers. Use the boot sections
of the slaves for in-system programming.

rolf
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 14 · Cache Hits: 14   94   108 · Page-Gen-Time: 0.030449s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI