Go Down

Topic: Programming Arduino without the IDE (Read 8502 times) previous topic - next topic

domingosl

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?


CrossRoads

Quote
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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

domingosl


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...

PaulS

Quote
Yes but AVRdude is for In system programming right?

No. It is for programming Arduinos with bootloaders via the USB to serial converter, too.

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.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

hbx2013

#5
Jan 12, 2014, 12:19 am Last Edit: Jan 12, 2014, 12:20 am by hbx2013 Reason: 1
just grab the avrdude.exe from your
C:\Program Files (x86)\Arduino\hardware\tools\avr\bin folder and put it on the customers PC.

In the same folder, create a bat-file with this line (replace with your COM-port + hex-name):

avrdude.exe -Cavrdude.conf -patmega2560 -cwiring -PCOM5 b 115200 -D -Uflash:w:yourHEXfile.hex:i

Put your hex-file in the same directory.

Now, they only have to run your bat-file.

Edit:
Oh, and you also need to install the drivers (i:e lisusb0.dll) on that PC. It's also in the directory mentioned above

krupski


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.

Wouldn't that work?

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

krupski


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.

Hopefully it will be that easy....... (sure)!  :)
Gentlemen may prefer Blondes, but Real Men prefer Redheads!

domingosl

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.

PaulS

Quote
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.

Go Up