Skip to content

Building AVRDUDE for macOS

mcuee edited this page Apr 20, 2024 · 36 revisions

Prerequisites

On macOS, you can normally install AVRDUDE through MacPorts (port install avrdude) or Homebrew (brew install avrdude).

The following things are needed to build AVRDUDE on MacOS:

  • A C compiler; either full XCode, or the XCode Command Line tools
  • cmake, pkg-config, hidapi, libftdi1, libusb, libelf, libserialport (libserialport is not available with MacPorts, so you have to build from source)

(note: alternative to pkg-config is pkgconf, both should work but you can install one of them).

Minimum required version for CMake is 3.14.

The following two build systems are supported.

  1. Homebrew
  2. MacPorts

Build Instructions without GNU Readline (using macOS bundled libedit) -- recommended

To build AVRDUDE for macOS using MacPorts, run the following commands:

port install cmake pkg-config hidapi libftdi1 libusb libelf libserialport
git clone https://github.com/avrdudes/avrdude.git
cd avrdude
./build.sh

To build AVRDUDE for macOS using Homebrew for macOS Intel or macOS Apple Silicon, run the following commands:

brew install cmake pkg-config hidapi libftdi libusb libelf libserialport
git clone https://github.com/avrdudes/avrdude.git
cd avrdude
./build.sh

Build Instructions with GNU Readline

macOS ships libedit which is a replacement of GNU Readline. As of Dec 2022, with the various fixes in place, libedit is considered as good enough for macOS for the purpose of avrdude, GNU Readline is not required.

In case you still prefer to use GNU Readline, you can follow the instructions below.

Homebrew:

brew install cmake hidapi libftdi libusb libelf readline libserialport
git clone https://github.com/avrdudes/avrdude.git
cd avrdude
(for macOS Intel)
cmake -D CMAKE_C_FLAGS=-I/usr/local/include -D CMAKE_EXE_LINKER_FLAGS=-L/usr/local/Cellar -D HAVE_LIBREADLINE:FILEPATH=/usr/local/opt/readline/lib/libreadline.dylib -D CMAKE_BUILD_TYPE=RelWithDebInfo -B build_darwin
(for macOS Apple Silicon) 
cmake -D CMAKE_C_FLAGS=-I/opt/homebrew/include -D CMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/Cellar -D HAVE_LIBREADLINE:FILEPATH=/opt/homebrew/opt/readline/lib/libreadline.dylib -D CMAKE_BUILD_TYPE=RelWithDebInfo -B build_darwin
cmake --build build_darwin

MacPorts:

port install cmake hidapi libftdi1 libusb libelf readline libserialport
git clone https://github.com/avrdudes/avrdude.git
cd avrdude
cmake -D CMAKE_C_FLAGS=-I/opt/local/include -D CMAKE_EXE_LINKER_FLAGS=-L/opt/local/lib -D CMAKE_BUILD_TYPE=RelWithDebInfo -B build_darwin
cmake --build build_darwin

Installation for MacPorts

To install a local build on your system for MacPorts, run the following commands:

sudo cmake --build build_darwin --target install

Installation of git main for Homebrew

Example run log.

mcuee@mcuees-Mac-mini ~ % brew install avrdude
==> Downloading https://formulae.brew.sh/api/formula.jws.json
############################################################################################################################# 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
############################################################################################################################# 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/avrdude/manifests/7.3
Already downloaded: /Users/mcuee/Library/Caches/Homebrew/downloads/dd48fff588b18c1065949ff85a7e767286dc3c96de049b1e8ef6bba405763ae1--avrdude-7.3.bottle_manifest.json
==> Fetching avrdude
==> Downloading https://ghcr.io/v2/homebrew/core/avrdude/blobs/sha256:7e4fbdde7efdd2122c7668c7ad8997c58c6f84577cd9622677eb2c09e0db48
############################################################################################################################# 100.0%
==> Pouring avrdude--7.3.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/avrdude/7.3: 14 files, 7.5MB
==> Running `brew cleanup avrdude`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
mcuee@mcuees-Mac-mini ~ % brew install avrdude --HEAD
Error: avrdude 7.3 is already installed
To install HEAD, first run:
  brew unlink avrdude
mcuee@mcuees-Mac-mini ~ % brew unlink avrdude
Unlinking /opt/homebrew/Cellar/avrdude/7.3... 7 symlinks removed.
mcuee@mcuees-Mac-mini ~ % brew install avrdude --HEAD
==> Fetching avrdude
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/b48fd4fca1f9a6988fb5058355df27d8d5651145/Formula/a/avrdude.
############################################################################################################################# 100.0%
==> Cloning https://github.com/avrdudes/avrdude.git
Updating /Users/mcuee/Library/Caches/Homebrew/avrdude--git
==> Checking out branch main
Already on 'main'
Your branch is up to date with 'origin/main'.
HEAD is now at 5c1649dc Update NEWS
==> cmake -S . -B build/shared -DCMAKE_INSTALL_SYSCONFDIR=/opt/homebrew/etc -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_RPATH=@loader_pat
==> cmake --build build/shared
==> cmake --install build/shared
==> cmake -S . -B build/static -DCMAKE_INSTALL_SYSCONFDIR=/opt/homebrew/etc
==> cmake --build build/static
🍺  /opt/homebrew/Cellar/avrdude/HEAD-5c1649d: 13 files, 6.8MB, built in 9 seconds
==> Running `brew cleanup avrdude`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /Users/mcuee/Library/Caches/Homebrew/avrdude--7.3... (1.6MB)

From now on, you can use brew reinstall avrdude to catch up with git main.