Go Down

Topic: Flashing via SD card (Read 3 times) previous topic - next topic

Adrastos

Hello,

I'm working on a project that would greatly benefit from being able to load .hex files off of an SD card, and then flash the ATMega chip to essentially run different programs at will.

I've browsed the forums for doing this, and the general concensus is that I would need to write a bootloader that reads an SD card to flash. While the Uzebox does this, I'd rather not get into that - way more than I want.

Instead, I was thinking of using two ATMegas - one which is the standard Arduino running the standard bootloader. The other loads .hex files from an SD card and uploads them to the first chip.

Is this feasible? If so, can someone point me to the protocol for serial program uploading? (I essentially want to emulate the Arduino UI upload). I read the app note on the original STK500 protocol, but it wasn't exactly very clear, and going through the source code for the bootloader is rather confusing as well.

Thanks!

mowcius


Adrastos

Thanks, this looks like I can hack it into doing exactly what I want.

However, it looks like that bootloader is designed to be under 4 KB, but I thought the 328 only had room for a 2 KB bootloader?

mowcius

I have not looked into that but I presume it is under 2KB. As you say, the max is 2KB (well as far as I know). Not sure about the size of that one though.

Mowcius

Adrastos

Just got home to test it out. Unfortunately, the uMMC bootloader is 3450 bytes when compiled. This is fine if using an ATMega644PA (which I might do in the end anyway...), but it's far too big for the 328P.

Fortunately, I've been able to figure out the source code well enough that I think I might be able to whip up my own bootloader that will fit on a 328.

It might be just a pipe dream, but I'll keep you posted!

BenF

Quote
...but it's far too big for the 328P

Not so - max bootloader size for the AtMega328P is 4KB.

Adrastos

Sooo.. 2048 words == 4096 KB?

BenF

Quote
Sooo.. 2048 words == 4096 KB?

2048 words == 4096 bytes

Nachtwind

I like the idea of this very much - but i thought you couldnt run code tat is not in a certain memory section of the atmega which is write protected?
Am i wrong here?
Believe me, Mike, I calculated the odds of this succeeding against the odds I was doing something incredibly stupid[ch8230] and I went ahead

mowcius

Well you are not running the code off the SD card, rather loading the arduino up with the code that is on the SD card. Then you could remove the SD card and the code would still be running.

You are correct that you cannot run code that is not on the chip.

Mowcius

D3C3PT1C0N

#10
Jun 04, 2010, 02:05 pm Last Edit: Jun 04, 2010, 02:06 pm by Fredx Reason: 1
It would be very cool, if it were possible to choose between code-files from SD card to install into Arduino. - by pressing input button you can choose between those files and for showing what file is selected, we may use graphical display or some 7 segment dispalys or just led blinking (file no 1 is 1 blink...etc)

Insert SD card to Arduino, choose your code-file and press reset button to upload code to Arduino.

mowcius

That could be easily done on the data storage boards from rogue robotics due to the file features already implemented. I considered this but I have not got round to changing my arduino bootloader to this one to let me do it yet.

This has been discussed a few times before (quite a lot recently).
I still think that it would also be nice to be able to read off the SD card and program to an un-modified arduino board (standard bootloader).  ;)

Mowcius

D3C3PT1C0N

#12
Jun 04, 2010, 02:14 pm Last Edit: Jun 04, 2010, 02:21 pm by Fredx Reason: 1
Actually i was also thinking about using default bootloader. If we could use the SD Card just like Arduino sofware "Arduino 0018" (but without it) - choose code and upload it. (the codes inside SD should be pre-verified/compiled)

Here is a youtube video about using SD-Card without any Shield (just some wires and resistors and SD card). - i am planning to do this.

http://www.youtube.com/watch?v=Hu0tokpsdrM

Adrastos

#13
Jun 04, 2010, 03:40 pm Last Edit: Jun 04, 2010, 03:40 pm by Adrastos Reason: 1
Ugh... Yea, I meant bytes.

Well that is good then. BOOTSZ would have to be set to 00 for that, if I can remember.

Though I might still give that custom bootloader a try to see if I can make it any smaller. (the uMMC one looks like it contains two methods of uploading sketches... If I'm only going go be loading from the sd card then I could probably get rid of half the current code...

Again, I'll keep you posted.

Thanks for the help!

Adrastos

Not modifying the bootloader is what I had originally intended so that would be nice.

I was planning on using this in my "ArduinoBoy" project. There would be a glcd and two or three chips (possibly one for handling the display). When the device is turned on, the "programmer" chip displays a list of hex files (games in this case). The user picks one, then the "proccessor" chip gets flashed and takes control of the system.

Go Up