HobbyKing.com New Products Flash Sale
Reply
Thread Tools
This thread is privately moderated by jabram, who may elect to delete unwanted replies.
Old Jan 23, 2013, 03:09 AM
Click eagle to read my blog
jabram's Avatar
Australia, NSW, Kendall
Joined Jul 2012
5,112 Posts
Mini-HowTo
Programming ATMEGA32U2 on ArduFlyer 2.5

There is a lot of information in this blog, please read it all, possibly read it more than once, do not start to apply any of the information before you fully understand it all and it actually makes sense to you, if there is anything you are not sure about, ask first, it can save a lot of time, expense and frustration.

A lot more APM 2.5 information can be found on Page 1 at APM 2.5, ArduCopter, RC Timer ArduFlyer, Tutorials & Discussion, updated regularly


A few people expressed an interest in updating the firmware on the ATmega32u2 used in APM 2.5 and ArduFlyer 2.5, the earlier ArduFlyer 2.5 had the bootloader missing leaving you no option but to use a programmer to update the firmware.

Quote:
If you wish to restore the bootloader, you can get the file I created in this post
Restore DFU Bootloader to ArduFlyer 2.5 ATmega32U2
http://www.rcgroups.com/forums/showp...postcount=2498
then follow the same instructions below to program that into the ATmega32U2, thereafter you can use Atmel Flip to perform firmware upgrades
I know there are many different cheaper ways to program an Atmel microcontroller, I have over the years purchased some "clone" programmers, sooner or later it comes back to bite you when Atmel change something or uses a feature that was until then undocumented and the "clone" cannot work with those newer features..

Best to start out with a genuine Atmel programmer. The cheapest one is only $34, http://store.atmel.com/CBC.aspx?q=c:100115 supports a lot of devices and has continuing support for future devices, so it is $34 well spent IMHO.

In this mini tutorial I am using an Atmel AVR ONE! a more expensive programmer however the steps except for the name of the programmer are the same.

I am using Atmel Studio 6 on Windows 7 x32 and x64, I have also tested it on Windows 8 x64, also tested Atmel Studio 6.1

You can download Studio 6.x here
http://www.atmel.com/tools/atmelstudio.aspx

When you receive your Atmel programmer DO NOT CONNECT IT TO YOUR PC before you install Studio 6, reason is that windows may install the wrong driver, Studio 6 install will install the correct drivers and the install will be a lot easier if the Atmel programmer is not plugged into the PC USB connector until after install of Studio 6 is completed.

Studio 6 is a large program, it does a lot more than just program flash microcontrollers however here we will just use it for programming.

You can download latest ArduPPM_vx.x.xx_ATMega32U2.hex from here http://code.google.com/p/ardupilot-mega/downloads/list

Once Studio 6 is installed start Studio 6 and connect the USB cable to your programmer, if Studio 6 suggests your programmer needs a firmware Update, follow the instructions and allow it to perform that firmware Update.

First check that Studio 6 has detected your programmer, click on View - Available Atmel Tools and it should list your programmer, here it shows my AVR ONE is connected


Arduflyer has 2 ISP headers for ISP programming, one for the ATMega2560 and another one for ATMega32u2, it is IMPORTANT to take note of which is pin 1 on the ISP connector as we will alter match that to the ISP programming cable


The 6 pin ISP connector on your programmer has a marking for pin 1, your cable colors and the direction the cable exits the header may be different they don't matter orient using the Pin 1 triangle marker.


Before you connect the ISP cable from your programmer to ArduFlyer 2.5

Connect USB cable to Arduflyer, make sure ArduFlyer is powere up LEDs flashing.

Connect USB cable to your Programmer, make sure the power LED on your programmer is on.

Paying attention to match Pin 1 on the cable with Pin 1 on the ArduFlyer ATmega23u2 ISP header, connect the ISP cable. DO NOT try to connect the cable with neither device powered up that is NOT safer. It has been designed to be connected with target device and programmer both powered up.

NOTE: ArduFlyer 2.5 is powered up and running as I connect the programmer cable, programmer is also already powered up.


The programmer is connected to the Arduflyer 2.5 ATMega32u2 ISP connector, we are ready to proceed.

In Studio 6 click on Tools - Device Programming


The Device Programming window appears,
Under Tools select your programmer if it not already selected
Under Device select ATmega32u2
Under Interface select ISP


Click Apply
Drag the ISP Clock slider until it reads just under 3Mhz
Click Set


