Bootloader
Re: Bootloader
Hey... Found this with Google:
http://avrrepository.org/svn/listing.ph ... rev=8&sc=0
[edit: easier spot to grab the tarball-- http://avrrepository.org/svn/listing.ph ... h=%2F&sc=0]
-Clay
http://avrrepository.org/svn/listing.ph ... rev=8&sc=0
[edit: easier spot to grab the tarball-- http://avrrepository.org/svn/listing.ph ... h=%2F&sc=0]
-Clay
-
- Posts: 252
- Joined: Tue Dec 02, 2008 12:38 am
- Location: Carlsbad, California (USA)
Re: Bootloader
Okay, so I can use the code pretty much as-is, but I need to make sure I do something like PORTD |= (1<<6) before using the routines? And then clearing the bit when I'm done?havok1919 wrote:The SPI pins itself are on PORTB (PB7=SCK, PB6=MISO, PB5=MOSI) and then we have PORTD.6 as the chip select.DavidEtherton wrote:It looks like that code is set up to use PORTB, not PORTD?
Sorry if I'm being dense, the interesting part to me is FAT16 decoding in as little space as possible.
-Dave
Re: Bootloader
Well, I *think* that the code takes into account that you can put the chip select elsewhere-- from looking at it I'm guessing that we'd just change in mmc_if.h:DavidEtherton wrote:Okay, so I can use the code pretty much as-is, but I need to make sure I do something like PORTD |= (1<<6) before using the routines? And then clearing the bit when I'm done?
Sorry if I'm being dense, the interesting part to me is FAT16 decoding in as little space as possible.
Code: Select all
#define MMC_CS_PORT PORTB
#define MMC_CS_DIR DDRB
Code: Select all
#define MMC_CS_PORT PORTD
#define MMC_CD_DIR DDRD
Code: Select all
#define MMC_SCK 7
#define MMC_MOSI 5
#define MMC_MISO 6
#define MMC_CS 6
Just for laughs I tried to build the code on WinAVR now, but they changed the way fdevopen and the whole stream thing works (yeah, great idea, let's use unix stream based IO on the microcontroller... ) which is just making me appreciate CodeVision and IAR all the more at the moment.
-Clay
-
- Posts: 252
- Joined: Tue Dec 02, 2008 12:38 am
- Location: Carlsbad, California (USA)
Re: Bootloader
ladyada, assuming we can get this code working on AVCORE, do you think it would be difficult to "port" it to fuzebox assuming the port mappings are in the ballpark?
We could use the new "hardware type" byte in the EEPROM to know where to look.
-Dave
We could use the new "hardware type" byte in the EEPROM to know where to look.
-Dave
Re: Bootloader
Don't care, the Fuzebox is 200% compatible with the ref design. She also used portd.6 for the chip select.
Uze
Uze
-
- Posts: 252
- Joined: Tue Dec 02, 2008 12:38 am
- Location: Carlsbad, California (USA)
Re: Bootloader
I added __AVR_ATmega64__ to the list of predefined symbols in order to get uart.c to compile (and added -DUZEBOX as well so I could check for the different port assignments) and GPIOR1 register suddenly became unrecognized in the audio assembly core? (beta4, playing with the Tutorial copy of the kernel)
I ended up taking -D__AVR_ATmega64__ back out again, but this was a bit worrisome?
-Dave
I ended up taking -D__AVR_ATmega64__ back out again, but this was a bit worrisome?
-Dave
-
- Posts: 252
- Joined: Tue Dec 02, 2008 12:38 am
- Location: Carlsbad, California (USA)
Re: Bootloader
Okay, this is REALLY weird -- I can't properly flash my AVCORE if there's an SD card inserted. As soon as I eject it, it works properly again.
WARNING: Flash byte address 0x000N (either 0 or 4 so far) is 0x00 (should be 0xC) .. FAILED!
-Dave
WARNING: Flash byte address 0x000N (either 0 or 4 so far) is 0x00 (should be 0xC) .. FAILED!
-Dave
Re: Bootloader
Uh, __AVR_ATmega64__ ? Don't you mean 644?
Uze
Don't worry too much, I had similar problems with my prototype and could never find a fix. Clay, did you had a fix for that?I can't properly flash my AVCORE if there's an SD card inserted. As soon as I eject it, it works properly again.
Uze
-
- Posts: 252
- Joined: Tue Dec 02, 2008 12:38 am
- Location: Carlsbad, California (USA)
Re: Bootloader
Probably -- I guess I figured 64 was a family of which 644 was a member of.uze6666 wrote:Uh, __AVR_ATmega64__ ? Don't you mean 644?
Uze
Also get this warning in uart.c which seems ominous:
../kernel/uart.c:117: warning: 'SIG_USART0_RECV' appears to be a misspelled signal handler
-
- Posts: 252
- Joined: Tue Dec 02, 2008 12:38 am
- Location: Carlsbad, California (USA)
Re: Bootloader
Looks like that code works fine. Seems plenty fast too, which is nice (looks like it can read a sector in less than a frame).
Just annoying to have to eject the card, hit program, and then reinsert the card.
See attachment for a demo (would be nice to know if it also works on fuzebox, only tested on AVCORE)
EDIT: Now prints out ascii text on right. Compressed to save space.
On my (FAT16) 2G SD card, the boot sector is at (hex) 0087, a FAT at 008F, another copy at 017B. The root directory is at 0267.
Sector zero is nearly empty -- there's some stuff at the very end which is probably a partition table (didn't realize SD cards had those). I'm guessing the little-endian int32 starting at offset 1C7 is the location of the boot sector since it contains 87 00 00 00.
-Dave
Just annoying to have to eject the card, hit program, and then reinsert the card.
See attachment for a demo (would be nice to know if it also works on fuzebox, only tested on AVCORE)
EDIT: Now prints out ascii text on right. Compressed to save space.
On my (FAT16) 2G SD card, the boot sector is at (hex) 0087, a FAT at 008F, another copy at 017B. The root directory is at 0267.
Sector zero is nearly empty -- there's some stuff at the very end which is probably a partition table (didn't realize SD cards had those). I'm guessing the little-endian int32 starting at offset 1C7 is the location of the boot sector since it contains 87 00 00 00.
-Dave
- Attachments
-
- tutorial.zip
- (15.2 KiB) Downloaded 349 times