Friday, October 13, 2017

PI Zero TMK ISP

Using a Raspberry Pi to compile TMK and as an ISP programmer

I have been using Raspberry Pi's for various things since they have been generally available. They make great general purpose embedded computers. Since they are running Linux they can be made to do just about anything.

The default Raspbian distribution has everything necessary to compile TMK. There are many guides to setting up Raspbian. Once you have it up and running you need only run the following command to install all the additional software for compiling.

sudo apt install gcc-avr avr-libc dfu-programmer git

That installs the gcc avr compiler and the avr libraries for the ATmega series of chips. dfu-programmer is for programming chips over USB with the DFU protocol. git is for cloning the TMK code from github.

git clone https://github.com/di0ib/tmk_keyboard.git

This will clone my fork of TMK.

This video shows the whole process. I did it on a Raspberry Pi Zero, it will work the same on a Raspberry Pi 3 or 2, or the original Pi.


I also tested this on a Raspberry Pi 3. It compiles in half the time as the Zero. 28 seconds vs 59 seconds to compile the default Gherkin firmware.

Pi GPIO ISP

I did not install avrdude from the Raspbian repository. Instead I installed it manually using the instructions on Adafruit. They have detailed instructions on how to install a custom version of avrdude that supports the GPIO outputs of the Raspberry Pi.

I used the same pogo pin contraption I use with my other programmer.

 Pogo pins to connect to a Pro Micro.

 Connected to the Raspberry Pi GPIO header with jumper wires.

Closeup of the connections on the GPIO header.

I tested this on a Raspberry Pi Zero with USB WiFi. I controlled it remotely over the network through a SSH session.

The Raspberry Pi Zero (W) does not come with a header installed. The normal sized Raspberry Pi 2 and 3 do have the header installed.

What can you do with an ISP programmer?

You can program the Atmel chip directly without using the bootloader code. You can also replace the existing bootloader with a different one. Or, if you want all the space available, you can overwrite the bootloader and use all the flash space for your code, and not have a bootloader.