Launch .bin file file from fat32 sd card (with fsrw24)
Hello everybody,
I'm back with on·of mine strange questions.
Thanks to fsrw24 I'm·using a fat32 sd card in my propeller project and I'm very happy with it because I need fat32 support and the new seek feature present·in the last fsrw release.
In addition I have a .bin file (an eeprom/ram image generated using propTools)·on the SD card that I want to load and execute from my initial/main application.
The·idea is to·add·a runBinFromSD method·to fsrw object to accomplish the job. Do you think it's possible?
If I'm not wrong the "runBinFromSD" method should simply
1)·stop all running cogs except the one running SD driver
2)·load the entire·.bin file content into hub·RAM starting at address 0
3) run a·spin interpreter
Point 1 is quite easy, while point 2 should be something like
pread(0, get_filesize)
(I fear that in this way I'll lost some hub vars used by fsrw)
Do you agree? What about point 3?·Am I·missing something?
Any help would be·appreciated.
Many Thanks
Marco
I'm back with on·of mine strange questions.
Thanks to fsrw24 I'm·using a fat32 sd card in my propeller project and I'm very happy with it because I need fat32 support and the new seek feature present·in the last fsrw release.
In addition I have a .bin file (an eeprom/ram image generated using propTools)·on the SD card that I want to load and execute from my initial/main application.
The·idea is to·add·a runBinFromSD method·to fsrw object to accomplish the job. Do you think it's possible?
If I'm not wrong the "runBinFromSD" method should simply
1)·stop all running cogs except the one running SD driver
2)·load the entire·.bin file content into hub·RAM starting at address 0
3) run a·spin interpreter
Point 1 is quite easy, while point 2 should be something like
pread(0, get_filesize)
(I fear that in this way I'll lost some hub vars used by fsrw)
Do you agree? What about point 3?·Am I·missing something?
Any help would be·appreciated.
Many Thanks
Marco
Comments
The only way to do this is to have an assembly language SD card read routine that's launched in its own cog and given a list of blocks or groups of blocks on the SD card to read into RAM. Once that's done, it's easy for the assembly routine to start up a Spin interpreter and there are several examples of that.
Have a look at FemtoBasic's sdspiFemto.spin object which provides low-level (sector level) SD card I/O for FemtoBasic including a loader.
If you put Mike's FemtoBasic in EEPROM (or·even just HUB RAM, which initially surprised me), it can load a new·program (saved as a .bin in the·Propeller·Tool)·off of an SD card, wherein the·.bin program is specified by an autoexec.bas text file (also) on the SD card.· Works like a charm!· Mike has·mentioned other ways to do this as well.· A couple of potentially related threads:
Booting the Prop from SD card - discussion and ideas
A dedicated object specifically for this under the name "BootBinary" or similar might be a good idea.· That would be less intimidating to the uninitiated, like myself.· I think the conversion is at least·somewhat over my head at this point, but it should actually be quite straight-forward as the "heavy-lifting" has already been done with objects in the Obex.· Actually, the FemtoBasic approach works just fine, even though it's only using a single Basic-like statement in the Autoexec.bas file.· But it would be nice to have a dedicated object for boot purposes (perhaps with a menu option), wherein the documentation and file names were custimized for the general case, perhaps without reference to Basic as that might scare the uninitiated away because they may feel that they're already in deep·over their head and don't want to add even more complexity by going through Basic to accomplish their mission.· Actually, the Basic part is just one line in the .bas file, and any of the Basic-handling "guts" are quickly replaced when the .bas file is interpreted.· So, don't let the Basic part scare anyone away, but a general-purpose object would be nice, even if just changed mostly in name and documentation.· --My three cents ~ $1 New Taiwan Dollar, with an extra cent thrown in for inflation and the falling greenback.
·