-
Notifications
You must be signed in to change notification settings - Fork 47
Appendix E: Flashing a Bootloader
You only need to flash a bootloader if you're building a Ploopy Nano Trackball from scratch, or if your bootloader has become corrupted in some way.
This guide will cover a method for flashing a bootloader onto the Ploopy Nano Trackball. Note, however, that there are alternative methods available; this simply covers one such method.
Programming a bootloader is much different than programming QMK or any other firmware. To do so, we need to use a special connector on the Ploopy PCB called the ICSP header. Your PCB will probably just have six holes in the PCB, with no plastic connector prongs jutting out of the board. That's perfectly usable, and you won't need to add a connector in order to proceed.
You'll need a programmer. A "programmer" can be many different things. We use an Arduino Nano and six pieces of jumper wire (copper wire, nothing fancy) to program bootloaders, but many different kinds of programmers can be used. See this list for more examples.
The remainder of this guide will assume that you're using an Arduino Nano to reprogram your Ploopy device. If you're using another programmer, you may need to make adjustments to these steps.
- The Arduino IDE
- An Arduino Nano (I get them on Amazon)
- A USB mini-B to USB A cable (something like this)
- Hookup wire (something like this; any breadboard jumper wire or 24AWG hookup wire will do fine)
- A 10uF capacitor (something like this)
You can find a copy of the necessary bootloader here. Download and save it. For the purposes of this guide, it will be assumed that you saved the file as bootloader_atmega32u4_1.0.0.hex
.
avrdude
is the software that we'll use to flash the bootloader. It runs on Windows, Mac, and Linux, so you should be good to go.
Verify that it's installed by opening up a terminal window (cmd
on Windows machines). Typing in avrdude
should show that it's installed.
If you've got an Arduino Nano, you'll need to program the Arduino Nano with the ArduinoISP sketch so that it can program the Ploopy PCB.
You'll only need to do this step once. If your Arduino Nano is already programmed to be an ArduinoISP, skip this step.
- Plug your Arduino Nano into your computer (via its USB mini-B port).
- The Arduino Nano should have a few status LEDs that illuminate when it's powered on.
- You don't need the Ploopy PCBs for this step. You can put them aside for now.
- Fire up the Arduino IDE (install it if you don't already have it installed).
- Open up the ArduinoISP sketch in Arduino IDE (in
File -> Examples -> 11.ArduinoISP -> ArduinoISP
). - Upload the ArduinoISP sketch onto the Arduino Nano.
- Make sure that, in the Arduino IDE,
Tools > Board
is set toArduino Nano
andTools > Programmer
is set toAVRISP mk II
.
- Make sure that, in the Arduino IDE,
If the Arduino IDE reports that you successfully flashed the firmware onto the Arduino Nano, then you're done.
The Ploopy PCB ICSP header consists of six holes (or six pins, if you've added a connector). The pins are numbered like this:
1 -> ■ o <- 2
3 -> o o <- 4
5 -> o o <- 6
Note that pin 1 is a square pad on the board. Also, this is the way the header looks when viewed from the top of the board (i.e. when the microcontroller is visible). Here's a picture of what it looks like.
Hook up the ICSP connector on the Ploopy PCB to the programmer. If you're using an Arduino Nano, make the following connections:
ICSP Pin 1 -> Arduino Pin D12 (MISO)
ICSP Pin 2 -> Arduino 5V (V_USB)
ICSP Pin 3 -> Arduino Pin D13 (SCLK)
ICSP Pin 4 -> Arduino Pin D11 (MOSI)
ICSP Pin 5 -> Arduino Pin D10 (RST/CS)
ICSP Pin 6 -> Arduion GND (GND)
If your board doesn't have a header soldered to it (i.e. there are holes that go straight through the board instead of pins that jut out of the board), you'll need to ensure good physical contact between the wire and the pin holes in order for the programming step to work.
Take a 10uF capacitor and hook it up to the Arduino Nano, between the RST and GND pin.
Once the programmer is connected to your computer and the Ploopy PCB is connected to the programmer, it's time to flash the bootloader.
Open up a terminal, and navigate to the location where your bootloader hex file is located. Use the following command to flash the bootloader onto the device via avrdude:
avrdude -p m32u4 -c avrisp -b 19200 -U flash:w:bootloader_atmega32u4_1.0.0.hex -U lfuse:w:0x5e:m -U hfuse:w:0x99:m -U efuse:w:0xc3:m -P /dev/ttyUSB3
/dev/ttyUSB3
is just a placeholder. You'll need to verify which USB port your programmer is connected to.
If programming with Windows, you'll replace /dev/ttyUSB3
with something like COM3
.
Once successfully flashed, the only thing running on the ATmega32u4 is the bootloader code. Effectively, it's in bootloader mode.
You can now use the regular technique of flashing new QMK firmware onto the Ploopy PCB. You can check that out at Appendix D: QMK Firmware Programming.
If something is clear, check out the QMK ISP programming guide.
Copyright (C) 2021, Ploopy Corporation.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".