Click Read, top right under Device signature
It will read and display Device Signature and Target Voltage
If at this point you see an error message, check your ISP connector, rectify the problem and start again


The tabs down the left side
Click on Memories - your file names will not be filled in like they are on my screen capture, that is showing what I had selected earlier, it remembers.


On the right there is a TAB [...] colored light blue in the screen capture below, click on that TAB


to navigate to where you saved ArduPPM_vxxx_ATMEGA32U2.hex
select the file and click on Open


Click on Program the top Program button of the two, the one for programming Flash and you should see a moving bar and status messages on the lower left


If on the bottom left you see;
Erasing device ... OK
Programming Flash .. OK
Verifying Flash .. Ok

Then you are all done

without switching anything off - disconnect the ISP cable FIRST, close the programming window and close Studio 6.

AFTER you have shut down Studio 6 you can disconnect your programmer's USB cable from your PC.

DO NOT tinker with any other TABs on the left , there is no need to and can land you in serious trouble if you don't know what you are doing
jabram is offline Find More Posts by jabram
RCG Plus Member
Last edited by jabram; Feb 12, 2014 at 10:45 AM.
Reply With Quote
Sign up now
to remove ads between posts
Old Feb 19, 2013, 03:00 AM
Registered User
New Zealand, Auckland
Joined Dec 2011
79 Posts
APM 2.5 time's out when i try to flash the 32u2 chip

HI jabram

i hope you can help i have a atmel avr II and when i try to flash the 32u2 chip using studio 6 it times out.

any help will be apreciated.

regards
theo
soundmind is offline Find More Posts by soundmind
Reply With Quote
Old Feb 26, 2013, 09:55 PM
Click eagle to read my blog
jabram's Avatar
Australia, NSW, Kendall
Joined Jul 2012
5,112 Posts
Quote:
Originally Posted by soundmind View Post
HI jabram

i hope you can help i have a atmel avr II and when i try to flash the 32u2 chip using studio 6 it times out.

any help will be apreciated.

regards
theo
Theo, sorry for the late reply, exactly what is an avr II ?
jabram is offline Find More Posts by jabram
RCG Plus Member
Old Mar 01, 2013, 10:13 PM
Registered Aircraft Offender
Truglodite's Avatar
Carmichael, CA
Joined Feb 2007
3,517 Posts
Thank you very much Jabram. Is this at all possible with AVRdude and a USBasp programmer? $35 for a programmer isn't much and thanks to your guide I have a back up plan. However I'm very cheap, and I've flashed many KK boards, esc's, & OSD's with my trusty cheap USBasp. I was hoping that flashing the AFM 32u2 would not be much different. I'm no programmer and am fairly clueless about the internals of programming an Amtel chip. So I am afraid this might brick my board:

avrdude.exe -p m32u2 -c usbasp -U flash:w:ArduPPM_v2.3.13_ATMega32u2.hex

I guess it's not this simple. Any help on this matter would be greatly appreciated.

Kev
Truglodite is offline Find More Posts by Truglodite
Last edited by Truglodite; Mar 02, 2013 at 01:07 AM.
Reply With Quote
Old Mar 27, 2013, 05:59 AM
Flying Wood For Fun
irun4fundotca's Avatar
Canada, ON, Harrowsmith
Joined Jan 2012
6,695 Posts
bootloaders not missing on my newer board they are shipping now

Great job on this Tutorial jabram!!
irun4fundotca is offline Find More Posts by irun4fundotca
RCG Plus Member
Last edited by irun4fundotca; Jul 11, 2013 at 08:03 AM.
Reply With Quote
Old Mar 27, 2013, 03:21 PM
Registered Aircraft Offender
Truglodite's Avatar
Carmichael, CA
Joined Feb 2007
3,517 Posts
Thanks for sharing this great news!
Truglodite is offline Find More Posts by Truglodite
Reply With Quote
Old Apr 03, 2013, 07:30 AM
Click eagle to read my blog
jabram's Avatar
Australia, NSW, Kendall
Joined Jul 2012
5,112 Posts
Quote:
Originally Posted by Truglodite View Post
Thank you very much Jabram. Is this at all possible with AVRdude and a USBasp programmer? $35 for a programmer isn't much and thanks to your guide I have a back up plan. However I'm very cheap, and I've flashed many KK boards, esc's, & OSD's with my trusty cheap USBasp. I was hoping that flashing the AFM 32u2 would not be much different. I'm no programmer and am fairly clueless about the internals of programming an Amtel chip. So I am afraid this might brick my board:

avrdude.exe -p m32u2 -c usbasp -U flash:w:ArduPPM_v2.3.13_ATMega32u2.hex

I guess it's not this simple. Any help on this matter would be greatly appreciated.

Kev
Sorry, I can't help you with AVRdude, sure it is possible, I have not used AVRdude, it is easy enough to make mistakes using decent programming software which I have used since day one with AVR and going back many years to the first microprocessors. With AVRdude lots of reading or trust someone else has worked it out correctly is not how I work. No problem with saving a few dollars however the saying you get what you pay for applies with the cheaper programmers. When Atmel had a silly price on their cheapest programmer it made sense but the price now, so there is no point in saving a few bucks, false economy IMHO..
jabram is offline Find More Posts by jabram
RCG Plus Member
Old Apr 03, 2013, 07:47 AM
Click eagle to read my blog
jabram's Avatar
Australia, NSW, Kendall
Joined Jul 2012
5,112 Posts
Quote:
Originally Posted by irun4fundotca View Post
bootloaders not missing on my newer board they are shipping now
Thanks, that is correct, I purchased mine back in Nov 2012.
jabram is offline Find More Posts by jabram
RCG Plus Member
Old Apr 03, 2013, 02:14 PM
Registered Aircraft Offender
Truglodite's Avatar
Carmichael, CA
Joined Feb 2007
3,517 Posts
Thanks jabram, I humbly accept your point. When I have an urgent need to update the encoder, I'll invest in one of those $35 programmers. Although, I will still have to rely on trusting real programmers like yourself.

Kev
Truglodite is offline Find More Posts by Truglodite
Reply With Quote
Old May 21, 2013, 06:53 PM
Click eagle to read my blog
jabram's Avatar
Australia, NSW, Kendall
Joined Jul 2012
5,112 Posts
Restore DFU Bootloader to ArduFlyer 2.5 ATmega32U2

http://www.rcgroups.com/forums/showp...postcount=2498

After doing that you can use Atmel Flip for any further Atmega32U2 updates.
jabram is offline Find More Posts by jabram
RCG Plus Member
Old Jul 11, 2013, 07:46 AM
Registered User
Denmark
Joined Apr 2013
37 Posts
Hi Jabram

Thanks for your nice videos and other guides

