Shop OBEX P1 Docs P2 Docs Learn Events
Launch .bin file file from fat32 sd card (with fsrw24) — Parallax Forums

Launch .bin file file from fat32 sd card (with fsrw24)

mistikomistiko Posts: 2
edited 2009-11-22 22:40 in Propeller 1
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

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-22 18:16
    You won't be able to finish #2 or do #3. The problem is that FSRW is written in Spin and occupies part of the hub memory including various tables scattered all over the lower portion of memory. As you try to read the new program into RAM, it will destroy the program trying to read it.

    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.
  • JRetSapDoogJRetSapDoog Posts: 954
    edited 2009-11-22 22:40
    I don't think you'll need to worry about which SD driver you use initially because it will get swapped out in the process and you can use the latest and greatest or whatever you want in the final loaded binary (.bin).· You might not be worrying about that, but it's somthing I·considered recently when applying Mike's FemtoBasic·(on his suggestion)·to similar-sounding objectives·as yours (but I'm new, so I'm not sure, but for what it's worth).·

    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:

    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.

    ·
Sign In or Register to comment.