Getting Started with Adafruit's WICED Feather on Fedora


UPDATE, 2016-04-04: Quick update to clarify how the new udev rules get applied after creating the file. No reboot or service restart required.

UPDATE, 2016-04-03: Just as I was about to post this write-up, I discovered some of the info below is included in the README.md included in the BSP files. Their information is only for Debian/Ubuntu distros and they incorrectly state that you need to restart udev for the rules changes to take effect. But hey - the info was there if you knew where to look.


I recently picked up Adafruit's latest Feather board - the the WICED Feather. They have a really great tutorial but it's light on tips and tricks for using the boards under Linux. I thought I'd write down what I had to do to start working with the board on my system in the hopes that it's useful to others. Or at least to me in the future ;)

NOTE: My desktop is running Fedora 23, so the file locations and package names are based on that. They should be similar to Debian or Debian-based systems, but you'll likely have to translate appropriately.

udev Prereqs

If you've ever programmed Arduinos or other microcontrollers on Linux, you probably know what a pain in the butt it is to deal with permissions and the udev rules needed to make things work for a normal, non-root user. The WICED is extra special because it will identify itself as two different USB PIDs to your host system depending on which mode it is in. In normal mode, it uses PID 0010 and in DFU mode, it uses 0008. This tripped me up until I double checked my kernel output and found the second PID when the WICED goes into DFU mode.

When in normal mode, here is an example of what you should see when you connect the board to your Linux box. I've removed the date/time and hostname to make it easier to read.

kernel: usb 3-9.1: USB disconnect, device number 18
kernel: usb 3-9.1: new full-speed USB device number 19 using xhci_hcd
kernel: usb 3-9.1: New USB device found, idVendor=239a, idProduct=0010
kernel: usb 3-9.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
kernel: usb 3-9.1: Product: WICED Feather Board
kernel: usb 3-9.1: Manufacturer: Adafruit Industries
kernel: usb 3-9.1: SerialNumber: 00000000001B
kernel: cdc_acm 3-9.1:1.0: ttyACM0: USB ACM device
kernel: cdc_acm 3-9.1:1.2: ttyACM1: USB ACM device

Notice Adafruit's VID (239a) and the board's PID (0010). When you put the board into DFU mode, either manually (double-clicking the reset button) or when uploading code via the Arduino IDE, you'll see something like this in your kernel logs:

kernel: usb 3-9.1: USB disconnect, device number 19
kernel: usb 3-9.1: new full-speed USB device number 20 using xhci_hcd
kernel: usb 3-9.1: New USB device found, idVendor=239a, idProduct=0008
kernel: usb 3-9.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
kernel: usb 3-9.1: Product: WICED Feather DFU
kernel: usb 3-9.1: Manufacturer: Adafruit Industries
kernel: usb 3-9.1: SerialNumber: 00000000001C

Notice that bot the PID and SerialNumber have changed, but the VID has stayed the same. We'll need to account for both of these PIDs in our udev rules. I have the following in /etc/udev/rules.d/50-arduino.rules:

# Adafruit devices
ATTRS{idVendor}=="239a", ENV{ID_MM_DEVICE_IGNORE}="1"
# WICED Feather
ATTRS{idVendor}=="239a", ATTRS{idProduct}=="0010", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="239a", ATTRS{idProduct}=="0010", ENV{MTP_NO_PROBE}="1"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="239a", ATTRS{idProduct}=="0010", GROUP:="wheel", MODE:="0660"
ATTRS{idVendor}=="239a", ATTRS{idProduct}=="0008", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="239a", ATTRS{idProduct}=="0008", ENV{MTP_NO_PROBE}="1"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="239a", ATTRS{idProduct}=="0008", GROUP:="wheel", MODE:="0660"

Note that I set the group ownership above to the wheel group. You can use whatever group you want, so long as the the user you're logging in as is a member of that group.

I've also added lines to prevent the MTP and ModemManager subsystems from probing the device when connected.

Once you have your udev rules file all set up, all you need to do is connect your device and the proper files with your specified permissions and ownership will be created. No need to reboot or restart services. If you already had your Feather connected to your host before you created the rules file, simply disconnect, count to five or so, and reconnect.

Additional OS Packages

Next, you'll need to install some support packages that are either required by the BSP provided by Adafruit, or are handy when working with the board.

sudo dnf install pyusb python-click dfu-util

The pyusb and python-click packages are used by the feather_dfu.py command that is part of the BSP. The dfu-util binary is included for OS X and Windows in the BSP, but not Linux - it relies on the tool installed elsewhere on the system.

Arduino BSP

Make sure you have the Arduino IDE/environment installed and functioning. I downloaded the latest as of this writing (1.6.8) and so far I haven't had any issues.

Now you can follow the Adafruit tutorial's instructions to install the BSP. I used the git option and things worked fine.

Serial Port options

Per the Adafruit tutorial, the serial ports ended up being ordered as-described. /dev/ttyACM0 is the "programming" port and should be used as the target in the Arduino IDE and /dev/ttyACM1 is the "debug" port that currently responds to AT-style commands.

Quirks and Wrap-up

That's it - you should be able to flash your WICED Feather with your code now.

I will note that I've seen the following output when I flash code:

Sketch uses 27,104 bytes (20%) of program storage space. Maximum is 131,072 bytes.
Global variables use 5,560 bytes of dynamic memory.
dfu-util 0.8

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Opening DFU capable USB device...
ID 239a:0008
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 1024
DfuSe interface name: "Internal Flash   "
Downloading to address = 0x080e0000, size = 32264
Download	[=========================] 100%        32264 bytes
Download done.
File downloaded successfully
dfu-util: Error during download get_status

Ignoring dfu-util complaining about an invalid suffix signature (???), even though the last message is an error, note that it does show that the code downloaded successfully and it does in fact work. I'm writing this off as part of the "Developer Edition" quirks mentioned on the product page. I was clearly warned and I expected this.

Happy flying with your new Feather(s)!