Arduino Mega 2560: Difference between revisions

From Leo's Notes
This page was last edited on 18 June 2020, at 04:14.
m add category
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
This guide will help you flash the new firmware onto your Arduino Mega 2560 board. The update is necessary if you want to make your arduino a HID (eg: emulate as a Keyboard, Mouse).
Some notes on the Arduino Atmega 2560


You should consult the guide available already at Arduino's website at http://arduino.cc/en/Hacking/DFUProgramming8U2.
==Device Firmware Update (DFU) Mode==
[[File:Mega dfu.jpeg|thumbnail]]In order to use the Arduino Atmega 2560 board as a USB HID device, you will need to update the firmware that runs on the secondary Atmega 8u2 1222 microprocessor which handles the USB communication. In order to update the firmware on this microprocessor, it needs to enter a Device Firmware Update (DFU) mode by connecting the HWB pin to ground and then resetting the Atmega 8u2 chip.


== Device Firmware Update (DFU) Mode ==
If done successfully, you should see a "Arduino Mega 2560 DFU" device.


The Arduino guide does not go into detail on how to get your mega board into DFU mode. Fortunately, there is no soldering required as we only need to short two things:
Once in this state, to update the firmware, download Flip from the Microchip site:https://www.microchip.com/developmenttools/ProductDetails/flip
# The MEGA8U2 Reset pin
# HWB pin


Refer to the image below from http://gebloggendings.wordpress.com/category/elektronik/arduino/
Included with Flip is the appropriate USB drivers for this DFU device. On Windows 10, you will need to create the following registry and re-insert the device before being able to update the device's driver with the USB driver that's available from within the Flip install directory.
[[File:Mega dfu.jpeg|thumbnail]]
{{Highlight
| code = Windows Registry Editor Version 5.00


== Flashing the Update Firmware ==
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\03EB2FF90000]
"SkipBOSDescriptorQuery"=hex:01,00,00,00
"osvc"=hex:00,00
| lang = text
}}
[[File:Flip on Windows 10.jpg|thumb]]
Select the .hex file you wish to flash the Atmega with:


Download FLIP from Atmel's website (http://www.atmel.com/tools/flip.aspx).  
* Stock USB serial firmware: https://raw.githubusercontent.com/arduino/ArduinoCore-avr/master/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex
* USB HID firmware: ???


Get the file at https://github.com/arduino/Arduino/blob/master/hardware/arduino/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial-mega.hex
Open Flip and click on "Select Target Device". Choose AT90USB82. Click on "Select Communications Medium" and select USB. If you get an error about a missing <code>atlibusbdfu.dll</code>, you did not install the device driver properly. Select the .hex file and then click 'Run' to erase and flash.


The contents of the update is available below:
When the flash completes, you should be able to power cycle the Arduino and have it come up (as a regular Arduino + serial device, or USB HID, depending on the firmware you chose).
<syntaxhighlight lang="text" line start="1" enclose="div">
==See Also==
:10000000A2C00000BBC00000B9C00000B7C0000023
:10001000B5C00000B3C00000B1C00000AFC0000018
:10002000ADC00000ABC00000A9C000005AC4000071
:100030001EC40000A3C00000A1C000009FC00000BB
:100040009DC000009BC0000099C0000097C0000048
:1000500095C0000093C0000091C0000014C10000D2
:100060008DC000008BC0000089C0000087C0000068
:1000700085C0000083C0000081C000007FC0000078
:100080007DC000007BC0000079C0000077C0000088
:1000900075C0000073C000001201100102000008CA
:1000A0004123100001000102DC0109023E000201AF
:1000B00000C0320904000001020201000524000111
:1000C0001004240206052406000107058203080027
:1000D000FF09040100020A000000070504024000B5
:1000E00001070583024000010403090432034100B3
:1000F00072006400750069006E006F002000280027
:100100007700770077002E006100720064007500B0
:1001100069006E006F002E0063006300290000007C
:100120002403410072006400750069006E006F00D6
:1001300020004D006500670061002000320035009E
:1001400036003000000011241FBECFEFD2E0DEBF2A
:10015000CDBF11E0A0E0B1E0E0EDFFE002C005900E
:100160000D92A631B107D9F712E0A6E1B1E001C0C6
:100170001D92AF32B107E1F7F1D028C741CF9C0102
:10018000DC01AE57BF4FED91FC9111974191119653
:10019000FC93EE9380589F4FE817F90711F42D93C5
:1001A0003C939FB7F894F901EC57FF4F8081815041
:1001B00080839FBF842F0895DF92EF92FF920F9369
:1001C0001F93FC018489813019F0823021F405C02D
:1001D00040E3D42E04C0DD2402C030E2D32E838954
:1001E000823011F488E0D82A8589873031F0883050
:1001F00031F0863031F482E003C084E001C086E053
:10020000D82A1092C9001092C8001092CA00E78440
:10021000F0880189128980E0E81681EEF80680E016
:10022000080780E0180719F420E130E00FC0C8018A
:10023000B701969587957795679560587B47814E6E
:100240009F4FA8019701A0D6215030403093CD0098
:100250002093CC00D092CA0080E0E81681EEF80628
:1002600080E0080780E0180711F082E001C080E01C
:100270008093C80088E98093C9001F910F91FF9077
:10028000EF90DF9008951F920F920FB60F921124F6
:100290002F938F939F93EF93FF939091CE008EB304
:1002A0008430F1F4E0919901F0919A019083E0910A
:1002B0009901F0919A01CF01019690939A01809350
:1002C00099018959914021F489E191E092838183D8
:1002D0009FB7F89480919D018F5F80939D019FBF90
:1002E000FF91EF919F918F912F910F900FBE0F90E3
:1002F0001F901895FC01858580FF02C05F980895C6
:100300005F9A089580E091E0D5C580E091E088C5CE
:1003100084B7877F84BF28E10FB6F89420936000EC
:10032000109260000FBE87E690E09093CD0080931E
:10033000CC0086E08093CA001092C8002093C900C8
:10034000539A5A9A8AB180638AB98BB180638BB908
:1003500083D284E085BD5F9A579A08950F931F93C7
:10036000CF93DF93D5DF2FB7F8948EE991E0909388
:100370001F0280931E0290932102809320022FBFC0
:100380002FB7F89489E191E090939A0180939901B5
:1003900090939C0180939B012FBF7894CEE9D1E08C
:1003A00003E08FB7F894909122028FBF903809F143
:1003B00080E091E0ABD497FD1CC0E0911E02F0916B
:1003C0001F028083E0911E02F0911F02CF0101966F
:1003D00090931F0280931E028E51924011F4D2839B
:1003E000C1839FB7F894809122028F5F809322028D
:1003F0009FBF8FB7F89410919D018FBFA89902C03D
:10040000113678F1A89A80919D01882361F05D985A
:100410000093160108C089E191E0B1DE682F80E009
:1004200091E0DAD411501123B1F78091160188239D
:1004300051F0809116018150809316018091160130
:10044000882309F45D9A80911701882351F08091E7
:10045000170181508093170180911701882309F4B7
:100460005C9A8FB7F894909122028FBF992369F01C
:100470008EE991E084DE982F8091C80085FFFCCF43
:100480009093CE005C980093170180E091E095D4A2
:100490002AD487CFDA01923049F0933061F091305D
:1004A000F9F4E8E9F0E022E130E01EC0EAEAF0E029
:1004B0002EE330E019C0813049F0813018F08230ED
:1004C00079F408C0E8EEF0E0849107C0ECEEF0E0CB
:1004D000849103C0E0E2F1E08491282F30E004C071
:1004E000E0E0F0E020E030E0ED93FC93C9010895F6
:1004F00028E030E040E003C04F5F220F331F281791
:100500003907D0F3842F8295807F08958093E90086
:100510008091EB0081608093EB001092ED0060937E
:10052000EC004093ED008091EE00881F8827881F23
:1005300008951092F40090E09093E9001092F0007A
:100540001092E8001092ED008091EB008E7F809376
:10055000EB009F5F953081F70895809127028823F3
:100560008CF403C08EB38823B1F08091E80082FF41
:10057000F9CF8091E8008B778093E80008958EB3DF
:10058000882349F08091E80080FFF9CF8091E8004E
:100590008E778093E800089594E68091EC0080FFC8
:1005A00005C08091E80080FF05C023C08091E8006D
:1005B00082FD1FC08EB3882311F482E008958EB3AC
:1005C000853011F483E008958091EB0085FF02C02F
:1005D00081E008958091E10082FFDFCF8091E1000A
:1005E0008B7F8093E100992311F484E0089591506A
:1005F000D4CF80E008959C0140912D0250912E02AD
:100600004617570718F4F90120E038C06115710545
:1006100011F0AB01F8CF8091E8008E778093E8006D
:1006200040E050E0F0CF8091E80083FF02C081E01D
:1006300008958091E80082FD2DC08EB3882381F15A
:100640008EB3853079F18091E80080FF17C09091DA
:10065000F20006C081918093F100415050409F5FAD
:100660004115510511F09830A8F320E0983009F4B5
:1006700021E08091E8008E778093E80041155105D4
:1006800091F6222381F606C08EB3882349F08EB3FB
:10069000853041F08091E80082FFF6CF80E0089538
:1006A00082E0089583E008959C0140912D025091CD
:1006B0002E024617570710F490E03BC061157105F4
:1006C00011F0AB01F9CF8091E8008E778093E800BC
:1006D00040E050E0F1CF8091E80083FF02C081E06C
:1006E00008958091E80082FD30C08EB3882399F18F
:1006F0008EB3853091F18091E80080FF1AC080911F
:10070000F20009C0F9012F5F3F4FE491E093F1003F
:10071000415050408F5F4115510511F0883090F3E2
:1007200090E0883009F491E08091E8008E77809322
:10073000E8004115510579F6992369F606C08EB394
:10074000882349F08EB3853041F08091E80082FF24
:10075000F6CF80E0089582E0089583E008959C013B
:100760006115710529F48091E8008B778093E8008A
:10077000F90120C08091E80083FF02C081E0089564
:100780008EB3882339F18EB3853031F18091E80042
:1007900082FFF0CF06C08091F100819361507040DC
:1007A00021F08091F2008823B1F78091E8008B77E7
:1007B0008093E80061157105E9F606C08EB38823C1
:1007C00049F08EB3853041F08091E80080FFF6CF8C
:1007D00080E0089582E0089583E0089542D044D0F7
:1007E0001EBA10922502109224021092230284E075
:1007F00089BD89B5826089BD09B400FEFDCF8091B5
:10080000D800982F9F779093D80080688093D80065
:10081000809163008E7F809363008091D8008F7DEC
:100820008093D8008091E0008E7F8093E0008091DB
:10083000E1008E7F8093E1008091E20081608093EF
:10084000E2008091E100877F8093E1008091E200E7
:1008500088608093E2000895C1DF81E080932602E2
:1008600008951092E20008951092E10008951F92F9
:100870000F920FB60F9211241F932F933F934F9314
:100880005F936F937F938F939F93AF93BF93EF93F8
:10089000FF93E9EEF0E0108117701082E0EFF0E0D6
:1008A0008081877F80837894C3D0F894A9EEB0E0EC
:1008B0001C92E0EFF0E08081886080831C93FF91C0
:1008C000EF91BF91AF919F918F917F916F915F91C8
:1008D0004F913F912F911F910F900FBE0F901F903E
:1008E00018951F920F920FB60F9211242F933F93DA
:1008F0004F935F936F937F938F939F93AF93BF9328
:10090000EF93FF938091E10080FF1BC08091E20094
:1009100080FF17C08091E1008E7F8093E10080917D
:10092000E2008E7F8093E2008091E20080618093FC
:10093000E2008091D80080628093D80019BC1EBA72
:10094000D1D18091E10084FF29C08091E20084FF31
:1009500025C084E089BD89B5826089BD09B400FEE7
:10096000FDCF8091D8008F7D8093D8008091E100E9
:100970008F7E8093E1008091E2008F7E8093E20081
:100980008091E20081608093E200809125028823BB
:1009900011F481E001C084E08EBBA4D18091E1001C
:1009A00083FF27C08091E20083FF23C08091E10094
:1009B000877F8093E10082E08EBB109225028091B8
:1009C000E1008E7F8093E1008091E2008E7F809332
:1009D000E2008091E20080618093E200AADD80E085
:1009E00060E042E093DD8091F00088608093F00049
:1009F00079D18091E10082FF0AC08091E20082FFFC
:100A000006C08091E1008B7F8093E1006BD1FF9164
:100A1000EF91BF91AF919F918F917F916F915F9176
:100A20004F913F912F910F900FBE0F901F901895EF
:100A30001F93DF93CF93CDB7DEB7AC970FB6F89483
:100A4000DEBF0FBECDBFE7E2F2E08091F1008193FF
:100A500022E0EF32F207C9F7809127023091280295
:100A6000353009F487C0363040F43130C9F13130C7
:100A700070F0333009F01DC133C0383009F4EFC0D5
:100A8000393009F4FEC0363009F013C192C0803805
:100A900021F0823809F00DC108C0909123028091A5
:100AA0002402882399F0926011C080912B028770F4
:100AB0008093E9008091EB0090E025E09695879582
:100AC0002A95E1F7982F91701092E9008091E80043
:100AD000877F8093E8009093F1001092F100CAC0E4
:100AE000882319F0823009F0E4C090E08F71907093
:100AF000009721F0029709F0DDC00CC08091290217
:100B0000813009F0D7C010922402333069F5809308
:100B100024022AC080912902882331F520912B02DA
:100B2000277009F4C7C02093E9008091EB0080FF93
:100B3000C1C0333021F48091EB00806213C08091FA
:100B4000EB0080618093EB0081E090E002C0880FB1
:100B5000991F2A95E2F78093EA001092EA008091AB
:100B6000EB0088608093EB001092E9008091E80030
:100B7000877F83C0882309F09CC01091290280914F
:100B8000E800877F8093E800E8DC04C08EB3882308
:100B900009F490C08091E80080FFF8CF812F8F7713
:100BA00011F492E001C093E09EBB80688093E30063
:100BB00081C08058823008F07CC0809129029091D9
:100BC0002A0223E08C3D920799F55FB7F894DE0185
:100BD00015964EE020E030E061E2E42FF0E0609313
:100BE0005700849120FF03C082958F704F5F982F2C
:100BF0009F70892F805D8A3308F0895F8C931196EE
:100C00001C9211972F5F3F4F12962431310529F71F
:100C10005FBF8AE28B8383E08C838091E800877FCB
:100C20008093E800CE0103966AE270E0E4DC11C034
:100C300060912B02AE014F5F5F4F2CDCBC0100972F
:100C4000C9F18091E800877F8093E80089819A81CB
:100C50002BDD8091E8008B778093E8002BC08038F3
:100C600041F58091E800877F8093E800809125021C
:100C70008093F1008091E8008E778093E8006DDC2E
:100C800019C08823B1F490912902923098F4809190
:100C9000E800877F8093E800909325025EDC8091D6
:100CA0002502882311F483E001C084E08EBB2DDB94
:100CB00001C028DB8091E80083FF0AC08091EB002F
:100CC00080628093EB008091E800877F8093E8004A
:100CD000AC960FB6F894DEBF0FBECDBFCF91DF91BB
:100CE0001F91089508951F938EB3882361F010918A
:100CF000E9001092E9008091E80083FF01C098DECE
:100D000017701093E9001F9108950895FC018EB3A8
:100D1000843021F587859089A189B2890097A10542
:100D2000B105E1F085818093E9008091E80082FFC0
:100D300015C08091F200882319F42FEF3FEF04C013
:100D40008091F100282F30E08091F200882341F457
:100D50008091E8008B778093E80002C02FEF3FEF8F
:100D6000C9010895FC018EB3843011F587859089FF
:100D7000A189B2890097A105B105D1F08181809345
:100D8000E9008091F2008823A9F09091E800809119
:100D9000E8008E778093E80095FD0CC0FDDB982F6E
:100DA000882349F48091E8008E778093E80003C09F
:100DB00092E001C090E0892F0895FC018EB3843049
:100DC00051F487859089A189B2890097A105B10561
:100DD00011F0CF01C7CF08951F93FC01162F8EB3DA
:100DE0008430D9F487859089A189B2890097A105BB
:100DF000B10599F081818093E9008091E80085FD3B
:100E000008C08091E8008E778093E800C5DB8823D6
:100E100029F41093F10080E001C082E01F91089551
:100E20000F931F93CF93DF93EC010D96FC0189E0A4
:100E3000DF011D928A95E9F72A813B8109818C8126
:100E4000882311F410E001C014E0C90151DB182B14
:100E50001260802F61E8412F59DB882329F12E8110
:100E60003F810D818885882311F410E001C014E0D2
:100E7000C9013EDB182B1260802F60E8412F46DB52
:100E8000882391F02A853B8509858C85882311F478
:100E900010E001C014E0C9012BDB182B1260802F79
:100EA00061EC412F33DB01C080E0DF91CF911F91D6
:100EB0000F910895CF93DF93EC018091E80083FFB9
:100EC00060C0888190E020912B0230912C0228177D
:100ED000390709F056C080912802813261F08232D0
:100EE00020F4803209F04DC019C0823269F183329A
:100EF00009F047C038C080912702813A09F041C00B
:100F00008091E800877F8093E800CE010F9667E02C
:100F100070E071DB8091E8008B7713C0809127022D
:100F2000813279F58091E800877F8093E800CE01D7
:100F30000F9667E070E013DCCE013ED98091E800A7
:100F40008E778093E8001DC0809127028132C9F41A
:100F50008091E800877F8093E800809129028D8747
:100F6000CE01C8D90DC080912702813251F4809101
:100F7000E800877F8093E800CE0160912902C5DEFA
:100F8000ECDADF91CF910895A1E21A2EAA1BBB1BC8
:100F9000FD010DC0AA1FBB1FEE1FFF1FA217B30745
:100FA000E407F50720F0A21BB30BE40BF50B661F5B
:100FB000771F881F991F1A9469F76095709580951F
:100FC00090959B01AC01BD01CF010895F894FFCF2E
:100FD0000003400000044000000208000000000080
:060FE0000000000000000B
:00000001FF
</syntaxhighlight >


Ensure that your arduino is in DFU mode and has the DFU drivers installed (available from the FLIP's install directory). Open Flip. Flip should be able to see that you have a AT90USB82 device. Load the .hex file and connect FLIP with your arduino via USB. Then click on 'Run' to apply the update.
* Flip: https://www.microchip.com/developmenttools/ProductDetails/flip
 
* Flip on Windows 10: https://s3-us-west-1.amazonaws.com/groupsioattachments/12118/16428821/319/0?AWSAccessKeyId=AKIAJECNKOVMCCU3ATNQ&Expires=1592452489&Signature=RHajJiaX1IVgPfIpyKN5OUoV9MM%3D&response-content-disposition=inline%3B+filename%3D%22Flip+on+Windows+10.pdf%22
See also: http://noquest.com/electronics/arduino-uno-firmware-update/
* USB HID Protocol - http://www.freebsddiary.org/APC/usb_hid_usages.php
 
 
== HID Keyboard ==
Refer to http://www.freebsddiary.org/APC/usb_hid_usages.php


[[Category:Guides]]
[[Category:Guides]]
[[Category:Arduino]]
[[Category:Arduino]]
{{Navbox Tinkering}}
[[Category:Tinkering]]

Latest revision as of 04:14, 18 June 2020

Some notes on the Arduino Atmega 2560

Device Firmware Update (DFU) Mode

In order to use the Arduino Atmega 2560 board as a USB HID device, you will need to update the firmware that runs on the secondary Atmega 8u2 1222 microprocessor which handles the USB communication. In order to update the firmware on this microprocessor, it needs to enter a Device Firmware Update (DFU) mode by connecting the HWB pin to ground and then resetting the Atmega 8u2 chip.

If done successfully, you should see a "Arduino Mega 2560 DFU" device.

Once in this state, to update the firmware, download Flip from the Microchip site:https://www.microchip.com/developmenttools/ProductDetails/flip

Included with Flip is the appropriate USB drivers for this DFU device. On Windows 10, you will need to create the following registry and re-insert the device before being able to update the device's driver with the USB driver that's available from within the Flip install directory.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\03EB2FF90000]
"SkipBOSDescriptorQuery"=hex:01,00,00,00
"osvc"=hex:00,00

Select the .hex file you wish to flash the Atmega with:

Open Flip and click on "Select Target Device". Choose AT90USB82. Click on "Select Communications Medium" and select USB. If you get an error about a missing atlibusbdfu.dll, you did not install the device driver properly. Select the .hex file and then click 'Run' to erase and flash.

When the flash completes, you should be able to power cycle the Arduino and have it come up (as a regular Arduino + serial device, or USB HID, depending on the firmware you chose).

See Also