Multiple environments (Uno/Teensy) build the wrong libraries. Multiple errors

I am building a project with two environments: one for Arduino Uno and one for Teensy 3.6.

[env:uno]
platform = atmelavr
board = uno
framework = arduino
board_build.mcu = atmega328p
upload_protocol = usbasp
build_flags =
    -e
lib_deps =
watterott/digitalWriteFast@^1.0.0
robtillaart/RunningAverage@^0.3.2
khoih-prog/TimerInterrupt@^1.0.2
wilmouths/RGB@^1.0.9
contrem/arduino-timer@^3.0.1
adafruit/Adafruit BusIO@^1.14.5

[env:teensy36]
platform = teensy
board = teensy36
framework = arduino
board_build.f_cpu = 256000000L
lib_deps =
watterott/digitalWriteFast@^1.0.0
marcoschwartz/LiquidCrystal_I2C@^1.1.4
robtillaart/RunningAverage@^0.3.2
khoih-prog/TimerInterrupt@^1.0.2
wilmouths/RGB@^1.0.9
khoih-prog/Teensy_TimerInterrupt@^1.3.0
luni64/TeensyTimerTool@^1.4.1
contrem/arduino-timer@^3.0.1
adafruit/Adafruit BusIO@^1.14.5

Upon building ONLY for Uno I get a TON of errors regarding the SPI library (which my project heavily depends on) and a contributed library digitalWriteFast

… the screen goes on and on with errors (I do not want to copy-paste 6 screenshots here), however, particular attention to the following one:

where even Serial is not getting recognised! What is going on?

my headers are:

#include <Arduino.h>
#include <SPI.h>
#include <digitalWriteFast.h>
#include <RGBLed.h>
#include <arduino-timer.h>

I have even removed the Teensy environment (commenting it) and it does not want to work

If I right-click on the SPI.h header to see the definition, pio reads the Teensy implementation, not the Arduino avr one

[EDIT 1]

I fully removed ALL references to Teensy, deleted the pio folder and for the first time ever I had to add the <HardwareSerial.h> header.

Why do I need it? I do not recall having to include it

[EDIT 2]

I just found out that commenting the following lines in my .ini file allows me to compile with no errors:

image

I can compile with the Uno environment just fine when I remove these lines. I don’t even know what GCC option that is.

[env:uno]
platform = atmelavr
board = uno
framework = arduino
board_build.mcu = atmega328p
upload_protocol = usbasp
;build_flags =
;    -e
lib_deps =
    watterott/digitalWriteFast@^1.0.0
    robtillaart/RunningAverage@^0.3.2
    khoih-prog/TimerInterrupt@^1.0.2
    wilmouths/RGB@^1.0.9
    contrem/arduino-timer@^3.0.1
    adafruit/Adafruit BusIO@^1.14.5

Yep. I am an idiot. [a hungry idiot to be precise :frowning_face: ]

I should have used upload_flags, not ~build_flags~.

Now, this only worked once I removed all references to Teensy.

I will bring them back and check.

Thanks, max

When I looked at the source code, it was already complaining in avr/io.h that

#    warning "device type not defined"

which should not happen since it normally hits this line

#elif defined (__AVR_ATmega328P__)
#  include <avr/iom328p.h>

and __AVR_ATmega328P__ is a built-in macro that gets auto activated when avr-gcc is invoked with -mmcu=atmega328p. So the only thing I can think of is that -e destroys this because it’s some “disable built-in macros” flag for GCC.

1 Like