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

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

1282931333455

Comments

  • pilot0315pilot0315 Posts: 863
    edited 2022-02-17 16:13

    @iseries

    Migrating everything I have written to the P2.
    I am attempting to get all of my modules ( compass, gps and others) to work on the P2. Have been out of the loop for over a year and a half. Some code is
    in C others in Spin. Also having to contend with the changes in Spin with the Proptool 2.6.2 by adding the () everywhere.
    Flexprop appears not to have a version of fdserial. Or am I missing something?
    Thanks for sending the code. Very similar to mine.
    Thanks
    Martin

  • @pilot0315 ,

    Correct, no fdserial. With smartpin one is not needed. Very easy to write serial drivers.

    Mike

  • @pilot0315 said:
    @ersmith
    @anybody

    I have been searching for the equivalent of this in FlexProp to use in C:

    include "fdserial.h"

    Any ideas?

    Unfortunately that part of the simpletools library hasn't been ported to the P2 & FlexC yet. You can use any Spin2 object in a C program though, for example the spin/SimpleSerial.spin2 file, or JonnyMac's jm_serial.spin2.

    I'm sorry I don't have an answer for you about the problems you've been having launching programs from FlexProp. There's some kind of Windows bug that only shows up on some systems; probably it's timing related, but I haven't been able to find it yet.

  • @iseries

    Do you have an example?

  • @ersmith

    Thanks for the help. I will try your suggestions.
    May ask a couple of questions if needed.

  • @pilot0315 ,

    Everything you need should be here: P2Custom Libraries

    Mike

  • pik33pik33 Posts: 2,358
    edited 2022-02-17 19:35

    launching programs from FlexProp.

    I still have problems with it with all 3 systems I use. 2 Linux PCs and a Raspberry Pi. While I managed to load and flash programs using different baud rates, this was not stable and very annoying. I decided to return to loadp2, which works stable, until proploader can work stable for me. The only problem left in this configuration is: closing the internal terminal window resets the Propeller

    The symptoms were:

    • to upload the program, but don't flash, I had to use 921600. This worked at about 90% reliability.
    • to flash the program, I had to use 2 Mbps. The proploader cannot flash at all using 921600. At 2 Mbps it was not 100% reliable but with good chance of success
    • uploading programs without flashing at 2 Mbps was very slow and in most cases failed.
    • at any baud rate I got garbage instead of debug information on the terminal if using debug. The external terminal worked beter for debug

    No such symptoms occur using loadp2. It can load and flash and debug at 2 Mbps and does it fast.

    So.. I will try proploader every time a new version will be available and, if problems still persist, there is always loadp2 to return to.

  • @iseries

    I will check that out.
    Thanks
    Martin

  • Just tried the latest loadp2 from Eric and it was able to load my program 20 out of 20 times with no issues. Seems to work much better than the previous versions I have tried. I really don't use that loader anymore since I wrote my own because of the failures and wanting to load over Wifi.

    I also had a hard time getting the new loader to work though. The Proploader code which is an all-inclusive baby only would work for small programs.
    I tried a number of different combinations to get it to work and finally found one.

    proploader.exe -k -2 -t -r -q -p com10 -D baud-rate=230400 -D loader-baud-rate=2000000 '${fileDirname}\\build\\${fileBasenameNoExtension}.elf'
    

    I use Visual Studio Code for all my development and had to find the correct options to make it work with that tool. Since I'm working with P2LLVM which generates elf file I wanted to see how it held up.

    If I change the download speed it seems to timeout before the terminal connects and I get no output. So, loading time seems to be an issue.

    But it seems to always say download compete even if the program does not run. No download failures that I found.

    Have not tried the Wifi option yet.

    Mike

  • I’m kind of dead in the water here… and have confused myself rather nicely while chasing loader issues. Would someone be kind enough to post the DIP switch settings that are known to work for a P2-EVAL rev C with the lastest version of Flex?

  • roglohrogloh Posts: 5,281
    edited 2022-02-19 00:15

    @iseries said:
    Just tried the latest loadp2 from Eric and it was able to load my program 20 out of 20 times with no issues. Seems to work much better than the previous versions I have tried. I really don't use that loader anymore since I wrote my own because of the failures and wanting to load over Wifi.

    Am glad to hear loadp2 is stable. I spent some time a while back getting the serial connection timeouts working better with this code and that has probably made it into the later versions by now. It is tricky to get the timeouts right as you needed to factor in total pipeline length involving external USB device hardware FIFO lengths etc, and not make it too short. Adding WIFI to the programming path probably introduces even more (semi-random) delays which could make things worse, so I'm not surprised you have some issues with proploader.
    EDIT: ok, just read that you don't use the Wifi option, you are probably just seeing USB serial timeouts then (like we had on loadp2 a while back).

  • Hi @ersmith
    We are trying to build a 3rd party sensor library on the P2 and ran into problems with flexspin ... should your compiler allow bitfields with this syntax?

    union Block_header {
        uint32_t bytes;
        struct {
            uint32_t type : 4;
            uint32_t size : 12;
            uint32_t idx : 16;
        };
    };
    

    I ran into issues compiling it, with the driver code referencing these bit fields and wonder if it is because it is inside a union. A workaround may be to eliminate the union and use structs instead, as that seemed to at least compile without issues. It might also be due to running an older version of your compiler, if you have since fixed this problem. I've not updated in a while.

    /Users/roger/Documents/Code/vltest/vl53l5cx_api.c:557: error: unknown identifier type in class _struct__Block_header
    /Users/roger/Documents/Code/vltest/vl53l5cx_api.c:557: error: type is not a member of _struct__Block_header
    /Users/roger/Documents/Code/vltest/vl53l5cx_api.c:558: error: unknown identifier type in class _struct__Block_header
    /Users/roger/Documents/Code/vltest/vl53l5cx_api.c:558: error: type is not a member of _struct__Block_header
    /Users/roger/Documents/Code/vltest/vl53l5cx_api.c:560: error: unknown identifier idx in class _struct__Block_header
    /Users/roger/Documents/Code/vltest/vl53l5cx_api.c:560: error: idx is not a member of _struct__Block_header
    /Users/roger/Documents/Code/vltest/vl53l5cx_api.c:561: error: unknown identifier idx in class _struct__Block_header

    Sample access code that was generating the above was stuff like this:

            bh_ptr = (struct Block_header *)&(output[i]);
            if (((uint8_t)bh_ptr->type >= (uint8_t)0x1)
                        && ((uint8_t)bh_ptr->type < (uint8_t)0x0d))
            {
    
  • roglohrogloh Posts: 5,281
    edited 2022-02-21 05:51

    Ok, so I just found this note in the Parallax Web page linking to FlexC that lists some limitations while I was getting the link to the latest FlexC version to download. Seems like the "No anonymous structs and unions" one is likely to be the reason for this issue, if it is indeed the case today that this limitation still applies, because our bit field struct accesses are anonymous.

    The current version of FlexC has some limitations with respect to C99

    • No support for 64 bit arithmetic (long long is not support, and double is treated the same as float)
    • No variable length arrays
    • No anonymous structs and unions
    • Limits on designated initializers
    • Incomplete standard library"
  • @JRoark said:
    I’m kind of dead in the water here… and have confused myself rather nicely while chasing loader issues. Would someone be kind enough to post the DIP switch settings that are known to work for a P2-EVAL rev C with the lastest version of Flex?

    I don't have a rev C, but for my rev B and eval boards I use:

    LED: ON
    Flash: ON
    Pull-Up: OFF
    Pull-Down: OFF

    I think turning Flash ON and everything else OFF should work too.

  • @rogloh said:
    Ok, so I just found this note in the Parallax Web page linking to FlexC that lists some limitations while I was getting the link to the latest FlexC version to download. Seems like the "No anonymous structs and unions" one is likely to be the reason for this issue, if it is indeed the case today that this limitation still applies, because our bit field struct accesses are anonymous.

    Yes, that is the problem (that limitation still exists). Giving the bitfield struct a name like "s" and changing the accesses to things like "bh_ptr->s.type" should help.

  • I find using the WiFi setup is very erratic and inconsistent. I tried the dip settings that Eric recommends, most of the time it does not work correctly. This is getting to be very frustrating.

    When not using the WiFi setup everything seems to work as expected, but that limits the things that I want to do.

    Ray

  • @ersmith
    Hi Eric. I am havving an issue with flexpropp 5.9.8.
    When I cold start my computer using Linux Mint 20 with all current updates I have the following Issues:
    cd flexprop
    ,/flexprop
    version 5.9.8 loads, to compile and run a progam, takes 17 seconds. Serial output from P2 unformated gibberish.
    cd flexprop1 ' this folder contains version 5.9.2.
    ./flexprop
    version 5.9.2 loads, compile and run the same program 2.5 seconds. Serial output from P2 formated output as expected using command ser.position(0,5).
    cd flexprop 'back to 5.9.8
    ./flexprop
    compile and run same code as before, load time 2.5 seconds, now it outputs the correct data but command ser.position(0,5) is ignored and no formatting is happening.
    Can you look into this. If Necessary I can send you the code.
    Jim

  • @Rsadeika said:
    I find using the WiFi setup is very erratic and inconsistent. I tried the dip settings that Eric recommends, most of the time it does not work correctly. This is getting to be very frustrating.

    When not using the WiFi setup everything seems to work as expected, but that limits the things that I want to do.

    I'm sorry, but that's not enough information for me to be able to diagnose anything. At a minimum I'd need to know what operating system you're using, which version of FlexProp, and how things are failing.

    It really sounds like the WiFi support is a failed experiment, and my best course of action is to remove it from FlexProp and go back to serial only.

  • @RS_Jim said:
    @ersmith
    Hi Eric. I am havving an issue with flexpropp 5.9.8.
    When I cold start my computer using Linux Mint 20 with all current updates I have the following Issues:
    cd flexprop
    ,/flexprop
    version 5.9.8 loads, to compile and run a progam, takes 17 seconds. Serial output from P2 unformated gibberish.
    cd flexprop1 ' this folder contains version 5.9.2.
    ./flexprop
    version 5.9.2 loads, compile and run the same program 2.5 seconds. Serial output from P2 formated output as expected using command ser.position(0,5).
    cd flexprop 'back to 5.9.8
    ./flexprop
    compile and run same code as before, load time 2.5 seconds, now it outputs the correct data but command ser.position(0,5) is ignored and no formatting is happening.
    Can you look into this. If Necessary I can send you the code.
    Jim

    Jim, have you tried the most recent flexprop (5.9.9-beta)? If you're building it yourself on Linux that'll be the version you get from github now.

  • dgatelydgately Posts: 1,628
    edited 2022-02-22 18:33

    @ersmith said:

    @Rsadeika said:
    I find using the WiFi setup is very erratic and inconsistent. I tried the dip settings that Eric recommends, most of the time it does not work correctly. This is getting to be very frustrating.

    When not using the WiFi setup everything seems to work as expected, but that limits the things that I want to do.

    I'm sorry, but that's not enough information for me to be able to diagnose anything. At a minimum I'd need to know what operating system you're using, which version of FlexProp, and how things are failing.

    It really sounds like the WiFi support is a failed experiment, and my best course of action is to remove it from FlexProp and go back to serial only.

    Arg! Don't give up so soon :* The only PropLoader issue I'm seeing is loading to Flash (wired or WiFi). This is with P2 Edge Rev C, Mini Breakout, Parallax WiFi Module (latest firmware 1.4 (2021-06-07 16:02:10 1-g8af598a)), on macOS ver 12.2.1 & Raspberry Pi4 Raspbian GNU/Linux 11 (bullseye). I'm quite able to load to RAM & run programs with PropLoader wired or WiFi. Since loadp2 was able to load to Flash, can PropLoader mirror what loadp2 was doing? I'm sure WiFi loading to Flash will add to the difficulty, but should be worth trying.

  • I have to agree with dgately, do not remove what you have so far. What exits is better than nothing at all, will find a way to work around what is working now. So far you have provided some very good code, keep up the good work.

    In my old age I get frustrated very easily, I will start minimizing my complaints in my threads and posts.

    Ray

  • RS_JimRS_Jim Posts: 1,762
    edited 2022-02-23 00:24

    eric here is a copy of what I got when I ran the install for the latest flexprop
    '''make: [Makefile:191: spin2cpp/doc/spin.pdf] Error 43 (ignored)
    mkdir -p flexprop/bin
    mkdir -p flexprop/doc
    mkdir -p flexprop/board
    cp -r README.md License.txt samples src flexprop
    cp -r spin2cpp/Flexspin.pdf spin2cpp/doc/general.pdf spin2cpp/doc/basic.pdf spin2cpp/doc/c.pdf spin2cpp/doc/spin.pdf flexprop/doc
    cp: cannot stat 'spin2cpp/Flexspin.pdf': No such file or directory
    cp: cannot stat 'spin2cpp/doc/general.pdf': No such file or directory
    cp: cannot stat 'spin2cpp/doc/basic.pdf': No such file or directory
    cp: cannot stat 'spin2cpp/doc/c.pdf': No such file or directory
    cp: cannot stat 'spin2cpp/doc/spin.pdf': No such file or directory
    make: [Makefile:171: flexprop_base] Error 1 (ignored)
    cp -r spin2cpp/Flexspin.html spin2cpp/doc/general.html spin2cpp/doc/basic.html spin2cpp/doc/c.html spin2cpp/doc/spin.html flexprop/doc
    cp -r spin2cpp/doc/* flexprop/doc
    cp -r spin2cpp/Changelog.txt flexprop/doc/Changelog-compiler.txt
    cp -r Changelog.txt flexprop/doc/Changelog-gui.txt
    cp -r loadp2/README.md flexprop/doc/loadp2.md
    cp -r loadp2/LICENSE flexprop/doc/loadp2.LICENSE.txt
    cp -r spin2cpp/COPYING.LIB flexprop/doc/COPYING.LIB
    cp -r spin2cpp/include flexprop/
    cp -r doc/.txt flexprop/doc
    cp -r board/
    flexprop/board
    cc -o flexprop.bin src/flexprop_native.c -I/usr/include/tcl8.6 -ltk8.6 -ltcl8.6 -lfontconfig -lXft -lXss -lXext -lX11 -lz -ldl -lpthread -lm
    make -C loadp2 P2ASM="pwd/bin/flexspin -2 -Ipwd/spin2cpp/include"
    make[1]: Entering directory '/home/jim/flexprop/loadp2'
    make[1]: Nothing to be done for 'default'.
    make[1]: Leaving directory '/home/jim/flexprop/loadp2'
    make -C PropLoader OS=linux SPINCMP="pwd/bin/flexspin"
    make[1]: Entering directory '/home/jim/flexprop/PropLoader'
    VERSION v1.9-13 (2022-02-22 16:43:26 gd9d58d4)
    make[1]: Nothing to be done for 'all'.
    make[1]: Leaving directory '/home/jim/flexprop/PropLoader'
    mkdir -p ~flexprop
    mkdir -p flexprop/bin
    cp -r bin/flexspin bin/flexcc bin/loadp2 bin/proploader flexprop/bin
    cp -r mac_scripts/* flexprop/bin
    cp -r flexprop/* ~flexprop
    cp -rp flexprop.bin ~flexprop/flexprop
    cp -rp tcl_library ~flexprop/
    jim@jim-HP-Pavilion-g6-Notebook-PC:~/flexprop$ ./flexprop
    bash: ./flexprop: Is a directory
    jim@jim-HP-Pavilion-g6-Notebook-PC:~/flexprop$
    '''
    where do we go from here?
    Jim
    EDIT: Eric, I can get flexprop to run by entering flexprop.bin otherwise it says flexprop is a directory.

  • One of the things I didn't like about flexprop was that it put the compiled programs in the same directory as the source code. This led to clutter that I had to take care of later.

    So, I was thinking again, and I thought I have the source code I could just change the program to output the files into a build folder just like I want. Well, after looking at the source code I came across this line of code:

    fprintf(f, "  [ -o <name> ]      set output filename to <name>\n");
    

    What? you mean that function was there all along and I just haven't been using it? That's right you got to read the documentation.

    flexspin.exe -2 -O1 -I D:/flexprop/include -I D:/Custom -o P2\build\libbase64.binary P2\libbase64.c
    

    This puts the libbase64.binary and libbase64.p2asm in the build folder instead of with my source.

    MIke

  • @RS_Jim said:
    ...
    mkdir -p ~flexprop
    mkdir -p flexprop/bin
    cp -r bin/flexspin bin/flexcc bin/loadp2 bin/proploader flexprop/bin
    cp -r mac_scripts/* flexprop/bin
    cp -r flexprop/* ~flexprop
    cp -rp flexprop.bin ~flexprop/flexprop
    cp -rp tcl_library ~flexprop/
    jim@jim-HP-Pavilion-g6-Notebook-PC:~/flexprop$ ./flexprop
    bash: ./flexprop: Is a directory
    jim@jim-HP-Pavilion-g6-Notebook-PC:~/flexprop$
    '''
    where do we go from here?

    do a 'ls -al' in the ~/flexprop folder and check permissions of flexprop

  • @Rsadeika , @dgately : I'm not proposing removing the WiFi support because of complaints, but rather because it (a) does not work reliably for some people (and I cannot figure out why), and (b) even worse makes serial not work for some people (and again, I cannot figure out why). The old loadp2 program didn't support WiFi, but at least it worked :(.

  • @RS_Jim : The installation directory must be different from the source directory. That probably isn't emphasized enough in the readme, although the instructions do show creating a "src" directory to contain the flexprop source code. I'd suggest deleting everything and starting again, this time making sure to do the mkdir -p src and cd src steps in the Linux build instructions.

  • @ersmith
    Eric,
    I found the problem. I had an extra flexprop dir in /flexprop, thats why I had the error. I deleted the extra directory renamed flexprop.bin to flexprop and all is well. I ended up with the extra dirs because I had an error occur in the makefile and when I ran it the second time, it created directories inside of directories.
    The issue I was having with the loader was solved with the latest. Questions? when running flexprop is there anyway to tell what version is running? Second question, is there anyway to get formatting (like serial position) into the terminal?
    Thanks for all you do!
    Jim

  • hinvhinv Posts: 1,253

    @ersmith Excellent overview/tutorial on FlexProp! I see you are going for full spectrum dominance in the propeller development department.
    Ever thought about adding Android to the platform list? Androwish is very functional, and probably has all of the features FlexProp would need on the front end. As for the back end compilers those could be farmed off to the internet or to a local http server just by putting a wrapper around the compiler backends and forwarding the needed files to the http server and getting, have the http server compile and send back the binaries or errors. Since you are already doing some of the debug stuff in tcl/tk, this could open up a lot of possibilities for the classroom. All the teacher would need to provide is a raspberry pi or linux machine acting as a hotspot and compiler webserver. Then the students could edit their code on the go, and give us all cheap debug screens, especially since there is a huge crop of obsolete phones because of the push for Voice over LTE! I am thinking that this would make Gavin's(I would ping him for his opinion if I knew what his forum username was) and other teachers lives a lot simpler if done right.

    Keep up the good work!

    I would also like to make a contribution to your cause, but I don't do patreon, and I'm usually broke on the dollar side of things. Got a Bitcoin Cash address?

  • iseriesiseries Posts: 1,475
    edited 2022-02-24 12:24

    I'm trying to debug your code to see why the downloads are not working on windows system.

    It seems the issue is that the program is loading but not starting but returning that the load was good.
    Terminal Error
    The download complete is right after the fastloader or regular loader. Don't know which one is being used.

    Mike

    I looked over your code and it looks like mine except for two things. I don't remove the equals at the end and I don't send after tilde.

  • hinvhinv Posts: 1,253

    Been playing with FlexProp on a Raspi2b with a P1and the fibo.bas works but puts several empty boxes like there is a font problem. This makes me wonder what those outputs actually getting over the serial line. The Runtime Character Set to Parallax OEM, but it doesn't produce non-ascii characters, just boxes.. I'm using the "Internal Ascii terminal"
    Anybody run into this?

    Thanks,
    hinv
    P.S. I would love to have a Petscii terminal.

Sign In or Register to comment.