Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 22 of 22

Thread: Platform IO Configuration

  1. #1
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    271

    Platform IO Configuration

    I am trying out Platform IO but I am unsure how to configure it correctly. I am trying to build the MahonyIMU.ino example from Paul's github https://github.com/PaulStoffregen/NXPMotionSense.git

    I have made only one change to the code adding:

    #include "Arduino.h"

    . . . to the existing includes so it looks like this:

    #include "Arduino.h"
    #include <NXPMotionSense.h>
    #include <MahonyAHRS.h>
    #include <Wire.h>
    #include <EEPROM.h>

    When I try and build it I get these results in the terminal:

    The terminal process terminated with exit code: 1


    Terminal will be reused by tasks, press any key to close it.


    > Executing task in folder Teensy-PropShield-MahonyIMU: C:\Users\Andy\.platformio\penv\Scripts\platformio. exe run <
    Processing teensylc (platform: teensy; board: teensylc; framework: arduino)
    -------------------------------------------------------------------------------------------------------------------
    Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boa.../teensylc.html
    PLATFORM: Teensy 4.4.0 > Teensy LC
    HARDWARE: MKL26Z64 48MHz, 8KB RAM, 62KB Flash
    DEBUG: Current (jlink) External (jlink)
    PACKAGES: toolchain-gccarmnoneeabi 1.50401.190816 (5.4.1), framework-arduinoteensy 1.147.0 (1.47)
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 91 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- <EEPROM> 2.0
    |-- <Mahony> 1.1
    |-- <NXPMotionSense> 1.0
    | |-- <EEPROM> 2.0
    | |-- <Wire> 1.0
    | |-- <VirtualWire>
    |-- <Wire> 1.0
    Compiling .pio\build\teensylc\src\main.cpp.o
    Compiling .pio\build\teensylc\lib2da\NXPMotionSense\NXPMotio nSense.cpp.o
    Compiling .pio\build\teensylc\FrameworkArduino\HardwareSeria l5.cpp.o
    Compiling .pio\build\teensylc\FrameworkArduino\HardwareSeria l6.cpp.o
    lib\NXPMotionSense\NXPMotionSense.cpp: In member function 'bool NXPMotionSense::begin()':
    lib\NXPMotionSense\NXPMotionSense.cpp:40:34: error: '_crc16_update' was not declared in this scope
    crc = _crc16_update(crc, buf[i]);
    ^
    lib\NXPMotionSense\NXPMotionSense.cpp: In member function 'bool NXPMotionSense::writeCalibration(const void*)':
    lib\NXPMotionSense\NXPMotionSense.cpp:268:32: error: '_crc16_update' was not declared in this scope
    crc = _crc16_update(crc, p[i]);
    ^
    *** [.pio\build\teensylc\lib2da\NXPMotionSense\NXPMotio nSense.cpp.o] Error 1
    =========================================== [FAILED] Took 14.42 seconds ===========================================



    Can anyone offer any guidance?

  2. #2
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    257
    Hi,

    In the dependency-graph you see its using <NXPMotionSense> 1.0 and states that the function _crc16_update (from which library ?) was not declared. So NXPMotionSense must be depending on another library. Why did you add the libraries directly to the header of the file ?

    Cor

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    271
    I am not a C++ programmer, I literally took the code from the MahonyIMU.ino example from Paul's github https://github.com/PaulStoffregen/NXPMotionSense.git and added the Arduino include line. I am not sure how to go about converting it to .cpp format

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,553
    Quote Originally Posted by CorBee View Post
    _crc16_update ... was not declared
    ....
    So NXPMotionSense must be depending on another library.
    That's from the core library, specifically this file.

    https://github.com/PaulStoffregen/co...3/util/crc16.h

    Can't say why PlatformIO isn't finding it. Maybe try using Arduino?

  5. #5
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    257
    Question is if the nxpmotionsense lib has been installed from platformIO or not

    PlatformIO has a system to install libraries, you can first check from the terminal if a library exists:
    $platformio lib search nxpmotionsense
    Gives as answer:
    NXPMotionSense
    ==============
    #ID: 686
    Motion sensing with NXP FXOS8700 Accelerometer & Magnetometer and NXP FXAS21002 Gyroscope.

    The library can then be installed using:
    platformio lib install id=686

    Another option is to add a copy the library-source inside the platformio project in the lib directory. But adding in that way means that any dependencies need to be added manual also.

  6. #6
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    271
    Quote Originally Posted by CorBee View Post
    Question is if the nxpmotionsense lib has been installed from platformIO or not

    PlatformIO has a system to install libraries, you can first check from the terminal if a library exists:
    $platformio lib search nxpmotionsense
    Gives as answer:
    NXPMotionSense
    ==============
    #ID: 686
    Motion sensing with NXP FXOS8700 Accelerometer & Magnetometer and NXP FXAS21002 Gyroscope.

    The library can then be installed using:
    platformio lib install id=686

    Another option is to add a copy the library-source inside the platformio project in the lib directory. But adding in that way means that any dependencies need to be added manual also.
    Do you happen to know how do I enter PlatformIO CLI commands from within VSCode? Sorry for slow replies I am currently working on my garden fence )0:

  7. #7
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    257
    Just open the embedded terminal in VSCODE (rightmost icon on the statusbar on the bottom)

  8. #8
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    271
    Thanks, got it and have now installed it. Any ideas how I can resolve the crc16.h issue:

    > Executing task in folder Teensy-PropShield-MahonyIMU: C:\Users\Andy\.platformio\penv\Scripts\platformio. exe run <
    Processing teensylc (platform: teensy; board: teensylc; framework: arduino)
    -------------------------------------------------------------------------------------------------------------------
    Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boa.../teensylc.html
    PLATFORM: Teensy 4.4.0 > Teensy LC
    HARDWARE: MKL26Z64 48MHz, 8KB RAM, 62KB Flash
    DEBUG: Current (jlink) External (jlink)
    PACKAGES: toolchain-gccarmnoneeabi 1.50401.190816 (5.4.1), framework-arduinoteensy 1.147.0 (1.47)
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 90 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- <EEPROM> 2.0
    |-- <NXPMotionSense> 1.0
    | |-- <EEPROM> 2.0
    | |-- <Wire> 1.0
    | |-- <VirtualWire>
    |-- <Wire> 1.0
    Compiling .pio\build\teensylc\src\main.cpp.o
    Compiling .pio\build\teensylc\libe29\EEPROM\EEPROM.cpp.o
    Compiling .pio\build\teensylc\libe4e\Wire\Wire.cpp.o
    Compiling .pio\build\teensylc\libe4e\Wire\WireIMXRT.cpp.o
    src\main.cpp:7:19: fatal error: crc16.h: No such file or directory


    ************************************************** *************
    * Looking for crc16.h dependency? Check our library registry!
    *
    * CLI > platformio lib search "header:crc16.h"
    * Web > https://platformio.org/lib/search?query=header:crc16.h
    *
    ************************************************** *************


    compilation terminated.
    Archiving .pio\build\teensylc\libe29\libEEPROM.a
    *** [.pio\build\teensylc\src\main.cpp.o] Error 1
    Indexing .pio\build\teensylc\libe29\libEEPROM.a
    =========================================== [FAILED] Took 13.58 seconds ===========================================
    The terminal process terminated with exit code: 1


    Terminal will be reused by tasks, press any key to close it.

    Paul said it is part of the core:

    Quote Originally Posted by PaulStoffregen View Post
    That's from the core library, specifically this file.

    https://github.com/PaulStoffregen/co...3/util/crc16.h

    Can't say why PlatformIO isn't finding it. Maybe try using Arduino?
    I am not sure why it is not resolved if that is the case, I thought the core was automatically referenced?

  9. #9
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    257
    if you look at the examples in the github for this library you will find out ...

  10. #10
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    271
    Quote Originally Posted by CorBee View Post
    if you look at the examples in the github for this library you will find out ...
    Thanks for your help. I have a bit of time now so I am going to go and read up on the PlatformIO library manager and try to get my head round it.

  11. #11
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    257
    If you look at: https://github.com/PaulStoffregen/NX...ateSensors.ino

    You see that the program starts with:
    Code:
    #include <NXPMotionSense.h>
    #include <Wire.h>
    #include <EEPROM.h>
    #include <util/crc16.h>
    The last line makes the link to crc16

  12. #12
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    271
    Yes, I saw that thanks, I am just not quite sure how to include it in the PlatformIO project in order to get the PlatformIO library manager to recognise it. If I copy it as it is above it does not work hence I need to have a read up on the library manager. Thanks again.

  13. #13
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    257
    You could simply copy this: https://github.com/PaulStoffregen/co...3/util/crc16.h
    into the library-section of your project as a fast solution

  14. #14
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    271
    I tried copying the crc16.h file to:

    \lib\crc16\src

    I then tried compiling and get:

    Processing teensylc (platform: teensy; board: teensylc; framework: arduino)
    -------------------------------------------------------------------------------------------------------------------
    Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boa.../teensylc.html
    PLATFORM: Teensy 4.4.0 > Teensy LC
    HARDWARE: MKL26Z64 48MHz, 8KB RAM, 62KB Flash
    DEBUG: Current (jlink) External (jlink)
    PACKAGES: toolchain-gccarmnoneeabi 1.50401.190816 (5.4.1), framework-arduinoteensy 1.147.0 (1.47)
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 93 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- <EEPROM> 2.0
    |-- <Mahony> 1.1
    |-- <NXPMotionSense> 1.0
    | |-- <EEPROM> 2.0
    | |-- <Wire> 1.0
    | |-- <VirtualWire>
    |-- <Wire> 1.0
    Compiling .pio\build\teensylc\src\main.cpp.o
    Compiling .pio\build\teensylc\lib0b7\NXPMotionSense_ID686\NX PMotionSense.cpp.o
    Compiling .pio\build\teensylc\FrameworkArduino\AudioStream.c pp.o
    Compiling .pio\build\teensylc\FrameworkArduino\DMAChannel.cp p.o
    .pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMoti onSense.cpp: In member function 'bool NXPMotionSense::begin()':
    .pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMoti onSense.cpp:40:34: error: '_crc16_update' was not declared in this scope
    crc = _crc16_update(crc, buf[i]);
    ^
    .pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMoti onSense.cpp: In member function 'bool NXPMotionSense::writeCalibration(const void*)':
    .pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMoti onSense.cpp:268:32: error: '_crc16_update' was not declared in this scope
    crc = _crc16_update(crc, p[i]);
    ^
    *** [.pio\build\teensylc\lib0b7\NXPMotionSense_ID686\NX PMotionSense.cpp.o] Error 1
    =========================================== [FAILED] Took 13.66 seconds ===========================================
    The terminal process terminated with exit code: 1

    I then tried with an extra include:

    #include<crc16.h>



    and I then get:

    Processing teensylc (platform: teensy; board: teensylc; framework: arduino)
    -------------------------------------------------------------------------------------------------------------------
    Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boa.../teensylc.html
    PLATFORM: Teensy 4.4.0 > Teensy LC
    HARDWARE: MKL26Z64 48MHz, 8KB RAM, 62KB Flash
    DEBUG: Current (jlink) External (jlink)
    PACKAGES: toolchain-gccarmnoneeabi 1.50401.190816 (5.4.1), framework-arduinoteensy 1.147.0 (1.47)
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 93 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- <crc16>
    |-- <EEPROM> 2.0
    |-- <Mahony> 1.1
    |-- <NXPMotionSense> 1.0
    | |-- <EEPROM> 2.0
    | |-- <Wire> 1.0
    | |-- <VirtualWire>
    |-- <Wire> 1.0
    Compiling .pio\build\teensylc\src\main.cpp.o
    Compiling .pio\build\teensylc\lib0b7\NXPMotionSense_ID686\NX PMotionSense.cpp.o
    Compiling .pio\build\teensylc\FrameworkArduino\EventResponde r.cpp.o
    Compiling .pio\build\teensylc\FrameworkArduino\HardwareSeria l1.cpp.o
    .pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMoti onSense.cpp: In member function 'bool NXPMotionSense::begin()':
    .pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMoti onSense.cpp:40:34: error: '_crc16_update' was not declared in this scope
    crc = _crc16_update(crc, buf[i]);
    ^
    .pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMoti onSense.cpp: In member function 'bool NXPMotionSense::writeCalibration(const void*)':
    .pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMoti onSense.cpp:268:32: error: '_crc16_update' was not declared in this scope
    crc = _crc16_update(crc, p[i]);
    ^
    *** [.pio\build\teensylc\lib0b7\NXPMotionSense_ID686\NX PMotionSense.cpp.o] Error 1
    =========================================== [FAILED] Took 14.96 seconds ===========================================
    The terminal process terminated with exit code: 1

    Still confused . . . got to walk the dog and will then have another look (o:

  15. #15
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    257
    Can you share your full code ?

  16. #16
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    271
    Its just Paul's code from this repo https://github.com/PaulStoffregen/NXPMotionSense.git in MahonyIMU.ino from folder \examples\MahonyIMU\

    Here it is in its present form:

    // Inertial Monitoring Unit (IMU) using Mahony filter.
    //
    // To view this data, use the Arduino Serial Monitor to watch the
    // scrolling angles, or run the OrientationVisualiser example in Processing.

    #include"Arduino.h"
    #include<MahonyAHRS.h>
    #include<crc16.h>
    #include<NXPMotionSense.h>
    #include<Wire.h>
    #include<EEPROM.h>

    NXPMotionSense imu;
    Mahony filter;

    void setup() {
    Serial.begin(9600);
    imu.begin();
    filter.begin(100); // 100 measurements per second
    }

    void loop() {
    float ax, ay, az;
    float gx, gy, gz;
    float mx, my, mz;
    float roll, pitch, heading;

    if (imu.available()) {
    // Read the motion sensors
    imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz);

    // Update the Mahony filter
    filter.update(gx, gy, gz, ax, ay, az, mx, my, mz);

    // print the heading, pitch and roll
    roll = filter.getRoll();
    pitch = filter.getPitch();
    heading = filter.getYaw();
    Serial.print("Orientation: ");
    Serial.print(heading);
    Serial.print(" ");
    Serial.print(pitch);
    Serial.print(" ");
    Serial.println(roll);
    }
    }



  17. #17
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    271
    I just pushed the whole PlatformIO project to:

    https://github.com/The-Experimentali...-MahonyIMU.git

  18. #18
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    257
    Hi,

    I just tried to use your code and got the same errors. The direct link between NXPmotionSense and util/crc16 seems to be inside Nxpmotionsense.cpp. Just adding CRC16.h to your project does not seem to solve this (even if you place #include<CRC16.h> above #include<NXPmotionsense.h>
    Have not dealt with this kind of issue before and dont see an easy way to get around this without changing the code of NXPmotionsense, maybe others do ?

    Cor

  19. #19
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    530
    Compiles nicely with VisualTeensy (https://youtu.be/8oTSou1I3IM) so in principle it should be possible with Platform.io as well.

    As you already pointed out it looks like it doesn't find the crc16 header, on the other side it does not complain about a missing header. Would be interesting to see a more complete compiler output.

    Edit:
    Can it be that there is another CRC16.h in the platformio search path which doesn't contain the required declarations?
    Last edited by luni; 09-08-2019 at 08:25 AM.

  20. #20
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    257
    This is the output I get (I tried with teensy3.1 but this gives the same issues as teensyLC)
    Code:
    compilation terminated.
    Archiving .pio/build/teensy31/lib08f/libWire.a
    Indexing .pio/build/teensy31/lib08f/libWire.a
    Compiling .pio/build/teensy31/lib24a/NXPMotionSense/NXPMotionSense.cpp.o
    Compiling .pio/build/teensy31/lib24a/NXPMotionSense/matrix.c.o
    Compiling .pio/build/teensy31/FrameworkArduino/AudioStream.cpp.o
    Compiling .pio/build/teensy31/FrameworkArduino/DMAChannel.cpp.o
    *** [.pio/build/teensy31/src/main.cpp.o] Error 1
    /home/corbee/.platformio/packages/framework-arduinoteensy/libraries/NXPMotionSense/NXPMotionSense.cpp: In member function 'bool NXPMotionSense::begin()':
    /home/corbee/.platformio/packages/framework-arduinoteensy/libraries/NXPMotionSense/NXPMotionSense.cpp:41:34: error: '_crc16_update' was not declared in this scope
       crc = _crc16_update(crc, buf[i]);
                                      ^
    /home/corbee/.platformio/packages/framework-arduinoteensy/libraries/NXPMotionSense/NXPMotionSense.cpp: In member function 'bool NXPMotionSense::writeCalibration(const void*)':
    /home/corbee/.platformio/packages/framework-arduinoteensy/libraries/NXPMotionSense/NXPMotionSense.cpp:269:32: error: '_crc16_update' was not declared in this scope
       crc = _crc16_update(crc, p[i]);
                                    ^
    *** [.pio/build/teensy31/lib24a/NXPMotionSense/NXPMotionSense.cpp.o] Error 1

  21. #21
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    530
    Did a quick search for crc16.h and found a few of them on my system. I'd try to change something in the "intended" header to provoke a compiler error. If you don't get an error it probably includes a different file.

  22. #22
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    271
    Quote Originally Posted by luni View Post
    Compiles nicely with VisualTeensy (https://youtu.be/8oTSou1I3IM) so in principle it should be possible with Platform.io as well.

    As you already pointed out it looks like it doesn't find the crc16 header, on the other side it does not complain about a missing header. Would be interesting to see a more complete compiler output.

    Edit:
    Can it be that there is another CRC16.h in the platformio search path which doesn't contain the required declarations?
    I followed your video and it worked a treat . . . VisualTeensy it is then (o:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •