Platform IO Configuration

Status
Not open for further replies.

Experimentalist

Well-known member
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/boards/teensy/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\NXPMotionSense.cpp.o
Compiling .pio\build\teensylc\FrameworkArduino\HardwareSerial5.cpp.o
Compiling .pio\build\teensylc\FrameworkArduino\HardwareSerial6.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);
^
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);
^
*** [.pio\build\teensylc\lib2da\NXPMotionSense\NXPMotionSense.cpp.o] Error 1
=========================================== [FAILED] Took 14.42 seconds ===========================================



Can anyone offer any guidance?
 
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
 
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.
 
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:
 
Just open the embedded terminal in VSCODE (rightmost icon on the statusbar on the bottom)
 
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/boards/teensy/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:

That's from the core library, specifically this file.

https://github.com/PaulStoffregen/cores/blob/master/teensy3/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?
 
if you look at the examples in the github for this library you will find out ...
 
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.
 
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/boards/teensy/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\NXPMotionSense.cpp.o
Compiling .pio\build\teensylc\FrameworkArduino\AudioStream.cpp.o
Compiling .pio\build\teensylc\FrameworkArduino\DMAChannel.cpp.o
.pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMotionSense.cpp: In member function 'bool NXPMotionSense::begin()':
.pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMotionSense.cpp:40:34: error: '_crc16_update' was not declared in this scope
crc = _crc16_update(crc, buf);
^
.pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMotionSense.cpp: In member function 'bool NXPMotionSense::writeCalibration(const void*)':
.pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMotionSense.cpp:268:32: error: '_crc16_update' was not declared in this scope
crc = _crc16_update(crc, p);
^
*** [.pio\build\teensylc\lib0b7\NXPMotionSense_ID686\NXPMotionSense.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/boards/teensy/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\NXPMotionSense.cpp.o
Compiling .pio\build\teensylc\FrameworkArduino\EventResponder.cpp.o
Compiling .pio\build\teensylc\FrameworkArduino\HardwareSerial1.cpp.o
.pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMotionSense.cpp: In member function 'bool NXPMotionSense::begin()':
.pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMotionSense.cpp:40:34: error: '_crc16_update' was not declared in this scope
crc = _crc16_update(crc, buf);
^
.pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMotionSense.cpp: In member function 'bool NXPMotionSense::writeCalibration(const void*)':
.pio\libdeps\teensylc\NXPMotionSense_ID686\NXPMotionSense.cpp:268:32: error: '_crc16_update' was not declared in this scope
crc = _crc16_update(crc, p);
^
*** [.pio\build\teensylc\lib0b7\NXPMotionSense_ID686\NXPMotionSense.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:
 
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);
}
}


 
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
 
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:
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
 
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.
 
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:
 
Use lib_ignore to exclude incorrectly detected libraries

In case anyone else comes here with the same problem, the fix for platformio is to edit platformio.ini in your project and add:

Code:
lib_ignore = 
	VirtualWire

The problem was that platformio tries to figure out what dependencies your code has based on an analysis of the includes in your project, which transitively analyses all the header and source code files in your project and available platform libraries. This can go wrong if more than one header file with the same name exists, and in this case both the teensy platform libraries and VirtualWire contain <util/crc16.h>. Fortunately, lib_ignore lets us tweak the results of the dependency scan. See https://docs.platformio.org/en/latest/projectconf/section_env_library.html#lib-ignore
 
Status
Not open for further replies.
Back
Top