Shop OBEX P1 Docs P2 Docs Learn Events
Welcome to the C/C++ code category! — Parallax Forums

Welcome to the C/C++ code category!

The category for all varieties of C/C++ used with the Parallax Propeller 1 and 2.
Supported by the Parallax community.

Comments

  • Ahle2Ahle2 Posts: 1,179
    edited 2021-12-10 11:00

    Finally a forum for C++! :smiley:

    I know that a lot of people (especially hobbyists) doesn't like C++ (it's understandable considered the vastness of it and sometimes the verbosity). Still it's THE choice for professional embedded development for a reason. I have said it many times before, but I say it yet again. The P2 NEEDS GCC or Clang, then a lot more companies will consider the P2 instead of ARMs, Atmels, PICs. etc for embedded systems. In my work life as an embedded programmer I rarely come across a job that isn't C, C++ or Rust in 2021 (or in 2012 for that matter, minus Rust). Python is fantastic and widely used in embedded projects for scripting, testing, building, tools etc, but for the actual code running on the processor in the end, it's mostly those mentioned above.

    The P2 is a fantastic microcontroller and deserves GCC or Clang badly! I want to nudge Parallax to give this a priority.
    Still, my feeling in the forums, is that quite a small percentage of people consider this a problem and for their own needs they are mostly happy with Basic, Spin, Pasm, Python, TAQOZ and the different "in house" C compilers (I love flexspin), and why shouldn't they? All of those are nice choices and everybody can choose what they like. I program the P2 in Spin2 a lot and like it, but if I would ever do a more complex project or a commercial project I would choose C++ (and Pasm for drivers).

  • There are a number of C++ compilers available for the P2, including a port of clang and at least two versions of GCC (riscvp2 and p2gcc). None of those have an IDE, but it should be straightforward to hook them up to Visual Studio Code. Catalina and flexspin do come with IDEs, but no C++ support (or rather, very minimal C++ support in flexspin's case).

    It would definitely be nice if Parallax officially supported one of the compilers, but they've made it pretty clear that they don't plan to do that. At this point it's up to the community. Catalina, flexspin, and riscvp2 are at least somewhat compatible on the P2 (thanks to the fairly standard propeller2.h header file).

  • Ahle2Ahle2 Posts: 1,179

    I always use VSC with GCC, flexspin, etc. anyway, so I'm not interested in a complete IDE. Even though the riscvp2 solution seems to be both fast and up to date, I don't consider it the way to go. We really need a native solution and as far as I understand the p2gcc is a good start but not nearly complete enough. I haven't heard about Clang on P2 anywhere, what's the status of that? Is it useful?

    Btw, both Catalina and flexspin are really great options when coding in pure C.

  • Here's the LLVM port: https://github.com/ne75/p2llvm
    I haven't checked on it in ages, but I noticed it has a bunch of new commits since the last build on my CI server, so I'm booting up the build agent again to get a recent build available.

  • @Ahle2 said:
    I always use VSC with GCC, flexspin, etc. anyway, so I'm not interested in a complete IDE. Even though the riscvp2 solution seems to be both fast and up to date, I don't consider it the way to go. We really need a native solution and as far as I understand the p2gcc is a good start but not nearly complete enough.

    The biggest problem with riscvp2 is the name. If I had called it "p2-cmm" or something like that, and not advertised the fact that the intermediate code is rv32im compatible, people would probably have used it quite happily. It does compile to native code, that just happens at run time instead of ahead of time.

  • @ersmith said:

    @Ahle2 said:
    I always use VSC with GCC, flexspin, etc. anyway, so I'm not interested in a complete IDE. Even though the riscvp2 solution seems to be both fast and up to date, I don't consider it the way to go. We really need a native solution and as far as I understand the p2gcc is a good start but not nearly complete enough.

    The biggest problem with riscvp2 is the name. If I had called it "p2-cmm" or something like that, and not advertised the fact that the intermediate code is rv32im compatible, people would probably have used it quite happily. It does compile to native code, that just happens at run time instead of ahead of time.

    I must admit I haven't used it yet. Wonder how the speed compares to Spin2 bytecode. Also, does it support overlays? (or rather, clearing the icache for the overlay region)

  • @Wuerfel_21 said:

    @ersmith said:

    The biggest problem with riscvp2 is the name. If I had called it "p2-cmm" or something like that, and not advertised the fact that the intermediate code is rv32im compatible, people would probably have used it quite happily. It does compile to native code, that just happens at run time instead of ahead of time.

    I must admit I haven't used it yet. Wonder how the speed compares to Spin2 bytecode. Also, does it support overlays? (or rather, clearing the icache for the overlay region)

    It's a compiler, not an interpreter, and the speed is pretty much comparable to other compilers like flexcc, p2gcc, and Catalina (so in quite a different league from Spin2). On small benchmarks like dhrystone riscvp2 was actually the fastest compiler I benchmarked. On a big program (micropython) p2gcc and riscvp2 kept switching 1st and 2nd place in speed as Roger and I added various optimizations.

    I'm not sure what you mean by "overlays"... from disk? Not exactly, although if you load code from disk and execute it the JIT compiler will translate it on the fly. The icache is managed automatically, with the most recently executed code kept in it and older code evicted when it fills up.

  • @ersmith said:

    @Wuerfel_21 said:

    @ersmith said:

    The biggest problem with riscvp2 is the name. If I had called it "p2-cmm" or something like that, and not advertised the fact that the intermediate code is rv32im compatible, people would probably have used it quite happily. It does compile to native code, that just happens at run time instead of ahead of time.

    I must admit I haven't used it yet. Wonder how the speed compares to Spin2 bytecode. Also, does it support overlays? (or rather, clearing the icache for the overlay region)

    It's a compiler, not an interpreter, and the speed is pretty much comparable to other compilers like flexcc, p2gcc, and Catalina (so in quite a different league from Spin2). On small benchmarks like dhrystone riscvp2 was actually the fastest compiler I benchmarked. On a big program (micropython) p2gcc and riscvp2 kept switching 1st and 2nd place in speed as Roger and I added various optimizations.

    I'm not sure what you mean by "overlays"... from disk? Not exactly, although if you load code from disk and execute it the JIT compiler will translate it on the fly. The icache is managed automatically, with the most recently executed code kept in it and older code evicted when it fills up.

    Yeah, but when the loaded code has been cached and is then overwritten by different code, that'd cause a problem, wouldn't it?

  • @Wuerfel_21 said:

    I'm not sure what you mean by "overlays"... from disk? Not exactly, although if you load code from disk and execute it the JIT compiler will translate it on the fly. The icache is managed automatically, with the most recently executed code kept in it and older code evicted when it fills up.

    Yeah, but when the loaded code has been cached and is then overwritten by different code, that'd cause a problem, wouldn't it?

    Ah, I see what you mean. The JIT compiler recognizes the RISC-V "fence.i" instruction to flush the icache, so you'll have to issue that before jumping to the new overlay. I would expect most overlay managers would do that already.

  • RossHRossH Posts: 5,454

    Catalina, flexspin, and riscvp2 are at least somewhat compatible on the P2 (thanks to the fairly standard propeller2.h header file).

    It might be worth revisiting the header file situation on the Propeller 1. Perhaps we could leave propeller.h as platform dependent but define a new common propeller1.h, analogous to what we did for propeller2.h

    Just a thought.

  • @RossH said:

    Catalina, flexspin, and riscvp2 are at least somewhat compatible on the P2 (thanks to the fairly standard propeller2.h header file).

    It might be worth revisiting the header file situation on the Propeller 1. Perhaps we could leave propeller.h as platform dependent but define a new common propeller1.h, analogous to what we did for propeller2.h

    Just a thought.

    Possibly, although propgcc (the most widely used C compiler, since it's included in SimpleIDE) is pretty moribund now, so changing anything in that seems difficult.

  • RossHRossH Posts: 5,454

    @ersmith said:

    @RossH said:

    Catalina, flexspin, and riscvp2 are at least somewhat compatible on the P2 (thanks to the fairly standard propeller2.h header file).

    It might be worth revisiting the header file situation on the Propeller 1. Perhaps we could leave propeller.h as platform dependent but define a new common propeller1.h, analogous to what we did for propeller2.h

    Just a thought.

    Possibly, although propgcc (the most widely used C compiler, since it's included in SimpleIDE) is pretty moribund now, so changing anything in that seems difficult.

    Indeed. It looks like it has not been modified since 2015 - https://code.google.com/archive/p/propgcc/ - there doesn't even seem to be a P2 version.

    Am I looking in the right place?

  • @RossH said:

    @ersmith said:

    @RossH said:

    Catalina, flexspin, and riscvp2 are at least somewhat compatible on the P2 (thanks to the fairly standard propeller2.h header file).

    It might be worth revisiting the header file situation on the Propeller 1. Perhaps we could leave propeller.h as platform dependent but define a new common propeller1.h, analogous to what we did for propeller2.h

    Just a thought.

    Possibly, although propgcc (the most widely used C compiler, since it's included in SimpleIDE) is pretty moribund now, so changing anything in that seems difficult.

    Indeed. It looks like it has not been modified since 2015 - https://code.google.com/archive/p/propgcc/ - there doesn't even seem to be a P2 version.

    Am I looking in the right place?

    https://github.com/parallaxinc/propgcc is the official repo, but it's not much newer (if at all). PropGCC was ported to the P2-hot, which was a completely different chip from the current P2. When that project collapsed the GCC port pretty much collapsed with it, IIRC.

  • @RossH said:

    @ersmith said:

    @RossH said:

    Catalina, flexspin, and riscvp2 are at least somewhat compatible on the P2 (thanks to the fairly standard propeller2.h header file).

    It might be worth revisiting the header file situation on the Propeller 1. Perhaps we could leave propeller.h as platform dependent but define a new common propeller1.h, analogous to what we did for propeller2.h

    Just a thought.

    Possibly, although propgcc (the most widely used C compiler, since it's included in SimpleIDE) is pretty moribund now, so changing anything in that seems difficult.

    Indeed. It looks like it has not been modified since 2015 - https://code.google.com/archive/p/propgcc/ - there doesn't even seem to be a P2 version.

    Am I looking in the right place?

    David Betz's repo has a few more changes than the official repo: https://github.com/dbetz/propeller-gcc
    According to the commit log, summer of 2016 was the last time it saw any substantial progress. There were rare updates from 2017-2019, but nothing since then.

  • @ersmith

    Howdy, we have conversed in the past. I am attempting to run FlexProp on a P1 at the moment. How do you set it to run on the P1. Do you have a possible set of instructions for "DUMMIES" to make the initial change over somewhat painless. I am having issues with SimpleIde and it was suggested that I try your IDE.
    How does one change between the two platforms with this Ide. Also since the project that I am working on is in Prop C++ where would I find libraries and how difficult is it to port over libraries. Lastly at this time I need to use the counters on the P1 for this project. Is there a library for the counters in this IDE.
    Thanks ahead of time for the help.
    Martin.
    BTW. I have seen you in the zoom meeting and I am impressed with your work. Cooooollllll stuff.
    Makes my day.
    Thanks again.
    Martin

  • ersmithersmith Posts: 6,038

    @pilot0315 This is probably not the best comment thread for discussion of FlexProp -- I'd suggest either asking a new question or using one of the existing FlexProp threads. But to briefly answer your questions:

    (1) To switch to the P1 go to the "Commands" menu, select "Configure commands...", and then click on either "P1 defaults" or "P1 bytecode defaults". Bytecode is smaller, but was designed for Spin so it may not support all features of C.

    (2) FlexProp doesn't come with any libraries, other than the subset of SimpleTools that Roy Eltham ported a while ago. On the other hand with FlexProp you can use most OBEX objects from either C or Spin.

    Regards,
    Eric

  • pilot0315pilot0315 Posts: 907
    edited 2024-07-25 02:49

    @ersmith
    Thanks for the help. You are right this thread probably is not the best for this question but I am going to look at your explanation and check it out.
    Thanks for the help. I am having issues with the propeller tool with all kinds of problems. Looks like it is no longer supported and it is acting weird.
    Appreciate your patience. Since as you indicated FlexProp was designed for Spin I hope it can fix my issues.
    Martin

    And one last stupid quesition where is the serial terminal?
    Never mind I found it. Dumb me. But that is how we learn.

Sign In or Register to comment.