There’s a neat little Arduino-like microcontroller board with a very powerful PIC32 called the USB 32-Bit Whacker (UBW32) that can be had for $40 from Sparkfun. Side-by-side, the UBW32 blows the Arduino Mega out of the water! The UBW32 is a 32-bit microcontroller, runs at 80 MHz, packs 128 KB RAM, 512 KB Flash, and has 78 IO pins! Compare that with the top of the line Arduino — the Arduino Mega 2560 — which is an 8-bit microcontroller, runs at 16 MHz, and only has 8 KB and 256 KB of RAM and Flash, respectively. Almost 50% more expensive, the Mega can only process roughly 5% of what the beastly UBW32 can do.
Now, programming the UBW32 isn’t quite as easy as programming the Arduino’s, so I hope to spread some light on how to program it. First, unlike older microcontrollers you do not need a dedicated hardware programmer. It comes shipped with a USB Bootloader that allows you to easily upload new firmware to it. Because this article’s title implies doing this with Linux, and because I like Linux more than the other operating systems out there, I’ll only be concentrating on delivering the steps on how to do this with Linux. Additionally, there is a wealth of information on the web dealing with the PIC32 on Windows, whereas that is not so true with Linux.
Probably one of the first things you’ll want to do when you receive your UBW32 is to add some 0.1″ male headers along the length of the underside of the board so you can easily plug it into a breadboard. Also, I’d suggest adding an 8-pin male or female (doesn’t matter which) on the top of the board, opposite the side of the USB connector.
Here’s a picture of the unpopulated UBW32 as it comes from Sparkfun:
So, whether or not you’ve soldered the headers to the board, let’s connect to it and issue some commands to the firmware. I’m using Ubuntu 11.10 (Oneiric) with minicom (sudo apt-get install minicom) so the command I use to connect to the board is:
minicom -D /dev/ttyACM0
Your serial device could be in another location. “lsusb” and “ls /dev/tty*” will help your out in the shell.
Once I’ve connected I get the following text:
Welcome to minicom 2.5
Compiled on May 2 2011, 10:05:24.
Press CTRL-A Z for help on special keys
AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0
!8 Err: Unknown command 'AT:4154'
You can safely ignore this as minicom, by default, is treating your device as a modem and trying to send it “AT” commands. Type in “V” and hit enter. This will give you the version number. If Sparkfun decides to ship these with the newest firmware (1.6.3 as of this writing) and you see this in the output, then great! You don’t need to hastle with upgrading the firmware and you can wait till I publish the next article in this series.
Otherwise, if you get “UBW32 Version 1.4” like I did, this is how you go about upgrading the firmware. You’ll need libhid-dev which is no longer in the Ubuntu repositories. The yaVDR PPA has these packages, so if you’re on 11.10, add these to your repositories:
deb http://ppa.launchpad.net/yavdr/main/ubuntu oneiric main
deb-src http://ppa.launchpad.net/yavdr/main/ubuntu oneiric main
Then, just “sudo apt-get install libhid-dev” and you’re one step closer…
Now download the programmer from http://members.dslextreme.com/users/paintyourdragon/uc/ubw32/ubw32.tar.bz2, extract it, and “cd” to that directory. “make”, “sudo make install”, and “sudo chmod +s /usr/local/bin/ubw32”. Now download the latest version of the firmware from http://www.schmalzhaus.com/UBW32/ and extract it. Now do “ubw32 -w D32.hex -n -r” which will erase the current firmware on your board, upload the new one (D32.hex), NOT verify the write, and reset the device.
You’re now all set! In later articles, I’ll possibly go into installing MPLAB X — the cross-platform Microchip IDE, — installing the C32 compiler, installing gcc for the pic32’s, etc. My ultimate goal with this device is to create a “Universal bus interrogator” which reads and writes several protocols like SPI, I2C, MIDI, etc. like the Bus Pirate with an oscilloscope, spectrum analyzer, and logic analyzer and have it all controllable via Python. For now, here are some references which you may find useful: