Shop OBEX P1 Docs P2 Docs Learn Events
SPIN on Linux? — Parallax Forums

SPIN on Linux?

prof_brainoprof_braino Posts: 4,313
edited 2013-04-06 08:34 in Propeller 1
EDIT - Got it to work - Here's my notes (and review comments) for setting up SimpleIDE on Ubuntu 12.04. The focus is limited to loading a simple spin file, in particular devkernel.spin for propforth. It shows the tools is set up, and can load an image to prop EEPROM. This is geared toward first time users, as in kids and their parents.

http://code.google.com/p/propforth/wiki/LinuxPropforth

Please review, copy, or just read :)

* * *

I am in the process of switching to linux, in particular Ubuntu 12.04. At present, I'm running the Spin Tool on a windows virtual machine. I'm looking to skip the virtual machine work directly from linux on x86 PC and RaspberryPi. I'd also like to work from android devices, like samsung Captive phone and Nexus tablet, which I understand to be based on linux and might be treated in some ways similar to the PC linux. I think that are several partial solutions, which is the "right way" to go?

The primary requirement is to load the executable to the prop.

The other primary requierments is that it is straight-forward as possible to get it to run.

A secondary requirement is to be able to compile a single spin program into an executable. (The spin program has parameters that are set as constants at compile time, such as the I/O pin assignment for serial).

All other functions, such as GUI, multiple source files, compiling C, etc are nice to have but not show stoppers.

* BST - Brad's Spin tool is the recommended method, is this still the primary solution? Recent threads indicate this might be in some way broken, is this the case? Is bstc the tool folks actually use?

* homespun - http://propeller.wikispaces.com/Homespun+Spin+Compiler - is this the "better" choisce these days?

* simpleIDE - is this only used as the interface to the C compiler?

* stick with virtual window machine?

The prefered option would be something that we just load and use. The least favorite options are those that require loading and compiling source, configuring extra comipilers, or adding non standard support to the OS.
«1

Comments

  • kitsunekitsune Posts: 22
    edited 2013-04-04 10:25
    Here's my experience (Ubuntu 10.04): I started out with the Spin Tool running on a guest XP in a VirtualBox. Both the simple serial interface (3 transistors) and the USB interface were working.
    Had trouble installing BST under Ubuntu until I found http://gpio.kaltpost.de/?page_id=1378 which was extremely helpful. In my installation, i could not make the BST serial terminal work with the simple interface, but it runs perfectly well with the USB interface. IMHO, just being able to use #define makes BST worthwhile (and it has some other nice features, such as pointing out unused variables, compiler output listings, etc.). I do 99% of my programming in PASM -- after some SPIN in cog#0 starts the PASM cogs, it is overwritten by more PASM...

    I could not make SimpleIDE run under Ubuntu 10.04 if I remember correctly (because of a different Python version (?) -- I am not certain).
    Cannot comment on "homespun".
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-04 10:44
    kitsune wrote: »
    Here's my experience (Ubuntu 10.04): I started out with the Spin Tool running on a guest XP in a VirtualBox. Both the simple serial interface (3 transistors) and the USB interface were working.
    Had trouble installing BST under Ubuntu until I found http://gpio.kaltpost.de/?page_id=1378 which was extremely helpful. In my installation, i could not make the BST serial terminal work with the simple interface, but it runs perfectly well with the USB interface. IMHO, just being able to use #define makes BST worthwhile (and it has some other nice features, such as pointing out unused variables, compiler output listings, etc.). I do 99% of my programming in PASM -- after some SPIN in cog#0 starts the PASM cogs, it is overwritten by more PASM...

    I could not make SimpleIDE run under Ubuntu 10.04 if I remember correctly (because of a different Python version (?) -- I am not certain).
    Cannot comment on "homespun".
    If you do 99% of your programming in PASM, you might consider using Eric Smith's spin2cpp which can assemble PASM and can also concert Spin to C++ which can be compiled with PropGCC. This will all run under Windows, Mac, and Linux. The Spin to C++ translation produces much faster code than the native Spin compiler but that code does take up a bit more space even when using the PropGCC CMM memory model. However, since you say you only write a small amount of Spin code to launch your PASM code, that probably won't be an issue for you.
  • jazzedjazzed Posts: 11,803
    edited 2013-04-04 10:57
    SimpleIDE can compile spin projects - it has a different usage model though. Mindrobots uses it.

    Python error with SimpleIDE? Must have been another problem.

    Roy's SPIN compiler (dubbed SpinRoy by someone) can be built to run on any OS platform. It has preprocessor stuff.
  • kitsunekitsune Posts: 22
    edited 2013-04-04 10:57
    Thanks, David -- probably something I should be looking into.
    If it weren't for the trouble getting the IDEs to work (I am not really into the nitty-gritty of setting up software under Linux: gave up after failing to get Catalina and SimpleIDE to run as expected), I would also consider gcc provided it were to output clean cog memory model code. I am not too thrilled about gcc inline assembly (tend to use *.S files instead when writing AVR code [90% c, 10% assembler]).
    Kind regards,
    Fred
  • jazzedjazzed Posts: 11,803
    edited 2013-04-04 10:59
    kitsune wrote: »
    I would also consider gcc provided it were to output clean cog memory model code.

    What's dirty about it?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-04 11:02
    kitsune wrote: »
    Thanks, David -- probably something I should be looking into.
    If it weren't for the trouble getting the IDEs to work (I am not really into the nitty-gritty of setting up software under Linux: gave up after failing to get Catalina and SimpleIDE to run as expected), I would also consider gcc provided it were to output clean cog memory model code. I am not too thrilled about gcc inline assembly (tend to use *.S files instead when writing AVR code [90% c, 10% assembler]).
    Kind regards,
    Fred
    I'm not sure what your definition of "clean cog memory model code" is but PropGCC can certainly compile code to run directly in the COG with no LMM kernel. You are, of course, severely limited in the amount of code you can fit into a COG and you might have to supply a small space in hub memory to use as a stack if your COG code uses nested function calls. It does work though.
  • kitsunekitsune Posts: 22
    edited 2013-04-04 11:12
    "clean" = "no overhead"; please do not perceive this as any criticism towards gcc: I do use gcc for the AVR series of micrcocontrollers, quite happily in fact. What I am / have been doing with the Propeller requires speed, and maybe I am too much of a control freak to fully trust gcc to produce the kind of code I want (I know very well about the usually excellent optimization I get when I compile c code written for AVRs -- but I did look at numerous *.lss files before I developed that trust. Still lack that type of experience with the Propeller and definitely with PropGCC).
  • David BetzDavid Betz Posts: 14,516
    edited 2013-04-04 11:17
    kitsune wrote: »
    "clean" = "no overhead"; please do not perceive this as any criticism towards gcc: I do use gcc for the AVR series of micrcocontrollers, quite happily in fact. What I am / have been doing with the Propeller requires speed, and maybe I am too much of a control freak to fully trust gcc to produce the kind of code I want (I know very well about the usually excellent optimization I get when I compile c code written for AVRs -- but I did look at numerous *.lss files before I developed that trust. Still lack that type of experience with the Propeller and definitely with PropGCC).
    There is essentially no overhead in code compiled by PropGCC in -mcog mode. You'll have to look at the generated code yourself to see if you consider it "good enough". It won't compete with carefully handcrafted PASM code but it is pretty good.
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-04-04 11:20
    kitsune wrote: »
    If it weren't for the trouble getting the IDEs to work (I am not really into the nitty-gritty of setting up software under Linux: gave up after failing to get Catalina and SimpleIDE to run as expected)

    This is the type of user I have in mind for this question.

    What requires the least amount setting up under linux to load spin to a prop? On PC? On Raspberry Pi?

    If it takes more than a couple weeks to get it working, it probably won't work out. Is a windows virtual machine still the most straight forward method? The install takes two days to download all the updates and Smile, but at least it works.
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-04 11:31
    jazzed wrote: »
    SimpleIDE can compile spin projects - it has a different usage model though. Mindrobots uses it.

    I uses it and I likes it!!

    It goes from Win to Mac to Linux (multiple flavors) and works for me. I don't do lots of original development in Spin but I do a lot of tweaking/cutting/pasting/compiling an loading and it does all of that for me. Once you get used to the IDE, it's nice too because you can go from Spin to C/C++ without thinking about the IDE changing.

    I think it still uses BSTC as the underlying compiler but I imagine will change over to SpinRoy (use it three times and it sticks) some day.

    I'm guessing (hoping/betting) SimpleIDE stays a multi-platform/multi-language tool for the Propeller programmer. Between it, the latest an greatest SpinRoy and the PropGCC package, it should take you most anywhere.

    I believe Heater has it running the Raspberry Pi but I haven't tried that yet (ok, it's on my list!).

    David Betz's Prop loader is becoming (has become) a very versatile tool for loading the P1 and P emulators. It's part of the PropGCC package. It supports configuration files for the various hardware boards which is very useful (and can be used to pass load time parameters into a C/C++ program at load time, if I remember correctly - very cool!)

    I'm currently back to running a lot on a Win7 environment due to some projects I'm working on but long term, I've become a Mac/Linux user with Win reluctantly running in a virtual box if ABSOLUTELY needed.
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-04 11:37
    If it takes more than a couple weeks to get it working, it probably won't work out. Is a windows virtual machine still the most straight forward method? The install takes two days to download all the updates and Smile, but at least it works.

    I think you are WELL aware of my proudly acknowledged attention deficit issues...if anything takes me two weeks, I'm at least a week into a different project by then.

    My memory may be failing me but I recall SimpleIDE taking about 5 minutes plus download time to get it installed and running example programs on a Fedora 17 distribution. I have done it on Ubuntu and don't recall it being painful.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-04 11:37
    Braino,
    I am in the process of switching to linux...
    Excellent.
    ...in particular Ubuntu 12.04.
    Ah well. It's a good start I guess.

    *BST - Despite my recent thread BST is alive and well on Linux. Brad's latest prerelease vesion does not run on my 64-bit Debian but previous versions do. Especially the "release" versions. Don't forget there is also BSTC and BSTL the
    command line compiler and loader if you want to go that way. All highly recommended.

    * HomeSpun. Works fine. You just need to install the mono run time for .NET.

    $apt-get install mono

    or whatever they do on Ubuntu now a days. I even have HomeSpun running on the Raspberry Pi under Raspian.

    * SimpleIDE. Excellent choice. Also works for Spin. If there is no released binaries that do that on Linux just shout and I'll make one for you. I also have SimpleIDE running under the Raspberry Pi, although it cannot compile Spin there yet as it uses BST for which there is no ARM version. Hope that gets fixed soon now that we have SpinRoy.

    * stick with virtual window machine? Dear God no.
    The least favorite options are those that require loading and compiling source, configuring extra compilers, or adding non standard support to the OS.
    You have to get your feet wet with compiling stuff for Linux someday. It's an initiation right:) Luckilly propgcc and/or SimpleIDE have been very easy to build from sources.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-04 11:40
    mindrobots,
    ..if anything takes me two weeks, I'm at least a week into a different project by then.

    I like that. My boss does not, but I do:)
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-04-04 11:42
    OK, simpleIDE looks like a starting point. Where are the most complete set up instructions to the most compete version? (In this case, goggle is not our friend).
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-04 11:52
    OK, simpleIDE looks like a starting point. Where are the most complete set up instructions to the most compete version? (In this case, goggle is not our friend).

    That's the best part, Steve comes to your home and personally installs it!! :smile: Make sure there is someone else on the list behind you though because it's really hard to get him to leave!! :lol:

    Kidding aside, I need to look around for instructions (or hope someone else can point you to them), it's been a while since I've done it. I don't want to lead you astray with old info after leading you here!
  • jazzedjazzed Posts: 11,803
    edited 2013-04-04 12:01
    Start here: https://sites.google.com/site/propellergcc/downloads

    The Debian distributions work on Ubuntu and Mint. Choose 32 bit or 64 bit to fit your system.

    Version 0-8-5 is the latest for public use: https://code.google.com/p/propside/downloads/list?can=2&q=0-8-5&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount

    If you're resourceful enough, you can find the latest one we are testing (bugs and all).
  • SRLMSRLM Posts: 5,045
    edited 2013-04-04 12:09
    I prefer to use Gedit for editing the text files (with highlighting here), BSTC for compiling and downloading the code, and picocom for a terminal. All in all, it's a one click compile-download-terminal solution.

    Here is the bash script that I use to automate the process.
    #Compile based on port selection
    # - USB
    # - Wixel
    port=$(ls /dev/*USB* 2> /dev/null)
    if [ "$port" != "" ] ; then
    	#Download with USB port...
    	#Changes: uses the -f (fast download) option
    	bstc.linux -f -b -p0 -d $port -Ox -l -w1 $compilefile > bstoutput.txt
    else
    	port=$(ls /dev/ttyACM* 2> /dev/null)
    	if [ "$port" = "" ] ; then
    		echo
    		echo "Could not find Propeller on /dev/*USB* or /dev/ttyACM*"
    		echo
    		exit 1
    	else
    		#Download with Wixel port
    		#Downloads to EEPROM and runs
    		#If it doesn't download to EEPROM then the wixel will reset the Propeller
    		bstc.linux -p2 -d $port -Ox -l -w1 $compilefile > bstoutput.txt	
    	fi
    fi
    
    #Open Terminal if successful compilation
    cat bstoutput.txt
    
    grep -q "Error" bstoutput.txt
    if [ $? -eq 0 ]; then
    	cat bstoutput.txt
    else
    	grep -q "No Propeller detected on" bstoutput.txt
    	if [ $? -eq 0 ]; then
    		echo "Could not find Propeller chip..."
    		cat bstoutput.txt
    	else   		
    		picocom --send-cmd "ascii-xfr -s -c 0" -b $baud $port
    	fi
    fi
    
    rm bstoutput.txt
    rm $path/compile_time.dat
    

    To use, you just
    ./compile.sh top_level.spin
    
  • SRLMSRLM Posts: 5,045
    edited 2013-04-04 12:13
    As for Android: I doubt that you'll get BST to run on it. Maybe, with some hacking, you can get BSTC to run to compile the code. Downloading it? Who knows. I've always heard that Android was based on Linux, with the subtext that it's easy to port programs. Android uses a completely different model for programming, regardless of what the OS is based on.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-04 12:17
    SRLM,

    I have managed to compile some simple Qt(C++) apps to run on Android. Seems the Qt guys have now taken on Android as a primary platform so it must be even easier now. So the Spin compiler and loader should not be a big problem. No idea about Simple IDE. Still, where does the serial port come from. Can't do it on my phone.
  • Peter KG6LSEPeter KG6LSE Posts: 1,383
    edited 2013-04-04 12:23
    Heater. wrote: »
    SRLM,

    I have managed to compile some simple Qt(C++) apps to run on Android. Seems the Qt guys have now taken on Android as a primary platform so it must be even easier now. So the Spin compiler and loader should not be a big problem. No idea about Simple IDE. Still, where does the serial port come from. Can't do it on my phone.

    My Samsung supports USB OTG and I can see No reason why a FTDI chip cant e used ..

    UPDATE http://slickdevlabs.com/slick-usb-2-serial-library/
    this and my FTDI based USB-19-H Keyspan adapter is working great ....

    UPDATE the parallax " USB to 232 " Rev B is also recognized and I can bang bits .

    also Here is a wild Idea ....... the modern tablets have Tons of CPU power for there needs ...... I have on my samsing S3 phone a X86 Emulation program . I can boot in to Puppy and DSL linux . its a slow boot but it does work . sooooo with a few more tweaks Ill bet it may be possable to shoehorn a a version of BST or what not on it ......
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-04-04 14:30
    jazzed wrote: »
    Version 0-8-5 is the latest for public use: https://code.google.com/p/propside/downloads/list?can=2&q=0-8-5&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount

    If you're resourceful enough, you can find the latest one we are testing (bugs and all).

    What threw me was the "CMM preview test package" tag, it looked like a testing beta version. I definitely do NOT want the one your working on, If you haven't got it working, I certainly won't.

    Will the default LMM work with stock memory, or do we have to change things to get it to work?
  • jazzedjazzed Posts: 11,803
    edited 2013-04-04 14:54
    What threw me was the "CMM preview test package" tag, it looked like a testing beta version. I definitely do NOT want the one your working on, If you haven't got it working, I certainly won't.

    Version 0-8-5 is what people have been using for 6+ months.

    Ya, I know what you mean about the WIP (work in progress) version. I just mentioned it because we had an unplanned pre-release before without having a chance to say the thing is done. Wanted to head it off at the pass.

    There are many improvements coming in the next version which is a bit over-due.

    Will the default LMM work with stock memory, or do we have to change things to get it to work?

    Yes, it should work. HUB is the generic board type for C. The SPIN board type should always be NONE.

    The user guide which is out of date doesn't talk about SPIN much if anything.
    To work with a SPIN top file, just open the top file and click the COG button to set a project.

    Make sure the compiler is set to SPIN before building with the hammer.
    Load RAM and RUN with the blue "play" arrow.

    If you really need me to look over your shoulder as Rick suggested, it can be done with Google.

    Best of luck,
    --Steve
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-04-04 15:55
    So, using SimpleIDE, I want to take an existing known good SPIN file, (devkernel.spin) and load it onto the prop.

    I followed the instructions in the User Guide (I think).
    * downloaded the 0-8-5 archive
    * created a directory PropSoftware
    * move the archive here and extracted the archive
    * ran sudo ./setup.sh braino
    * ran ldd ./simpleide (this said "not found")
    * ran ./simpleide (closed two of the three windows that popped up, the splash and the properties. Why did properties window open, do I need to set something?)
    * created project TEST20130404. Type SPIN.

    Where am I to put the devkernel.spin file I want to run? I can't find the project directory I think I created, and there doesn't look like there's a directory specifically for source.

    Am I close?
  • jazzedjazzed Posts: 11,803
    edited 2013-04-04 16:23
    Where am I to put the devkernel.spin file I want to run? I can't find the project directory I think I created, and there doesn't look like there's a directory specifically for source.

    Am I close?

    Congratulations. You are very close.

    The TEST20130404 project should have created a TEST20130404.spin file in project manager.
    Parallax wants me to refine SPIN behavior after the upcoming release. Sorry for any trouble.

    Your devkernel.spin file can live anywhere.

    1) Use the Yellow file folder button (or with the Menu -> File -> Open command) to find and open your devkernel.spin file.
    2) Once you do that, click the blue COG in the toolbar next to the wrench. That will create a project called devkernel.
    3) Once you have the project you can compile/load, etc....

    The properties pops up to let you know it's there just incase something needs to be adjusted.
    I'm pretty sure the startup sequence is mentioned in the manual.

    Hmm, ldd not found? Ok. I need to make Linux packages for these installer things in the near future.
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-04-04 21:24
    Did some stuff....
    Found my SPIN source...
    Made a project....
    Figured out "Set Project" after I got tricked...

    The Hammer Icon gets me Bulding....Done.
    The green down arrow gets "Error opening serial port /dev/ttyUSB0", as do the other two arrow buttons.

    Do I need to add SimpleIDE or BST to the USB group or such?
    Do I need to log out or reboot?

    so close!!!
  • jazzedjazzed Posts: 11,803
    edited 2013-04-04 21:58
    Almost home!
    Do I need to add SimpleIDE or BST to the USB group or such?

    Assuming you really have /dev/ttyUSB0 ....

    You need to add "dialout" to your groups. I.E ....
    So we need to add 'fred' to the 'dialout' group. The -G option adds users to groups, but it also removes you from any groups you do not mention. The -a option simplifies this, so we only need to note the new groups we are joining, but we still need the -G option. Here's how it looks:

    $usermod -a -G dialout fred

    Now, this is the case for most distributions, however SUSE has modified this command, and removed the -a option. As of SUSE 11.3, there is an -A option, which can be used like this:

    $usermod -A dialout fred
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-04-04 22:34
    Whoo Hoo! It works!

    It needed my username added to the dialout group.

    This wasn't in the instructions, was it? Is this peculiar to Ubuntu 12.04?
  • Heater.Heater. Posts: 21,230
    edited 2013-04-04 22:39
    Well done.

    No those permissions issues are all over Linux. And a GOOD THING to. You'll soon the hang of it. Some instructions in the install procedure would obviously not go amiss though.
  • kitsunekitsune Posts: 22
    edited 2013-04-05 00:09
    I was mistaken about Python, sorry, my bad.
    Encouraged by the discussion above, I once again attempted to install SimpleIDE 0.7.2 under Ubuntu 10.4. The installation works, but when i attempt to run SimpleIDE, I get this message: "Cannot mix incompatible Qt libraries". I know, SimpleIDE expects a Qt version >=4.8 which is not compatible with Ubuntu 10.04 if I am not mistaken. That is quite painful. I will stick to BST because I want to spend my time writing Propeller code instead of struggling with IDE installation issues. But maybe somebody can tell me if there is an easy workaround?
  • Heater.Heater. Posts: 21,230
    edited 2013-04-05 00:51
    kitsune,

    I think you should try the latest SimpleIDE release as indicated above, https://code.google.com/p/propside/downloads/list?can=2&q=0-8-5&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount

    There should be no issue with incompatible libs as SimpleIDE comes with it's own Qt libs.

    Don't forget propgcc and SimpleIDE are still quite new stuff and it can be expected to have wrinkles. One day we might hope to see packages for Ubuntu, Debian, RedHat etc that streamline installation. But that's a lot of work to maintain I would imagine.

    As for "struggling with IDE installation issues" I wasted half a day figuring out why BST does not run on my machine until I hit upon a version that does.
Sign In or Register to comment.