[FYI] PropWare: Complete build system and library for PropGCC

1235»

Comments

  • Sounds very nice, David! The use of the << operator to replace printf is a slick solution to the code bloat problem.
  • I've taken a brief break from PWEdit and created a new peripheral for the MCP2515 CAN bus controller. Here's an example of using it in loopback mode to send three messages and filter such that only two of them are received:

    Verbose/commented version on GitHub here.
    #include <PropWare/PropWare.h>
    #include <PropWare/hmi/output/printer.h>
    #include <PropWare/serial/can/mcp2515.h>
    
    using namespace PropWare;
    
    const Port::Mask MOSI         = Port::P0;
    const Port::Mask MISO         = Port::P1;
    const Port::Mask SCLK         = Port::P2;
    const Port::Mask CS           = Port::P7;
    const Port::Mask CLOCK_MASK   = Port::P8;
    
    const uint8_t messages[][6] = {
            "Hello",
            "David",
            "Katie"
    };
    
    void read (MCP2515 &can, const MCP2515::BufferNumber bufferNumber) {
        if (can.check_receive_buffer(bufferNumber)) {
            uint8_t buffer[MCP2515::MAX_DATA_BYTES];
            uint8_t bytesRead;
            can.read_message(bufferNumber, &bytesRead, buffer);
            pwOut << "Message: `" << (const char *) buffer << "`\n";
        } else {
            pwOut << "No message\n";
        }
    }
    
    int main () {
        const SPI spi(MOSI, MISO, SCLK);
        MCP2515   can(spi, CS);
    
        const Pin clock(CLOCK_MASK, Pin::OUT);
        clock.start_hardware_pwm(8000000);
    
        can.start(MCP2515::BAUD_1000KBPS, MCP2515::LOOPBACK);
    
        can.set_mask(MCP2515::BUFFER_0, WORD_0);
        can.set_filter(MCP2515::FILTER_0, 2);
    
        pwOut << "Expected message received:\n";
        can.send_message(2, 6, messages[0]);
        read(can, MCP2515::BUFFER_0);
    
        pwOut << "Message should _not_ be received!\n";
        can.send_message(3, 6, messages[1]);
        read(can, MCP2515::BUFFER_0);
    
        pwOut << "Expected message received:\n";
        can.send_message(2, 6, messages[2]);
        read(can, MCP2515::BUFFER_0);
    }
    
    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
  • Hi howdy, I can't get AUTO_OPTIMIZATION to turn off.

    My CMakeLists.txt:
    cmake_minimum_required(VERSION 3.3)
    find_package(PropWare REQUIRED)
    
    set(BOARD ROBOPI)
    
    project(roombaPropNew CXX)
    
    set(MODEL cmm)
    
    set(AUTO_OPTIMIZATION OFF)
    
    set(COMMON_FLAGS -O1)
    
    create_simple_executable(${PROJECT_NAME}
            NeuralNet.cpp
            NeuralNet.h
            roomba_network.cpp)
    
    set(CMAKE_VERBOSE_MAKEFILE ON)
    

    The relevant parts of the verbose make output (-O1 chosen at random for purposes of this test);
    ...
    [ 33%] Building CXX object CMakeFiles/roombaPropNew.dir/NeuralNet.cpp.obj
    /opt/parallax/bin/propeller-elf-gcc    -save-temps -O1 -Os -m32bit-doubles -Wall -ffunction-sections -fdata-sections     -std=gnu++0x -mcmm -I/usr/PropWare/include    -o CMakeFiles/roombaPropNew.dir/NeuralNet.cpp.obj -c /home/grant/workspace/robogarnt/Roomba/roombaPropNew/NeuralNet.cpp
    [ 66%] Building CXX object CMakeFiles/roombaPropNew.dir/roomba_network.cpp.obj
    /opt/parallax/bin/propeller-elf-gcc    -save-temps -O1 -Os -m32bit-doubles -Wall -ffunction-sections -fdata-sections     -std=gnu++0x -mcmm -I/usr/PropWare/include    -o CMakeFiles/roombaPropNew.dir/roomba_network.cpp.obj -c 
    ...
    /opt/parallax/bin/propeller-elf-gcc   -save-temps -O1 -Os -m32bit-doubles -Wall -ffunction-sections -fdata-sections     -std=gnu++0x -mcmm   -Wl,--gc-sections CMakeFiles/roombaPropNew.dir/NeuralNet.cpp.obj CMakeFiles/roombaPropNew.dir/roomba_network.cpp.obj  -o roombaPropNew  /usr/PropWare/lib/cmm/libPropWare.a /usr/PropWare/lib/cmm/libLibpropeller.a /usr/PropWare/lib/cmm/libSimple.a 
    ...
    }
    

    As you can see, -Os is still hanging around. Changing the model worked, turning off 32 bit doubles worked in another test. I'm using CLion, if it makes any difference. This could very, very easily be user error on my part. :)
  • Thank you for reporting this! Turns out it's a typo on my end. There's a few ways to fix this:

    1) Change your code to use the incorrectly spelled version: "AUTO_OTPIMIZATION"
    2) Change the file "FindPropWare.cmake" in the PropWare installation directory and change "AUTO_OTPIMIZATION" to "AUTO_OPTIMIZATION"
    3) Download either an updated 3.x pre-release or version 2.1.1, both of which I will release tomorrow evening after fixing the typo
    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
  • Glad to help; thanks for making the tool. Being able to use CLion is a godsend
  • Both releases have been pushed and links are updated on both PropWare sites (master and develop).
    scandoslav wrote: »
    I'm using CLion, if it makes any difference.
    Thrilled to see another CLion user! It is truly fantastic isn't it? I'm really looking forward to 2016.2 which they say might finally come with remote-debugging capability! That's one big step closer to working with more embedded systems!

    Just curious, what OS are you running?

    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
  • DavidZemon wrote: »
    Both releases have been pushed and links are updated on both PropWare sites (master and develop).
    scandoslav wrote: »
    I'm using CLion, if it makes any difference.
    Thrilled to see another CLion user! It is truly fantastic isn't it? I'm really looking forward to 2016.2 which they say might finally come with remote-debugging capability! That's one big step closer to working with more embedded systems!

    Just curious, what OS are you running?

    I've only had it for a day or so, but so far it's just as easy and intuitive as the other JetBrains stuff I've used. Sure beats trying to cargo-cult-cobble together a build system for (the also excellent) Sublime Text. :)

    I'm running Ubuntu 14.04.
  • scandoslavscandoslav Posts: 11
    edited July 2016 Vote Up0Vote Down
    Ping_Demo.cpp doesn't work as posted. CLion says it "Cannot find ping.h" when I include <PropWare/Ping.h>, and that it "Can't resolve type 'Ping'" when I tried including "ping.h" instead.


    Not worth noting: some errors rate "Cannot", while others get "Can't". Subtle artistry, IDE.
  • DavidZemonDavidZemon Posts: 2,224
    edited July 2016 Vote Up0Vote Down
    @scandoslav,

    What version of PropWare are you running? The version is specified in <PropWare installation>/version.txt
    david@balrogJr:~$ cat /usr/PropWare/version.txt 
    2.1.1david@balrogJr:~$
    

    It's possible you have PropWare 3.x installed but are referencing 2.x documentation. If that's the case, refer to the documentation for the develop branch, which is here: http://david.zemon.name/PropWare-develop/ and specifically, Ping_Demo.cpp. You notice the include paths changed drastically between 2.x and 3.x. I do apologize for that, but it needed to happen.
    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
  • Okay, looks like I had the documentation wrong in the "Detailed Description" of the Ping class in the develop branch. I've pushed out the fix and updated the documentation.
    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
  • scandoslavscandoslav Posts: 11
    edited July 2016 Vote Up0Vote Down
    Apparently I never did anything with the 2.1.1 deb after downloading it, so I was running 2.0.1. I somehow managed to miss the fact that I even COULD run 3.x, and will start using it immediately. :)

    update: everything is beautiful and nothing hurts
  • Glad to hear it! Do be aware that 3.x is still in development (pre-release), so you might run into snags. Do please let me know if that happens and I'll get it fixed quick as I can. I'm also not 100% finalized on the folder structure... I think I like it... but I'm still open for suggestions and considering other options. See here for a list of what's been done so far:
    https://github.com/parallaxinc/PropWare/milestone/4
    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
  • setting COMMON_FLAGS seems to have stopped working since the last time I tried it, nothing added to it shows up in the verbose cmake output, and setting 32_BIT_DOUBLE to OFF but adding -m32bit-doubles to COMMON_FLAGS doesn't appease the libraries that need it, and no optimizations are applied after disabling AUTO_OPTIMIZATION, etc.

    I switched to 3.0.0.83 on Ubuntu 16.04 between now and when I was last aware of it working, so maybe botched some part of the reinstall.

    Also, is Appendix A floating around anywhere? I'd like to read what it says about cmake for propware. :)
  • Okay, I've reproduced the issue with COMMON_FLAGS variable not doing anything in v3.x. I'll tackle this tonight, after work and let you know when its fixed.
    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
  • DavidZemonDavidZemon Posts: 2,224
    edited August 2016 Vote Up0Vote Down
    scandoslav wrote: »
    setting COMMON_FLAGS seems to have stopped working since the last time I tried it, nothing added to it shows up in the verbose cmake output, and setting 32_BIT_DOUBLE to OFF but adding -m32bit-doubles to COMMON_FLAGS doesn't appease the libraries that need it, and no optimizations are applied after disabling AUTO_OPTIMIZATION, etc.

    Thanks for the bug report. 3.0.0.84 fixes the issue. Download here.
    scandoslav wrote: »
    Also, is Appendix A floating around anywhere? I'd like to read what it says about cmake for propware. :)

    Oh, I hate to be the bearer of bad news. That reference to "Appendix A" must have been copied/pasted from another page. I looked through the git history and apparently that is what used to be "Appendix A." That's all the documentation there is on PropWare's build system.

    However, if you're using 3.x, be sure to reference the 3.x PropWare documentation at http://david.zemon.name/PropWare-develop/ instead of the 2.x docs at http://david.zemon.name/PropWare/. I'll see about adding a banner to the top of the 2.x documentation to make it more obvious that there are two different places where documentation can be found.

    Do please let me know (with posts here or feel free to submit issues to the issue tracker) if you find any other bugs or would like documentation updated. I'm going to take the rest of tonight at least to run through the docs and see what all I can add and update.
    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
  • DavidZemonDavidZemon Posts: 2,224
    edited August 2016 Vote Up0Vote Down
    The latest development build of PropWare, 3.0.0.90, adds two buffered UART options.

    1) An example shown in PropWare_BufferedUART. This uses PropWare's existing UARTTX and UARTRX classes in independent COG drivers to transmit and receive asynchronously.

    2) A new class in the PropWare namespace, PropWare::FullDuplexSerial, which is a front-end to the tried-and-true FullDuplexSerial driver code. An example showing its usage can be found in PropWare_FullDuplexSerial.

    The PropWare::FullDuplexSerial driver is quite efficient in terms of code size. It's been added to Hello_Demo so that one can easily compare it to the other drivers. Using the PropWare::Printer::printf method results in 5,680 bytes when backed by a PropWare::UARTTX object but only 5,076 bytes when backed by PropWare::FullDuplexSerial.

    Comparing PropWare::UART and children with PropWare::FullDuplexSerial

    You might ask yourself: "Why would I ever use the UARTTX and UARTRX classes when they're larger than FDS and they're not even buffered?"

    The original objects have a few benefits:

    1) UART children do not require a dedicated cog. They can be invoked from any cog at any time.
    2) UART children support significantly higher baud rates (up to 4.4 MBaud transmit and 2.7 MBaud receive). Depending on your memory model and baud rate, they may require significantly more than one stop bit. However, FDS tops out at 1 Mbaud transmit and approximately 250 kbaud receive.
    3) UART children support different configuration options, such as variable stop bits, parity, and up to 16 data bits per word.

    But of course, FDS offers

    1) Asynchronous execution
    2) Smaller code
    3) Different configuration options: invert tx, invert rx, and ignore TX/echo on RX (open-drain/source TX is available via SharedUARTTX)

    Be aware of the requirements for your project and choose the UART implementation that best fits your needs. The important part is that both sets of classes implement the PropWare::PrintCapable and PropWare::ScanScapable interfaces, so you can effortlessly swap backends on a whim.
    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
  • I'd like to introduce everyone to the new homepage for PropWare:
    http://david.zemon.name/PropWare/

    I've moved away from Doxygen as the soul web framework. Doxygen is now used only for the API docs and example projects. A simple AngularJS + Bootstrap framework is used to house the rest of the documentation, such as download and getting started instructions.

    The files had to undergo significant changes (though the content should be the same still), so do please let me know if you see any issues and I'll get them fixed. I'm also interested in hearing anyone's opinion on the new site and how it could be improved. Now that it's built with Angular instead of Doxygen, I have a lot more freedom to do as I please with it.
    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
  • DavidZemonDavidZemon Posts: 2,224
    edited September 2016 Vote Up0Vote Down
    I just learned about a cool feature in CMake. It has the ability to export all of the required compile commands for your project to a JSON file.

    I have a simple CMakeLists.txt file:
    cmake_minimum_required(VERSION 3.3)
    find_package(PropWare REQUIRED)
    
    project(Scratch)
    
    set(MODEL cmm)
    create_simple_executable(Scratch main.cpp)
    

    And if I add the line "set(CMAKE_EXPORT_COMPILE_COMMANDS ON)"
    cmake_minimum_required(VERSION 3.3)
    find_package(PropWare REQUIRED)
    
    project(Scratch)
    
    set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
    
    set(MODEL cmm)
    create_simple_executable(Scratch main.cpp)
    

    Then it also generates a json file with the following content:
    [
    {
      "directory": "/home/david/reusable/Documents/Programming/PropellerProjects/Scratch/bin",
      "command": "/opt/parallax/bin/propeller-elf-gcc       -Os -m32bit-doubles -Wall -ffunction-sections -fdata-sections -save-temps --std=gnu++0x -fno-exceptions -fno-rtti -fno-threadsafe-statics -mcmm -I/usr/PropWare/include  -o CMakeFiles/Scratch.dir/main.cpp.obj -c /home/david/reusable/Documents/Programming/PropellerProjects/Scratch/main.cpp",
      "file": "/home/david/reusable/Documents/Programming/PropellerProjects/Scratch/main.cpp"
    }
    ]
    

    Official CMake documentation for the feature can be found here: https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html
    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
  • I've been continuing to concentrate on PropWare's documentation, and the next step is complete: http://david.zemon.name/PropWare/#/reference/cmake-reference

    This page hopefully takes care of the dire need for better documentation on PropWare's build system. Please take a look at it, and other pages; I'm interested to here any criticism you might have.

    I've also added a page that describes how to build PropWare from source: http://david.zemon.name/PropWare/#/reference/build-from-source

    Next up: more and better CMake examples on this page: http://david.zemon.name/PropWare/#/reference/cmake-by-example
    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
  • Have you made any progress on SimpleIDE, PropWare, and Windows 10?

    Discovery
  • Bad news. It looks to me like PropWare is incompatible with PropGCC build 2408, which is what ships with SimpleIDE. I've also been unable to get anything in SimpleIDE working correctly under a new version of PropGCC (though that could very well be my own fault, not a bug in SimpleIDE/PropGCC/anything else).

    I suspect it has something to do with one or more of the many bugs and features that have been tackled since build 2408.

    Some parts of PropWare work. Others don't (it's not an all or nothing deal). Perhaps an older version of PropWare (the 2.x release?) would work... I don't know. I was able to confirm with certainty that the PropWare::SD class does not function correctly, though others such as PropWare::Pin and PropWare::SimplePort do. PropWare::Printer also works, but it seems the underlying implementation does not, because the pwOut instance doesn't work. I was able to confirm PropWare::Printer works by testing the SimplePrinter as shown in this example.

    I'm pretty saddened and annoyed by this... I do hope Parallax is willing to work with the community to get SimpleIDE upgraded to a new version of PropGCC, and soon.
    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
Sign In or Register to comment.