2016-04-17

Arduino-MK with Sparkfun Pro Micro 3.3V

Arduino-Makefile needed coaxing to in order to compile code targeting the SparkFun Pro Micro 3.3V. A major source of headache is the requirement for BOARD_SUB which isn't documented and required diving into the source code, and also the fact the Pro Micro has 2 PIDs for each variant (5V and 3.3V).

Hope this will help someone in the same position as me. This makefile is meant for use on Debian Linux, with Arduino-MK installed via apt-get install arduino-mk.

MONITOR_PORT = /dev/ttyACM0

# this should point to where the sparkfun board definitions are installed
SPF_AVR_PATH = $(HOME)/.arduino15/packages/SparkFun/hardware/avr/1.1.3

# Use own arduino install which is way more advanced than the default 1.0
# installed by arduin-core
ARDUINO_DIR = $(HOME)/arduino-1.6.7

USER_LIB_PATH := $(HOME)/Arduino/libraries

# this is needed to stdint.h exposes needed #defines
CPPFLAGS += -std=gnu++11 

# this is needed so we don't run into __cxa_guard_acquire issues
CPPFLAGS += -fno-threadsafe-statics 


BOARD_TAG          = promicro
BOARD_SUB      = 8MHzatmega32U4
# also Arduino-mk isn't clever enough yet to properly extract PID from
# boards.txt, so we specify it here for now
USB_PID       = 0x9204
ALTERNATE_CORE    = promicro8
ALTERNATE_CORE_PATH = $(SPF_AVR_PATH)
BOOTLOADER_PATH    = caterina
BOOTLOADER_FILE    = Caterina-promicro8.hex
ISP_PROG           = usbasp


include /usr/share/arduino/Arduino.mk

Cheers,
Steve