I was programming my APM25 and forgot to remove the GPS. This resulted in a deaf APM25. (i can't program it any more)


Did try latest software og PM = no good (Upload succeeded, but verify failed: exp76 got 21 at 2)
Did try in CLI mode.... got this " NNNNNNNNNNNNNfN:$H@VxxxmaB;89///5Q! @ *@`5@E
"3 989000Z(@`st: %u
bytes free: Error: pure virtual call ?naninfovf.H?G!A??
<??
````````?i3O!331!"2122h111113A3t3312223 u8:]K{~+!!!!! C!E!"s!! _!!;!-!!!! ! 7! +!!! !"m!"G! +!!! !" !! ! ! ! ! !! !!/! ?! ! ! ! !!! !!!!h"!S!!"!" !h""w!! !
!!!e!!!) %!#!!g!"c]E?$[O
Piz*8LQ.iz@PhrF#aXil}i-=M\{L., 1BS 5401 %&EU&QO>?9e==?
[9rbr/>#<o<???H???U?h
RI4]S
@@@
L?>S
lll'
*x
9
c@\A@A6
L>2}~LlLlLlLl(LlLlLlLlLlLl
@>=o;>=o;L>u< @
#=>@
#=>@{.>@{.>@L>,@?? @?=d @?=dL>L>@ @ @ @,
!{NTTg })'kk~?h
6
6Tr!HT)}S6[
tos{Z_i{X7-U:u;Vvs?WIYW~_si;;{IVesO/m8O)SezCbyY}+L^5?:?qwKvw~;{wrv?'\%_;{o/9[jWYs_Mg.W8!n,Y_
Init ArduCopter V2.9.1b
Free RAM: 2211
FW Ver: 120
----------------------------------------

load_all took 1040us
(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g (g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g (g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g(g( "

Did also try Arduino with the special APM25 version = no good. Got this "
avrdude: verification error, first mismatch at byte 0x0000
0x45 != 0x0c
avrdude: verification error; content mismatch "

And it is In every program uploaded code. Even small ones.

Now for the question....
So i think the atmega32u2 may be broken/defective and ordered a new one.
BUT can i replace it without programming it with ur software ?



Thanks in advance
/Tvixen
Tvixen is offline Find More Posts by Tvixen
Last edited by Tvixen; Jul 11, 2013 at 02:07 PM.
Reply With Quote
Old Jul 11, 2013, 07:53 AM
Flying Wood For Fun
irun4fundotca's Avatar
Canada, ON, Harrowsmith
Joined Jan 2012
6,695 Posts
Unless the atmega32u2 you ordered has been preprogrammed for this use only, you would have to program it to function as intentended for the apm, but remember to remove the gps

but jabram might know of a way to fix the current one ,If there is one
And he will definately know more details on how or what steps to take with a new one when you get it
irun4fundotca is offline Find More Posts by irun4fundotca
RCG Plus Member
Reply With Quote
Old Jul 11, 2013, 02:11 PM
Registered User
Denmark
Joined Apr 2013
37 Posts
Quote:
Originally Posted by irun4fundotca View Post
Unless the atmega32u2 you ordered has been preprogrammed for this use only, you would have to program it to function as intentended for the apm, but remember to remove the gps

but jabram might know of a way to fix the current one ,If there is one
And he will definately know more details on how or what steps to take with a new one when you get it
Nope it's straigth from Farnell 5$. So i have to program it i suppose. If it's the only way

Yes i'll better wait for jabram, i think he knows some tricks ...hopefully
Tvixen is offline Find More Posts by Tvixen
Reply With Quote
Old Jul 12, 2013, 04:20 AM
Registered User
Denmark
Joined Apr 2013
37 Posts
Quote:
Originally Posted by jabram View Post
There is a lot of information in this blog, please read it all, possibly read it more than once, do not start to apply any of the information before you fully understand it all and it actually makes sense to you, if there is anything you are not sure about, ask first, it can save a lot of time, expense and frustration.

A few people expressed an interest in updating the firmware on the ATmega32u2 used in APM 2.5 and ArduFlyer 2.5, the earlier ArduFlyer 2.5 had the bootloader missing leaving you no option but to use a programmer to update the firmware.
---
-----
--------


If on the bottom left you see;
Erasing device ... OK
Programming Flash .. OK
Verifying Flash .. Ok

Then you are all done

without switching anything off - disconnect the ISP cable FIRST, close the programming window and close Studio 6.

AFTER you have shut down Studio 6 you can disconnect your programmer's USB cable from your PC.

DO NOT tinker with any other TABs on the left , there is no need to and can land you in serious trouble if you don't know what you are doing
Hi Guys
I do not quite understand what the difference is between this motode and the one in wiki https://code.google.com/p/ardupilot-...ki/APM2Encoder

Is there a kind soul who can explain me, why this part can't be done without a programer. (that is, unless your usb port is burned)

/Tvixen
Tvixen is offline Find More Posts by Tvixen
Last edited by Tvixen; Jul 12, 2013 at 05:08 AM.
Reply With Quote
Old Jul 12, 2013, 07:36 PM
Click eagle to read my blog
jabram's Avatar
Australia, NSW, Kendall
Joined Jul 2012
5,112 Posts
Quote:
Originally Posted by Tvixen View Post
Hi Guys
I do not quite understand what the difference is between this motode and the one in wiki https://code.google.com/p/ardupilot-...ki/APM2Encoder

Is there a kind soul who can explain me, why this part can't be done without a programer. (that is, unless your usb port is burned)

/Tvixen
Very simple explanation, some ArduFlyer 2.5 boards sold in 2012 and early 2013 did not have the bootloader already programmed into the ATmega32U2 therefore following the instructions you linked to would not work as there was no bootloader.

This blog contains instructions to program the missing bootloader into the ATmega32u2.

If your ArduFlyer 2.5 board already has the boot loader then you do NOT need to use a programmer you simply follow the instructions you linked to and perform any firmware updates using USB.
jabram is offline Find More Posts by jabram
RCG Plus Member
Reply

Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Wanted Where to get the best deal on an APM 2.5 crazy1pilot FPV Equipment (FS/W) 11 Jan 29, 2013 08:43 AM
Sold Turnigy Plush 10 (5) w/ Programming Card (1) bob4432 Aircraft - Electric - Power Systems (FS/W) 0 Jan 15, 2013 06:23 PM
Sold Turnigy Plush 10 (5) w/ Programming Card (1) bob4432 Aircraft - Electric - Multirotor (FS/W) 0 Jan 15, 2013 06:21 PM
Alert How do I program Differential Ailerons on a Flash 5 PLANE FREAK Hitec/Multiplex USA 4 Aug 05, 2004 10:14 PM