Burn Bootloader and Wireless sketch in one shot

Started by Charly86, September 03, 2014, 06:05:49 PM

Charly86

Hi there,

I would start to try wireless upload and I've got a question (sorry if it has been already replied).

If I burn the bootloader then I will need the 1st time upload a sketch that will check received magic packet to put it on the flash SPI EEP and then reboot so the bootloader flash the Arduino and start new sketch.

To avoid this, ideally I would like to burn hex file of bootloader AND 1st listening sketch (with fixed nodeID of course) in one shoot so I can directly start to remotely upload new sketch without the need to solder FTDI connector on Moteino to upload the 1st program.

Is there a such hex file available ? If not I would be very interested on how to compile bootloader + 1 sketch file in the same time and then burn both in one shot.

Any ideas ?

Thanks for your help.

Felix

It's possible. But there's a catch as always ;)
The catch is that the bootloader sits at the very end of the flash memory (31-32K address space). Your program starts at the very beginning (0x0).
So to create your custom HEX image, first burn the bootloader as you normally do. Then upload your sketch via FTDI. Then read back the whole HEX using AVR Studio. That will create a large 32K HEX image which is probably going to be half empty (total size of 32K - 1K bootloader - your sketch size). Then you can always start burning that HEX instead of the bootloader. The catch also means it will take significantly longer to burn that fat HEX instead of a tiny 1K hex. I don't know if there's a way to burn two HEXes. Or maybe .. just maybe .. after reading the big HEX, you could just remove the lines in the HEX that are completely blank (0xFF) including their addresses. As long as there is a gap but addresses are still in order AVR should be able to flash with the HEX gap in the middle, that should make it faster. But this is just theory .. you'll have to try it to test my theory. Let us know if it works. If not, then you can still burn the whole big HEX and solve your requirement, it will just take 5-10 seconds more in total.

Charly86

Felix,

You kicked my ass !!!!

So simple and efficient, I'm still thinking how I could have missed this one  :o, I'm flashing so much bootloaders that I totally forgot I could also read the device, shame on me  :-[.

Thank's