Framework-cmsis core_cm0plus.h not found on Linux

Compiling against ARM’s CMSIS for my Adafruit Metro M0 board fails on Linux, because the include path for the core_cm0plus.h header is specified incorrectly in the compiler invocation:
~/.platformio/packages/framework-cmsis/CMSIS/Core/include

The correct path on disk is the same with a capital I (same on GitHub):
~/.platformio/packages/framework-cmsis/CMSIS/Core/Include

I did the same on macOS and it works there, because it uses case-in-sensitive paths. Linux paths, however, are case-sensitive and so the compiler is not including the right one. I checked the package.json, but I didn’t see how to change the way that PlatformIO deduces the include paths. Happy to fix this and make a PR, if you point me to the right location.

Here is the full error output:

$ pio run -e adafruit_metro_m0 -v
Processing adafruit_metro_m0 (platform: atmelsam; board: adafruit_metro_m0; build_type: debug; platform_packages: framework-cmsis-atmel, framework-cmsis; build_flags: -I$PROJECT_PACKAGES_DIR/framework-cmsis-atmel/CMSIS/Device/ATMEL, -I$PROJECT_PACKAGES_DIR/framework-cmsis-atmel/CMSIS/Device/ATMEL/samd21/include, -I$PROJECT_PACKAGES_DIR/framework-cmsis/CMSIS/Core/include, -lc -lm -lgcc -lstdc++; src_filter: -<*> +<main.c> +<*_samd21.c>; board_build.ldscript: misc/samd21g18a_flash.ld)
------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing platformio/framework-cmsis @ *
Unpacking  [####################################]  100%
Tool Manager: framework-cmsis @ 2.50700.210515 has been installed!
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/adafruit_metro_m0.html
PLATFORM: Atmel SAM (6.3.1) > Adafruit Metro M0 Expresss
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES: 
- framework-cmsis 2.50700.210515 (5.7.0) 
- framework-cmsis-atmel 1.2.2 
- toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
arm-none-eabi-gcc -o .pio/build/adafruit_metro_m0/src/main.o -c -std=gnu11 -ffunction-sections -fdata-sections -Wall -mthumb -nostdlib --param max-inline-insns-single=500 -mcpu=cortex-m0plus -Og -g2 -ggdb2 -DF_CPU=48000000L -DUSBCON -DPLATFORMIO=50200 -DARDUINO_SAMD_ZERO -DADAFRUIT_METRO_M0_EXPRESS -DARM_MATH_CM0PLUS -D__SAMD21G18A__ -D__PLATFORMIO_BUILD_DEBUG__ -Iinclude -Isrc -I/home/ez/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL -I/home/ez/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL/samd21/include -I/home/ez/.platformio/packages/framework-cmsis/CMSIS/Core/include src/main.c
In file included from src/main.c:2:0:
/home/ez/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:239:10: fatal error: core_cm0plus.h: No such file or directory

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

#include <core_cm0plus.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
arm-none-eabi-gcc -o .pio/build/adafruit_metro_m0/src/startup_samd21.o -c -std=gnu11 -ffunction-sections -fdata-sections -Wall -mthumb -nostdlib --param max-inline-insns-single=500 -mcpu=cortex-m0plus -Og -g2 -ggdb2 -DF_CPU=48000000L -DUSBCON -DPLATFORMIO=50200 -DARDUINO_SAMD_ZERO -DADAFRUIT_METRO_M0_EXPRESS -DARM_MATH_CM0PLUS -D__SAMD21G18A__ -D__PLATFORMIO_BUILD_DEBUG__ -Iinclude -Isrc -I/home/ez/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL -I/home/ez/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL/samd21/include -I/home/ez/.platformio/packages/framework-cmsis/CMSIS/Core/include src/startup_samd21.c
*** [.pio/build/adafruit_metro_m0/src/main.o] Error 1
arm-none-eabi-gcc -o .pio/build/adafruit_metro_m0/src/system_samd21.o -c -std=gnu11 -ffunction-sections -fdata-sections -Wall -mthumb -nostdlib --param max-inline-insns-single=500 -mcpu=cortex-m0plus -Og -g2 -ggdb2 -DF_CPU=48000000L -DUSBCON -DPLATFORMIO=50200 -DARDUINO_SAMD_ZERO -DADAFRUIT_METRO_M0_EXPRESS -DARM_MATH_CM0PLUS -D__SAMD21G18A__ -D__PLATFORMIO_BUILD_DEBUG__ -Iinclude -Isrc -I/home/ez/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL -I/home/ez/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL/samd21/include -I/home/ez/.platformio/packages/framework-cmsis/CMSIS/Core/include src/system_samd21.c
In file included from /home/ez/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,
                from src/startup_samd21.c:44:
/home/ez/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:239:10: fatal error: core_cm0plus.h: No such file or directory

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

#include <core_cm0plus.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/adafruit_metro_m0/src/startup_samd21.o] Error 1
In file included from /home/ez/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,
                from src/system_samd21.c:44:
/home/ez/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:239:10: fatal error: core_cm0plus.h: No such file or directory

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

#include <core_cm0plus.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/adafruit_metro_m0/src/system_samd21.o] Error 1
============================================== [FAILED] Took 3.04 seconds ==============================================

Environment        Status    Duration
-----------------  --------  ------------
adafruit_metro_m0  FAILED    00:00:03.044

For now I am creating a symlink as a workaround:

$ cd ~/.platformio/packages/framework-cmsis/CMSIS/Core
$ ln -s Include include
$ ls -la
total 16
drwxr-xr-x  4 ez ez 4096 Sep 30 12:45 .
drwxr-xr-x 10 ez ez 4096 Sep 30 12:29 ..
lrwxrwxrwx  1 ez ez    7 Sep 30 12:45 include -> Include
drwxr-xr-x  2 ez ez 4096 Sep 30 12:44 Include
drwxr-xr-x  3 ez ez 4096 Sep 30 12:29 Template

Bug report to Issues · platformio/platform-atmelsam · GitHub please.

Hold up – the Atmel SAM platform doesn’t even have framework = cmsis as an option

What is the exact platformio.ini here?

Seems like you just have the typo in your platformio.ini

-I$PROJECT_PACKAGES_DIR/framework-cmsis/CMSIS/Core/include

in your build_flags.

Hi Max, thanks a lot for your quick reply.

Seems like you just have the typo in your platformio.ini

You are right! I am using this config and I will have to fix it: pio-cmsis-openocd-lldb/platformio.ini at 717393d5eaaf564370af68d6df87a65e622f0dda · weliveindetail/pio-cmsis-openocd-lldb · GitHub

My mistake, sorry. You got it right in the repo I was forking from: pio-baremetal-atmel-cmsis/build_atmel_cmsis.py at a11f17715a6abf5920620faca9ed0c4d6d349fcb · maxgerhardt/pio-baremetal-atmel-cmsis · GitHub