Who says you have to have an USBasp AVR programmer to flash the KK2.0 or KK2.1? I have flashed ATTiny microcontrollers before using Arduino as the ISP programmer, so why not try that on the KK2.0? And I happen to have a couple of Arduinos hanging around, so I decided to give it a try. I will show you how I flash KK2.0 flight controller using the Arduino.
These instructions should work for both the Arduino Uno and the Arduino Mega. it saves you money buying extra parts when you have the Arduino available.
Note that this tutorial also works with KK2.1, the latest KK2 board.
Preparation for Flashing the KK2 board with ArduinoSoftware wise, you need follow these steps first.
- Install Arduino IDE 1.0.5 or later version.
- Download the KK 2.0 windows flashing tool.
- Downloaded the latest Firmware for the KK 2.0 board.
- Unzip all files.
- Hobbyking KK 2.0 flight controller board.
- One of the Arduino Board such as Arduino Uno, Nano, or Mega.
- A 10 uF Capacitor (optional)
- Some female to female and Male to Female jumper wires.
Arduino Setup and Wire ConnectionDo not power up anything just yet.
First you need to connect your Arduino to your PC using USB cable, in the IDE open up the example sketch in File->Examples->ArduinoISP. Upload this sketch to your Arduino, it will make your Arduino an ISP programmer.
Connect the Arduino and the KK2.0 board according to the following pin layout
click picture to enlarge.
Arduino Uno / Nano
Arduino Pin 10 – SS / Reset Arduino Pin 11 – MOSI Arduino Pin 12 – MISO Arduino Pin 13 – SCKArduino Mega
Arduino Pin 50 – MISO Arduino Pin 51 – MOSI Arduino Pin 52 – SCK Arduino Pin 53 – SS / ResetDo not power the KK 2.0 with your arduino, and avoid sharing the same power source. You might failed if you do that. The easiest thing to do is, power your Arduino with the USB cable from the computer, and use external power source to power your KK board, for example an ESC 5V BEC from your quadcopter.
Now power up your KK2.0 board.
Next you need to put a 10 uF capacitor between the SS/Reset pin and the GND (I flased two KK2.0 without this, and it seems working fine). Check the below picture for more details. Basically, the long leg of the capacitor should be connected to the Reset side and the shorter leg should be connected to the GND.
Let’s Start Flashing in Command LineDon’t get freaked out by command line, all you need to do is to type the following lines in the CMD and check whether the output is the same as mine.
Please double check your ISP pin connections before you proceed. Now that everything is powered and connected, we can run the following command to check if everything is ready to be flashed.
D:\kkflashtool\lib\avrdude\windows\avrdude.exe -P COM3 -p m324pa -c arduino -b 19200Arduino Mega 2560
D:\kkflashtool\lib\avrdude\windows\avrdude.exe -P COM3 -p m324pa -c avrisp -b 19200Replace COM3 with the port on which your Arduino is connected to.
The output should be similar to this.
If it says “Ok”, then we are ready to flash the KK2.0 board. If the Device signature is all zeros, you’ve probably connected the ISP pins on the KK board the wrong way around. Just double check and plug it in other way.
To start the firmware flash, execute the following commands.
Arduino Uno R3
D:\kkflashtool\lib\avrdude\windows\avrdude.exe -P COM3 -b 19200 -c arduino -p m324pa -v -e -U flash:w:"D:\KK2_1V6\KK2_1V6\kk2.hex":iArduino Mega 2560
D:\kkflashtool\lib\avrdude\windows\avrdude.exe -P COM3 -b 19200 -c avrisp -p m8 -v -e -U flash:w:"D:\KK2_1V6\KK2_1V6\kk2.hex":i
- Replace COM3 with the port on which your Arduino is connected to.
- Replace “D:\kk2.hex” with the full path to your firmware file.
After it’s done and you see “Thank you” on the screen, restart KK2.0 and you should see the new firmware number which means you have upgraded the firmware successfully. Enjoy flying!
Firmware on KK2.1I heard the 1.6 Firmware has bugs on the KK2.1, kind people have been working hard to provide new firmware to fix these bugs, check out Stevei’s KK Firmware.
Also notice the KK2.1 has a different chip, which is m644p, so you need to use a different command to flash it.
C:\Users\Oscar>D:\flash\lib\avrdude\windows\avrdude.exe -P COM1 -b 19200 -c avr isp -p m644p -v -e -U flash:w:"D:\kk2\KK2V1_1V11S2.hex":i
Possible Errors When Flashing Firmware
avrdude.exe: Expected signature for for ATmega8 is 1E 93 07
You need to change the original command to
Double check chip, or use -F to override this check.
C:\Users\Oscar>D:\flash\lib\avrdude\windows\avrdude.exe -P COM1 -b 19200 -c avr isp -p m644p -v -e -U flash:w:"D:\kk2\KK2V1_1V11S2.hex":i1