[Solved] Hello World program fails with "Illegal Instruction" in built-in file on RPi Zero W

Hi

I am getting this compiler error in one of the built-in files (variant.cpp) when building a trivial Hello World program. I am only getting it for the SAM/Due platform and not for the AVR/Uno platform.

Does anyone know if there is some simple work-around I could use here, or do I need to wait for an upstream bugfix?

This issue looks very similar to this one: Illegal Instruction [.pio/build/teensy40/src/main.cpp.o] Error 132 - #17 by maxgerhardt

Here is the console output (I am using the CLI):

pi@raspberrypi:~/Documents/RHex_Barebones $ pio run -e due -v
Processing due (platform: atmelsam; board: due; framework: arduino; monitor_speed: 115200)
CONFIGURATION: https:// docs.platformio. org/page/boards/atmelsam/due.html
PLATFORM: Atmel SAM (5.1.1) > Arduino Due (Programming Port)
HARDWARE: AT91SAM3X8E 84MHz, 96KB RAM, 512KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink, stlink)
PACKAGES:

  • framework-arduino-sam 1.6.12
  • framework-cmsis 1.40500.0 (4.5.0)
  • framework-cmsis-atmel 1.2.0
  • 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 3 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode
    arm-none-eabi-g++ -o .pio/build/due/FrameworkArduinoVariant/variant.cpp.o -c -fno-rtti -fno-exceptions -std=gnu++11 -fno-threadsafe-statics -Os -ffunction-sections -fdata-sections -Wall -mcpu=cortex-m3 -mthumb -nostdlib --param max-inline-insns-single=500 -DPLATFORMIO=50004 -D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO=10805 -DF_CPU=84000000L -DUSBCON -DUSB_VID=0x2341 -DUSB_PID=0x003E “-DUSB_PRODUCT="Arduino Due"” -DUSB_MANUFACTURER="Arduino" -DARDUINO_ARCH_SAM -I/home/pi/.platformio/packages/framework-arduino-sam/cores/arduino -I/home/pi/.platformio/packages/framework-arduino-sam/system/libsam -I/home/pi/.platformio/packages/framework-arduino-sam/system/CMSIS/CMSIS/Include -I/home/pi/.platformio/packages/framework-arduino-sam/system/CMSIS/Device/ATMEL -I/home/pi/.platformio/packages/framework-arduino-sam/variants/arduino_due_x /home/pi/.platformio/packages/framework-arduino-sam/variants/arduino_due_x/variant.cpp
    /home/pi/.platformio/packages/framework-arduino-sam/variants/arduino_due_x/variant.cpp: In function ‘void init()’:
    /home/pi/.platformio/packages/framework-arduino-sam/variants/arduino_due_x/variant.cpp:451:1: internal compiler error: Illegal instruction
    }
    ^
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See for instructions.
    *** [.pio/build/due/FrameworkArduinoVariant/variant.cpp.o] Error 1
    ========== [FAILED] Took 22.11 seconds =============================

Environment Status Duration


uno IGNORED
due FAILED 00:00:22.111
=========== 1 failed, 0 succeeded in 00:00:22.111 ========
pi@raspberrypi:~/Documents/RHex_Barebones $

Here is my source file:

#include <Arduino.h>

void setup()
{
Serial.begin(115200);
Serial.println ( “Hello World!” );
}

void loop()
{
delay(1000);
Serial.println ( “Beep!” );
}

Here is my platform.ini

[env:uno]
platform = atmelavr
board = uno
framework = arduino
monitor_speed = 115200

[env:due]
platform = atmelsam
board = due
framework = arduino
monitor_speed = 115200

Here is the pio system info:

pi@raspberrypi:~/Documents/RHex_Barebones $ pio system info
PlatformIO Core 5.0.4
Python 3.7.3-final.0
System Type linux_armv6l
Platform Linux-5.4.83±armv6l-with-glibc2.28
File System Encoding utf-8
Locale Encoding UTF-8
PlatformIO Core Directory /home/pi/.platformio
PlatformIO Core Executable /home/pi/.platformio/penv/bin/platformio
Python Executable /home/pi/.platformio/penv/bin/python
Global Libraries 0
Development Platforms 4
Tools & Toolchains 12


Yep it should be the same issue as when compiling for a Teensy: The toolchain-gccarmnoneeabi package is not actually executable on the Rasperry Pi Zero W, due to some binary incompatibility.

Please do the following (actually pretty much the same as in the topic you’ve linked)

  1. download the toolchain-gccarmnoneeabi-linux_armv6l-1.90301.201121.tar.gz file the bintray on the Pi to some path, e.g. using wget https://bintray.com/maxgerhardt/pio-tools/download_file?file_path=toolchain-gccarmnoneeabi-linux_armv6l-1.90301.201121.tar.gz
  2. Use that downloaded file in the platformio.ini by adding
platform_packages =
   toolchain-gccarmnoneeabi@file:///home/pi/toolchain-gccarmnoneeabi-linux_armv6l-1.90301.201121.tar.gz

Where the /home/pi/toolchain-gccarmnoneeabi-linux_armv6l-1.90301.201121.tar.gz must be adapted to match the actual downloaded path.

Then retry compilation.

Wonderful. That saved my day :smiley: