Archive for the ‘Microcontrollers’ Category

Cheap Chinese USB ISP Programmers

Saturday, August 1st, 2015

The assembled unit, ready for use

The assembled unit, ready for use (click to zoom)

I bought one of these convenient little USB ISP programmers from a Chinese mail-order supplier while stocking up on Arduino parts and tools. I didn’t have a particular use in mind at the time, it was just an impulse purchase and I tossed it in my tool box without trying it out. Yesterday I suddenly wanted to examine the embedded AVR chip in a production device (not my own project) and dug out this programmer and tried to use it.

It turns out that most of these cheap Chinese USB ISP programmers (there are many variations and sellers) are shipped with firmware that doesn’t work with avrdude (the standard open-source AVR programming software). Fortunately, they are built out of an Atmel MEGA8 microcontroller, and it is usually possible to install the excellent, open-source USBasp firmware on them. Doing this can be tricky, however; the various designs use various different MEGA8 pin assignments for some of their functions.

The guts of the programmer showing the temporary tiny wire modification

The guts of the programmer showing the temporary tiny wire modification (click to zoom)

The one I have is a bit unusual in its use of GPIO pins so I had to make some changes to the code. But more annoying was the fact that it didn’t have a provision for (self) programming – no jumper or pad for connecting the reset signal for in-circuit programming. So to re-program it I had to solder a wire from one of the AVR pins to one of the ISP connector pins. And of course, after all that, to program it I needed – what else – a programmer. Luckily, I had an Atmel STK-500, which is a bit awkward to use, but worked well enough.

My modified USBasp code is here: source patch binary image
The site I bought it from is here: USB 2.0 ISP ASP Programmer Download Adapter
(But I don’t particularly recommend this seller because they take months to deliver to the US.)

Thank you to CE’s & PP’s Tech Blog for a good description of a similar hack to a similar cheap Chinese USB programmer.

The original firmware looked like this when connected:

usb 2-1.3: new low-speed USB device number 14 using ehci-pci
usb 2-1.3: New USB device found, idVendor=03eb, idProduct=c8b4
usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 2-1.3: Product: USBHID
usb 2-1.3: Manufacturer: zhifengsoft
hid-generic 0003:03EB:C8B4.0007: hiddev0,hidraw2: USB HID v1.01 Device [zhifengsoft USBHID] on usb-0000:00:1d.0-1.3/input0

Super-easy Teensy 3.1 Development Tools on Ubuntu

Wednesday, June 17th, 2015

I’ve been playing with Arduino and other small embedded controller prototyping systems in anticipation of a few cool projects I’m considering. The Arduino tool chain is very easy to set up on Ubuntu; basically one apt-get command will do it, installing the IDE, compiler, download tools, example programs, and everything. I’ve built and run several Arduino example sketches on a Duemillanove and a Bare Bones Board that I had lying around.

Another appealing controller family is the Teensy series, which has both AVR and ARM variants. I had picked up a couple of the ARM boards (Teensy 3.1 and Teensy LC) at Maker Faire and wanted to try them out. They can be used within the Arduino IDE but only if you have certain combinations of Arduino and Teensy software versions, and the Arduino version provided in the Ubuntu repo is not compatible. I could have built the Arduino tools from source but I really didn’t want to mess with the perfectly functional version that Ubuntu installed. So I started looking into setting up a pure ARM cross tool chain and writing code directly for the Freescale processor on the Teensy boards.

I couldn’t find anyone who had done this on Ubuntu using the stock Ubuntu packages for GCC and friends, but I found a good description by Karl Lunt of how he set up the tool chain on Windows: Bare-metal Teensy 3.x Development. Karl also had gathered the essential header files from Freescale, added the necessary C run time start code and linker script, and created a few useful library functions and demo programs, and of course, a Makefile. It only took a few tweaks to combine Karl’s files, standard Ubuntu packages, and the Teensy download tool into a working cross-developement tool set.

Here’s how you can do it:

# Install the ARM compiler from Ubuntu:
sudo apt-get install binutils-arm-none-eabi gcc-arm-none-eabi

# Install the Teensy download/reboot utility
case `uname -i` in
*_64) f=teensy.64bit.gz;;
*) f=teensy.gz;;
mkdir -p $HOME/bin
gunzip <$f >$HOME/bin/teensy
chmod a+rx $HOME/bin/teensy
rm $f
sudo mv 49-teensy.rules /etc/udev/rules.d

# Download Karl Lunt's archive of Teensy headers and support code:
mkdir teensy
unzip -d teensy
sed -i s/mk20d7/MK20D7/ teensy/include/common.h

# Download Karl Lunt's "blinky" demo program:
unzip blinky.c

# Download my tuned-for-Linux Makefile:

# That's it!
echo 'Now run "make"'

You can find the above steps in a ready-to-run script here.

Of course, you can copy and modify the Makefile to build your own projects.

My next step will be to try to add Teensy LC support.