Edmonton, Canada
Offline
Newbie
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
|
 |
« on: June 02, 2010, 11:32:04 pm » |
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
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #1 on: June 03, 2010, 04:46:38 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Edmonton, Canada
Offline
Newbie
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
|
 |
« Reply #2 on: June 03, 2010, 11:03:39 am » |
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
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #3 on: June 03, 2010, 02:28:10 pm » |
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
Newbie
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
|
 |
« Reply #4 on: June 03, 2010, 08:07:39 pm » |
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
God Member
Karma: 3
Posts: 992
Arduino rocks
|
 |
« Reply #5 on: June 03, 2010, 10:54:22 pm » |
...but it's far too big for the 328P Not so - max bootloader size for the AtMega328P is 4KB.
|
|
|
|
|
Logged
|
|
|
|
|
Edmonton, Canada
Offline
Newbie
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
|
 |
« Reply #6 on: June 03, 2010, 11:17:17 pm » |
Sooo.. 2048 words == 4096 KB?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
God Member
Karma: 3
Posts: 992
Arduino rocks
|
 |
« Reply #7 on: June 04, 2010, 12:31:50 am » |
Sooo.. 2048 words == 4096 KB? 2048 words == 4096 bytes
|
|
|
|
|
Logged
|
|
|
|
|
Bonn, Germany
Offline
God Member
Karma: 0
Posts: 903
|
 |
« Reply #8 on: June 04, 2010, 04:36:16 am » |
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 anyway.
|
|
|
|
North Yorkshire, UK
Offline
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #9 on: June 04, 2010, 06:45:47 am » |
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
Full Member
Karma: 0
Posts: 208
|
 |
« Reply #10 on: June 04, 2010, 07:05:07 am » |
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
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #11 on: June 04, 2010, 07:10:55 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Europe, Estonia
Offline
Full Member
Karma: 0
Posts: 208
|
 |
« Reply #12 on: June 04, 2010, 07:14:39 am » |
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
Newbie
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
|
 |
« Reply #13 on: June 04, 2010, 08:40:03 am » |
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
Newbie
Karma: 0
Posts: 47
A-R-D-U-I-N-O... GoooOOOO ARDUINO!
|
 |
« Reply #14 on: June 04, 2010, 09:01:48 am » |
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
|
|
|
|
|
|