Shop OBEX P1 Docs P2 Docs Learn Events
Boot a Spin program from Prop C? — Parallax Forums

Boot a Spin program from Prop C?

Gents:
The Spin sd.Run allows a Spin program to boot another Spin program from the SD card. It also allows a Spin program to boot a Prop C program from the SD card. The question I have is it possible to boot a Spin program from a Prop C program? A fair amount of Google searching hasn't yielded an answer and I suspect this is because the capability doesn't exist. Given that the Spin language is interpreted it requires the interpreter to be resident in RAM in order to run a Spin program. Hence, to boot a Spin program from C would require both loading the interpreter and the desired program, thus a much more complicated boot process.

Thanks in advance for your feedback.

Comments

  • The Spin interpreter is in ROM, hence always present. So what you're wanting to do should be rather easily pulled off. I'm not a C programmer, though, so I can't offer more than hope and the likelihood of success.

    -Phil
  • DavidZemonDavidZemon Posts: 2,973
    edited 2016-05-09 16:50
    This thread may be of interest to you. I've collected into the first post all of the different ways to combine C/C++ and Spin applications.
    http://forums.parallax.com/discussion/157563/combining-spin-and-c

    I've never personally done what you're looking for (though I know it's been asked here before) but I think you might want to take a look into SpinWrap first and then if that doesn't work for you, Spin2Cpp. Spin2Cpp I'm much more familiar with, and it gives you a few different options:

    1) Extract only the "DAT" section of a Spin file. This is useful if you want to use an existing PASM driver in a .spin file but then interact with it via C/C++.
    2) Transpile (convert) the entire .spin file into C or C++. You then have all the options available via PropGCC for compiling the resulting C/C++ code. Many objects from the obex have been successfully utilized in projects using this method.
    3) One of the newest features of spin2cpp is its ability to directly compile a .spin file into assembly (as opposed to the Spin byte codes which must be interpreted). If your reason for wanting PropGCC is because Spin isn't fast enough, then this option could be exactly what you really want.
  • David:
    Many thanks for the wealth of detail. I was aware of spin2cpp but didn't know about there were many other options as well.

    Greg
Sign In or Register to comment.