Bad CPU type in executable

Hi everyone. I am very new to the Arduino coding thing and I am having issues with getting the basic sketch uploaded to my controller. I am using a MacBook Air with atmel mega 328pb nano micro controller and when I try to upload the sketch I am getting the following error.

Failed uploading: cannot execute upload tool: fork/exec /Users//Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude: bad CPU type in executable

I have installed Rosetta 2 and it is still not working. I have also noticed that the rx light on the MC is also not coming on but the pwr and tx is permanently on.

Any advice on this would be appreciated.

You downloaded the Intel version, you need the ARM version

Hi @jaba21

Just to be sure, by "still not working", do you mean that you are still encountering that "bad CPU type in executable" error when you attempt to upload a sketch to the board? Or are you experiencing a different problem now after installing Rosetta 2?

I am experiencing the same "bad CPU type in executable" error.

Not sure what you are referring to.

Did you recently upgrade your Mac from Intel to Apple Silicon

ARM or Apple Silicon. I am assuming you have a newer Mac which now uses the Apple CPU.

I see the cause of the error now. The problem is that the version of the AVRDUDE tool being used to upload a sketch to the board is a 32-bit application.

Support for such applications was dropped starting from macOS Catalina:

In order to understand the best way to solve this problem, I'm going to ask you to provide the full verbose output from a compilation.


:red_exclamation_mark: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Open any sketch in Arduino IDE.
  2. Configure Arduino IDE for use with the "atmel mega 328pb nano micro controller", just as you did before when the upload failed.
  3. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  4. Check the box next to "Show verbose output during: ☐ compile" in the "Preferences" dialog.
  5. Click the "OK" button.
    The "Preferences" dialog will close.
  6. Select Sketch > Verify/Compile from the Arduino IDE menus.
  7. Wait for the compilation to finish.
  8. Right click on the black "Output" panel at the bottom of the Arduino IDE window.
    A context menu will open.
  9. Select Copy All from the menu.
  10. Open a reply here on this forum topic by clicking the "Reply" button.
  11. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  12. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the compilation output into the code block.
  13. Move the cursor outside of the code block markup before you add any additional text to your reply.
  14. Click the "Reply" button to publish the post.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.

Click here for attachment instructions

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a reply here on this forum topic by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:

    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

FQBN: atmel-avr-xminis:avr:atmega328pb_xplained_mini
Using board 'atmega328pb_xplained_mini' from platform in folder: /Users/jasonbaransky/Library/Arduino15/packages/atmel-avr-xminis/hardware/avr/0.6.0
Using core 'arduino' from platform in folder: /Users/jasonbaransky/Library/Arduino15/packages/arduino/hardware/avr/1.8.6

Detecting libraries used...
/Users/jasonbaransky/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_ATMEL_ATMEGA328PB_XMINI -DARDUINO_ARCH_AVR -I/Users/jasonbaransky/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/jasonbaransky/Library/Arduino15/packages/atmel-avr-xminis/hardware/avr/0.6.0/variants/atmega328pb-xmini /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/sketch/Blink.ino.cpp -o /dev/null
Generating function prototypes...
/Users/jasonbaransky/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_ATMEL_ATMEGA328PB_XMINI -DARDUINO_ARCH_AVR -I/Users/jasonbaransky/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/jasonbaransky/Library/Arduino15/packages/atmel-avr-xminis/hardware/avr/0.6.0/variants/atmega328pb-xmini /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/sketch/Blink.ino.cpp -o /private/var/folders/1v/n5xy_hlx7hb_7z7ql6my03dr0000gn/T/2747137333/sketch_merged.cpp
/Users/jasonbaransky/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /private/var/folders/1v/n5xy_hlx7hb_7z7ql6my03dr0000gn/T/2747137333/sketch_merged.cpp

Compiling sketch...
/Users/jasonbaransky/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_ATMEL_ATMEGA328PB_XMINI -DARDUINO_ARCH_AVR -I/Users/jasonbaransky/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/jasonbaransky/Library/Arduino15/packages/atmel-avr-xminis/hardware/avr/0.6.0/variants/atmega328pb-xmini /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/sketch/Blink.ino.cpp -o /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/sketch/Blink.ino.cpp.o
Compiling libraries...
Compiling core...
Using precompiled core: /Users/jasonbaransky/Library/Caches/arduino/cores/atmel-avr-xminis_avr_atmega328pb_xplained_mini_7a12876830f89e20a5457f669769951c/core.a
Linking everything together...
/Users/jasonbaransky/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-gcc -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/Blink.ino.elf /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/sketch/Blink.ino.cpp.o /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/../../cores/atmel-avr-xminis_avr_atmega328pb_xplained_mini_7a12876830f89e20a5457f669769951c/core.a -L/Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086 -lm
/Users/jasonbaransky/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/Blink.ino.elf /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/Blink.ino.eep
/Users/jasonbaransky/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -R .eeprom /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/Blink.ino.elf /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/Blink.ino.hex
/Users/jasonbaransky/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-size -A /Users/jasonbaransky/Library/Caches/arduino/sketches/9A732F4702D563228009F58CD87F2086/Blink.ino.elf
Sketch uses 928 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

OK, I see you are using the 3rd party "Atmel AVR Xplained-minis" boards platform. Maintenance of this platform was abandoned a decade ago, so that is why it still uses a version of the upload tool that has been obsolete for many years.

If you are using one of the Chinese ATmega328PB-based Nano derivative boards that are common on online marketplaces, then you should be able to use the board definition for the original Arduino Nano board (even though the derivative boards use a different microcontroller model, they have configured the boards to work like the original):

  1. Select Tools > Board > Arduino AVR Boards > Arduino Nano from the Arduino IDE menus.
  2. Select Sketch > Upload from the Arduino IDE menus.

Hopefully the upload will be successful and everything will work as expected. If not, provide the output from the upload attempt in a reply here on the forum topic and we'll provide assistance with overcoming the new problem.

I am using the Apple M1 chip

So I assume you downloaded the Apple Silicon version of the IDE. I see the solution is in post 12.

this is what it is doing now.

I also assume so... I can not remember. :face_with_peeking_eye:

Select Tools > Processor > ATmega328P (Old Bootloader) from the Arduino IDE menus and then try uploading again.

Hopefully this time the upload will finish successfully.

yes!!!! That worked! Awesome thanks for the help Arduino Team!

1 Like

Copy the avrdude executable from the current Arduino AVR board install to the Xplained-mini board install. Something like (in "terminal"):

# save old avrdude, just in case
mv ~/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9 ~/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9-old
# replace it with the newer avrdude
cp -R ~/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/  ~/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9

This worked for my (albeit on an Intel Mac.) There may have been a time when the main avrdude did not support the Xplained boards, but that's long past...