Arduino IDE with its libraries for P2?

Christof Eb.Christof Eb. Posts: 320
edited 2019-08-14 - 06:49:38 in Propeller 2
Hi,
after just following the forums for many months, I am very impressed to read that there will be a real P2 nearby. Congratulations!
As do many others I use the Arduino environment to program controllers. Starting from arduino nano to Teensy or esp32 or Linkit Smart Duo. So I don t have to learn a new Environment for another mc and I can reuse my own code. The best of all are the libraries. I have been able to achieve the success of projects mainly by reusing the code of others, which I could not have been able at all without the libraries. I am not saying, that arduino is the best environment. No, it is not, but it gives me really great benefit.
So, when will there be Arduino for P2?
Regards Christof

Comments

  • DavidZemonDavidZemon Posts: 2,818
    edited 2019-08-12 - 13:24:30
    Impossible. It can never happen.

    There we go, should be any day now :smiley:


    There are a few different ways to go about it and a few different questions that you actually mean to ask.

    Firstly, as you alluded to, the editing environment (the Arduino IDE) is a whole separate entity from the Arduino libraries that come with the IDE. I do not expect anyone will create a fork of the Arduino IDE to use a P2-compatible build system any time soon. I've not seen any interest for it here (and, IMO, rightfully so since its text editor is missing very basic features).

    Second is the libraries. Someone tried to port all (some?) of the Arduino libraries to Propeller 1 many years ago. The original repo is lost, but Martin saved the code in his own GitHub repository here: https://github.com/Martin-H1/libArduino
    You may be able to combine that with p2gcc (https://github.com/davehein/p2gcc) to get the Arduino libraries working on P2 today.

    Or maybe use the RISC-V compiler along with @ersmith's black magic instead of p2gcc.

    Or you could wait anywhere from <a very long time> to indefinitely for someone to make a port of GCC or LLVM that directly produces P2 code. There are countless threads about it at this point, all of them ending with "we're waiting on Parallax and no one has heard from Parallax on the matter since end of 2018."

    ALL of these solutions will require you writing your own build system to compile the libraries and your code, and you'll be on your own to find a suitable text editor.

    So, when will there be Arduino for P2? Today? Tomorrow? In a few months? Never? All seem like perfectly valid answers.
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
    CI Server: https://ci.zemon.name?guest=1
  • So, when will there be Arduino for P2?
    Once a good C++ compiler toolchain compatible with arduino source files and suitable libraries are available for P2.

    There is some useful information here if someone wants to make a start...I had sort of assumed a gcc dependency but apparently this may not be the case.

    https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification
  • Thanks for the answers!
    I think, Parallax have to steer here, if they want to. Perhaps have to invest. It will make it more easy for people who are already using (the non-perfect (you can use a different editor)) Arduino to switch to P2.
    Last year I had to decide the platform to do a project. In this case the decision was based on the availability of libraries. Arduino has a lot to offer here really! The hardware of P1 could have done it too, but the software would have cost me at least 3 rare weekends more and I am not sure, if I would have got it working.
    My bigger project this year was decided 70% by libraries, 30% by hardware. Neither was speaking for P1.

    Well, I never fell in love with SPIN. This only makes sense, if you are willing to do assembler for fast parts of your code. With the high amount of memory available now, I see the benefit of compact bytecode even less.
    Having no floating-point math is not a strength.

    So I think, that it would be advisable to focus efforts in one direction to get as much libraries as possible working quickly. If products from for example adafruit and their libraries can be used it is win-win!

  • Hi Christof,

    Why do you need the Arduino IDE? You should invest your time learning C/C++. It is far more flexible and functional. Also, Parallax investing in a Arduino like IDE could potentially twart more meaningful projects, like the C/C++ toolchain.

    Plus, there are many people here requiring C and C++ development. Except for you, and to my knowledge, nobody requires an Arduino like IDE.

    Arduino is too easy, but not flexible enough for out-of-the-box or mpre complex projects.

    Kind regards, Samuel Lourenço
  • I Gotta agree with Christof. Not that the Arduino IDE is better than the tools for the P2, not so. However... there are millions of kids out there who are comfortable with the Arduino in all its guises simply BECAUSE of it's limitations. Most of those users will never veer away from the environment and processors they already know.

    I doubt that anyone would ever take the time to generate a compatible set of tools that would take advantage of more than 40% of the P2's capability... but even that 40% could fill some substantial gaps in the Arduino processor lineup and introduce a HUGE number of future users to the power of the Propeller family. It could also spark many of them to learn some of that other 60%. Once a few of the kids started bragging about the magic things they did with the "extras" there would be lots of others wanting to know HOW.
  • The Arduino IDE uses a C++ compiler behind the scenes, so this isn't an "either/or"; what Christof is asking for starts with a C++ compiler and then goes on to Arduino compatible libraries.

    A sufficiently motivated programmer could probably use the riscvp2 toolchain (which does support C++) to implement Arduino libraries on P2 now.
    FlexGUI, a GUI for programming the P1 and P2 in Spin, PASM, BASIC, and C.
    Help support its development at Patreon or PayPal.
  • Samuel,
    Arduino is c/c++. It uses gcc.
    Limits? Just try it with Teensy3.6 or Teensy4.0 now.
  • I'm getting confused about what is "Arduino". I thought it was a hardware platform that could accept standardized shields. If that's so then Teensy isn't Arduino. Or is Arduino anything that can be programmed with the Arduino IDE?
  • Sorry, I was referring to the arduino ide, which gives a somewhat simplified access to gcc for various Controllers and has a really huge number of libraries. These are given as source files together with examples. Many of them are portable.
    In my opinion the strength lies in these libraries and in the possibility to just use your known tool and your old own code.
  • David Betz wrote: »
    I'm getting confused about what is "Arduino". I thought it was a hardware platform that could accept standardized shields. If that's so then Teensy isn't Arduino. Or is Arduino anything that can be programmed with the Arduino IDE?

    All of the above.

    "I have an Arduino" means I have a physical board made by Arduino.

    "I like to use Arduino for that" probably means that they use the Arduino IDE (and therefore Arduino build system, Arduino libraries, and Arduino-supplied GCC port), but could simply mean that they're using libArduino, a set of C++ libraries aimed at Arduino-like boards.

    It's all very vague since "Arduino" started out as a complete ecosystem. Just like SimpleIDE.... how many times have we all seen people asking for help with "SimpleIDE" when they're really asking about help with a PropGCC error, or even a basic C/C++ syntax question?
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
    CI Server: https://ci.zemon.name?guest=1
  • Hi, I have now altered the titel of the thread. Great, that this is possible.
    I have had a look at the Obex. It is impressive, but still the most drivers are for spin.
    So let me ask my question the other way round.

    If you don't switch to Arduino IDE, what is the plan to quickly catch up regarding libraries?
    And what is the plan to make it easy for makers to switch from xx to P2?
  • I have used Arduino for many years to program STM32, ESP8266, and ESP32. Arduino's environment is a little different in that they predefine pins to have specific functions and the libraries are built to that idea.

    They also have startup code section and a loop section to handle multitasking.

    On the Propeller this is not the case as any pin can be used. It also has multiple processors so it doesn't really fit the loop structure of the Arduino environment.

    When I need to interface to a new device I tend to either port the code from the Arduino libraries or write them from scratch as they don't make use of the Propeller environment.

    I don't see how the P1 would work in the Arduino environment but maybe the P2 would fit better since it now supports ADC and DAC.

    I don't like the Arduino environment for programming and I have already converted most of the devices I use with the P1.

    Mike
  • The pin mapping are a valid point - the P2 certainly doesn't force you into any specific pin selection.

    But, saying that the Prop doesn't fit into the Arduino's "setup()" and "loop()" functions doesn't make sense to me. Those are just two functions, invoked from a file that looks like
    void main () {
    Setup();
    while(1) {
      loop();
    }
    

    Nearly every embedded C/C++ program in the world, including those written for the Propeller, fit into this pattern just fine. If you need to start multiple cores/cogs, you would trigger them from the Setup() function. Whatever you want your initial cog/core to do, you do it in the loop() function.
    So let me ask my question the other way round.

    If you don't switch to Arduino IDE, what is the plan to quickly catch up regarding libraries?
    And what is the plan to make it easy for makers to switch from xx to P2?

    Short answer: there is no plan. That might seem crazy to you (you wouldn't be the only one) but it's the truth as far as anyone outside of Parallax can see at the moment.
    But we can throw out some ideas for plans right now, if you'd like?

    Plan 1: Use libArduino with RISC-V
    Plan 2: Use libArduino with p2gcc
    Plan 3: Use libArduino with GCC after porting GCC for P2
    Plan 4: Use libArduino with LLVM after porting LLVM for P2
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
    CI Server: https://ci.zemon.name?guest=1
Sign In or Register to comment.