Discussion and Questions about a P2 Operating System

Cluso99Cluso99 Posts: 16,147
edited 2020-05-18 - 01:59:41 in Propeller 2
I'm getting close to having my P1 OS running on P2 :)

I have the SD and serial/monitor routines working, and they can remain resident.
I have Kye's FAT32 driver (including my P1 OS additions) now compiling and the basics running :)
I have a few of my OS commands (DIR, LS, etc) running on P2 (currently compiled in, not as a separate exe)

Now is the time to discuss...

* How binary files are formatted for loading and running under the OS
* How spin2 files can be loaded and run
* How the SPIN2 Interpreter can remain resident while running, plus
* Loading and running additional spin2 cogs

Chip,
First up, I need to know the mechanics of how I can use the spin2 interpreter when loading a new spin2 compiled file from SD.
I have the locating and loading from SD covered.

Where is the interpreter in hub?
Is the interpreter always in this location?
I presume the hubexec portion is re-entrant from multiple cogs?
How do I compile a spin2 program without the compiler?
How do I pick out the spin2 section from this binary file?
How do I launch a new cog with a new spin2 binary file?

Comments

  • Eric,
    How can I use fastspin to take a spin2 file and generate a pasm file that I can load/run from SD?

    eg I have small spin/spin2 files such as the DIR and LS commands.
    These would possibly all reside within a cog.
    Can I compile these individual files and what will it produce?

    I guess I should take the DIR file and separate out the part I want to be able to load/run from a cog???
  • Cluso99 wrote: »
    Eric,
    How can I use fastspin to take a spin2 file and generate a pasm file that I can load/run from SD?

    eg I have small spin/spin2 files such as the DIR and LS commands.
    These would possibly all reside within a cog.
    Can I compile these individual files and what will it produce?

    I guess I should take the DIR file and separate out the part I want to be able to load/run from a cog???

    fastspin lets you specify the HUB address you want things compiled for, and I've used it to load/run programs from a file system (the host PC, but SD would work exactly the same). I've posted an example of how to do this twice before, but searching in the forums is a pain and it's not surprising you didn't find it. Perhaps third time's a charm :) I've attached it here.
  • ersmith wrote: »
    Cluso99 wrote: »
    Eric,
    How can I use fastspin to take a spin2 file and generate a pasm file that I can load/run from SD?

    eg I have small spin/spin2 files such as the DIR and LS commands.
    These would possibly all reside within a cog.
    Can I compile these individual files and what will it produce?

    I guess I should take the DIR file and separate out the part I want to be able to load/run from a cog???

    fastspin lets you specify the HUB address you want things compiled for, and I've used it to load/run programs from a file system (the host PC, but SD would work exactly the same). I've posted an example of how to do this twice before, but searching in the forums is a pain and it's not surprising you didn't find it. Perhaps third time's a charm :) I've attached it here.

    Thanks Eric. Now that I have the SD access nailed I can give it a proper test. :)
  • Cluso99Cluso99 Posts: 16,147
    edited 2020-05-21 - 07:07:45
    Eric,
    I've given this a try but I have a problem.
    "blink" works fine.

    However, when I issue the "ls" command it returns "fs_init returned -1" error.

    Does flexgui use loadp2?

    I am running flexgui from C:\flexgui4.19\flexgui.exe and main, ls and blink are in this directory too. I have renamed main and compiled it, and I've recompiled ls with the additional line added.

    Once I get this running I can see how to shoehorn the SD and FAT32 driver into it.
  • Cluso99 wrote: »
    Does flexgui use loadp2?
    Yes.
    I am running flexgui from C:\flexgui4.19\flexgui.exe and main, ls and blink are in this directory too. I have renamed main and compiled it, and I've recompiled ls with the additional line added.
    What do you mean by "the additional line added"? The most recent code I posted (in this thread) should compile and work as-is. I also provided batch files "make.bat" and "run.bat" to show how to rebuild and how to run (although you can also choose to load main.binary with flexgui instead).
  • Cluso99Cluso99 Posts: 16,147
    edited 2020-05-21 - 23:25:20
    You said there was a bug in Les LS that prevented it running a second time. I inserted that line but this isn’t the problem.
    I ran flexgui to compile and run the main program (I renamed it tho). It works when I enter blink ie it flashes the led and then returns for a new command. But when I try ls it fails with the error above.
    I thought this should work??? Or am I not understanding this correctly.
  • Cluso99 wrote: »
    You said there was a bug in Les that prevented it running a second time. I inserted that line but this isn’t the problem.
    Not in the code that I posted in this thread. So I suggest you try that. For me, it works fine and I can run ls as many times as I want, from flexgui or from loadp2 directly.

    In any case if you can run programs from the PC then your 9p connection is working, so it's probably not worth spending a lot of time debugging any one specific example. I'd suggest instead looking at the programs in the flexgui\samples\fileserver directory to see how to read and write data from the PC.
  • Thanks Eric :)
    I will try that out today if I get a chance.
    Btw dam autocorrect!
  • Cluso99 wrote: »
    ...
    Btw dam autocorrect!
    LOL ;)

  • Eric,
    The penny just dropped. Of course it's working since it can load and run blink :smiley:
Sign In or Register to comment.