reasonably untitled

Setup Your Adafruit Flora With Arduino 1.5.5 And Arduino Eclipse

18 May 2014

Using an Adafruit Flora with Arduino 1.5.5 and Arduino Eclipse

This blogpost should apply to most linux distributions. It has been tested with Linux Mint 15.

Eclipse

To set up eclipse to work with the adafruit flora [1] you first need to get the arduino eclipse plugin [2] either from the eclipse marketplace or you follow the instructions given on its page.

For me it worked with eclipse kepler without any issues until now.

Arduino IDE and Florafication

I downloaded the arduino IDE version 1.5.5 from [3] and extracted the archive.

The next steps are taken from [4] and somehow modified to apply for IDE version 1.5.5.

You still have to follow the instructions to download the header file pins_arduino.h and the bootloader Caterina-Flora8.hex from [4].

The boards.txt modifications I did are as follows, it’s somehow a mixup of [5] and several other blog posts.

##############################################################

flora8.name=Adafruit Flora
flora8.upload.tool=avrdude
flora8.upload.protocol=avr109
flora8.upload.maximum_size=28672
flora8.upload.speed=57600
flora8.upload.disable_flushing=true
flora8.upload.use_1200bps_touch=true
flora8.upload.wait_for_upload_port=true
flora8.bootloader.tool=avrdude
flora8.bootloader.low_fuses=0xff
flora8.bootloader.high_fuses=0xd8
flora8.bootloader.extended_fuses=0xcb
flora8.bootloader.path=caterina
flora8.bootloader.file=Caterina-Flora8.hex
flora8.bootloader.unlock_bits=0x3F
flora8.bootloader.lock_bits=0x2F
flora8.build.mcu=atmega32u4
flora8.build.f_cpu=8000000L
flora8.build.vid=0x239A
flora8.build.pid=0x8004
flora8.build.usb_product="Adafruit Flora"
flora8.build.core=arduino
flora8.build.variant=flora
flora8.build.extra_flags={build.usb_flags}

Now it’s time to patch the header and source files of the arduino standard library as described in [6]. Just execute the batch file below.

# /bin/bash
# originally from http://www.baeyens.it/eclipse/installAdvice.shtml
arch=avr
prepend="#ifdef ARDUINO_ARCH_"${arch^^}
append="#endif ARDUINO_ARCH_"${arch^^}
find -path "*/arch/${arch}/*.cpp" -or -path "*/arch/${arch}/*.h" -or -path "*/arch/${arch}/*.c" |xargs -I % sh -c "sed -i.bak \"1i ${prepend}\" %; echo "">> %; echo \"$append\">> %;"
arch=sam
prepend="#ifdef ARDUINO_ARCH_"${arch^^}
append="#endif ARDUINO_ARCH_"${arch^^}
find -path "*/arch/${arch}/*.cpp" -or -path "*/arch/${arch}/*.h" -or -path "*/arch/${arch}/*.c" |xargs -I % sh -c "sed -i.bak \"1i ${prepend}\" %; echo "">> %;echo \"$append\">> %;"

USB changes

As the Adafruit Flora has its own USB device ID, the USBCore from Arduino has to be patched to support the Flora and also the kernel has to be aware what to do (and more important what NOT to do) with the unknown USB device ID.

You have to patch the file USBCore.cpp in the folder <your arduino 1.5.5 installation>/hardware/arduino/avr/cores/arduino/

--- a/hardware/arduino/avr/cores/arduino/USBCore.cpp
+++ b/hardware/arduino/avr/cores/arduino/USBCore.cpp
@@ -60,6 +60,8 @@
 #define USB_MANUFACTURER "Arduino LLC"
 #elif USB_VID == 0x1b4f
 #define USB_MANUFACTURER "SparkFun"
+#elif USB_VID == 0x239A
+#define USB_MANUFACTURER "Adafruit"
 #elif !defined(USB_MANUFACTURER)
 // Fall through to unknown if no manufacturer name was provided in a macro
 #define USB_MANUFACTURER "Unknown"

Now add a UDEV rule for the Flora that assigns the correct group to the device and tells the ModemManager to ignore the device. Add the following lines to the file /etc/udev/rules/90-flora.rules - you have to be root to do this.

SUBSYSTEMS=="usb",ATTRS{idVendor}=="239a",ATTRS{idProduct}=="0004",MODE="0660",GROUP="plugdev",ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEMS=="usb",ATTRS{idVendor}=="239a",ATTRS{idProduct}=="8004",MODE="0660",GROUP="plugdev",ENV{ID_MM_DEVICE_IGNORE}="1"

That should it be pretty much.

References

[1] https://learn.adafruit.com/getting-started-with-flora

[2] http://www.baeyens.it/eclipse

[3] http://arduino.cc/en/Main/OldSoftwareReleases

[4] https://learn.adafruit.com/getting-started-with-flora/ide-florafication

[5] http://matthewarcus.wordpress.com/2013/05/18/fun-with-flora

[6] http://www.baeyens.it/eclipse/installAdvice.shtml

Tweet