SD/MMC bootloader

Your source for all things Atmel.

Moderator: phalanx

SD/MMC bootloader

Postby tvelliott » Fri Aug 12, 2005 6:47 am

Hi all,

I'm new to AVRs, but I love them so far... I was thinking about writing a bootloader that would look look for a binary image on an SD/MMC card on boot. If it was there, then flash the AVR from it. It seems this would be handy for in-field upgrades, it would also be extremely fast.....etc, etc. My question is: Has anyone already done an open-source implementation of this idea for the ATMega series? If not, I'll get one started this weekend...
tvelliott
 
Posts: 36
Joined: Sat Aug 06, 2005 10:50 pm

SD/mmc bootloader

Postby TSPRAP » Fri Aug 12, 2005 8:16 pm

If you use gcc they have examples of interfacing a FAT16/32 SD/MMC card. I can't remember were the link was. If I find it I'll post it. It would be easier then carring a laptop and ISP.



EDIT: Found it AVRlib
TSPRAP
 
Posts: 74
Joined: Sun Jul 10, 2005 3:06 pm
Location: http://tinyurl.com/fgfko

Re: SD/MMC bootloader

Postby roach » Thu Nov 10, 2005 12:32 pm

tvelliott wrote:...If not, I'll get one started this weekend...


Hi TV. This sounds really interesting. Did you find what you were looking for? Can you post some links?
User avatar
roach
 
Posts: 496
Joined: Mon Oct 17, 2005 11:45 am
Location: Montreal, CA

Re: SD/MMC bootloader

Postby tvelliott » Sun Dec 11, 2005 4:04 pm

roach wrote:
tvelliott wrote:...If not, I'll get one started this weekend...


Hi TV. This sounds really interesting. Did you find what you were looking for? Can you post some links?


No, I didn't find one, but I am almost done with writing one. I can program the entire program space on the ATMega128 in less than 7 seconds. I will post a link here when I'm ready to publish the code.
tvelliott
 
Posts: 36
Joined: Sat Aug 06, 2005 10:50 pm

Postby gonzzo » Mon Dec 12, 2005 8:55 am

hi tvelliott

I would be verrrry interested in this. please keep us posted.

dan
gonzzo
 
Posts: 3
Joined: Mon Dec 12, 2005 8:47 am

Postby tvelliott » Fri Dec 30, 2005 9:25 pm

gonzzo wrote:hi tvelliott

I would be verrrry interested in this. please keep us posted.

dan


As promised, here it is.

Hope you enjoy!!

http://hanfordsite.com/files/mega_mmc_b ... -12-30.zip
tvelliott
 
Posts: 36
Joined: Sat Aug 06, 2005 10:50 pm

Postby sonos » Fri Jan 06, 2006 2:31 pm

tvelliott wrote:As promised, here it is.


Thanks for this great hack on Pascal Stang's code! I was trying to do something like this a few months ago.
sonos
 
Posts: 3
Joined: Fri Jan 06, 2006 2:27 pm

Postby tvelliott » Fri Jan 06, 2006 3:16 pm

sonos wrote:
tvelliott wrote:As promised, here it is.


Thanks for this great hack on Pascal Stang's code! I was trying to do something like this a few months ago.


I'm not aware of any code from Pascal Stang in here, but I did try to give credit due to Sham et al for the FAT16 implementation. Also, Paul @ pjrc.com for a good writeup on FAT32.


Have fun!
I thought there would be a lot more response to it. Sure has made development easier for me


[edit]

Here are some references

This is the majority of what I started with. There are a lot of bugs in this code. I also
stripped out all the write code, as we don't need it for a bootloader that has to fit in 4K.
I merged in some of my own mmc code. I think I would have been better off starting from
scratch, but here it is

ftp://ftp.circuitcellar.com/pub/Circuit ... ham176.zip

mmc code reference (this is the bible of mmc/sd spi mode access)
http://www.sandisk.com/Assets/File/OEM/ ... mcv1.0.pdf

FAT32 reference mostly from here
(no code, but a great reference)
http://www.pjrc.com/tech/8051/ide/fat32.html
tvelliott
 
Posts: 36
Joined: Sat Aug 06, 2005 10:50 pm

Postby tvelliott » Sat Jan 07, 2006 1:42 am

After some more research, I'm not sure if more credit should go to Pascal Stang or Sham et al.

I guess I would just like to add that I went through every part of the code I have presented here. Give credit to whomever you please. Bottom line is that the code I have presented has been tested on several different brands and sizes of SD/MMC cards with FAT16 and FAT32 file systems formatted with Windows and Linux mkfs.vrat and mfs.msdos. I have used the fat code in an mp3 player that I developed. It is working at 320kbps. Hope it works for you.

Cheers,
tve
tvelliott
 
Posts: 36
Joined: Sat Aug 06, 2005 10:50 pm

Postby roach » Tue Mar 07, 2006 2:00 pm

This is AWESOME!

I was toying with the idea of implementing a bootloader that could support having a bunch of different programs on an MMC or CF card, that the bootloader could load whatever program the user selected from a list (via some unspecified input method. Possibly touchscreen or just over UART).

This will be a great starting point. Thanks!
User avatar
roach
 
Posts: 496
Joined: Mon Oct 17, 2005 11:45 am
Location: Montreal, CA

Postby SuperUser » Fri May 19, 2006 2:20 am

Great Job! :P

Takes me a few hours to adapt it to my hardware and than it was working without any change in your code. (less than 3700 words in total, there is some room to add features in the available 4096 word space)

I have some few comments/improvements:
a) MMC init should be done with a lower SPI clock frequency (thats according the MMC/SD spec). I am now starting with a slower clock and after mmc_init() i switch to the fastes SPI clock.
b) i am first checking if a SD/MMC card is in the slot at all. If not i jump immediately to 0 -> increases the boot time
c) the timeout in the spi_put()/spi_get() routines is quite long. I reduced it from 0x2000 to 0x100
d) i would like to have FAT12 support also, because i am using small SD cards normally. Perhaps i will add this to the code

Thanks a lot for publishing
SuperUser
 
Posts: 1
Joined: Fri May 19, 2006 2:07 am

Re: SD/MMC bootloader

Postby santosh0705 » Wed Mar 10, 2010 9:12 am

Hi, I was looking for the same. but the file is not downloadable pls do the needful.
santosh0705
 
Posts: 1
Joined: Wed Mar 10, 2010 8:56 am

Re: SD/MMC bootloader

Postby Reggie » Sun Mar 28, 2010 5:39 pm

Cya,
Reggie.
Reggie
 
Posts: 3
Joined: Tue Jan 12, 2010 6:50 pm


Return to Code

Who is online

Users browsing this forum: No registered users and 1 guest