I'm looking for a way to auto upload a new program to an Arduino mega from a memory card.
For example, insert a memory card and the program on the card is automatically uploaded to the Arduino. Is this possible?
I'm looking for a way to auto upload a new program to an Arduino mega from a memory card.
For example, insert a memory card and the program on the card is automatically uploaded to the Arduino. Is this possible?
The Auto bootloader for the Arduino is designed to work with AVRDUDE that runs on a PC and that reads a hex file (of the sketch) and communicates with the bootloader to write the sketch into the AVR chip. So what you are proposing is pretty much not possible without somehow having a functional PC processor chip running on the standalone board, running AVRDUDE.
However it might be possible to have a different bootloader written that could communicate with a SD memory module and knew how to select and process HEX files? Not a simple project for sure, but it could be very useful for some Arduino applications.
Lefty
Thanks for the info.
It would be very handy for me indeed.
Very possible, but a bit more involved.
AFAIK, the sketch upload is a simple serial file transfer to the ATMega chip.
You would need another microcontroller/processor that has the ability to read from a SD card, handle some basic protocol checks, and communicate good/fail process.
Assuming the original Arduino bootloader already exists on the Mega, I think this particular need could be filled with a second mega. There is enough power on the ATMega168/328 to read/write to a SDCard but it doesn't leave much overhead. In theory, the ATMega1280 that is on the Mega should provide that overhead back, making this fairly feasible.
Sounds a little 'black hat' though
So you are suggestion that I could make one Arduino upload a sketch to another Arduino?
That may work as well. Basically I don't want to expose the source code to the client - not that I am worried about copy, there is nothing special about the code. I just don't want them to tinker, or accidentally delete a line, and then claim the code doesn't work.
EDIT
What do you think about this?
http://www.4d-electronics.co.nz/FISP/FISP-USB%20Data%20Sheet.pdf
Jassper, you can achieve that (avoiding to expose your source code) by providing only the hex file (source code compiled for ATmega chip).
You could also re-write the boot loader to check for an update from your specialized storage where the code resides and re-program the FLASH on the fly, then reset into your new code. (Like the current Arduino bootloader does, but without a connection to USB to do it.)
For example, Bootloader would check a file on a SD card. If the version matches the current flashed version, just execute the FLASH code. (like the normal bootloader does now.) If the numbers differ, load and re-program the FLASH on the fly with the new code. Reset the controller and boot again, or just jump to the new flashed code.
I haven't done this with an AVR, but I have used this in other projects were the code (or parts of it) were stored encrypted. The stub program allocates memory (in setup()), copies from EEPROM to that memory (optionally decrypting it if it is stored encrypted), and then jumps into the appropriate address in that memory (executing what was in EEPROM, essentially)
Mind you- the built-in EEPROM is kind of small for that in the AVR. We had a little more space in our project...
Jassper, you can achieve that (avoiding to expose your source code) by providing only the hex file (source code compiled for ATmega chip).
But the client would still need a Laptop and some form of uploader like AVR Studio, correct? The easier I can make it for them the better.
You could also re-write the boot loader to check for an update from your specialized storage .....
retrolefty mentioned this as well and I think I will look into that a bit further as well.
Thanks everyone.
All you need is a "tool" that could transmit the hex file over the serial port. This could be a laptop with Arduino IDE, another arduino with SD card, a terminal etc.
Mr. BroHogan suggested in another thread a customer-friendly way to do a software upgrade: have an arduino-based device ("source") that reads the compiled sketch (hex file) from SD card and sends it over serial to the "target" (receiving) Arduino. The challenge, I guess, is to figure out the right baud rate for transmission. Otherwise, if you know the target's baud rate, you can configure it on the source.
Both suggestions sound interesting, but I can't seem to find the source code for the bootloader. Arduino has the hex file, but wheres the source?
I found the source here:
I don't know if it is the official site, but seems to be valid.
Thanks, I also found the code in the Arduino directory as well, looks to be the same.
But, the code is a bit over my head. I'll give it some deeper inspection but if anyone wants to lend a hand, contact me.
Thanks.
What I did was to provide my client with a USBTinyISP from Adafruit and a thumb drive containing AVRDude, Avrdude.conf, the .hex file from the sketch, and a batch file that I made from copying the command I got by setting the upload.verbose=true in preferences.txt and modifying it slightly to point to the files on the thumb drive.
Makes it simple for the client and I don't have to worry about him mucking with the code. If he needs changes I make them for him and just provide him with a new hex file.