Get the SparkFun ProMicro working with inotool

2014-04-08 ยท 1197 words ยท 6 minute read

I’ve recently bought a few SparkFun ProMicro 5V 16Mhz clones from Ebay because they are extremely cheap (7 Euro each) and habe native USB. The only problem i had is that i was not able to program them using inotool .

The upload issue ๐Ÿ”—

To get them working with the Arduino IDE you simply have to download the so called “Arduino Addon files” from Sparkfun and place them in the hardware folder of your Arduino installation. The IDE then recognizes them and provides you the new board models for compilation and uploads. Sometimes it works, but somtimes it will not upload the compiled source and give me this error message:

1Found programmer: Id = "Hello w"; type = o
2    Software Version = H.e; Hardware Version = l.l
3avrdude: error: buffered memory access not supported. Maybe it isn't
4a butterfly/AVR109 but a AVR910 device?

As you can see you can read parts of the Hello World string that is continously sent by the Example 1: Blinkies! sketch that was running at the time i tried to upload source. This indicates that the software reset didn’t worked correctly for some unknown reason.

arduino modifications ๐Ÿ”—

So I decided to get this working with inotool to avoid using the Arduino IDE and probably fix the upload issue at the same time. I downloaded the Arduino Addon Files again and checked the contents:

 1    โ”œโ”€โ”€ boards.txt
 2    โ”œโ”€โ”€ bootloaders
 3    โ”‚ย ย  โ””โ”€โ”€ caterina
 4    โ”‚ย ย      โ”œโ”€โ”€ build.txt
 5    โ”‚ย ย      โ”œโ”€โ”€ Caterina.c
 6    โ”‚ย ย      โ”œโ”€โ”€ Caterina-fio.hex
 7    โ”‚ย ย      โ”œโ”€โ”€ Caterina.h
 8    โ”‚ย ย      โ”œโ”€โ”€ Caterina.hex
 9    โ”‚ย ย      โ”œโ”€โ”€ Caterina-lilypadusb.hex
10    โ”‚ย ย      โ”œโ”€โ”€ Caterina-makey.hex
11    โ”‚ย ย      โ”œโ”€โ”€ Caterina-minibench.hex
12    โ”‚ย ย      โ”œโ”€โ”€ Caterina-promicro16.hex
13    โ”‚ย ย      โ”œโ”€โ”€ Caterina-promicro8.hex
14    โ”‚ย ย      โ”œโ”€โ”€ Caterina-wiflyin.hex
15    โ”‚ย ย      โ”œโ”€โ”€ Descriptors.c
16    โ”‚ย ย      โ”œโ”€โ”€ Descriptors.h
17    โ”‚ย ย      โ”œโ”€โ”€ Makefile
18    โ”‚ย ย      โ”œโ”€โ”€ program.txt
19    โ”‚ย ย      โ””โ”€โ”€ Readme.txt
20    โ”œโ”€โ”€ driver
21    โ”‚ย ย  โ”œโ”€โ”€ FioV3.inf
22    โ”‚ย ย  โ”œโ”€โ”€ LilyPadUSB.inf
23    โ”‚ย ย  โ”œโ”€โ”€ MakeyMakey.inf
24    โ”‚ย ย  โ”œโ”€โ”€ Minibench.inf
25    โ”‚ย ย  โ”œโ”€โ”€ ProMicro.inf
26    โ”‚ย ย  โ””โ”€โ”€ WiFlyin.inf
27    โ”œโ”€โ”€ README.md
28    โ””โ”€โ”€ variants
29        โ”œโ”€โ”€ minibench
30        โ”‚ย ย  โ””โ”€โ”€ pins_arduino.h
31        โ””โ”€โ”€ promicro
32            โ””โ”€โ”€ pins_arduino.h
33
34    6 directories, 26 files
  • The boards.txt has the definitions for the 4 Sparkfun boards with AtMega32u4 processors (Pro Micro 5V, Pro Micro 3.3V, Fio 3.3V, Makey Makey).
  • In the bootloaders folder is a modified/extended version of the original caterina bootloader for the Leonardo.
  • The drivers folder contains the windows drivers for the boards.
  • variants contains the pin configurations.

If you simply install the Addon files as usually (copy the folder into the hardware folder), inotool recognizes the new boards, but fails to compile/upload. So i tried to integrate the new files into the original folders:

1sed -i 's/caterina/caterina-sparkfun/g' ~/Downloads/SF32u4_boards-master/boards.txt
2cat ~/Downloads/SF32u4_boards-master/boards.txt >> /usr/share/arduino/hardware/arduino/boards.txt
3cp -r ~/Downloads/SF32u4_boards-master/bootloaders/caterina/ /usr/share/arduino/hardware/arduino/bootloaders/caterina-sparkfun
4cp -r ~/Downloads/SF32u4_boards-master/variants/* /usr/share/arduino/hardware/arduino/variants/
  1. replace caterina in boards.txt with caterina-sparkfun. This makes sure that the modified bootloader is used and not the original one.
  2. append the contents of the new boards.txt to the original boards.txt.
  3. copy the new caterina bootloader into the original bootloaders folder, but rename it to caterina-sparkfun.
  4. copy the new variants into the original variants folder

If we now go into a inotool project and call ino list-models we get this list:

 1             uno: [DEFAULT] Arduino Uno
 2       atmega328: Arduino Duemilanove w/ ATmega328
 3       diecimila: Arduino Diecimila or Duemilanove w/ ATmega168
 4         nano328: Arduino Nano w/ ATmega328
 5            nano: Arduino Nano w/ ATmega168
 6        mega2560: Arduino Mega 2560 or Mega ADK
 7            mega: Arduino Mega (ATmega1280)
 8        leonardo: Arduino Leonardo
 9         esplora: Arduino Esplora
10           micro: Arduino Micro
11         mini328: Arduino Mini w/ ATmega328
12            mini: Arduino Mini w/ ATmega168
13        ethernet: Arduino Ethernet
14             fio: Arduino Fio
15           bt328: Arduino BT w/ ATmega328
16              bt: Arduino BT w/ ATmega168
17      LilyPadUSB: LilyPad Arduino USB
18      lilypad328: LilyPad Arduino w/ ATmega328
19         lilypad: LilyPad Arduino w/ ATmega168
20        pro5v328: Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328
21           pro5v: Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168
22          pro328: Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328
23             pro: Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168
24       atmega168: Arduino NG or older w/ ATmega168
25         atmega8: Arduino NG or older w/ ATmega8
26    robotControl: Arduino Robot Control
27      robotMotor: Arduino Robot Motor
28      promicro16: SparkFun Pro Micro 5V/16MHz
29       promicro8: SparkFun Pro Micro 3.3V/8MHz
30           fiov3: SparkFun Fio V3 3.3V/8MHz
31       minibench: SparkFun Makey Makey

inotool modifications ๐Ÿ”—

As you can see, at the end of the list are the new boards. If they do not appear, do a ino clean first. Now ino compiles our source but fails to upload it :-(

So we have to do a little modification to ino itself, see the Github diff of the original repo and my fork.

I simply changed the behavior of inotool to do a softwre reset with the 1200 Baud connect/disconnect method to happen whenever the specified bootloader for a certain board model starts with “caterina” instead of is equal to “caterina”.

compile and upload code ๐Ÿ”—

Compilation works like a charm:

 1    bouni@fnord: ~/tmp/blinky$ ino build -m promicro16
 2    Searching for Board description file (boards.txt) ... /usr/share/arduino/hardware/arduino/boards.txt
 3    Searching for Arduino lib version file (version.txt) ... /usr/share/arduino/lib/version.txt
 4    Detecting Arduino software version ...  1.0.5 (1.0.5)
 5    Searching for Arduino core library ... /usr/share/arduino/hardware/arduino/cores/arduino
 6    Searching for Arduino standard libraries ... /usr/share/arduino/libraries
 7    Searching for Arduino variants directory ... /usr/share/arduino/hardware/arduino/variants
 8    Searching for make ... /usr/bin/make
 9    Searching for avr-gcc ... /usr/bin/avr-gcc
10    Searching for avr-g++ ... /usr/bin/avr-g++
11    Searching for avr-ar ... /usr/bin/avr-ar
12    Searching for avr-objcopy ... /usr/bin/avr-objcopy
13    src/sketch.ino
14    Searching for Arduino lib version file (version.txt) ... /usr/share/arduino/lib/version.txt
15    Detecting Arduino software version ...  1.0.5 (1.0.5)
16    Scanning dependencies of src
17    Scanning dependencies of arduino
18    src/sketch.cpp
19    arduino/wiring_shift.c
20    arduino/WInterrupts.c
21    arduino/wiring_digital.c
22    arduino/wiring_pulse.c
23    arduino/wiring.c
24    arduino/wiring_analog.c
25    arduino/avr-libc/malloc.c
26    arduino/avr-libc/realloc.c
27    arduino/IPAddress.cpp
28    arduino/Stream.cpp
29    arduino/WString.cpp
30    arduino/Print.cpp
31    arduino/Tone.cpp
32    arduino/USBCore.cpp
33    arduino/HID.cpp
34    arduino/main.cpp
35    arduino/HardwareSerial.cpp
36    arduino/WMath.cpp
37    arduino/new.cpp
38    arduino/CDC.cpp
39    Linking libarduino.a
40    Linking firmware.elf
41    Converting to firmware.hex

And upload also:

 1    bouni@fnord: ~/tmp/blinky$ ino upload -m promicro16
 2    Guessing serial port ... /dev/ttyACM0
 3
 4    Connecting to programmer: .
 5    Found programmer: Id = "CATERIN"; type = S
 6        Software Version = 1.0; No Hardware Version given.
 7    Programmer supports auto addr increment.
 8    Programmer supports buffered memory access with buffersize=128 bytes.
 9
10    Programmer supports the following devices:
11        Device code: 0x44
12
13    avrdude: AVR device initialized and ready to accept instructions
14
15    Reading | ################################################## | 100% 0.00s
16
17    avrdude: Device signature = 0x1e9587
18    avrdude: reading input file ".build/promicro16/firmware.hex"
19    avrdude: writing flash (6076 bytes):
20
21    Writing | ################################################## | 100% 0.48s
22
23    avrdude: 6076 bytes of flash written
24    avrdude: verifying flash memory against .build/promicro16/firmware.hex:
25    avrdude: load data flash data from input file .build/promicro16/firmware.hex:
26    avrdude: input file .build/promicro16/firmware.hex contains 6076 bytes
27    avrdude: reading on-chip flash data:
28
29    Reading | ################################################## | 100% 0.05s
30
31    avrdude: verifying ...
32    avrdude: 6076 bytes of flash verified
33
34    avrdude: safemode: Fuses OK (H:CB, E:D8, L:FF)
35
36    avrdude done.  Thank you.