Part 4 - Installing firmware

This involves a whole bunch of steps. Here's what I did, and hopefully one of the least painful ways to do it. I used Windows 7.

Summary:

  • Decide on layout, save as .json.
  • Setup firmware (pins on micro-controller, key layout from previous step). Build to a .hex file
  • Flash the firmware on to the pro micro.

Step 1 - Decide on layout/layers, save as .json.

Use http://www.keyboard-layout-editor.com/ to generate a .json file with your layout/layers. Select "Default 60%" layout to get started.

Look for the .json export and save it out. You can also copy/paste it from the "Raw data" tab. You'll get a file that looks vaguely like:

["~\n`","!\n1","@\n2","#\n3","$\n4","%\n5","^\n6","&\n7","*\n8","(\n9",")\n0","_\n-","+\n=",{w:2},"Backspace"],
[{w:1.5},"Tab","Q","W","E","R","T","Y","U","I","O","P","{\n[","}\n]",{w:1.5},"|\n\\"],
[{w:1.75},"Caps Lock","A","S","D","F","G","H","J","K","L",":\n;","\"\n'",{w:2.25},"Enter"],
[{w:2.25},"Shift","Z","X","C","V","B","N","M","<\n,",">\n.","?\n/",{w:2.75},"Shift"],
[{w:1.25},"Ctrl",{w:1.25},"Win",{w:1.25},"Alt",{a:7,w:6.25},"",{a:4,w:1.25},"Alt",{w:1.25},"Win",{w:1.25},"Menu",{w:1.25},"Ctrl"]
for each layer

Step 2 - Build the firmware online (TMK)

Go to http://kb.sized.io - this lets you build the firmware online. Hit "upload .json" and upload the json from stage one.

Go through each stage, making sure each part is correct. Use this mapping ("AVR") column to help you do the mappings.

Make sure each column has a pin, and each row has a pin. No room for any LEDs.

Diode Direction - Column To Row

Bootloader Size - 4096KB

If you press "Download configuration", it will save a .json file with all your pinouts and all the work you've done on this site. You can

use this again on later if you need to rebuild the firmware (e.g. change key layout, or you messed up the pins).

After you're all happy, press "Download .hex file". The .hex file is the compiled code that goes on the pro micro. It is already

compiled for you on via the website. Pretty neat!

Step 3 - Getting the .hex file onto the pro micro

This part involves lots of steps. Here is my experience, though you will probably want to read other peoples guides and form your own idea of what to do.

First, a brief explanation on bootloader mode.

The pro micro has two modes: "regular" mode and "bootloader" mode. When in regular mode, it runs whatever code was in the .hex file.

When in bootloader mode, it sits around, letting you flash a new .hex file. To Set your pro micro to bootloader mode, you have to:

  • Unplug Pro micro from computer. If your computer thought it was a device (e.g. keyboard), wait for the device to disappear from device manager. This can take around 20-30 seconds.
  • Short (aka connect the two pins) "ground" and "reset". Do this while the pro micro isn't connected to the computer.
  • Plug the pro micro into the computer
  • Quickly unshort (remove paperclip from ground) and re-short (reconnect paperclip to reset/ground) a few times.
  • You can make this easier by connecting a button, or even just wiring two extension wires to the pro micro.

Step 3.1 - Making your computer recognize the pro micro

  • Open Device Manager, and put your pro micro into bootloader mode - a device should pop up on one of your COM Ports. I got COM4. Note which COM port the devices pops up in bootloader mode. I got COM5 for regular mode, COM4 for bootloader.
  • If not, you're out of luck. Try another method (look around on the internet). Maybe your Arduino didn't come with a bootloader (so when you short the pins, nothing happens. If that's the case, you're in real trouble. Maybe you didn't get into bootloader mode properly with the paperclip).

Step 3.2 - Flashing the firmware

We use a program called "AVRDude" to push the .hex file from our computer to the pro micro

  • First, download and unzip WinAVR: http://blog.zakkemble.co.uk/avr-gcc-builds/
  • Go to the "bin" directory in windows explorer. Confirm there is an "avrdude.exe" lying around.
  • Copy your .hex file into this directory.
  • Hold [Shift] then [Right-click], select "Open cmd terminal here"
  • Now we want to flash the firmware. Type (or copy) this command. Replace COM4 with correct port, and filename.hex with your .hex
  • avrdude -p atmega32u4 -P COM4 -c avr109 -U flash:w:filename.hex
  • When you run it, it will fail because you aren't in bootloader mode.
  • Put your pro micro into bootloader mode. Watch Device manager. When it pops up, quickly go back to your command prompt and hit [Up Arrow] (this brings previous command) and then press enter to execute it. You can also spam up and enter a whole bunch.
  • If you get the timing right, it will start uploading the .hex to the Pro micro
  • It might take a few tries to get the timing right. Remember you only have EIGHT seconds to upload the .hex.
  • After the 8 Seconds elapses, the pro micro goes back into "Regular" mode. So if your flash was successful, it will load the keyboard code, and you can use the keyboard!