Im developing a consumer product that use an atmega328 with the Arduino bootloader and a FTDI chip on the same board, so it actually behave like an ordinary Arduino uno board. I can program my board using the Arduino IDE whiteout having to modify anything. I want to give my customers the possibility to update the firmware of my board, let say in the future i make a new program and i send it over email to them, and then they burn that program on the board using a usb cable.
The thing is, my target are not tech people, i cant tell them to install the arduino ide, load an script, compile it and the burn it to the board, it needs to be a very simple task, download the firmware, download the firmware uploader (a program made by me), connect the board and hit a button.
So in theory i can use the Arduino IDE to compile my program into hex code right? I know how to communicate with my board using serial a how to reset it so the bootloader restarts and checks for a new program, but after that i dont know what to do... how can I send that hex in a way the arduino bootloader knows is a new program?
i can use the Arduino IDE to compile my program into hex code right?
Yes. Under File:Preferences, check the Verbose output boxes, see where the hex code ends up.
Maybe you can write a batch file that runs the AVRdude commands that the IDE runs.
Still requires customers to have avrdude, or some portion of it, on the PC.
CrossRoads:
Maybe you can write a batch file that runs the AVRdude commands that the IDE runs.
Still requires customers to have avrdude, or some portion of it, on the PC.
Yes but AVRdude is for In system programming right? Thats for burning programs without the arduino bootloader... Remember that I will have the arduino bootloader on the atmega328, so in theory i can use plain serial communication...
In system programming requires the users to have an AVR ISP to connect to the ICSP header on the board. Serial just requires them to connect PC USB to USB/Serial on your board as PaulS said.
CrossRoads:
In system programming requires the users to have an AVR ISP to connect to the ICSP header on the board. Serial just requires them to connect PC USB to USB/Serial on your board as PaulS said.
The Arduino IDE calls GCC or G++ or whatever, compiles and links the program into a .HEX file, then AVRDUDE sends that hex file to the Arduino via the serial port.
The net result is that a stream of serial data is sent to the Arduino.
If the output of the Arduino IDE and AVRDUDE could be "captured" and stored in one file (a small binary file of raw bytes). couldn't this then simply be sent to the Arduino via a COM port?
Why couldn't the OP capture the updated raw code, then write a tiny C++ program that opens a COM port, sends the binary data to the Arduino (either from an external file or from within as an array of uint8_t's)?
This single program named "update.exe" could be run, send a stream of data to an Arduino and accomplish the update. No IDE or AVRDUDE or anything else needed.
Isn't there some back & forth comm's as part of the programming? So the PC side needs some smarts to receive data from the bootloader running on the 328 and decide if things are working.
CrossRoads:
Isn't there some back & forth comm's as part of the programming? So the PC side needs some smarts to receive data from the bootloader running on the 328 and decide if things are working.
Well, I've been looking into it and what seems to be going on is the STK-500 protocol.
AVRDUDE is doing it all "the right way" by checking for a proper device signature, getting timing info, etc...
As you thought, these is some back and forth communication (some of which seems to be necessary and can't be done away with).
I'm going to look into it some more, because I also have a use for this functionality (i.e. being able to program AVR chips without AVRDUDE).
I think the solution will be to implement a subset of the STK-500 protocol (well documented by Atmel and code examples simply by looking at AVRDUDE source) and then just send and receive the bytes the Arduino needs to keep the bootloader happy, then blast out the bytes of code.
Well actually there is a program that uses avrdude to send an hex file to the arduino bootloader, its call xloader (http://russemotto.com/xloader/), is not open source. But it seems that only opens avrdude and send a command to it.
I think this is the way to go, instead of creating a new avrdude, since that program can be distributed without any license related problem, a while ago i made a visual basic program that call a .com program silently.
Isn't there some back & forth comm's as part of the programming?
Yes, there is. Look at all the issues in Installation and Troubleshooting section, about the not-in-sync message that is displayed when avrdude does not get the expected response.