Can SPIN Bytecode be Loaded from an SD Card after Initial Bootup?
JRetSapDoog
Posts: 954
To spare readers the detail, the goal of my original post is summed up by the following:
For gluttons for punishment, my original post is quoted in the first response that follows, but it may be good to skip it.
Post Edited (JRetSapDoog) : 11/8/2009 11:01:29 PM GMT
"[noparse][[/noparse]Cause] a Spin program to be loaded into the Propeller's main memory
from a specified file on an attached SD card. This file should be a copy of
the binary form of a Spin program as saved from the Propeller Tool.
Once the Spin program has been successfully loaded, it begins execution.
The loaded Spin program completely replaces the running FemtoBasic."
······················· --excerpted from FemtoBasic/DongleBasic User Manuals
from a specified file on an attached SD card. This file should be a copy of
the binary form of a Spin program as saved from the Propeller Tool.
Once the Spin program has been successfully loaded, it begins execution.
The loaded Spin program completely replaces the running FemtoBasic."
······················· --excerpted from FemtoBasic/DongleBasic User Manuals
For gluttons for punishment, my original post is quoted in the first response that follows, but it may be good to skip it.
Post Edited (JRetSapDoog) : 11/8/2009 11:01:29 PM GMT
Comments
Take a look at FemtoBasic, PropDos, Sphinx... all reboot to different (loaded from SD) code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
Morpheusdual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory IO board kit $89.95, both kits $189.95
Propteus and Proteus for Propeller prototyping 6.250MHz custom Crystals run Propellers at 100MHz
Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
Thanks for those comments, Bill and Mike.· That sounds like exactly what I want to do.· I'll take a look at those objects.· Much appreciated!
Maybe a general-purpose object for this kind of "rebooting" as you call it would be nice.· The menu functionality sounds great, as well.
Hmm...I want the Spin program loader to also load Spin code (guess that's what a Spin program loader should load, but I'm not sure).·
Or does that mean to [noparse][[/noparse]1] use a spin program to [noparse][[/noparse]2] load a Basic or other interpreter to [noparse][[/noparse]3] finally load and run the target Spin program?·
Well...it's too early for me to be clear on the full scenario or·underlying mechanisms, but I know where to start digging.· Double thanks!!
You can include the fsrwFemto and sdspiFemto objects in your own Spin program and call the various routines yourself using the FemtoBasic code as a model or you can use FemtoBasic itself (or DongleBasic) to do the work for you. Your choice.
The low-level code in sdspiFemto can also load a Spin program from any address in any EEPROM attached to the Prop. For example, the Protoboard comes with a 64K byte EEPROM. The sdspiFemto EEPROM loader can load a Spin program from the 2nd 32K of the EEPROM and can reload the program from the 1st 32K.
Interesting, at least one of the sample·programs available for·the PSM·uses your sdspiFemto·driver that you mentioned in your last response here (the 2009/04/04 modified version), but·another program appears to use one called mb_spi (from·"lonesock").· Also, I think I've seen a couple different SD drivers used in the sample programs for the PSM, but I believe they either are a version of the fsrw driver·or derived therefrom.· So, perhaps that's good news for the equipment on hand.··But I can put together a different system, if need be,·as I intend to·do at some point anyway for other usage.·
Anyway, from the FemtoBasic manual, the SPIN "<file>" instruction appears to be the key.· There--described in 4 sentences what took me about 40--is exactly what I'm trying to do:
from a specified file on an attached SD card. This file should be a copy of
the binary form of a Spin program as saved from the Propeller Tool.
Once the Spin program has been successfully loaded, it begins execution.
The loaded Spin program completely replaces the running FemtoBasic."
If I understand you correctly, it appears that·I can just create the autoexec.bas Basic·file (using a standard plain text editor, I believe) and have it issue the SPIN "<FILE>" instruction on the Spin file of my choice, which will then take over from thereon.
BTW, it is this case that the as-yet-to-be-designed system I'm targeting won't have a PS/2 keyboard attached.· So, on the one hand, if being lazy and using the pre-built objects, perhaps I'd need to go with DongleBasic...since FemtoBasic may need a keyboard attached·in order to run.· On the other hand, perhaps using "my" own Spin program that uses the fsrwFemto.spin and your·sdspiFemto.spin objects would be the way to go, in that those probably don't reference a keyboard.· Or, perhaps I could just slightly modify FemtoBasic·to supply a file name.· I did·notice that DongleBasic uses objects of different names, but perhaps they are·similar (since, overall,·similar functionality is involved).
Well, although I'm still somewhat in the fog (being a total newbie), the sun is beginning to burn off that fog.· Thanks again for the help.
2) I recommend using the fsrwFemto and sdspiFemto objects from FemtoBasic if you're going to write your own Spin program. They're better designed to work separate from FemtoBasic than the corresponding routines in DongleBasic.
3) All of the high-level file system code is based on Rokicki's FSRW object which has recently been updated to V2.4. This newer version uses a new low-level driver called mb_spi... All of the FemtoBasic derivatives use a different low-level driver written in assembly that combines an I2C driver and the low-level SD card driver and includes boot loader functionality.
Regarding DongleBasic, if I'm not mistaken, it appears that the SPI pin configuration is set in the Constant section of the BB_definitions spin file [noparse][[/noparse]spiDO ('O' as in "Out," not zero/0), spiClk, spiDI, spiCS].· And I believe that we're using SPI to do MMC driving on MMC/SD cards.· So, from the DongleBasic perspective, would that mean that those are the pins that control an SD card?· It would seem so.· And if so, are they only set once (well...I could dig deeper to check that, admittedly)?· My Propeller System Module (PSM) from Raymond Allen uses Propeller pins P0..P3 to connect to pins on an SD card socket labeled Dat3, Cmd, Clk and Dat0, respectively (for reference, a pic with a partial schematic is attached from the PSM manual).· The PSM schematic appears to use the SD naming scheme (since·the PSM·uses·an SD socket).· I found a mapping from SD usage to SPI usage online.· For the mapping in this case (DongleBasic to PSM), I believe the mapping is as follows:·
But if so, functionally speaking, is there anything in the DongleBasic driver that requires the pins to be in the same order and/or be contiguous?· While my PSM SD socket pins are contiguous, they are in reverse order compared to the usage given in the DongleBasic caller.· I'm guessing (or hoping) that it's not a problem and that I can merely change the pins accordingly in BB_definitions (from 8..11 to 3..0).· Being contiguous is probably more important.· This is more of a status report than anything; I'm not expecting you to verify the pin usage, per se; just mostly talking out loud and hoping that someone will give a shoutout if they just happen to overhear something that souds a bit odd while they are working on something else (Huh?· Did he just say the world will end in 2012?·--or, since we're talking about terminals-- Did you say Gate 67?).·
BTW, I'm wondering, just for initial testing purposes, if the DongleBasic would need to be in EEPROM, or if it could merely be loaded into HUB RAM from the PC (in that the first 32KB of EEPROM content is merely copied to RAM on booting).· I'm guessing either way is fine, just as with other programs, but it's best to check.· I'm guessing you said "EEPROM" because that is my ultimate·target application.· Edit 1:· Hmm...on the other hand, maybe those objects have to load from EEPROM.· Yeah, guess that makes more sense.··And perhaps something involving reset is involved.· Edit 2:· Whoops!· Turns out I was wrong about being wrong; first casual guess was right, oddly enough.· See next 2 posts.
Anyway, at some point, I'll probably get the courage to try the above (or something close to it) and see what happens.· I thought I'd start with a DongleBasic test, as that seems like the quickest way to get started.· And if that works, maybe I'll have more confidence to look into FemtoBasic.· And if I want to "roll my own," I'll take your advice and use the fsrwFemto and sdspiFemto objects.· Thanks again.·
Post Edited (JRetSapDoog) : 11/8/2009 9:33:13 PM GMT
2) DongleBasic runs fine if just downloaded to RAM. In fact, that's used as a technique to load programs into 64K byte or 128K byte EEPROMs. You load your program into EEPROM, then load DongleBasic into RAM and do a "COPY [noparse][[/noparse]0],[noparse][[/noparse]<destination>]" where <destination> is the address where you want the program copied (in 32K multiples). Hitt Consulting's Prop-Dongle has a 64K EEPROM like Parallax's Protoboard and I would do a "COPY [noparse][[/noparse]0],[noparse][[/noparse]$8000]" to copy the downloaded program to the 2nd 32K of EEPROM, then re-download DongleBasic to the 1st 32K. I can then run the new program by doing "SPIN [noparse][[/noparse]$8000]". The same idea can work with the SD card but you can also use your PC to load up the SD card.
Post Edited (Mike Green) : 11/8/2009 8:18:02 PM GMT
Initially, it couldn't find my Spin program because it was named .binary from the spin tool, but I showed the hidden extensions and remedied that (renamed as myfile.bin not myfile.binary or myfile.binary.bin). I tried running things out of RAM first, and that worked. Then I burned to EEPROM, which also worked. Then, I reset, and that worked. Then, I took the card out, and, as expected, that did not work. In summary, it works from RAM or EEPROM, as you said (but that's not news to you).
Currently, I am confused, though, as to why it works out of RAM. Initially, I casually guessed that it would work out of RAM, like a typcial program. Then, after thinking about it for a bit, I concluded that it probably wouldn't because I thought it would specifically look for the EEPROM. Well, apparently, I over-thunk it. But in terms of why it does work out of RAM, I've under-thunk it. But I do know that it works. I also know you've got a nice explanation in the response before this one; it just hasn't sunk in yet. I don't as yet have a good idea about what things are fixed in unchangeable ROM in terms of the booting sequence or options thereof. And, equally important, I don't know how those various DongleBasic routines work. For that matter, at this point, I'm not clear on whether this technique is doing a reset or whether the routines just start a Spin interpreter in such a way that it equates to a fresh boot (interpreter in COG 0 and 7 clear ones (with no idea about the internal counter) and the SD Spin program in RAM). Actually, I'm such a newbie, that I only know how to start a Spin interpreter from one that up and already running. Well, for all I know, perhaps that's what this technique is doing but just killing itself in the process (I guess I mean, loading the SD Spin code into RAM, starting COG 0 on it, and then "falling on its sword" (COGSTOP) in the control cog and support cogs immediately afterwards).
Hey, sorry for the stream-of-consciousness (though hopefully it's instructive), but after writing the foregoing paragraph, I just looked in the Propeller manual to see if there's a command called RESET. There's not, but there's one called REBOOT (as well as a bit in the clock register that I guess can bring about the same result). So, this would be a so-called software reset. However, that wouldn't help us, would it! That would just result in loading DongleBasic once again, not loading the Spin program on the SD card. So, I guess that means that the "reset" that DongleBasic accomplishes is not done with smoke-and-mirrors (though well over my head) but rather through pretty much ordinary cog-control commands. I mean, of course it doesn't have any special access to Prop hardware/firmware that the rest of us don't, but, originally, I was open to the idea that some hardware of software reset was being done, or some special kind of linkage with the firmware, but it would seem not. DongleBasic can't get to the hardware reset pin (unless someone's circuit board was designed to connect a Prop output pin to it), and even if it could, it wouldn't work, just like a software reset wouldn't work. Or have I overthunk it again! Please feel free to correct me, anyone. And even if that's right, there's nuances that I'm not getting or misconceptions.
Having said all that, for now, I'm just glad it's working. There's many things that work that I don't understand but can use (my foot, especially while inserting into my mouth). So, we don't have to figure this out all today. I've learned a lot, already. And thanks again for the responses.
Also, I used the Forum Search, search.parallax.com (based on a tip in one of Mike's posts somewhere) and good 'ole Google to search for PropDOS and that also looks quite interesting.· For anyone interested,·a couple "starter" PropDOS links are as follows:·
Recent Forum Post:· http://forums.parallax.com/showthread.php?p=683157
Thanks again, Bill, for those useful pointers.· Greatly appreciated!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
Morpheusdual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory IO board kit $89.95, both kits $189.95
Propteus and Proteus for Propeller prototyping 6.250MHz custom Crystals run Propellers at 100MHz
Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
On Gadget Gangster: ·http://www.gadgetgangster.com/find-a-project/56?projectnum=281
Perhaps a version of that board with a prototyping (soldering) area right on the board might also be good.
P.S.:· Here in Taiwan, I ordered a Propeller System Module from GG and received good service from Nick.