Booting .eeprom files from SD cards
Phil Pilgrim (PhiPi)
Posts: 23,514
I wrote a lesson for my students that showed them how to boot their programs from SD card EEPROM image files, rather than uploading them. This is important for the class ROVs, since it makes it easy to swap students' programs in the field without having to have PCs present. So I wrote the following simple loader program:
and tested it with a simple LED blinky program. It worked as I expected it to, so I wrote it up as a lesson.
Come class time, two kids were able to complete the lesson, but no blinky-blinky. I brought one of their SD cards home to try on my bot and had the same issue. The card that worked for me is a 4GB HC from Kingston; the one that didn't, a 32GB Ultra Plus HC(I) from SanDisk. The kids are able to write to their 32GB SD cards from Spin using SD-MMC_FATEngine. It's just the booting that seems to be an issue.
-Phil
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ sdc : "SD-MMC_FATEngine" PUB start \sdc.fatEngineStart(22, 23, 24, 25, -1, -1, -1, -1, -1) \sdc.mountPartition(0) \sdc.bootPartition(string("myprog.eep"))
and tested it with a simple LED blinky program. It worked as I expected it to, so I wrote it up as a lesson.
Come class time, two kids were able to complete the lesson, but no blinky-blinky. I brought one of their SD cards home to try on my bot and had the same issue. The card that worked for me is a 4GB HC from Kingston; the one that didn't, a 32GB Ultra Plus HC(I) from SanDisk. The kids are able to write to their 32GB SD cards from Spin using SD-MMC_FATEngine. It's just the booting that seems to be an issue.
-Phil
Comments
I wrote my own loader for BINARY files. It uses FSRW. You're welcome to it if you think it will be helpful. I went with BINARY images as they're smaller.
The process works well -- I recently deployed it in a customer project that has three distinct behaviors. When they power up the device (laser tag weapon), they can select which option to load by holding a specific button.
I deleted all the files on my student's 32GB SD card and copied myprog.eep back to it. Now it works, but I have no idea why or what the difference was.
-Phil
However, I am not exactly doing what you are doing.
The other thing I found with SD cards is that they don't always release the DO pin. This was a problem for me because I share the DO pin with SRAM so it's probably not your problem. I had to modify the various SD drivers to output some more clocks after deactivating the SD card (ie after CS=1).
My PropOS contains the modified Kye's driver. I split the code in two parts, ready for some other things that I never got around to completing.
-Phil
-Phil
BootPartition finally calls readWriteBlock. The latter expects a sector address as its first parameter. Internally it adds the hidden sector count to form the final address. That said, BootPartition misuses said parameter to pass the hub address of the boot image sector chain. The PASM section extracts it like this: This works as long as hiddenSectors is 0. IOW, readWriteBlock(@bootSectors - hiddenSectors, "B") would be my candidate for a fix.
-Phil