How to design a PCB that allows firmware updates.

We have a small project to collect water well data in the field, basically a PCB with an ATmega2560, SD card and a bunch of sensors. The current version works well, but over the past few months, we had to change the firmware a few times. Bit of an issue, take laptop to field, connect and reload. Can be done but.

I would like to put a new file on the SD card and have the PCB load the new firmware and run.

My thoughts are to add another microcontroller to a new board that runs after reset and checks for a new version for the ATmega and loads as required. Similar (I think to the way the Uno and Mega boards currently work)

The problem I’m having is I’m new to this embedded electronics thing and have been have troubles locating any info.

Could someone point me in the right direction and any other help would be greatly

Thanks

This question is asked now & again. The bootloader as currently written checks to see if anyone is sending sketch-load commands after a reset, and starts the sketch load process if there is, otherwise the loaded sketch starts.

What would need to be done for Option 1 is to write a bootloader that checked for a sketch file on the SD card, if one existed then load that sketch up. If no sketch file found, check if anyone is sending sketch-load commands, and if neither, the loaded sketch runs.

For Option 2, the current bootloader just runs normally, not really caring who is providing the data.

I am pretty sure Option 2 has been done before, I recall reading about an art installation or similar where someone had a sketch that loaded new sketches into installed Arduino's.
In fact, that sounds a lot like what Optiloader does:
http://arduino.cc/forum/index.php/topic,68183.0.html

Option 1 maybe?
http://baldwisdom.com/bootdrive/

Demonic69:
Option 1 maybe?
BootDrive for Arduino | Bald Wisdom

That's option 2. Option 1 would be hacking the bootloader, which normally only looks at the UART to see if a new program is being uploaded, to check a digital pin or such for a flag that says it should start reading from a flash chip at a predefined location.

It would be kinda neat and magical but would make the bootloader larger. I nominate Crossroads to begin work immediately.

Nah, you need a real programmer for this. Someone that has made bootloaders before.

My thoughts are to add another microcontroller to a new board...

Would the SD card be shared between the two processors?

I think what OP is after, and this would make a great combination, is basically taking an Uno/equivalent with an SD/uSD sheild, and run basically Optiloader but put a sketch from the SD card into the target board instead of loading a bootloader.

Couldn't you just run a tiny sketch on the Arduino with a #include and a function in a .h file on the SD card?
When you say firmware, do you mean a sketch?

Getting an SD capable bootloader is probably one of the best if you can spare the 2k for the boot loader. I don't know of any off hand but I know I've seen some of the guys here starting to think about one recently.

The BootDrive is a nice option as well, leaving the stock bootloader on the micro and emulating AVRDude talking over the serial line.

For my own project I used a 2nd micro controller similar to the BootDrive, but I'm directly SPI programming my main chip, removing the need for a bootloader entirely and allowing faster communication between the two devices. I get around needing 2 SD cards or switching between them by talking through my updating micro controller to the same card that it reads to update the main controller. It impacts throughput significantly, but should also reduce write latency at the same time. If you're interested in perusing this option I can link you my code and schematics, but they are very early in development.

Couldn't you just run a tiny sketch on the Arduino with a #include and a function in a .h file on the SD card?

No the #include is an instruction to the compiler, it is never seen in the arduino code that is running.

Hi extent,

I´m interested in the code you wrote:

If you're interested in perusing this option I can link you my code and schematics, but they are very early in development.

Is it possible to get access to your files?
That would be fantastic... :slight_smile:

Best regards

pnewman,
Why not field boards with ZIF sockets, another at the shop. Program extra chips at the shop, exchange them with the ones in the field, then reprogram again if necessary, back at the shop, for the next update?
No fancy stuff, easily done, and a few more chips.
TomJ

2X on just changing the chip. Our company monkeys ]:smiley: (AKA service tech) can do it. They do it using a normal dip socket.

ATMega cartridge plug-in.. :smiley: