Page 1 of 1

SD/MMC bootloader

Posted: Fri Aug 12, 2005 6:47 am
by tvelliott
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...

SD/mmc bootloader

Posted: Fri Aug 12, 2005 8:16 pm
by TSPRAP
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

Re: SD/MMC bootloader

Posted: Thu Nov 10, 2005 12:32 pm
by roach
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?

Re: SD/MMC bootloader

Posted: Sun Dec 11, 2005 4:04 pm
by tvelliott
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.

Posted: Mon Dec 12, 2005 8:55 am
by gonzzo
hi tvelliott

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

dan

Posted: Fri Dec 30, 2005 9:25 pm
by tvelliott
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

Posted: Fri Jan 06, 2006 2:31 pm
by sonos
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.

Posted: Fri Jan 06, 2006 3:16 pm
by tvelliott
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

Posted: Sat Jan 07, 2006 1:42 am
by tvelliott
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

Posted: Tue Mar 07, 2006 2:00 pm
by roach
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!

Posted: Fri May 19, 2006 2:20 am
by SuperUser
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

Re: SD/MMC bootloader

Posted: Wed Mar 10, 2010 9:12 am
by santosh0705
Hi, I was looking for the same. but the file is not downloadable pls do the needful.

Re: SD/MMC bootloader

Posted: Sun Mar 28, 2010 5:39 pm
by Reggie