Title: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: jaspreet.guitar on January 12, 2013, 09:49:53 PM Here's a small tutorial on how you can use an Arduino board to program a KK2.0 board or your ESCs.
All you need is an Arduino board and a few connecting wires. Step 1: Burn the ArduinoISP code onto your Arduino board. The instructions for the same are given at: http://arduino.cc/en/Tutorial/ArduinoISP Step 2: Connect your Arduino board to your KK2.0 board/ESC. Basically you have to connect the MOSI of Arduino to MOSI of board, MISO of Arduino to MISO of board, and so on for SCK, RST, VCC, GND. Diagrams for the pinouts are attached. Step 3: Download the latest version of avrdude from: http://download.savannah.gnu.org/releases/avrdude/ A short tutorial on avrdude is given here: http://www.ladyada.net/learn/avr/avrdude.html Once you have downloaded avrdude. Open command prompt by typing 'cmd' at RUN. Go to the directory of the downloaded avrdude by using 'cd' command and then type 'avrdude' to open the program. Step 4: Once your avrdude is ready to burn the code, check whether the connection between the boards is alright by typing the command: avrdude -P COM4 -b 19200 -c avrisp -p m324pa -v -F COM4 represents the serial port at which your Arduino board is connected to your computer. You would have to change it according to your computer. If all goes well, you would get a similar output: avrdude: Version 5.11svn, compiled on Jan 18 2012 at 22:40:34 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2009 Joerg Wunsch Using Port : COM4 Using Programmer : avrisp Overriding Baud Rate : 19200 AVR Part : ATmega324PA Chip Erase delay : 9000 us PAGEL : PD7 BS2 : PA0 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail : Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW Max W ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- --- -- --------- eeprom 65 10 128 0 no 1024 4 0 9000 90 00 0xff 0xff flash 33 6 256 0 yes 32768 128 256 4500 45 00 0xff 0xff lock 0 0 0 0 no 1 0 0 9000 90 00 0x00 0x00 lfuse 0 0 0 0 no 1 0 0 9000 90 00 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 9000 90 00 0x00 0x00 efuse 0 0 0 0 no 1 0 0 9000 90 00 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 Programmer Type : STK500 Description : Atmel AVR ISP Hardware Version: 2 Firmware Version: 1.18 Topcard : Unknown Vtarget : 0.0 V Varef : 0.0 V Oscillator : Off SCK period : 0.1 us avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.07s avrdude: Device signature = 0x1e9511 avrdude: safemode: lfuse reads as D7 avrdude: safemode: hfuse reads as D1 avrdude: safemode: efuse reads as FC avrdude: safemode: lfuse reads as D7 avrdude: safemode: hfuse reads as D1 avrdude: safemode: efuse reads as FC avrdude: safemode: Fuses OK avrdude done. Thank you. Having done this, you can go ahead and finally burn the KK2.0 code onto your KK board. The latest firmware can be found at: http://www.rcgroups.com/forums/showpost.php?p=23209042&postcount=6371 You would have to copy the HEX file and paste it into your avrdude folder. The command to burn the code is: avrdude -P COM4 -b 19200 -c avrisp -p m324pa -v -e -U flash:w:kk2.hex:i You would get this output: avrdude: Version 5.11svn, compiled on Jan 18 2012 at 22:40:34 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2009 Joerg Wunsch Using Port : COM4 Using Programmer : avrisp Overriding Baud Rate : 19200 AVR Part : ATmega324PA Chip Erase delay : 9000 us PAGEL : PD7 BS2 : PA0 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail : Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW Max W ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- --- -- --------- eeprom 65 10 128 0 no 1024 4 0 9000 90 00 0xff 0xff flash 33 6 256 0 yes 32768 128 256 4500 45 00 0xff 0xff lock 0 0 0 0 no 1 0 0 9000 90 00 0x00 0x00 lfuse 0 0 0 0 no 1 0 0 9000 90 00 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 9000 90 00 0x00 0x00 efuse 0 0 0 0 no 1 0 0 9000 90 00 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 Programmer Type : STK500 Description : Atmel AVR ISP Hardware Version: 2 Firmware Version: 1.18 Topcard : Unknown Vtarget : 0.0 V Varef : 0.0 V Oscillator : Off SCK period : 0.1 us avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.07s avrdude: Device signature = 0x1e9511 avrdude: safemode: lfuse reads as D7 avrdude: safemode: hfuse reads as D1 avrdude: safemode: efuse reads as FC avrdude: erasing chip avrdude: reading input file "kk2.hex" avrdude: writing flash (32112 bytes): Writing | ################################################## | 100% 31.86s avrdude: 32112 bytes of flash written avrdude: verifying flash memory against kk2.hex: avrdude: load data flash data from input file kk2.hex: avrdude: input file kk2.hex contains 32112 bytes avrdude: reading on-chip flash data: Reading | ################################################## | 100% 25.80s avrdude: verifying ... avrdude: 32112 bytes of flash verified avrdude: safemode: lfuse reads as D7 avrdude: safemode: hfuse reads as D1 avrdude: safemode: efuse reads as FC avrdude: safemode: Fuses OK avrdude done. Thank you. You would notice that the display on your KK2.0 board changes during the code is being burnt. Once the procedure is completed, the board will automatically restart and you would notice that the new firmware has been installed. :thumbsup: I used the procedure to update my KK2.0 board, but I'm pretty sure you can use it change the firmware for your ESCs too. ;D Warning – It is possible to ruin your board while attempting this process. :P Title: Re: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: deepakkshr on January 12, 2013, 10:08:18 PM Great work buddy :thumbsup:
Title: Re: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: RonnieBear on February 11, 2013, 12:26:30 PM Hello jaspreet.guitar,
I am brand new to AVR programming. I found your post very informative, but I am confused on 1 point. When you download the file "avrdude-5.11svn-20111019.tar.gz" from http://download.savannah.gnu.org/releases/avrdude/ where is the executable? I see that there is an avrdude.conf.in file that contains the 324pa configuration, but I do not know what is supposed to run from the command line. Any help would be appreciated! note: I am on a Windows machine Title: Re: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: anwar on February 11, 2013, 12:35:54 PM That .tar.gz is just the source code, which you have to compile with some kind of compiler (like Visual C++ in Microsoft Visual Studio) to make the executable.
Seems like you have to use the precompiled version, like WinAVR from here : http://sourceforge.net/projects/winavr/ http://sourceforge.net/projects/winavr/files/WinAVR/20100110/ (this seems to be the latest). Title: Re: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: girishsarwal on February 11, 2013, 12:40:57 PM To get avrdude for Windows, either get hold of WinAVR or build from source. Since you're beginning, I'd suggest use WinAVR. Once setup, edit you path variables so it points to the WinAVR installation directory. More information here:
http://www.nongnu.org/avrdude/user-manual/avrdude_19.html Title: Re: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: anwar on February 11, 2013, 12:43:45 PM May be we should edit the first post to clear this confusion. Something like "If you are Windows, get WinAVR from .....".
Title: Re: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: RonnieBear on February 11, 2013, 12:50:29 PM Thank you for the suggestions. As far as I can tell, WinAVR has an older version of avrdude that does not have the configuration for the 324pa board on the KK2.0. I will try compiling from source and see how it goes
Title: Re: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: RonnieBear on February 12, 2013, 05:08:14 AM Success!
In case there are other beginners trying to do this, I will share the tricks I used. If you try using an Arduino Leonardo like I did, please follow the suggestions by PeterVH: http://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/ Instead of trying to compile the source code myself in Windows, I ended up using WinAVR, even though the version available on SourceForge does not use the newest version of avrdude (5.10 instead of 5.11svn). To get around this, I simply downloaded the uncompiled code for version 5.11svn from savannah.gnu, opened the file "avrdude.conf.in" and searched for the part definition for the ATmega324PA. I then copied and pasted this section into the "avrdude.conf" found in the \bin directory where WinAVR was installed. Thanks to everyone for your help!!! Title: Re: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: girishsarwal on February 12, 2013, 05:59:06 AM congratulations
Title: Re: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: justadude^-1 on August 16, 2013, 06:29:53 PM Hi there,
this workaround doesnt work for me. I have an arduino uno with a 328P on it so i have to change the command to avrdude -P COM4 -c arduino -p m328p -v -e -U flash:w:kk2.hex:i The answer of the command window is: C:\kkflashtool\lib\avrdude\windows>avrdude -P COM4 -c arduino -p m328p -v -e -U flash:w:kk2.hex:i avrdude: Version 5.11svn, compiled on Jan 18 2012 at 22:40:34 Copyright (c) 2000-2005 Brian Dean Copyright (c) 2007-2009 Joerg Wunsch System wide configuration file is "C:\kkflashtool\lib\avrdude\windows\a vrdude.conf" Using Port : COM4 Using Programmer : arduino AVR Part : ATmega328P Chip Erase delay : 9000 us PAGEL : PD7 BS2 : PC2 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail : Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW Max W ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- --- -- --------- eeprom 65 20 4 0 no 1024 4 0 3600 36 00 0xff 0xff flash 65 6 128 0 yes 32768 128 256 4500 45 00 0xff 0xff lfuse 0 0 0 0 no 1 0 0 4500 45 00 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 4500 45 00 0x00 0x00 efuse 0 0 0 0 no 1 0 0 4500 45 00 0x00 0x00 lock 0 0 0 0 no 1 0 0 4500 45 00 0x00 0x00 calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : Arduino Description : Arduino Hardware Version: 3 Firmware Version: 4.4 Vtarget : 0.3 V Varef : 0.3 V Oscillator : 28.800 kHz SCK period : 3.3 us avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.00s avrdude: Device signature = 0x1e950f avrdude: safemode: lfuse reads as 0 avrdude: safemode: hfuse reads as 0 avrdude: safemode: efuse reads as 0 avrdude: erasing chip avrdude: reading input file "kk2.hex" avrdude: writing flash (32172 bytes): Writing | ################################################## | 100% 5.31s avrdude: 32172 bytes of flash written avrdude: verifying flash memory against kk2.hex: avrdude: load data flash data from input file kk2.hex: avrdude: input file kk2.hex contains 32172 bytes avrdude: reading on-chip flash data: Reading | ################################################## | 100% 4.49s avrdude: verifying ... avrdude: 32172 bytes of flash verified avrdude: safemode: lfuse reads as 0 avrdude: safemode: hfuse reads as 0 avrdude: safemode: efuse reads as 0 avrdude: safemode: Fuses OK avrdude done. Thank you. And you see, the transfer of the data takes 5.31 s and not 31.86 s. I think my arduino isnt transfering the data to the KK board... Could anyone help me out with that? Title: Re: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: justadude^-1 on August 21, 2013, 06:16:04 PM I found the fault - i used a 10 µF Capacitor instead of a 22 µF Capacitor between RST and GND. Now it works flawlessly.
Title: Re: Tutorial - How to flash a firmware to a FC/ESC using ARDUINO Post by: SHIBLEEALAM73@GMAIL.COM on July 04, 2019, 06:06:04 PM Dear Japreet
after the command avrdude -P COM4 -b 19200 -c avrisp -p m324pa -v -F I am getting avrdude: Version 5.11svn, compiled on Jan 18 2012 at 22:40:34 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2009 Joerg Wunsch Using Port : COM4 Using Programmer : avrisp Overriding Baud Rate : 19200 only it is not showing the other lines as you have given? |