Issue Compiling

Hello all,

I am going to run a class at my school using the SIK and have run into an issue when I try to upload the code.

I am running a new MacBook Air M3 OS 14.6.1 and just installed the IDE 2.3.2 for Apple Silicone.

When I tried to upload I got the following error message:

fork/exec /Users/ericlatourelle/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++: bad CPU type in executable

Compilation error: fork/exec Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++: bad CPU type in executable

Any tips to fix the issue would be most appreciated!

The error message you’re encountering is due to the fact that the avr-g++ tool you have installed is not compatible with the architecture of your new MacBook Air M3. Your MacBook Air is based on Apple’s ARM architecture (Apple Silicon), but the avr-g++ tool you’re using is designed for Intel x86 architecture, which is causing the “bad CPU type in executable” error.

To solve this you have a couple of options:

1. Update Arduino IDE and Tools

Ensure you are using the latest version of the Arduino IDE and toolchain that supports Apple Silicon. The Arduino team occasionally releases updates that include compatibility fixes for newer hardware.

  1. Update the Arduino IDE: Check for updates in the Arduino IDE or download the latest version from the Arduino website.
  2. Update Board Packages: Go to the Arduino IDE and navigate to ToolsBoardBoards Manager. Find the package related to your board (e.g., “Arduino AVR Boards”) and ensure it is up-to-date.
  3. Update Tools: If there are any updates for the avr-gcc tools or other related tools, they should be updated automatically through the Boards Manager, but you may want to check if there’s a specific update for ARM architecture support.

2. Use Rosetta 2

If updating does not resolve the issue, you can use Rosetta 2 to run applications that are not yet natively compatible with Apple Silicon.

  1. Find Arduino IDE in Finder: Go to your Applications folder, locate the Arduino IDE app.
  2. Get Info: Right-click (or Control-click) on the Arduino IDE icon and select Get Info.
  3. Open Using Rosetta: Check the box labeled “Open using Rosetta” if it’s available.

This will allow the Arduino IDE to run in an emulated environment that supports Intel-based tools.

3. Manually Install Compatible AVR Toolchain

If the above solutions do not work, you might need to manually install a compatible AVR toolchain that supports Apple Silicon.

  1. Download Precompiled Toolchain: Look for precompiled toolchains compatible with Apple Silicon from sources like Homebrew, or other repositories that provide ARM-compatible binaries.
  2. Install the Toolchain: Follow the installation instructions provided by the toolchain provider.
  3. Configure Arduino IDE: Adjust the path to the new toolchain in the Arduino IDE settings if necessary.

4. Use an Alternative IDE

Consider using an alternative IDE or environment for compiling and uploading your code if the issue persists. Some users switch to platforms like PlatformIO, which might offer better support for newer hardware.

If you continue to experience difficulties, reaching out to the Arduino support forums or the community might provide additional solutions specific to the MacBook Air M3 and Arduino setup.

Thank you for the help!

Just in case others run into the same issue, when I went to right click on the IDE to open with Rosetta, there was no check box to activate. Once I used Terminal to install Rosetta, however, the IDE had no issues compiling without having to tell it to run with Rosetta.

Thank you,
Eric Latourelle
Science Department Chair
804.272.9517
Ne Cede Malis
www.VeritasSchool.com