Shop OBEX P1 Docs P2 Docs Learn Events
FlexProp: a complete programming system for P2 (and P1) - Page 3 — Parallax Forums

FlexProp: a complete programming system for P2 (and P1)

1356755

Comments

  • Happy for you on the signature key!
  • Got it. Worked with my Rev b out of the box first time.

    Thank you
  • Well done on the flexgui. It is a nice tool for working with the P2-EVAL-ES board.

    One note, in the Makefile in GitHub, the TCLROOT is set to the creators home folder:
    Ex:
    # where the Tcl and Tk source code are checked out (side by side)
    TCLROOT ?= /home/ersmith/src/Tcl
    

    I was not able to get this to build on Ubuntu 18.04 Linux, however I was able to get it to run after getting the environment set:
    NOTE: I am running Ubuntu 18.04 in VirtualBox on Win 10 64-bit

    1. Install some prerequisites
    sudo apt-get install python-tk xterm gcc-mingw-w64 tcl tk tcl-dev tk-dev
    
    NOTE: I am not sure the gcc-mingw-w64 is necessary

    2. Get the flexgui code:
    $ git clone --recursive https://github.com/totalspectrum/flexgui.git
    
    NOTE: I borrowed this command from a previous post.

    3. Trying to run Make on this fails to find the tk.h include
    $ make
    cpp -DTCL_SRC < version.inp > src/version.tcl
    i686-w64-mingw32-windres -o src/rc/wish.res.o --define STATIC_BUILD --include "/home/ersmith/src/Tcl/tk/generic" --include "/home/ersmith/src/Tcl/tcl/generic" --include "src/rc" "src/rc/wish.rc"
    src/rc/wish.rc:6:10: fatal error: tk.h: No such file or directory
     #include <tk.h>
    
    NOTE: The path for tcl/tk is set for ersmith. Also, I am guessing this is only for Windows at this stage.

    4. Get p2gcc and build it
    $ git clone --recursive  https://github.com/davehein/p2gcc.git
    
    $ cd p2gcc
    $ chmod +x build_linux 
    $ ./build_linux
    
    NOTE: This will produce some errors but it does build the required binaries.

    Ex:
    $ ls bin
    diffit  loadp2  p2asm  p2dump  p2dumpobj  p2gcc  p2link  s2pasm
    

    5. Create a 'bin' folder under flexgui and copy the p2gcc files in bin to the flexgui folder:
    $ cd ../flexgui/
    $ mkdir bin
    $ cp ../p2gcc/bin/* bin
    $ ls bin
    diffit  loadp2  p2asm  p2dump  p2dumpobj  p2gcc  p2link  s2pasm
    

    NOTE: The path to flexgui my be in a different location on each system

    6. Get and build spin2cpp
    $ git clone --recursive https://github.com/totalspectrum/spin2cpp.git
    $ cd spincpp
    $ make
    

    7. Copy the executable files under build and the include folder to the flexgui folder
    $ cp build/fastspin ../flexgui/bin/
    $ cp build/spin2cpp ../flexgui/bin/
    $ cp build/testlex ../flexgui/bin/
    $ cp -r include/ ../flexgui
    
    NOTE: The other option is to copy the spincpp/include from the flexgui folder to flexgui/include
    flexgui$ cp -r spin2cpp/include/ .
    

    8. I kept getting permission issues with the '.flexgui.config' file so I created it manually and changed the ownship and permissions:
    $ sudo touch .flexgui.config
    $ sudo chown ${USER}:${USER} .flexgui.config
    $ sudo chmod 755 .flexgui.config
    

    9. Add your user to dialout and tty
    $ sudo adduser ${USER} dialout
    $ sudo adduser ${USER} tty
    

    10. I created a rules file for the P2-EVAL-ES board so it would be consistent with the connection:
    Find the idVendor and idProduct of the P2-EVAL-ES
    $ dmesg
    [ 4953.719079] usb 2-2: New USB device found, idVendor=0403, idProduct=6015, bcdDevice=10.00
    [ 4953.719082] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    [ 4953.719083] usb 2-2: Product: Propeller P2-EVAL-ES
    [ 4953.719085] usb 2-2: Manufacturer: Parallax Inc.
    [ 4953.719086] usb 2-2: SerialNumber: DN43WXR7
    

    NOTE: idVendor=0403, idProduct=6015

    Using sudoedit, create a rules file and add the following:
    $ sudoedit /etc/udev/rules.d/50-ttyusb.rules
    

    Add this and write the file and exit:
    SUBSYSTEMs=="usb", ATTRS{idVendor}=="0403", \
    ATTRS={idProduct}=="6015", MODE:="0666", \
    GROUP="dialout"
    

    11. Also, I kept getting permissions issues with opening the ttyUSB0 device, so I found a site that suggested removing modemanager to get passed this. NOTE: This requires a reboot.
    https://askubuntu.com/questions/133235/how-do-i-allow-non-root-access-to-ttyusb0
    sudo apt-get remove modemmanager
    

    12. Once the system has rebooted, if running in a VirtualBox VM, the P2-EVAL-ES USB connection needs to be added to the VM:
    From the top of the VirtualBox window, select Devices->USB->Parallax Inc. Propeller P2-EVAL-ES [1000]

    13. From the flexgui folder, run the following to launch the gui:
    $ tclsh flexgui.tcl
    

    Select Port from the menu list and /dev/ttyUSB0 for the P2-EVAL-ES


    After this I was able to compile Spin, BASIC and C examples and load the binary on the board.

    I was not sure how to add screen shots, so I left them out.

    I hope this helps others.

    Cheers,

    Jon
  • Why you did not just install the windows versions directly?

    curious,

    Mike
  • Do you mean install the Windows versions on Linux or just use Windows? If it is the later, I prefer to work in Linux. If it is the former, I am not quite sure how to do that.
  • roglohrogloh Posts: 5,826
    edited 2019-11-25 00:27
    For Mac users with FlexGUI I found a quick way to avoid spawning the ugly XTERM when loadp2 is called after you click compile and run. Not sure if this will work with spaces in file names/folders, didn't try that as extra quotes can sometimes confuse the osascript and you may need to wrap these with \" instead.

    I also run my own loadp2 so you may have to adjust this to suit your specific path. Also if you don't want the terminal up you can remove the -t option and it will just download and exit unless there are errors in which case it stops, keeping the window open, and shows the error from loadp2 which is handy.

    Go to the Configure Commands menu option and change your Run Command to this...
    osascript -e "tell application \"Terminal\" to do script \"loadp2 %P -l 2000000 -b230400 %B  -CHIP -t && exit \"" > /dev/null
    
    Updated: fixed bad string.
  • I get: 178:179: syntax error: Expected expression but found “/”. (-2741) with that Run Command...


    dgately
  • ersmithersmith Posts: 6,064
    edited 2019-11-24 23:55
    *Edit*: sorry, I didn't notice that you were trying this on Linux rather than Mac. For Linux definitely the build scripts work, because I develop on Debian, so you can just do "make" in the flexgui/loadp2 and flexgui/spin2cpp submodules to build the Linux versions of loadp2 and spin2cpp.

    @JonM: Thanks for trying this out. I don't think you should need p2gcc for anything, nor will you need to fetch spin2cpp separately; both loadp2 and spin2cpp are submodules of the flexgui git repository. I haven't got a Mac build machine set up yet, but loadp2 has a "build_macos" script, so I think:
    # make sure to check out submodules
    git submodule --init
    cd loadp2
    ./build_macos # or ./build_linux for linux
    cd ../spin2cpp
    make
    
    should, I think, produce a usable "loadp2/loadp2" binary and "spin2cpp/build/fastspin" binary.

    I suspect what @msrobots was suggesting later is that you could unzip the Windows flexgui binary, then just copy the Mac/Linux versions of loadp2 and fastspin into the flexgui/bin directory (and optionally delete the Windows loadp2.exe and fastspin.exe programs, which you won't need for the Mac). Pretty much everything else is platform independent.

    Regards,
    Eric
  • roglohrogloh Posts: 5,826
    edited 2019-11-25 00:34
    dgately wrote: »
    I get: 178:179: syntax error: Expected expression but found “/”. (-2741) with that Run Command...

    dgately

    Apologies, I had pasted into the wrong spot when I added in the extra /dev/null above (first version didn't have that but it printed some extra output I didn't want). I think this is the correct string now:
    osascript -e "tell application \"Terminal\" to do script \"loadp2 %P -l 2000000 -b230400 %B  -CHIP  && exit \"" > /dev/null
    

    Also if you don't need any terminal at all and don't care about errors etc you can go commando and not have the window open at all by setting the run command to something like this:
    loadp2 %P -l 2000000 -b230400 %B  -CHIP
    
  • Actually Eric if you get a chance to plan more for future FlexGUI features it would be nice to have the ability to select download with a terminal window vs download only as different buttons and assign different run command strings to each, otherwise you need to change the string each time this varies. Or pass the terminal use as an option in the string and we can build different run scripts to deal with it perhaps... passing baud rates from the UI would be good too.

    Also some assignable(?) hotkeys would be really handy for the download and run options etc if they are supported from the TCL UI (not sure). Tiring clicking it with the mouse over and over.
  • rogloh wrote: »
    Actually Eric if you get a chance to plan more for future FlexGUI features it would be nice to have the ability to select download with a terminal window vs download only as different buttons and assign different run command strings to each, otherwise you need to change the string each time this varies. Or pass the terminal use as an option in the string and we can build different run scripts to deal with it perhaps... passing baud rates from the UI would be good too.
    Thanks for the suggestions. I think we could get a bit crazy though with options though. As it is closing the terminal window doesn't reset the Prop, so you can always launch with the window open and then close it if you find you don't want it. I do agree that being able to set the baud rate from the GUI and pass it to the run command would be very nice, I'll try to add that.
    Also some assignable(?) hotkeys would be really handy for the download and run options etc if they are supported from the TCL UI (not sure). Tiring clicking it with the mouse over and over.

    Control-R is already bound to compile & run. The hotkeys should show up next to the menu commands. I didn't put the hotkey string in the buttons because they were already getting rather long.

    Thanks,
    Eric
  • I've released version 4.0.4 of FlexGUI. It has several new features:

    - Thanks to the work of @ozpropdev and @evanh we can program the P2ES SPI flash
    - The loadp2 console on Windows now understands ANSI escape sequences, so micropython looks much better
    - fastspin now supports __pasm blocks in C, which work much like DAT blocks in Spin (so you can insert COG assembly right in with the C code that uses it).
    - similarly BASIC has "asm shared", which creates a global ASM block like DAT does. (plain "asm" inserts some assembly code that is to be executed immediately)
    - many bug fixes

    As usual, flexgui may be obtained from https://github.com/totalspectrum/flexgui/releases; get the flexgui.zip file for everything you need for Windows.
  • ersmith wrote: »

    Control-R is already bound to compile & run. The hotkeys should show up next to the menu commands. I didn't put the hotkey string in the buttons because they were already getting rather long.

    Thanks,
    Eric

    Hey thanks, that is great, Ctrl-R does compile and run. This is a hidden feature on the Mac. I don't see any hotkeys in the menus so didn't know about it. Are there any others?
  • Eric I had a look at your gui.tcl file and found a few other accelerators. They are not showing up on the Mac menus which is why I didn't know about them.

    Even though they currently do work when you press the Control keys, they seem to show up in the menus if you make them use the command keys for the Mac variant instead (at least in OS X 10.10.5 Yosemite). Eg.

    .mbar.file add command -label "New File" -accelerator Command-N -command { createNewTab }
    .mbar.file add command -label "Open File..." -accelerator Command-O -command { doOpenFile }
    .mbar.file add command -label "Save File" -accelerator Command-S -command { saveCurFile }

    but then you need to change the bindings as well from Control to Command etc, eg.

    bind . <Command-n> { createNewTab }
    bind . <Command-o> { doOpenFile }
    bind . <Command-s> { saveCurFile }

    I don't know if this is something easy to do differently for a Mac variant. Or possibly just setup both bindings in all cases. Not sure what the Command key is on the Windows/Linux machine. Is it the Windows key or ALT perhaps?
  • ersmith wrote: »
    ...
    - The loadp2 console on Windows now understands ANSI escape sequences, so micropython looks much better

    @ersmith, How did you do that one? Ansi in windows console?

    curious,

    Mike
  • rogloh wrote: »
    Eric I had a look at your gui.tcl file and found a few other accelerators. They are not showing up on the Mac menus which is why I didn't know about them.

    Even though they currently do work when you press the Control keys, they seem to show up in the menus if you make them use the command keys for the Mac variant instead (at least in OS X 10.10.5 Yosemite). Eg.

    .mbar.file add command -label "New File" -accelerator Command-N -command { createNewTab }
    .mbar.file add command -label "Open File..." -accelerator Command-O -command { doOpenFile }
    .mbar.file add command -label "Save File" -accelerator Command-S -command { saveCurFile }

    but then you need to change the bindings as well from Control to Command etc, eg.

    bind . <Command-n> { createNewTab }
    bind . <Command-o> { doOpenFile }
    bind . <Command-s> { saveCurFile }

    I don't know if this is something easy to do differently for a Mac variant. Or possibly just setup both bindings in all cases. Not sure what the Command key is on the Windows/Linux machine. Is it the Windows key or ALT perhaps?

    Hmmm, interesting. I'll have to do some research on how to handle this variation. Thanks for figuring this out though, I wouldn't have guessed that the Mac menus didn't show the accelerators.
  • msrobots wrote: »
    ersmith wrote: »
    ...
    - The loadp2 console on Windows now understands ANSI escape sequences, so micropython looks much better

    @ersmith, How did you do that one? Ansi in windows console?

    curious,

    Mike

    The Windows SetConsoleMode API lets you define how the console responds to ANSI escape sequences. There's also a registry entry to set the defaults, but calling SetConsoleMode directly avoids making the user edit the registry to set this.
  • ersmith wrote: »
    Hmmm, interesting. I'll have to do some research on how to handle this variation. Thanks for figuring this out though, I wouldn't have guessed that the Mac menus didn't show the accelerators.

    I found this useful snippet which may be useful if you need any cross platform variation decisions in your code... I just ran it on my Mac and it reported Darwin as the os as mentioned below.
    There is a Tcl global variable called tcl_platform that contains this information. To check this, just type in "tclsh" into your Terminal application, which will launch the Tcl command-line shell (not Wish). Then, type parray tcl_platform. Here is the output you'll see:
    
    
    % parray tcl_platform
    tcl_platform(byteOrder) = bigEndian
    tcl_platform(machine) = ppc
    tcl_platform(os) = Darwin
    tcl_platform(osVersion) = 7.6
    tcl_platform(platform) = unix
    

    Sourced from here...
    https://wiki.tcl-lang.org/page/New+Tcl/TkAqua+FAQ
  • roglohrogloh Posts: 5,826
    edited 2019-11-25 11:35
    Eric, I put in some of my own hacks into gui.tcl and managed to add a button that downloads with the terminal and one that downloads without it. It's pretty hacked up with duplicated pathways as you'll see because I don't know any TCL to do it the right way. If you want to take a look I have attached it. It is 4.0.3 based.

    I now just press Command-R to compile/download/run, and Command-T to compile/download/run and popup a console window. Works pretty nicely for me now, I even managed to get the window focus to switch the way I'd like via external scripts and windows to close down when things exit etc.

    gui.zip 10.1K
  • rogloh wrote: »
    % parray tcl_platform
    tcl_platform(byteOrder) = bigEndian
    tcl_platform(machine) = ppc
    tcl_platform(os) = Darwin
    tcl_platform(osVersion) = 7.6
    tcl_platform(platform) = unix
    [/code]
    Note that with an Intel Mac and the most recent macOS (Catalina, 10.15.1), you'll see:
    % parray tcl_platform
    tcl_platform(byteOrder)   = littleEndian
    tcl_platform(machine)     = x86_64
    tcl_platform(os)          = Darwin
    tcl_platform(osVersion)   = 19.0.0
    tcl_platform(platform)    = unix
    
    FYI, still Darwin, but now x86_64 & littleEndian... :smile:

    dgately

  • ersmith wrote: »
    *Edit*: sorry, I didn't notice that you were trying this on Linux rather than Mac. For Linux definitely the build scripts work, because I develop on Debian, so you can just do "make" in the flexgui/loadp2 and flexgui/spin2cpp submodules to build the Linux versions of loadp2 and spin2cpp.

    @JonM: Thanks for trying this out. I don't think you should need p2gcc for anything, nor will you need to fetch spin2cpp separately; both loadp2 and spin2cpp are submodules of the flexgui git repository. I haven't got a Mac build machine set up yet, but loadp2 has a "build_macos" script, so I think:
    # make sure to check out submodules
    git submodule --init
    cd loadp2
    ./build_macos # or ./build_linux for linux
    cd ../spin2cpp
    make
    
    should, I think, produce a usable "loadp2/loadp2" binary and "spin2cpp/build/fastspin" binary.


    Regards,
    Eric


    @ersmith I cloned the latest code from your flexgui repo on my Ubuntu 18.04 VM but attempting to build loadp2 fails with either build_linux or make:

    build_linux fail:
    flexgui/loadp2$ ./build_linux 
    loadp2.c:71:10: fatal error: MainLoader.h: No such file or directory
     #include "MainLoader.h"
              ^~~~~~~~~~~~~~
    compilation terminated.
    

    Make fails for:
    flexgui/loadp2$ make
    fastspin -2 -o MainLoader.bin MainLoader.spin2
    make: fastspin: Command not found
    Makefile:71: recipe for target 'MainLoader.bin' failed
    make: *** [MainLoader.bin] Error 127
    

    I found I had to build spin2cpp first then create a 'bin' folder under flexgui, copy the executable files in the spin2cpp/build folder to flexgui/bin, set my PATH to include the flexgui/bin folder and then I was able to build loadp2. I copied the resulting build/loadp2 to flexgui/bin.

    I also had to copy the spin2cpp 'include' folder and contents to the flexgui folder to compile a .c file.

    Cheers,

    Jon
  • evanhevanh Posts: 16,007
    edited 2019-11-26 06:14
    [deleted]
  • @evanh That is what I found. For a new config, this would not be set, thus building spin2cpp first and either setting the Path to that location or just copy the files to flexgui/bin and setting the Path to that location seemed to the best path.
  • evanhevanh Posts: 16,007
    Yeah, sorry, I posted before reading your whole post first.

  • @rogloh : Thank you for your suggestions for gui.tcl. I hope to do a MacOS pass soon and I'll try to get at least the accelerators working. I'm still not completely convinced of the utility of run with/without terminal, but perhaps that could be made a checkbox option or something similar.

    @JonM : Sorry for the difficulty you had building flexgui for Linux -- it really wasn't set up for that (I build on Linux, but for Windows; for my own use I had set up the flexgui directories manually). I've revised the Makefile and I think the newest github should work better for you.

    Thanks,
    Eric
  • @ersmith : No worries. I was just sharing my findings using the tool on Linux in case it was helpful to others or to be corrected if I were doing something wrong.

    It is a very useful tool for programming the P2-ES.
  • @ersmith : Exec'ing "make -f Makefile.mac" results in:
    ~/source/flexgui% make -f Makefile.mac
    make: *** No rule to make target `flexgui.zip', needed by `default'.  Stop.
    
    Makefile.mac has references to "fastgui" rather than "flexgui"... I edited all of those to "flexgui" and now make executes with success! I attached a new Makefile.mac (with ".txt" for the forum's sake) to this post.

    dgately
  • @dgately: thanks. I think actually the regular Makefile should now work for the Mac too (so plain "make install" should work on macosx, at least if you have gcc installed).

  • roglohrogloh Posts: 5,826
    edited 2019-11-26 23:44
    ersmith wrote: »
    @rogloh : Thank you for your suggestions for gui.tcl. I hope to do a MacOS pass soon and I'll try to get at least the accelerators working. I'm still not completely convinced of the utility of run with/without terminal, but perhaps that could be made a checkbox option or something similar.

    Ok, the utility of this as I see it is that currently when you download a program to a P2 application without requiring the terminal you have to do one of two things..

    1) modify the run command line switch and get rid of the -t and or -k options to loadp2, and then remember to set it back when you open a project that does need the terminal. When you are flipping between different projects that do or don't use the terminal changing this accordingly each time can be annoying.

    2) Or, each time you download for testing, have a new window get opened and stay open until you click it and then press ^] and/or return to exit, each time you want to download and test a program out, then go back and click the flexgui window to continue editing/recompiling etc.

    With hotkeys working it is nice and fast to not have to keep moving the mouse to new windows etc. Rapid re-cycle time improves workflow (well mine at least). I can just press command-R to download and run, or command-T to download and run with a terminal opened. It's nice and fast. The mod I did just interprets the %T as either -t or a space in the arguments, depending on which option you made. I think a better way would be to support two different run command strings, so people using other terminal programs or scripts could also make use of it instead of just for loadp2 which is what I am using (for now).

    I don't think all P2 applications will need the terminal. My video driver stuff certainly doesn't use it at this stage.
  • rogloh wrote: »
    ersmith wrote: »
    @rogloh : Thank you for your suggestions for gui.tcl. I hope to do a MacOS pass soon and I'll try to get at least the accelerators working. I'm still not completely convinced of the utility of run with/without terminal, but perhaps that could be made a checkbox option or something similar.

    Ok, the utility of this as I see it is that currently when you download a program to a P2 application without requiring the terminal you have to do one of two things..

    1) modify the run command line switch and get rid of the -t and or -k options to loadp2, and then remember to set it back when you open a project that does need the terminal. When you are flipping between different projects that do or don't use the terminal changing this accordingly each time can be annoying.

    2) Or, each time you download for testing, have a new window get opened and stay open until you click it and then press ^] and/or return to exit, each time you want to download and test a program out, then go back and click the flexgui window to continue editing/recompiling etc.
    Couldn't you just close the window if you don't want it? No need to press a ^] or return, just click on the close button and/or the hotkey for closing a window. Or does that not work on the Mac? On Windows and Linux I can ALT-F4 to close the window with focus, so to run without window I do ^R then either ^] or ALT-F4. Maybe window focus is messed up on Mac? On the other platforms the newly opened terminal window has focus.

    I can certainly see your point about workflow for projects that don't need a terminal window, but there are already so many options (such as just run, just compile, compile and run, compile and program flash, just program flash, ...) that I'm reluctant to add yet more of them to save one keystroke. But if the new window doesn't have focus then having to click on it is a pain, maybe we could figure out a way to change that.

    Fortunately the Tcl scripts are pretty easy to modify, as you've discovered, so you can treat src/gui.tcl as a giant config file. Maybe there should also be some way to run a user supplied Tcl script at startup, which you can keep in $HOME or somewhere where it won't be overwritten by updates.

    Thanks,
    Eric
Sign In or Register to comment.