Pages: [1] 2   Go Down
Author Topic: Flashing via SD card  (Read 2905 times)
0 Members and 1 Guest are viewing this topic.
Edmonton, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

look up ummc sd bootloader.
http://www.roguerobotics.com/wikidocs/code/bootloader_using_ummc

That will help you.

Mowcius
Logged

Edmonton, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Edmonton, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
...but it's far too big for the 328P
Not so - max bootloader size for the AtMega328P is 4KB.
Logged

Edmonton, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sooo.. 2048 words == 4096 KB?
Logged

Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Sooo.. 2048 words == 4096 KB?
2048 words == 4096 bytes
Logged

Bonn, Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 903
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Believe me, Mike, I calculated the odds of this succeeding against the odds I was doing something incredibly stupid[ch8230] and I went ahead

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Europe, Estonia
Offline Offline
Full Member
***
Karma: 0
Posts: 208
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: June 04, 2010, 07:06:58 am by Fredx » Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).  smiley-wink

Mowcius
Logged

Europe, Estonia
Offline Offline
Full Member
***
Karma: 0
Posts: 208
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

« Last Edit: June 04, 2010, 07:21:28 am by Fredx » Logged

Edmonton, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
« Last Edit: June 04, 2010, 08:40:19 am by Adrastos » Logged

Edmonton, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1] 2   Go Up
Jump to: