Shop OBEX P1 Docs P2 Docs Learn Events
PropWare Cogc_Demo.cpp — Parallax Forums

PropWare Cogc_Demo.cpp

David Zemon, I need you help with this issue. Thanks a lot!

2 Questions:

I have a error when trying "make" this "Cogc" example:
pi@raspberrypi:~/PropellerProjects/PropWare/Examples/Cogc/bin $ make
Scanning dependencies of target Cogc_Demo
[ 33%] Building CXX object CMakeFiles/Cogc_Demo.dir/Cogc_Demo.cpp.obj
[ 66%] Building COGCXX object CMakeFiles/Cogc_Demo.dir/blinky.cogcpp.cog
make[2]: CMAKE_C_COMPILER: Command not found
CMakeFiles/Cogc_Demo.dir/build.make:86: recipe for target 'CMakeFiles/Cogc_Demo.dir/blinky.cogcpp.cog' failed
make[2]: *** [CMakeFiles/Cogc_Demo.dir/blinky.cogcpp.cog] Error 127
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Cogc_Demo.dir/all' failed
make[1]: *** [CMakeFiles/Cogc_Demo.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2

I don´t have the CMAKE compiler? is everything compiling ok!! need other? :)

Where is called the file "blinky.cogcpp" from the file "Cogc_Demo.cpp"? How you do that? :P

The example is for blinky two leds in separate PIN´s, P16 (main Cog) and P23 (new cog). ok! :thumb:

Comments

  • from the bin directory, run
    rm -rf *
    cmake .. 
    make
    

    And provide the output. That will help me figure out what is wrong. Along with that, also please create a zip of the entire ~/PropellerProjects/PropWare/Examples/Cogc directory and post that here.
  • ASAS Posts: 149
    The error is the same:
    pi@raspberrypi:~/PropellerProjects/PropWare/Examples/Cogc/bin $ make
    Scanning dependencies of target Cogc_Demo
    [ 33%] Building CXX object CMakeFiles/Cogc_Demo.dir/Cogc_Demo.cpp.obj
    [ 66%] Building COGCXX object CMakeFiles/Cogc_Demo.dir/blinky.cogcpp.cog
    make[2]: CMAKE_C_COMPILER: Command not found
    CMakeFiles/Cogc_Demo.dir/build.make:86: recipe for target 'CMakeFiles/Cogc_Demo.dir/blinky.cogcpp.cog' failed
    make[2]: *** [CMakeFiles/Cogc_Demo.dir/blinky.cogcpp.cog] Error 127
    CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Cogc_Demo.dir/all' failed
    make[1]: *** [CMakeFiles/Cogc_Demo.dir/all] Error 2
    Makefile:94: recipe for target 'all' failed
    make: *** [all] Error 2
    

    the files go attached

    thanks!
  • I'm not seeing anything that sticks out in the zip you attached. Let's try this
    rm -rf *
    cmake ..
    make VERBOSE=1
    

    and this time provide all of the output (all three commands) instead of just the make command. No need for the zip this time around.
  • ASAS Posts: 149
    edited 2016-02-23 14:29
    I send now a ".zip" where I use 7zip to make it!

    the output is:
    pi@raspberrypi:~/PropellerProjects/PropWare/Examples/Cogc/bin $ rm -rf *
    pi@raspberrypi:~/PropellerProjects/PropWare/Examples/Cogc/bin $ cmake ..
    -- Found PropWare: /home/pi/PropWare (found suitable version "2.0.0", minimum required is "2.0.0")
    -- The CXX compiler identification is GNU 4.6.1
    -- The COGCXX compiler identification is unknown
    -- Check for working CXX compiler: /opt/parallax/bin/propeller-elf-gcc
    -- Check for working CXX compiler: /opt/parallax/bin/propeller-elf-gcc -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/pi/PropellerProjects/PropWare/Examples/Cogc/bin
    pi@raspberrypi:~/PropellerProjects/PropWare/Examples/Cogc/bin $ make VERBOSE=1
    /home/pi/cmake/cmake-3.3.2/bin/cmake -H/home/pi/PropellerProjects/PropWare/Examples/Cogc -B/home/pi/PropellerProjects/PropWare/Examples/Cogc/bin --check-build-system CMakeFiles/Makefile.cmake 0
    /home/pi/cmake/cmake-3.3.2/bin/cmake -E cmake_progress_start /home/pi/PropellerProjects/PropWare/Examples/Cogc/bin/CMakeFiles /home/pi/PropellerProjects/PropWare/Examples/Cogc/bin/CMakeFiles/progress.marks
    make -f CMakeFiles/Makefile2 all
    make[1]: Entering directory '/home/pi/PropellerProjects/PropWare/Examples/Cogc/bin'
    make -f CMakeFiles/Cogc_Demo.dir/build.make CMakeFiles/Cogc_Demo.dir/depend
    make[2]: Entering directory '/home/pi/PropellerProjects/PropWare/Examples/Cogc/bin'
    cd /home/pi/PropellerProjects/PropWare/Examples/Cogc/bin && /home/pi/cmake/cmake-3.3.2/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/PropellerProjects/PropWare/Examples/Cogc /home/pi/PropellerProjects/PropWare/Examples/Cogc /home/pi/PropellerProjects/PropWare/Examples/Cogc/bin /home/pi/PropellerProjects/PropWare/Examples/Cogc/bin /home/pi/PropellerProjects/PropWare/Examples/Cogc/bin/CMakeFiles/Cogc_Demo.dir/DependInfo.cmake --color=
    Dependee "/home/pi/PropellerProjects/PropWare/Examples/Cogc/bin/CMakeFiles/Cogc_Demo.dir/DependInfo.cmake" is newer than depender "/home/pi/PropellerProjects/PropWare/Examples/Cogc/bin/CMakeFiles/Cogc_Demo.dir/depend.internal".
    Dependee "/home/pi/PropellerProjects/PropWare/Examples/Cogc/bin/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/pi/PropellerProjects/PropWare/Examples/Cogc/bin/CMakeFiles/Cogc_Demo.dir/depend.internal".
    Scanning dependencies of target Cogc_Demo
    make[2]: Leaving directory '/home/pi/PropellerProjects/PropWare/Examples/Cogc/bin'
    make -f CMakeFiles/Cogc_Demo.dir/build.make CMakeFiles/Cogc_Demo.dir/build
    make[2]: Entering directory '/home/pi/PropellerProjects/PropWare/Examples/Cogc/bin'
    [ 33%] Building CXX object CMakeFiles/Cogc_Demo.dir/Cogc_Demo.cpp.obj
    /opt/parallax/bin/propeller-elf-gcc    -save-temps  -Os -m32bit-doubles -Wall     -std=gnu++0x -mcog -I/home/pi/PropWare/include    -o CMakeFiles/Cogc_Demo.dir/Cogc_Demo.cpp.obj -c /home/pi/PropellerProjects/PropWare/Examples/Cogc/Cogc_Demo.cpp
    [ 66%] Building COGCXX object CMakeFiles/Cogc_Demo.dir/blinky.cogcpp.cog
    CMAKE_C_COMPILER   -save-temps  -Os -m32bit-doubles -Wall     -std=gnu++0x   -I/home/pi/PropWare/include    -o CMakeFiles/Cogc_Demo.dir/blinky.cogcpp.cog /home/pi/PropellerProjects/PropWare/Examples/Cogc/blinky.cogcpp
    make[2]: CMAKE_C_COMPILER: Command not found
    CMakeFiles/Cogc_Demo.dir/build.make:86: recipe for target 'CMakeFiles/Cogc_Demo.dir/blinky.cogcpp.cog' failed
    make[2]: *** [CMakeFiles/Cogc_Demo.dir/blinky.cogcpp.cog] Error 127
    make[2]: Leaving directory '/home/pi/PropellerProjects/PropWare/Examples/Cogc/bin'
    CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Cogc_Demo.dir/all' failed
    make[1]: *** [CMakeFiles/Cogc_Demo.dir/all] Error 2
    make[1]: Leaving directory '/home/pi/PropellerProjects/PropWare/Examples/Cogc/bin'
    Makefile:94: recipe for target 'all' failed
    make: *** [all] Error 2
    
  • Okay, thank you for finding this. Looks like it might be a bug in PropWare. I can't test this while I'm at work, but you should be able to work around it by changing the project line in CMakeLists.txt to this:
    project(Cogc_Demo C CXX COGCXX)
    
  • ASAS Posts: 149
    edited 2016-02-23 15:38
    It´s working fine! I don´t test it but it compiles with no errors or warnings. Thank you!

    How you do to "call" the "blinky.cogcpp" from the "Cogc_Demo.cpp" ?
    Creating a
    extern unsigned int load_start_blinky_cog[];
    
    it will "call" the "blinky.cogcpp"?

    Where you define the size of the stack cog? You use the [cog] model memory it will be 2kb per cog, don´t need define stack?
  • That would be a generic PropGCC cogc question. It's kind of magical...

    The linker automagically generates a symbol called "load_start_<your file>_cog" and it points to a binary blob in your program. That binary blob is the compiled output of <your_file>.cogc or <your_file>.cogcpp depending on whether it is C or C++
  • ASAS Posts: 149
    ok! I see! thanks a lot :thumb:

    I suspected something like that, but is not usual for a definition of a file :P

    I already see that you have some examples of "cogs", I will try for sure.

    But one last question (for now):
    Where you define the size of the stack cog? You use the [cog] model memory it will be 2kb per cog, don´t need define stack in this case?
    If you use other memory model? (I will see your examples)

    I want a robust solution to understand almost everything about the propeller cogs. :P essencial in Propeller
  • AS wrote: »
    ok! I see! thanks a lot :thumb:

    I suspected something like that, but is not usual for a definition of a file :P

    I already see that you have some examples of "cogs", I will try for sure.

    But one last question (for now):
    Where you define the size of the stack cog? You use the [cog] model memory it will be 2kb per cog, don´t need define stack in this case?
    If you use other memory model? (I will see your examples)

    I want a robust solution to understand almost everything about the propeller cogs. :P essencial in Propeller

    Sorry, I know you asked that question earlier and I completely forgot to answer it.

    A stack is not provided in COG mode. HUB memory is not accessible (except through direct use of HUB instructions like rdlong) in COG mode so your only memory is what is available in the COG's 2kB of local memory. This is why is it has a very limited use case, but it's fantastic for writing little drivers and such. COG memory model works along the same principles as PASM code in a Spin file - it is completely independent of the rest of the code and carries none of the high-level features provided by the calling language such as stacks/heaps/etc. You're getting native assembly... but at the high price of developer time.
  • ASAS Posts: 149
    ok! I think I understand everything for now.

    I need make some experiences!

    Really thanks!
  • DavidZemon wrote: »
    AS wrote: »
    Where you define the size of the stack cog? You use the [cog] model memory it will be 2kb per cog, don´t need define stack in this case?
    If you use other memory model? (I will see your examples)

    I want a robust solution to understand almost everything about the propeller cogs. :P essencial in Propeller

    A stack is not provided in COG mode. HUB memory is not accessible (except through direct use of HUB instructions like rdlong) in COG mode so your only memory is what is available in the COG's 2kB of local memory.
    I'm afraid that's not accurate, at least not in reference to PropGCC. PropGCC always puts strings and global variables in HUB memory, even when compiled with -mcogc. The reason is that COG memory can only be read/written as longs, but C supports single byte (char) and two byte (short) data types, which would be very awkward to use in COG memory.

    PropGCC also always has a stack, although frequently the optimizer can keep variables in memory and not in the stack. The address of the stack is passed to a new COGC program in the PAR register. The size of the stack has to be set by the programmer. Some COGC programs won't need any stack at all, some might need a few dozen bytes; it's rare for any to need more than 100 bytes (unless they're calling printf or some similar complicated function).

    You can reduce the need for a stack by declaring functions as _NATIVE (so they don't need to save their return address on the stack before calling other functions) and by using variables explicitly declared as _COGMEM (so they get stored in COG memory rather than HUB).

  • ersmith wrote: »
    DavidZemon wrote: »
    AS wrote: »
    Where you define the size of the stack cog? You use the [cog] model memory it will be 2kb per cog, don´t need define stack in this case?
    If you use other memory model? (I will see your examples)

    I want a robust solution to understand almost everything about the propeller cogs. :P essencial in Propeller

    A stack is not provided in COG mode. HUB memory is not accessible (except through direct use of HUB instructions like rdlong) in COG mode so your only memory is what is available in the COG's 2kB of local memory.
    I'm afraid that's not accurate, at least not in reference to PropGCC. PropGCC always puts strings and global variables in HUB memory, even when compiled with -mcogc. The reason is that COG memory can only be read/written as longs, but C supports single byte (char) and two byte (short) data types, which would be very awkward to use in COG memory.

    PropGCC also always has a stack, although frequently the optimizer can keep variables in memory and not in the stack. The address of the stack is passed to a new COGC program in the PAR register. The size of the stack has to be set by the programmer. Some COGC programs won't need any stack at all, some might need a few dozen bytes; it's rare for any to need more than 100 bytes (unless they're calling printf or some similar complicated function).

    You can reduce the need for a stack by declaring functions as _NATIVE (so they don't need to save their return address on the stack before calling other functions) and by using variables explicitly declared as _COGMEM (so they get stored in COG memory rather than HUB).

    OH! That's very interesting. Thanks for the detailed info :)
Sign In or Register to comment.