I"m attempting to install Arduino IDE 2.3.6 on my new M4 MacBook Pro and I get the following error message about a Bad CPU type.
Tool arduino:arm-none-eabi-gcc@7-2017q4 already installed
Tool arduino:dfu-util@0.10.0-arduino1 already installed
Tool arduino:imgtool@1.8.0-arduino.2 already installed
Tool arduino:openocd@0.11.0-arduino2 already installed
Downloading packages
arduino:mbed_giga@4.4.1
Installing platform arduino:mbed_giga@4.4.1
Configuring platform.
env: bash: Bad CPU type in executable
WARNING cannot configure platform: exit status 126
Platform arduino:mbed_giga@4.4.1 installed
I get related Bad CPU Type error messages if I try to compile a sketch.
FQBN: arduino:mbed_giga:giga
Using board 'giga' from platform in folder: /Users/joehuber/Library/Arduino15/packages/arduino/hardware/mbed_giga/4.4.1
Using core 'arduino' from platform in folder: /Users/joehuber/Library/Arduino15/packages/arduino/hardware/mbed_giga/4.4.1
Detecting libraries used...
/Users/joehuber/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -w -g3 -nostdlib @/Users/joehuber/Library/Arduino15/packages/arduino/hardware/mbed_giga/4.4.1/variants/GIGA/defines.txt @/Users/joehuber/Library/Arduino15/packages/arduino/hardware/mbed_giga/4.4.1/variants/GIGA/cxxflags.txt -mcpu=cortex-m7 -mfloat-abi=softfp -mfpu=fpv5-d16 -w -x c++ -E -CC -DARDUINO=10607 -DARDUINO_GIGA -DARDUINO_ARCH_MBED_GIGA -DARDUINO_ARCH_MBED -DARDUINO_LIBRARY_DISCOVERY_PHASE=1 -I/Users/joehuber/Library/Arduino15/packages/arduino/hardware/mbed_giga/4.4.1/cores/arduino -I/Users/joehuber/Library/Arduino15/packages/arduino/hardware/mbed_giga/4.4.1/variants/GIGA -DCM4_BINARY_START=0x60000000 -DCM4_BINARY_END=0x60040000 -DCM4_RAM_END=0x60080000 -I/Users/joehuber/Library/Arduino15/packages/arduino/hardware/mbed_giga/4.4.1/cores/arduino/api/deprecated -I/Users/joehuber/Library/Arduino15/packages/arduino/hardware/mbed_giga/4.4.1/cores/arduino/api/deprecated-avr-comp -iprefix/Users/joehuber/Library/Arduino15/packages/arduino/hardware/mbed_giga/4.4.1/cores/arduino @/Users/joehuber/Library/Arduino15/packages/arduino/hardware/mbed_giga/4.4.1/variants/GIGA/../GIGA/includes.txt /Users/joehuber/Library/Caches/arduino/sketches/8C42F30D226517CE854568A0A93F156E/sketch/SpeedTrap38Master.ino.cpp -o /dev/null
fork/exec /Users/joehuber/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++: bad CPU type in executable
Compilation error: fork/exec /Users/joehuber/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++: bad CPU type in executable
Hi Thanks for that info. Yes enabling Rosetta solved that problem and also allowed the serial ports to be properly discovered too.
I hope the Arduino folks can make the entire tool chain compatible with Apple Silicon because Apple has announced the end of life for Rosetta. Or maybe Apple will be forced to change their plans and support Rosetta longer than anticipated.
The "Configuring platform" step is the execution of the platform's post-install script:
This indicates that it is the bash executable in your system that is an x86 (AKA "Intel") binary. That seems strange. Even though you were able to make your system compatible with this executable, it could be worth investigating to see if your installation of Bash is suboptimal. Bash is available in native Apple Silicon builds, so there is no reason to be using an x86 build. I would start by running the following command from a terminal:
file "$(which bash)"
This will return something like:
/usr/bin/bash: Mach-O 64-bit executable x86_64
This provides two separate items of useful information:
The prefix (in my example, /usr/bin/bash:) tells you the location of the bash executable in your system PATH (found using the which command). This is worth evaluating as it is possible you do already have a native Apple Silicon installation of Bash on your system, but it is not actually being used because there is a separate stray x86 installation that is located first in the system PATH.
The second component of the file command tells you the architecture of the file. If it says Mach-O 64-bit executable x86_64, then the file is an x86 binary. If it instead says Mach-O 64-bit executable arm64, then the file is a native Apple Silicon (ARM) binary.
Note that Arduino IDE does not install Bash on your system, so this is a general problem with your system, not Arduino-specific.
Although this error has the same root cause of trying to run an x86 executable on an Apple Silicon machine without Rosetta 2 being installed, it is different in that this is the GCC toolchain installed by the Arduino IDE Boards Manager. In this case it is expected as Arduino has not produced Apple Silicon builds of the ARM GNU Toolchain (AKA "gcc-arm-none-eabi").
I migrated my apps and documents from an x86 based MacBook to this new Apple Silicon one. I can imagine there might be an old file that got migrated inapproriately. There are a couple of other small undesirable things that got migrated over, so I wonder if it’s worth going back to a fresh OS install and rebuilding everything from scratch rather than migrating???
That is correct. The Arduino IDE application itself is a native Apple Silicon build. However, this doesn't mean that all the helper tools installed and used by Arduino IDE are as well. When running on an Apple Silicon machine, Arduino IDE will always install the Apple Silicon build of a tool dependency if that is available, but it falls back to the x86 build of the tool if an Apple Silicon version is not available.
Arduino has produced Apple Silicon builds of some of the helper tools, but has not yet done this for all of them. For example:
The other thing that must be considered is that when you install a 3rd party boards platform via Boards Manager, it installs whatever tools were specified by the 3rd party platform developer, which aren't necessarily maintained by Arduino. So a complete migration of the entire Arduino ecosystem away from a dependency on Rosetta 2 will require the efforts of various 3rd parties in addition to the Arduino company.
I am not very knowledgeable in this subject matter. It will also certainly be a question of your personal preferences and the difficulty of re-creating the parts of your current system you need.
I installed Bash on my macOS machine via Homebrew:
You might be able to get away with just running that brew install bash command without any other action. That may result in you having multiple copies of Bash installed on your machine. The question of which one of the two will be used will likely depend on your specific system PATH configuration (the folders in the PATH variable are searched in order and the first one that contains the specified executable is used).