platform-atmelavr
platform-atmelavr copied to clipboard
Can't find atmel-toolchain in alpine docker container
What kind of issue is this?
Possibly(?)
-
[X] Development Platform or Board. All issues (building, uploading, adding new boards, etc.) related to PlatformIO development platforms should be reported to appropriate repository related to your hardware https://github.com/topics/platformio-platform
-
[X] PlatformIO Core. If you’ve found a bug, please provide an information below.
Configuration
Operating system: Arch Linux x64
PlatformIO Version (platformio --version
): 3.6.1
Description of problem
I am running a docker container for my Continuous Integration, which I install platformio on. However when I try to build any project, PlatformIO reports that it can't find avr-gcc / avr-g++.
Steps to Reproduce
- Create docker image from: https://pastebin.com/pNWXjSgb
- Run docker container with name
jenkins-blueocean
- Shell in (or create a pipeline but this is easier):
sudo docker exec -i -t jenkins-blueocean /bin/bash
- Create a project: ex.
pio init -b uno
- Insert something in main.cpp (see basic source below)
-
pio run
Actual Results
https://pastebin.com/SqRkyrR5
Expected Results
Succesful build
If problems with PlatformIO Build System:
The content of platformio.ini
:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:uno]
platform = atmelavr
board = uno
framework = arduino
Source file to reproduce issue:
int main() {
}
void loop() {
}
Additional info
I also tried different projects, non are working.
This is something else I noticed. Even though the toolchain files exist, it can't find/execute them?
Ignore the path in the terminal that isn't the docker container's path!
Better example:
This is interesting:
https://superuser.com/questions/1176200/no-such-file-when-it-exists
Edit Looks like alpine cant run the toolchain because it's build against glibc, which alpine doesn't have.
https://github.com/gliderlabs/docker-alpine/issues/219
Okay, Installing the toolchain with:
https://github.com/takesako/alpine-iot
or just apk add avr-libc
almost works. It just can't find the correct spec?
https://pastebin.com/p4VEcY2v
Is there a way to tell PIO where to look for device-specs? I can't find any environment variables this quick.
Edit:
I pass the following build_flag with no success:
build_flags =
-specs=/usr/lib/gcc/avr/6.1.0/device-specs/specs-atmega328p
Also tried:
build_flags =
-specs=/var/jenkins_home/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/device-specs/specs-atmega328p
Verbose works manually, not through PIO
So verbose outputs the following with the previous build_flag:
avr-g++ -o .pioenvs/uno/FrameworkArduino/HardwareSerial1.cpp.o -c -fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -specs=/var/jenkins_home/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/device-specs/specs-atmega328p -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega328p -DPLATFORMIO=30602 -DARDUINO_AVR_UNO -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO=10805 -I/root/.platformio/packages/framework-arduinoavr/cores/arduino -I/root/.platformio/packages/framework-arduinoavr/variants/standard /root/.platformio/packages/framework-arduinoavr/cores/arduino/HardwareSerial1.cpp
or
avr-g++ -o .pioenvs/uno/src/main.cpp.o -c -fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -specs=/var/jenkins_home/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/device-specs/specs-atmega328p --version -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega328p -DPLATFORMIO=30602 -DARDUINO_AVR_UNO -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO=10805 -Isrc -Iinclude -I/root/.platformio/packages/framework-arduinoavr/cores/arduino -I/root/.platformio/packages/framework-arduinoavr/variants/standard src/main.cpp
PIO still fails. If I 1-on-1 copy and paste this in the shell it works!? So there is probably some environment-variable that is set for PIO.
Yes, it seems that existing AVR toolchain for ARM is not compatible with Alpine distributive. It should work with Ubuntu/Debian. Temporary solution is to remove everything from ~/.platformio/packages/toolchain-atmelavr
but keep package.json
. PlatformIO will use the next binaries https://github.com/platformio/platform-atmelavr/blob/develop/builder/main.py#L93
Another solution is to fork https://github.com/platformio/platform-atmelavr and remove "toolchain" dependency.
Also, we have a feature request https://github.com/platformio/platformio-core/issues/1367 which will allow overriding platform dependencies from platformio.ini
in PlatformIO Core 4.0
I got it working (atleast the building) with the build_flags below. I don't think each is necessary, but it works :man_shrugging: Note that /var/jenkins_home/
is usually your own home directory, however this is a jenkins docker container.
build_flags =
-B/usr/lib/gcc/avr/6.1.0/
-B/var/jenkins_home/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/
-I/var/jenkins_home/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include
-I/var/jenkins_home/.platformio/packages/toolchain-atmelavr/avr/include/
-I/var/jenkins_home/.platformio/packages/toolchain-atmelavr/libexec/gcc/avr/5.4.0/
~I will try and create a new image which will install the alpine atmel-toolchain and see if I can use some symlink magic to make it work.~
Update: I did not succeed in making a working image. I have quit on this approach currently. I am too busy with other stuff.