Yeah, that is what Chip told us. There is a little state machine that just blasts the contents of the ROM into RAM at boot.
I was thinking, since COG ID is where some chip configuration is done, like fuse access, etc, maybe it could also write mask that 16k for the "treat it like ROM" use case.
Ram copy is fine, but can get trashed pretty easy.
Having that 16K ram default to write protected at boot up and being able to change that after would be useful. A bit like the 8080/Z80 systems where an area of memory was paged to be eprom for booting and ram when desired.
IMHO supporting anything other than the absolute minimum is a waste.
After the initial booting sequence, then...
run the ROM SD routine that needs to:
* Initialise the SD card (mount)
* Read MBR and check for some identifier (Peters method)
* If found, read that data into hub/cog and run it
* Else, locate a file (fixed filename, say "bootp2.bin")
* Read that file into hub/cog and run it
* Else, run a monitor program (that also allows simple serial download protocol)
So, it needs to be able to
* initialise the SD card (mount)
* support read block (sector)
* support locating files 8.3 in FAT32
Do we need to bother with older formats FAT16 (or even FAT12)?
Do we need to bother with MMC cards?
Do we need to bother with previous SD types prior to SDHC/SDXC ?
The smallest and cheapest microSD card available at OfficeWorks in Australia is now the SanDisk SDHC 8GB Class 10. So is there any point is supporting anything older???
BTW my 8GB SanDisk SDHC is formatted as 32KB clusters. I think this is the norm and therefore any initial boot program would fit into this meaning no need to search for further clusters. ie the boot file would be contiguous which makes it simple.
Dropping FAT16 support from the code I posted would reduce size a little.
Not a whole lot, but some. It would also make the code easier to understand.
On the other hand, you remove a limitation with just a bit of extra code...
I think I'd be OK with dropping FAT16 support.
I have an old 2GB FAT16 uSD I've been testing with.
I just checked and it looks like Windows10 will let me format it as FAT32, so could still use it...
Dropping FAT16 support from the code I posted would reduce size a little.
Not a whole lot, but some. It would also make the code easier to understand.
On the other hand, you remove a limitation with just a bit of extra code...
I think I'd be OK with dropping FAT16 support.
I have an old 2GB FAT16 uSD I've been testing with.
I just checked and it looks like Windows10 will let me format it as FAT32, so could still use it...
Yes I have been reformatting to FAT32 from 1GB onwards IIRC. Use 32KB Allocation Unit Size (2GB and below seem to default to 16KB while 8GB seem to default to 32KB) and we can ensure the whole 32KB file will be contiguous which will make the code simpler again.
Attached is my version of Kye's PASM section - I have been shrinking it and reorganising it a bit. Some of the variables can be remapped over the initialisation code.
I have added a document file that I made while following his code - it might be useful to you, or you might notice something incorrect.
Thinking a little deeper, the boot code will ultimately need to execute using the internal RC oscillator and Chip will need to decide which pins the SD card will be on - we can recommend this to him.
SD booting is for when there is no flash. So it would probably be reasonable to use the same pins as the flash. ie Either flash or SD, not both.
There may be future patch cases, where you do want both.
i2c also tends to be cheaper, and smaller, in the smallest memory sizes, and is easy to do a presence-test on, so the most flexible BOOT order is then UART-Small Boot devices(i2c) - larger Boot devices(spi) - largest Boot devices.(SD)
Comments
Having that 16K ram default to write protected at boot up and being able to change that after would be useful. A bit like the 8080/Z80 systems where an area of memory was paged to be eprom for booting and ram when desired.
One the one hand, it seems like a waste somehow to have SD reading routines on the chip that you can't get to.
On the other hand, you can just load up your own, customized, version after boot.
I have feeling that the ROM version of SD reading is going to be so crippled compared to what you could load later, that you would rarely want it...
Filesystems are tough, because partial support is often worse than no support.
After the initial booting sequence, then...
run the ROM SD routine that needs to:
* Initialise the SD card (mount)
* Read MBR and check for some identifier (Peters method)
* If found, read that data into hub/cog and run it
* Else, locate a file (fixed filename, say "bootp2.bin")
* Read that file into hub/cog and run it
* Else, run a monitor program (that also allows simple serial download protocol)
So, it needs to be able to
* initialise the SD card (mount)
* support read block (sector)
* support locating files 8.3 in FAT32
Do we need to bother with older formats FAT16 (or even FAT12)?
Do we need to bother with MMC cards?
Do we need to bother with previous SD types prior to SDHC/SDXC ?
The smallest and cheapest microSD card available at OfficeWorks in Australia is now the SanDisk SDHC 8GB Class 10. So is there any point is supporting anything older???
Not a whole lot, but some. It would also make the code easier to understand.
On the other hand, you remove a limitation with just a bit of extra code...
I think I'd be OK with dropping FAT16 support.
I have an old 2GB FAT16 uSD I've been testing with.
I just checked and it looks like Windows10 will let me format it as FAT32, so could still use it...
Attached is my version of Kye's PASM section - I have been shrinking it and reorganising it a bit. Some of the variables can be remapped over the initialisation code.
I have added a document file that I made while following his code - it might be useful to you, or you might notice something incorrect.
Think I've heard that clocking out a bunch of zeros can fix that though...
I share the pins on my RamBlades so I have resolved the issues.
SD booting is for when there is no flash. So it would probably be reasonable to use the same pins as the flash. ie Either flash or SD, not both.
For the case of both, the flash will have code to drive the SD and it can be anywhere.
Otherwise, 57 could be SD CS and 56 some other CS.
i2c also tends to be cheaper, and smaller, in the smallest memory sizes, and is easy to do a presence-test on, so the most flexible BOOT order is then UART-Small Boot devices(i2c) - larger Boot devices(spi) - largest Boot devices.(SD)
When you have flash, the SD can be anywhere because it will always boot from flash. Hence the boot code could look for sd on the flash pins.
Code still all fits in one cog! (but just barely)
The serial I/O routines are still there.
If I do anything else with this version, it will just be to remove the extraneous stuff and maybe clean it up a bit.
Hi Ray,
How does this boot exactly?
How do you make the P2BOOT.BIN file?
I made a text file and renamed it P2BOOT.TXT and this is what I get from the serial console...
!0000000400000004Passed FAT block check (Last 2 bytes are $55AA)
Passed FAT block check (Last 2 bytes are $55AA)
Sector size confirmed to be 512 bytes
Two copies of FAT confirmed
P2P2BOOT BIN
Target file found !
When you compile in PNUT the resultant .obj file is the binary
I think this ( or something similar i.e. minus serial output ) would be a great addition to the ROM for boot up.