From ffa3ce71eed0e08b198b8a823e8fdc8592dc9a20 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 24 Sep 2010 10:35:54 -0400 Subject: [PATCH] Adding usbserial and usbdfu firmwares (and combined compiled .hex files). --- .../MEGA-dfu_and_usbserial_combined.hex | 234 ++++++ .../UNO-dfu_and_usbserial_combined.hex | 234 ++++++ .../firmwares/arduino-usbdfu/Arduino-usbdfu.c | 728 ++++++++++++++++ .../firmwares/arduino-usbdfu/Arduino-usbdfu.h | 220 +++++ .../firmwares/arduino-usbdfu/Board/LEDs.h | 110 +++ .../firmwares/arduino-usbdfu/Descriptors.c | 189 +++++ .../firmwares/arduino-usbdfu/Descriptors.h | 177 ++++ .../arduino/firmwares/arduino-usbdfu/makefile | 710 ++++++++++++++++ .../firmwares/arduino-usbdfu/readme.txt | 7 + .../arduino-usbserial/Arduino-usbserial.c | 255 ++++++ .../arduino-usbserial/Arduino-usbserial.h | 79 ++ .../firmwares/arduino-usbserial/Board/LEDs.h | 110 +++ .../firmwares/arduino-usbserial/Descriptors.c | 277 +++++++ .../firmwares/arduino-usbserial/Descriptors.h | 88 ++ .../Lib/LightweightRingBuff.h | 197 +++++ .../firmwares/arduino-usbserial/makefile | 775 ++++++++++++++++++ .../firmwares/arduino-usbserial/readme.txt | 13 + 17 files changed, 4403 insertions(+) create mode 100644 hardware/arduino/firmwares/MEGA-dfu_and_usbserial_combined.hex create mode 100644 hardware/arduino/firmwares/UNO-dfu_and_usbserial_combined.hex create mode 100755 hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.c create mode 100755 hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.h create mode 100755 hardware/arduino/firmwares/arduino-usbdfu/Board/LEDs.h create mode 100755 hardware/arduino/firmwares/arduino-usbdfu/Descriptors.c create mode 100755 hardware/arduino/firmwares/arduino-usbdfu/Descriptors.h create mode 100755 hardware/arduino/firmwares/arduino-usbdfu/makefile create mode 100644 hardware/arduino/firmwares/arduino-usbdfu/readme.txt create mode 100755 hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.c create mode 100755 hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.h create mode 100755 hardware/arduino/firmwares/arduino-usbserial/Board/LEDs.h create mode 100755 hardware/arduino/firmwares/arduino-usbserial/Descriptors.c create mode 100755 hardware/arduino/firmwares/arduino-usbserial/Descriptors.h create mode 100755 hardware/arduino/firmwares/arduino-usbserial/Lib/LightweightRingBuff.h create mode 100755 hardware/arduino/firmwares/arduino-usbserial/makefile create mode 100644 hardware/arduino/firmwares/arduino-usbserial/readme.txt diff --git a/hardware/arduino/firmwares/MEGA-dfu_and_usbserial_combined.hex b/hardware/arduino/firmwares/MEGA-dfu_and_usbserial_combined.hex new file mode 100644 index 000000000..f5a5ae649 --- /dev/null +++ b/hardware/arduino/firmwares/MEGA-dfu_and_usbserial_combined.hex @@ -0,0 +1,234 @@ +:20000000A2C00000BBC00000B9C00000B7C00000B5C00000B3C00000B1C00000AFC000004B +:20002000ADC00000ABC00000A9C0000023C40000A5C00000A3C00000A1C000009FC0000010 +:200040009DC000009BC0000099C0000097C0000095C0000093C0000091C0000004C100007A +:200060008DC000008BC0000089C0000087C0000085C0000083C0000081C000007FC0000050 +:200080007DC000007BC0000079C0000077C0000075C0000073C000001201100102000008E2 +:2000A0004123100000000102DC0109023E00020100C0320904000001020201000524000171 +:2000C00010042402060524060001070582030800FF09040100020A000000070504024000AC +:2000E0000007058302400000040309043203410072006400750069006E006F0020002800CC +:200100007700770077002E00610072006400750069006E006F002E0063006300290000003D +:200120002403410072006400750069006E006F0020004D00650067006100200032003500A5 +:2001400036003000000011241FBECFEFD2E0DEBFCDBF11E0A0E0B1E0E0E7FFE002C005908F +:200160000D92A631B107D9F712E0A6E1B1E001C01D92A033B107E1F7E2D0F8C641CF9C0187 +:20018000DC01AE57BF4FED91FC91119741911196FC93EE9380589F4FE817F90711F42D93A9 +:2001A0003C939FB7F894F901EC57FF4F8081815080839FBF842F089508950895FC0184893C +:2001C000813019F0823019F404C090E303C090E001C090E28389823009F498608589873091 +:2001E00031F0883031F0863029F4926003C0946001C096601092C9001092C8001092CA0091 +:200200002785308941895289203081EE380780E0480780E0580711F082E001C080E08093D1 +:20022000C80088E98093C9009093CA00203081EE380780E0480780E0580719F420E130E032 +:200240000DC0CA01B901969587957795679560587B47814E9F4F68D6215030403093CD0017 +:200260002093CC0008951F920F920FB60F9211242F938F939F93EF93FF939091CE0080914B +:2002800027028430F1F4E0919901F0919A019083E0919901F0919A01CF01019690939A0116 +:2002A000809399018959914021F489E191E0928381839FB7F89480919D018F5F80939D01A5 +:2002C0009FBFFF91EF919F918F912F910F900FBE0F901F901895FC01858580FF02C05F98FA +:2002E00008955F9A089580E091E0B4C580E091E067C584B7877F84BF28E10FB6F8942093F3 +:200300006000109260000FBE87E690E09093CD008093CC0086E08093CA001092C8002093A2 +:20032000C900539A5A9A8AB180638AB98BB180638BB995D284E085BD5F9A579A08950F9319 +:200340001F93CF93DF93D5DF2FB7F8948EE991E090931F0280931E02909321028093200217 +:200360002FBF2FB7F89489E191E090939A018093990190939C0180939B012FBF7894CEE9B7 +:20038000D1E003E080E091E08DD49C0197FD23C08FB7F894909122028FBF9038E1F0E09114 +:2003A0001E02F0911F022083E0911E02F0911F02CF01019690931F0280931E028E51924016 +:2003C00011F4D283C1839FB7F894809122028F5F809322029FBF8FB7F89410919D018FBF86 +:2003E000A89902C0113678F1A89A80919D01882361F05D980093160108C089E191E0BFDE7E +:20040000682F80E091E0B7D411501123B1F780911601882351F08091160181508093160175 +:2004200080911601882309F45D9A80911701882351F0809117018150809317018091170192 +:20044000882309F45C9A8FB7F894909122028FBF992369F08EE991E092DE982F8091C8008C +:2004600085FFFCCF9093CE005C980093170180E091E071D403D486CFDA01923049F09330C2 +:2004800061F09130F9F4E8E9F0E022E130E01EC0EAEAF0E02EE330E019C0813049F0813092 +:2004A00018F0823079F408C0E8EEF0E0849107C0ECEEF0E0849103C0E0E2F1E08491282F4A +:2004C00030E004C0E0E0F0E020E030E0ED93FC93C901089528E030E040E003C04F5F220F58 +:2004E000331F28173907D0F3842F8295807F08958093E9008091EB0081608093EB00109289 +:20050000ED006093EC004093ED008091EE00881F8827881F08951092F40090E09093E900A4 +:200520001092F0001092E8001092ED008091EB008E7F8093EB009F5F953081F70895809120 +:20054000280288239CF404C0809127028823B9F08091E80082FFF8CF8091E8008B77809395 +:20056000E800089580912702882349F08091E80080FFF8CF8091E8008E778093E800089503 +:2005800094E68091EC0080FF05C08091E80080FF05C025C08091E80082FD21C080912702EB +:2005A000882311F482E0089580912702853011F483E008958091EB0085FF02C081E0089558 +:2005C0008091E10082FFDDCF8091E1008B7F8093E100992311F484E008959150D2CF80E068 +:2005E00008959C0140912E0250912F024617570718F4F90120E03AC06115710511F0AB015A +:20060000F8CF8091E8008E778093E80040E050E0F0CF8091E80083FF02C081E008958091BF +:20062000E80082FD31C080912702882399F180912702853089F18091E80080FF17C090911A +:20064000F20006C081918093F100415050409F5F4115510511F09830A8F320E0983009F4D8 +:2006600021E08091E8008E778093E8004115510581F6222371F608C080912702882351F0C3 +:2006800080912702853041F08091E80082FFF4CF80E0089582E0089583E008959C01409193 +:2006A0002E0250912F024617570710F490E03DC06115710511F0AB01F9CF8091E8008E776D +:2006C0008093E80040E050E0F1CF8091E80083FF02C081E008958091E80082FD34C0809157 +:2006E00027028823B1F1809127028530A1F18091E80080FF1AC08091F20009C0F9012F5F5D +:200700003F4FE491E093F100415050408F5F4115510511F0883090F390E0883009F491E0E5 +:200720008091E8008E778093E8004115510569F6992359F608C080912702882351F08091AB +:200740002702853041F08091E80082FFF4CF80E0089582E0089583E008959C0161157105C8 +:2007600029F48091E8008B778093E800F90122C08091E80083FF02C081E008958091270215 +:20078000882351F180912702853041F18091E80082FFEECF06C08091F100819361507040D7 +:2007A00021F08091F2008823B1F78091E8008B778093E80061157105D9F608C0809127021F +:2007C000882351F080912702853041F08091E80080FFF4CF80E0089582E0089583E00895D6 +:2007E00043D045D01092270210922502109224021092230284E089BD89B5826089BD09B4E1 +:2008000000FEFDCF8091D800982F9F779093D80080688093D800809163008E7F8093630083 +:200820008091D8008F7D8093D8008091E0008E7F8093E0008091E1008E7F8093E1008091E3 +:20084000E20081608093E2008091E100877F8093E1008091E20088608093E2000895C0DFE8 +:2008600081E08093260208951092E20008951092E10008951F920F920FB60F9211242F934F +:200880003F934F935F936F937F938F939F93AF93BF93EF93FF938091E10080FF1CC0809144 +:2008A000E20080FF18C08091E1008E7F8093E1008091E2008E7F8093E2008091E200806143 +:2008C0008093E2008091D80080628093D80019BC1092270272DC8091E10084FF2AC080910F +:2008E000E20084FF26C084E089BD89B5826089BD09B400FEFDCF8091D8008F7D8093D80036 +:200900008091E1008F7E8093E1008091E2008F7E8093E2008091E20081608093E200809115 +:200920002502882311F481E001C084E08093270243DC8091E10083FF23C08091E20083FF33 +:200940001FC08091E100877F8093E10082E080932702109225028091E1008E7F8093E10072 +:200960008091E2008E7F8093E2008091E20080618093E200D0DD80E060E042E0B9DD7DD166 +:200980008091E10082FF0AC08091E20082FF06C08091E1008B7F8093E1006FD1FF91EF91A0 +:2009A000BF91AF919F918F917F916F915F914F913F912F910F900FBE0F901F9018951F93CE +:2009C000DF93CF93CDB7DEB7AC970FB6F894DEBF0FBECDBFE8E2F2E08091F100819322E0EC +:2009E000E033F207C9F78091280230912902353009F487C0363040F43130C9F1313070F0E5 +:200A0000333009F021C133C0383009F4F2C0393009F401C1363009F017C194C0803821F012 +:200A2000823809F011C108C09091230280912402882399F0926011C080912C0287708093AC +:200A4000E9008091EB0090E025E0969587952A95E1F7982F91701092E9008091E800877F0C +:200A60008093E8009093F1001092F100CDC0882319F0823009F0E8C090E08F719070009739 +:200A800021F0029709F0E1C00CC080912A02813009F0DBC010922402333069F58093240202 +:200AA0002AC080912A02882331F520912C02277009F4CBC02093E9008091EB0080FFC5C0A4 +:200AC000333021F48091EB00806213C08091EB0080618093EB0081E090E002C0880F991F30 +:200AE0002A95E2F78093EA001092EA008091EB0088608093EB001092E9008091E800877F69 +:200B000086C0882309F0A0C010912A028091E800877F8093E80013DD05C08091270288232A +:200B200009F493C08091E80080FFF7CF812F8F7711F492E001C093E090932702806880937F +:200B4000E30083C08058823008F07EC080912A0290912B0223E08C3D920799F55FB7F8948F +:200B6000DE0115964EE020E030E061E2E42FF0E060935700849120FF03C082958F704F5F82 +:200B8000982F9F70892F805D8A3308F0895F8C9311961C9211972F5F3F4F129624313105E2 +:200BA00029F75FBF8AE28B8383E08C838091E800877F8093E800CE0103966AE270E011DD1F +:200BC00012C060912C02AE014F5F5F4F55DCBC01009709F43AC08091E800877F8093E800A3 +:200BE00089819A815BDD8091E8008B778093E8002CC0803849F58091E800877F8093E800C6 +:200C0000809125028093F1008091E8008E778093E80095DC1AC08823B9F490912A029230ED +:200C2000A0F48091E800877F8093E8009093250286DC80912502882311F483E001C084E00A +:200C40008093270253DB01C04EDB8091E80083FF0AC08091EB0080628093EB008091E80026 +:200C6000877F8093E800AC960FB6F894DEBF0FBECDBFCF91DF911F91089508951F9380916D +:200C80002702882361F01091E9001092E9008091E80083FF01C093DE17701093E9001F91AA +:200CA00008950895FC0180912702843021F587859089A189B2890097A105B105E1F08581A5 +:200CC0008093E9008091E80082FF15C08091F200882319F42FEF3FEF04C08091F100282FA5 +:200CE00030E08091F200882341F48091E8008B778093E80002C02FEF3FEFC9010895FC0199 +:200D000080912702843011F587859089A189B2890097A105B105D1F081818093E900809192 +:200D2000F2008823A9F09091E8008091E8008E778093E80095FD0CC023DC982F882349F46F +:200D40008091E8008E778093E80003C092E001C090E0892F0895FC0180912702843051F4AF +:200D600087859089A189B2890097A105B10511F0CF01C5CF08951F93FC01162F80912702C6 +:200D80008430D9F487859089A189B2890097A105B10599F081818093E9008091E80085FD53 +:200DA00008C08091E8008E778093E800E9DB882329F41093F10080E001C082E01F91089582 +:200DC0000F931F93CF93DF93EC010D96FC0189E0DF011D928A95E9F72A813B8109818C8169 +:200DE000882311F410E001C014E0C90173DB182B1260802F61E8412F7BDB882329F12E819F +:200E00003F810D818885882311F410E001C014E0C90160DB182B1260802F60E8412F68DBBE +:200E2000882391F02A853B8509858C85882311F410E001C014E0C9014DDB182B1260802FCD +:200E400061EC412F55DB01C080E0DF91CF911F910F910895CF93DF93EC018091E80083FF8B +:200E600060C0888190E020912C0230912D022817390709F056C080912902813261F0823288 +:200E800020F4803209F04DC019C0823269F1833209F047C038C080912802813A09F041C002 +:200EA0008091E800877F8093E800CE010F9667E070E097DB8091E8008B7713C080912802B2 +:200EC000813279F58091E800877F8093E800CE010F9667E070E041DCCE0170D98091E800BE +:200EE0008E778093E8001DC0809128028132C9F48091E800877F8093E80080912A028D871F +:200F0000CE01E9D90DC080912802813251F48091E800877F8093E800CE0160912A02C1DEBB +:200F20000EDBDF91CF910895A1E21A2EAA1BBB1BFD010DC0AA1FBB1FEE1FFF1FA217B307E9 +:200F4000E407F50720F0A21BB30BE40BF50B661F771F881F991F1A9469F760957095809599 +:200F600090959B01AC01BD01CF010895F894FFCF00034000000440000002080000000000ED +:200F8000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6B +:200FA000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF51 +:200FC000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF31 +:200FE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF11 +:201000004BC0000064C0000062C0000060C000005EC000005CC000005AC0000058C00000F3 +:2010200056C0000054C0000052C00000CBC400004EC000004CC000004AC0000048C00000B9 +:2010400046C0000044C0000042C0000040C000003EC000003CC000003AC0000038C0000098 +:2010600036C0000034C0000032C0000030C000002EC000002CC000002AC0000028C00000F8 +:2010800026C0000024C0000022C0000020C000001EC000001CC0000011241FBECFEFD2E088 +:2010A000DEBFCDBF11E0A0E0B1E0E4EBFCE102C005900D92A836B107D9F711E0A8E6B1E0ED +:2010C00001C01D92A738B107E1F74FD3F1C598CF982F15C08091F200882371F48091E8004A +:2010E0008B7F8093E80003C08EB3882351F08091E80082FFF9CF02C08091F1009150992358 +:2011000049F708952091760130917501809174019091730180936D0190936E01C901809388 +:201120006F0190937001089580917101843009F45AC0853030F4813059F0833009F0C3C0BE +:201140001FC0853009F4A0C0863009F0BCC0AFC080917201823008F0B6C0D4DF8091720129 +:20116000882361F480916D0190916E0123E0FC0120935700E89507B600FCFDCF85E008C027 +:2011800080917201882311F0823029F4BBDF89E0809301010895813009F095C020E030E08C +:2011A00040E050E0F90184918F3F81F0CA01AA27BB2780936C0130936E0120936D018AE0D6 +:2011C0008093010185E08093690108952F5F3F4F4F4F5F4F2030F0E13F07F0E04F07F0E0B6 +:2011E0005F0701F7089580917201833051F581E0809368018091770190917801892B71F062 +:2012000080917301813009F05EC0809176019091750190936B0180936A0108958091730133 +:20122000882361F42CE088E190E00FB6F894A895809360000FBE20936000089510920001A8 +:201240000895882309F03FC0809173018F3F09F03AC0E0E0F0E093E085E090935700E895A9 +:2012600007B600FCFDCF80935700E89507B600FCFDCFE058FF4F20E1E030F20771F781E123 +:2012800080935700E8950895E091730180917201882321F4F0E0EB5FFE4F05C0813099F437 +:2012A000F0E0EE52FF4F808180937C01089580917201833041F480917301882321F48091E0 +:2012C000740180936C0108952F923F924F925F926F927F929F92AF92BF92CF92DF92EF92F0 +:2012E000FF920F931F93CF93DF938091850190918601909378018093770180917901882399 +:2013000051F08091790181508093790180917901882309F45D9A80917A01882351F08091F0 +:201320007A01815080937A0180917A01882309F45C9A80918001833009F4B2C1843030F41C +:20134000813071F0823009F0E3C111C1853009F4C5C1853008F4BAC1863009F0D9C1CDC11F +:201360005C9883E080937A018091E800877F8093E80080916801882329F0D6DE5D9A5C9AAF +:201380001092680120917701309178012115310529F42AC08EB3882309F4BAC18091E8000F +:2013A00082FFF8CF8091F10080937101215030403093780120937701E2E7F1E00CC080919F +:2013C000F10081932150304081E0E737F80719F43183208308C08091F200882381F7309394 +:2013E000780120937701A0DE80910101853009F0BAC08091770190917801892B21F482E042 +:2014000080930101B0C08AE163DE80916D018F715FDEC0916F01D091700120916D0130916C +:201420006E0121968E01021B130B219780917201882309F093C0180136942794C901A091F0 +:201440006C01B0E09C01AD0162E0E62EF12C012D112DE20EF31E041F151F59016A0190E0D8 +:2014600099249394B5E0A3E048C08091F200882371F48091E8008B7F8093E80004C08EB352 +:20148000882309F445C18091E80082FFF8CF0894210831088091F100682F8091F100782F1D +:2014A000F5010B0190925700E89511249F5F903419F021143104A1F4F901B0935700E89524 +:2014C00007B600FCFDCF2114310451F0F701A0935700E89507B600FCFDCFA801970190E0A7 +:2014E00042E0442E512C612C712CE40CF51C061D171DA40CB51CC61CD71C2114310409F0A0 +:20150000B4CFD0936E01C0936D0181E180935700E89527C08091F200882371F48091E80079 +:201520008B7F8093E80004C08EB3882309F4F0C08091E80082FFF8CF6091F10080916D01A7 +:2015400090916E01A7D380916D0190916E01019690936E0180936D010150104001151105FB +:20156000C9F680E1B5DD8091E8008B7FC3C08091E800877F8093E8005D9883E08093790154 +:2015800004C08EB3882309F4C3C08091E80080FFF8CF80910101893091F08A3069F4809167 +:2015A0007201813049F480916D0190916E018093F1009093F1009BC080917C0196C0609173 +:2015C0006F017091700120916D0130916E016F5F7F4F7B01E21AF30A6150704080917201E4 +:2015E000882389F5870116950795C901A0916C01B0E09C01AD011FC08091F200803271F4B7 +:201600008091E8008E7F8093E80004C08EB3882309F47EC08091E80080FFF8CFF90185918F +:2016200094918093F1009093F100015010402E5F3F4F4F4F5F4F01151105F1F670936E01E0 +:2016400060936D0129C0823039F523C08091F200803271F48091E8008E7F8093E80004C09E +:201660008EB3882309F454C08091E80080FFF8CF00916D0110916E01C80104D38093F1007B +:201680000F5F1F4F10936E0100936D010894E108F108E114F104D1F682E08093010127C0CE +:2016A0008091E800877F8093E800809169018093F1001092F1001092F1001092F1008091E7 +:2016C00001018093F1001092F10011C08091E800877F8093E8001092690119C08091E800C8 +:2016E000877F8093E800809101018093F1008091E8008E7F8093E8000AC08091E800877F08 +:201700008093E8005D9A5C9A82E08093010187D0DF91CF911F910F91FF90EF90DF90CF9017 +:20172000BF90AF909F907F906F905F904F903F902F9008952BD181E085BF15BE089584B799 +:20174000877F84BF88E10FB6F89480936000109260000FBE81E085BF82E085BF8AB18063DB +:201760008AB98BB180638BB90CC1E9DF789401C080D2809100018823D9F78091680188235D +:20178000B9F7D8DFE0916A01F0916B010995FA01923071F0933089F0913029F488E091E06A +:2017A00022E130E019C080E090E020E030E014C08AE191E02BE130E00FC0882339F48091D9 +:2017C0003501282F30E085E391E006C080913901282F30E089E391E091838083C9010895C0 +:2017E0008091EB0081608093EB001092ED006093EC004093ED008091EE00881F8827881FE4 +:2018000008951092F4001092F0001092E8001092ED00EBEEF0E080818E7F80830895809182 +:201820007F0188238CF403C08EB38823B1F08091E80082FFF9CF8091E8008B7F8093E8006D +:2018400008958EB3882349F08091E80080FFF9CF8091E8008E7F8093E80008959C0140917A +:201860008501509186014617570718F4F90120E038C06115710511F0AB01F8CF8091E80068 +:201880008E7F8093E80040E050E0F0CF8091E80083FF02C081E008958091E80082FD2DC091 +:2018A0008EB3882381F18EB3853079F18091E80080FF17C09091F20006C081918093F1002C +:2018C000415050409F5F4115510511F09032A8F320E0903209F421E08091E8008E7F809306 +:2018E000E8004115510591F6222381F606C08EB3882349F08EB3853041F08091E80082FF85 +:20190000F6CF80E0089582E0089583E0089554D056D01EBA10927D0184E089BD89B58260FA +:2019200089BD09B400FEFDCF8091D800982F9F779093D80080688093D800809163008E7FC5 +:20194000809363008091D8008F7D8093D8008091E0008E7F8093E0008091E1008E7F80932E +:20196000E1008091E20081608093E2008091E100877F8093E1008091E20088608093E20001 +:201980000895C5DF81E080937E010895C0DFE0EEF0E0808181608083E8EDF0E080818F77A8 +:2019A00080830AD00CD019BCE3E6F0E080818160808310927E0108951092E200089510929A +:2019C000E10008951F920F920FB60F9211242F933F934F935F936F937F938F939F93AF938A +:2019E000BF93EF93FF938091E10080FF1BC08091E20080FF17C08091E1008E7F8093E100F9 +:201A00008091E2008E7F8093E2008091E20080618093E2008091D80080628093D80019BC7D +:201A20001EBA26D18091E10084FF29C08091E20084FF25C084E089BD89B5826089BD09B451 +:201A400000FEFDCF8091D8008F7D8093D8008091E1008F7E8093E1008091E2008F7E8093D6 +:201A6000E2008091E20081608093E20080917D01882311F481E001C084E08EBBF9D08091D3 +:201A8000E10083FF22C08091E20083FF1EC08091E100877F8093E10082E08EBB10927D01F7 +:201AA0008091E1008E7F8093E1008091E2008E7F8093E2008091E20080618093E200A1DEF6 +:201AC00080E060E042E28CDED3D08091E10082FF0AC08091E20082FF06C08091E1008B7FC2 +:201AE0008093E100C5D0FF91EF91BF91AF919F918F917F916F915F914F913F912F910F905E +:201B00000FBE0F901F9018951F93DF93CF9300D0CDB7DEB7EFE7F1E08091F100819381E070 +:201B2000E738F807C9F790917F0180918001853011F1863040F48130B9F0813070F08330D5 +:201B400009F081C011C0883009F453C0893009F462C0863009F077C02DC0903809F474C00E +:201B6000923809F070C070C0992309F46DC0923009F069C069C0992309F065C01091810152 +:201B80008091E800877F8093E80049DE04C08EB3882309F459C08091E80080FFF8CF812F6F +:201BA0008F7711F492E001C093E09EBB80688093E3004AC09058923008F045C080918101F9 +:201BC0009091820160918301AE014F5F5F4FDFDDBC010097C9F18091E800877F8093E8001D +:201BE00089819A813BDE8091E8008B7F8093E8002BC0903841F58091E800877F8093E800C6 +:201C000080917D018093F1008091E8008E7F8093E80005DE19C09923B1F4909181019230AE +:201C200098F48091E800877F8093E80090937D01F6DD80917D01882311F483E001C084E0E3 +:201C40008EBB16D001C040DB8091E80083FF0AC08091EB0080628093EB008091E800877F59 +:201C60008093E8000F900F90CF91DF911F91089508958EB3882329F08091E80083FF01C030 +:201C800043CF0895F999FECF92BD81BDF89A992780B50895262FF999FECF1FBA92BD81BD6B +:201CA00020BD0FB6F894FA9AF99A0FBE01960895F894FFCF01021E938220DCFB1201100123 +:201CC00000000020EB03F72F00000001000109021B0001010080320904000000FE010200E6 +:201CE0000921030000000C0001040309042C03410072006400750069006E006F0020004D28 +:1C1D000000650067006100200032003500360030002000440046005500000000AE +:00000001FF diff --git a/hardware/arduino/firmwares/UNO-dfu_and_usbserial_combined.hex b/hardware/arduino/firmwares/UNO-dfu_and_usbserial_combined.hex new file mode 100644 index 000000000..2bceda5ad --- /dev/null +++ b/hardware/arduino/firmwares/UNO-dfu_and_usbserial_combined.hex @@ -0,0 +1,234 @@ +:200000009CC00000B5C00000B3C00000B1C00000AFC00000ADC00000ABC00000A9C000007B +:20002000A7C00000A5C00000A3C000001DC400009FC000009DC000009BC0000099C0000040 +:2000400097C0000095C0000093C0000091C000008FC000008DC000008BC00000FEC00000AB +:2000600087C0000085C0000083C0000081C000007FC000007DC000007BC0000079C0000080 +:2000800077C0000075C0000073C0000071C000006FC000006DC00000120110010200000806 +:2000A0004123010000000102DC0109023E00020100C0320904000001020201000524000180 +:2000C00010042402060524060001070582030800FF09040100020A000000070504024000AC +:2000E0000007058302400000040309043203410072006400750069006E006F0020002800CC +:200100007700770077002E00610072006400750069006E006F002E0063006300290000003D +:200120001803410072006400750069006E006F00200055006E006F00000011241FBECFEFB0 +:20014000D2E0DEBFCDBF11E0A0E0B1E0E4E6FFE002C005900D92A631B107D9F712E0A6E14B +:20016000B1E001C01D92A033B107E1F7E2D0F8C647CF9C01DC01AE57BF4FED91FC91119755 +:2001800041911196FC93EE9380589F4FE817F90711F42D933C939FB7F894F901EC57FF4F10 +:2001A0008081815080839FBF842F089508950895FC018489813019F0823019F404C090E3C8 +:2001C00003C090E001C090E28389823009F498608589873031F0883031F0863029F4926082 +:2001E00003C0946001C096601092C9001092C8001092CA002785308941895289203081EE87 +:20020000380780E0480780E0580711F082E001C080E08093C80088E98093C9009093CA0098 +:20022000203081EE380780E0480780E0580719F420E130E00DC0CA01B9019695879577958F +:20024000679560587B47814E9F4F68D6215030403093CD002093CC0008951F920F920FB689 +:200260000F9211242F938F939F93EF93FF939091CE00809127028430F1F4E0919901F09130 +:200280009A019083E0919901F0919A01CF01019690939A01809399018959914021F489E185 +:2002A00091E0928381839FB7F89480919D018F5F80939D019FBFFF91EF919F918F912F9106 +:2002C0000F900FBE0F901F901895FC01858580FF02C05F9808955F9A089580E091E0B4C5FB +:2002E00080E091E067C584B7877F84BF28E10FB6F89420936000109260000FBE87E690E064 +:200300009093CD008093CC0086E08093CA001092C8002093C900539A5A9A8AB180638AB9A3 +:200320008BB180638BB995D284E085BD5F9A579A08950F931F93CF93DF93D5DF2FB7F89478 +:200340008EE991E090931F0280931E0290932102809320022FBF2FB7F89489E191E0909365 +:200360009A018093990190939C0180939B012FBF7894CEE9D1E003E080E091E08DD49C01B2 +:2003800097FD23C08FB7F894909122028FBF9038E1F0E0911E02F0911F022083E0911E0281 +:2003A000F0911F02CF01019690931F0280931E028E51924011F4D283C1839FB7F89480917B +:2003C00022028F5F809322029FBF8FB7F89410919D018FBFA89902C0113678F1A89A809111 +:2003E0009D01882361F05D980093160108C089E191E0BFDE682F80E091E0B7D411501123FC +:20040000B1F780911601882351F08091160181508093160180911601882309F45D9A809125 +:200420001701882351F08091170181508093170180911701882309F45C9A8FB7F8949091D9 +:2004400022028FBF992369F08EE991E092DE982F8091C80085FFFCCF9093CE005C98009356 +:20046000170180E091E071D403D486CFDA01923049F0933061F09130F9F4E8E9F0E022E1E6 +:2004800030E01EC0EAEAF0E02EE330E019C0813049F0813018F0823079F408C0E8EEF0E0A0 +:2004A000849107C0ECEEF0E0849103C0E0E2F1E08491282F30E004C0E0E0F0E020E030E06B +:2004C000ED93FC93C901089528E030E040E003C04F5F220F331F28173907D0F3842F82956E +:2004E000807F08958093E9008091EB0081608093EB001092ED006093EC004093ED0080914A +:20050000EE00881F8827881F08951092F40090E09093E9001092F0001092E8001092ED0096 +:200520008091EB008E7F8093EB009F5F953081F708958091280288239CF404C08091270268 +:200540008823B9F08091E80082FFF8CF8091E8008B778093E800089580912702882349F055 +:200560008091E80080FFF8CF8091E8008E778093E800089594E68091EC0080FF05C08091DA +:20058000E80080FF05C025C08091E80082FD21C080912702882311F482E0089580912702CE +:2005A000853011F483E008958091EB0085FF02C081E008958091E10082FFDDCF8091E10030 +:2005C0008B7F8093E100992311F484E008959150D2CF80E008959C0140912E0250912F022C +:2005E0004617570718F4F90120E03AC06115710511F0AB01F8CF8091E8008E778093E800E7 +:2006000040E050E0F0CF8091E80083FF02C081E008958091E80082FD31C080912702882342 +:2006200099F180912702853089F18091E80080FF17C09091F20006C081918093F1004150F8 +:2006400050409F5F4115510511F09830A8F320E0983009F421E08091E8008E778093E8003D +:200660004115510581F6222371F608C080912702882351F080912702853041F08091E800A4 +:2006800082FFF4CF80E0089582E0089583E008959C0140912E0250912F024617570710F4AB +:2006A00090E03DC06115710511F0AB01F9CF8091E8008E778093E80040E050E0F1CF809152 +:2006C000E80083FF02C081E008958091E80082FD34C0809127028823B1F18091270285300E +:2006E000A1F18091E80080FF1AC08091F20009C0F9012F5F3F4FE491E093F100415050403A +:200700008F5F4115510511F0883090F390E0883009F491E08091E8008E778093E80041151E +:20072000510569F6992359F608C080912702882351F080912702853041F08091E80082FF71 +:20074000F4CF80E0089582E0089583E008959C016115710529F48091E8008B778093E8003E +:20076000F90122C08091E80083FF02C081E0089580912702882351F180912702853041F11A +:200780008091E80082FFEECF06C08091F10081936150704021F08091F2008823B1F780916D +:2007A000E8008B778093E80061157105D9F608C080912702882351F080912702853041F08B +:2007C0008091E80080FFF4CF80E0089582E0089583E0089543D045D0109227021092250226 +:2007E000109224021092230284E089BD89B5826089BD09B400FEFDCF8091D800982F9F770D +:200800009093D80080688093D800809163008E7F809363008091D8008F7D8093D800809122 +:20082000E0008E7F8093E0008091E1008E7F8093E1008091E20081608093E2008091E1002A +:20084000877F8093E1008091E20088608093E2000895C0DF81E08093260208951092E200D5 +:2008600008951092E10008951F920F920FB60F9211242F933F934F935F936F937F938F9330 +:200880009F93AF93BF93EF93FF938091E10080FF1CC08091E20080FF18C08091E1008E7FE8 +:2008A0008093E1008091E2008E7F8093E2008091E20080618093E2008091D80080628093A8 +:2008C000D80019BC1092270272DC8091E10084FF2AC08091E20084FF26C084E089BD89B5AF +:2008E000826089BD09B400FEFDCF8091D8008F7D8093D8008091E1008F7E8093E100809165 +:20090000E2008F7E8093E2008091E20081608093E20080912502882311F481E001C084E0BC +:200920008093270243DC8091E10083FF23C08091E20083FF1FC08091E100877F8093E100C5 +:2009400082E080932702109225028091E1008E7F8093E1008091E2008E7F8093E200809137 +:20096000E20080618093E200D0DD80E060E042E0B9DD7DD18091E10082FF0AC08091E2003C +:2009800082FF06C08091E1008B7F8093E1006FD1FF91EF91BF91AF919F918F917F916F91E0 +:2009A0005F914F913F912F910F900FBE0F901F9018951F93DF93CF93CDB7DEB7AC970FB6C9 +:2009C000F894DEBF0FBECDBFE8E2F2E08091F100819322E0E033F207C9F780912802309119 +:2009E0002902353009F487C0363040F43130C9F1313070F0333009F021C133C0383009F417 +:200A0000F2C0393009F401C1363009F017C194C0803821F0823809F011C108C09091230215 +:200A200080912402882399F0926011C080912C0287708093E9008091EB0090E025E09695BA +:200A400087952A95E1F7982F91701092E9008091E800877F8093E8009093F1001092F100EF +:200A6000CDC0882319F0823009F0E8C090E08F719070009721F0029709F0E1C00CC08091BA +:200A80002A02813009F0DBC010922402333069F5809324022AC080912A02882331F520917A +:200AA0002C02277009F4CBC02093E9008091EB0080FFC5C0333021F48091EB00806213C024 +:200AC0008091EB0080618093EB0081E090E002C0880F991F2A95E2F78093EA001092EA0038 +:200AE0008091EB0088608093EB001092E9008091E800877F86C0882309F0A0C010912A0273 +:200B00008091E800877F8093E80013DD05C080912702882309F493C08091E80080FFF7CFB3 +:200B2000812F8F7711F492E001C093E09093270280688093E30083C08058823008F07EC027 +:200B400080912A0290912B0223E08C3D920799F55FB7F894DE0115964EE020E030E061E26A +:200B6000E42FF0E060935700849120FF03C082958F704F5F982F9F70892F805D8A3308F06D +:200B8000895F8C9311961C9211972F5F3F4F12962431310529F75FBF8AE28B8383E08C83D8 +:200BA0008091E800877F8093E800CE0103966AE270E011DD12C060912C02AE014F5F5F4F4D +:200BC00055DCBC01009709F43AC08091E800877F8093E80089819A815BDD8091E8008B7747 +:200BE0008093E8002CC0803849F58091E800877F8093E800809125028093F1008091E800E9 +:200C00008E778093E80095DC1AC08823B9F490912A029230A0F48091E800877F8093E80094 +:200C20009093250286DC80912502882311F483E001C084E08093270253DB01C04EDB809133 +:200C4000E80083FF0AC08091EB0080628093EB008091E800877F8093E800AC960FB6F894F7 +:200C6000DEBF0FBECDBFCF91DF911F91089508951F9380912702882361F01091E9001092B0 +:200C8000E9008091E80083FF01C093DE17701093E9001F9108950895FC01809127028430D6 +:200CA00021F587859089A189B2890097A105B105E1F085818093E9008091E80082FF15C07F +:200CC0008091F200882319F42FEF3FEF04C08091F100282F30E08091F200882341F48091EC +:200CE000E8008B778093E80002C02FEF3FEFC9010895FC0180912702843011F58785908984 +:200D0000A189B2890097A105B105D1F081818093E9008091F2008823A9F09091E80080915B +:200D2000E8008E778093E80095FD0CC023DC982F882349F48091E8008E778093E80003C003 +:200D400092E001C090E0892F0895FC0180912702843051F487859089A189B2890097A105A4 +:200D6000B10511F0CF01C5CF08951F93FC01162F809127028430D9F487859089A189B28982 +:200D80000097A105B10599F081818093E9008091E80085FD08C08091E8008E778093E8009D +:200DA000E9DB882329F41093F10080E001C082E01F9108950F931F93CF93DF93EC010D968B +:200DC000FC0189E0DF011D928A95E9F72A813B8109818C81882311F410E001C014E0C90102 +:200DE00073DB182B1260802F61E8412F7BDB882329F12E813F810D818885882311F410E0C3 +:200E000001C014E0C90160DB182B1260802F60E8412F68DB882391F02A853B8509858C857F +:200E2000882311F410E001C014E0C9014DDB182B1260802F61EC412F55DB01C080E0DF9189 +:200E4000CF911F910F910895CF93DF93EC018091E80083FF60C0888190E020912C023091D0 +:200E60002D022817390709F056C080912902813261F0823220F4803209F04DC019C0823268 +:200E800069F1833209F047C038C080912802813A09F041C08091E800877F8093E800CE0192 +:200EA0000F9667E070E097DB8091E8008B7713C080912802813279F58091E800877F809348 +:200EC000E800CE010F9667E070E041DCCE0170D98091E8008E778093E8001DC080912802D9 +:200EE0008132C9F48091E800877F8093E80080912A028D87CE01E9D90DC0809128028132EB +:200F000051F48091E800877F8093E800CE0160912A02C1DE0EDBDF91CF910895A1E21A2EE6 +:200F2000AA1BBB1BFD010DC0AA1FBB1FEE1FFF1FA217B307E407F50720F0A21BB30BE40BA9 +:200F4000F50B661F771F881F991F1A9469F760957095809590959B01AC01BD01CF01089561 +:200F6000F894FFCF00034000000440000002080000000000000000000000FFFFFFFFFFFF8C +:200F8000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF71 +:200FA000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF51 +:200FC000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF31 +:200FE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF11 +:201000004BC0000064C0000062C0000060C000005EC000005CC000005AC0000058C00000F3 +:2010200056C0000054C0000052C00000CBC400004EC000004CC000004AC0000048C00000B9 +:2010400046C0000044C0000042C0000040C000003EC000003CC000003AC0000038C0000098 +:2010600036C0000034C0000032C0000030C000002EC000002CC000002AC0000028C00000F8 +:2010800026C0000024C0000022C0000020C000001EC000001CC0000011241FBECFEFD2E088 +:2010A000DEBFCDBF11E0A0E0B1E0E4EBFCE102C005900D92AC35B107D9F711E0ACE5B1E0E7 +:2010C00001C01D92AB37B107E1F74FD3F1C598CF982F15C08091F200882371F48091E80047 +:2010E0008B7F8093E80003C08EB3882351F08091E80082FFF9CF02C08091F1009150992358 +:2011000049F7089520916A013091690180916801909167018093610190936201C9018093D0 +:20112000630190936401089580916501843009F45AC0853030F4813059F0833009F0C3C0E2 +:201140001FC0853009F4A0C0863009F0BCC0AFC080916601823008F0B6C0D4DF8091660141 +:20116000882361F4809161019091620123E0FC0120935700E89507B600FCFDCF85E008C03F +:2011800080916601882311F0823029F4BBDF89E0809301010895813009F095C020E030E098 +:2011A00040E050E0F90184918F3F81F0CA01AA27BB278093600130936201209361018AE0FA +:2011C0008093010185E080935D0108952F5F3F4F4F4F5F4F2030F0E13F07F0E04F07F0E0C2 +:2011E0005F0701F7089580916601833051F581E080935C0180916B0190916C01892B71F092 +:2012000080916701813009F05EC080916A019091690190935F0180935E010895809167017B +:20122000882361F42CE088E190E00FB6F894A895809360000FBE20936000089510920001A8 +:201240000895882309F03FC0809167018F3F09F03AC0E0E0F0E093E085E090935700E895B5 +:2012600007B600FCFDCF80935700E89507B600FCFDCFE058FF4F20E1E030F20771F781E123 +:2012800080935700E8950895E091670180916601882321F4F0E0EB5FFE4F05C0813099F44F +:2012A000F0E0EE52FF4F808180937001089580916601833041F480916701882321F4809104 +:2012C00068018093600108952F923F924F925F926F927F929F92AF92BF92CF92DF92EF9208 +:2012E000FF920F931F93CF93DF938091790190917A0190936C0180936B0180916D018823D5 +:2013000051F080916D01815080936D0180916D01882309F45D9A80916E01882351F0809120 +:201320006E01815080936E0180916E01882309F45C9A80917401833009F4B2C1843030F44C +:20134000813071F0823009F0E3C111C1853009F4C5C1853008F4BAC1863009F0D9C1CDC11F +:201360005C9883E080936E018091E800877F8093E80080915C01882329F0D6DE5D9A5C9AC7 +:2013800010925C0120916B0130916C012115310529F42AC08EB3882309F4BAC18091E80033 +:2013A00082FFF8CF8091F100809365012150304030936C0120936B01E6E6F1E00CC08091C0 +:2013C000F10081932150304081E0EB36F80719F43183208308C08091F200882381F7309391 +:2013E0006C0120936B01A0DE80910101853009F0BAC080916B0190916C01892B21F482E072 +:2014000080930101B0C08AE163DE809161018F715FDEC0916301D09164012091610130919C +:20142000620121968E01021B130B219780916601882309F093C0180136942794C901A09108 +:201440006001B0E09C01AD0162E0E62EF12C012D112DE20EF31E041F151F59016A0190E0E4 +:2014600099249394B5E0A3E048C08091F200882371F48091E8008B7F8093E80004C08EB352 +:20148000882309F445C18091E80082FFF8CF0894210831088091F100682F8091F100782F1D +:2014A000F5010B0190925700E89511249F5F903419F021143104A1F4F901B0935700E89524 +:2014C00007B600FCFDCF2114310451F0F701A0935700E89507B600FCFDCFA801970190E0A7 +:2014E00042E0442E512C612C712CE40CF51C061D171DA40CB51CC61CD71C2114310409F0A0 +:20150000B4CFD0936201C093610181E180935700E89527C08091F200882371F48091E80091 +:201520008B7F8093E80004C08EB3882309F4F0C08091E80082FFF8CF6091F10080916101B3 +:2015400090916201A7D3809161019091620101969093620180936101015010400115110537 +:20156000C9F680E1B5DD8091E8008B7FC3C08091E800877F8093E8005D9883E080936D0160 +:2015800004C08EB3882309F4C3C08091E80080FFF8CF80910101893091F08A3069F4809167 +:2015A0006601813049F480916101909162018093F1009093F1009BC08091700196C06091A3 +:2015C00063017091640120916101309162016F5F7F4F7B01E21AF30A615070408091660120 +:2015E000882389F5870116950795C901A0916001B0E09C01AD011FC08091F200803271F4C3 +:201600008091E8008E7F8093E80004C08EB3882309F47EC08091E80080FFF8CFF90185918F +:2016200094918093F1009093F100015010402E5F3F4F4F4F5F4F01151105F1F670936201EC +:201640006093610129C0823039F523C08091F200803271F48091E8008E7F8093E80004C0AA +:201660008EB3882309F454C08091E80080FFF8CF0091610110916201C80104D38093F10093 +:201680000F5F1F4F10936201009361010894E108F108E114F104D1F682E08093010127C0E6 +:2016A0008091E800877F8093E80080915D018093F1001092F1001092F1001092F1008091F3 +:2016C00001018093F1001092F10011C08091E800877F8093E80010925D0119C08091E800D4 +:2016E000877F8093E800809101018093F1008091E8008E7F8093E8000AC08091E800877F08 +:201700008093E8005D9A5C9A82E08093010187D0DF91CF911F910F91FF90EF90DF90CF9017 +:20172000BF90AF909F907F906F905F904F903F902F9008952BD181E085BF15BE089584B799 +:20174000877F84BF88E10FB6F89480936000109260000FBE81E085BF82E085BF8AB18063DB +:201760008AB98BB180638BB90CC1E9DF789401C080D2809100018823D9F780915C01882369 +:20178000B9F7D8DFE0915E01F0915F010995FA01923071F0933089F0913029F488E091E082 +:2017A00022E130E019C080E090E020E030E014C08AE191E02BE130E00FC0882339F48091D9 +:2017C0003501282F30E085E391E006C080913901282F30E089E391E091838083C9010895C0 +:2017E0008091EB0081608093EB001092ED006093EC004093ED008091EE00881F8827881FE4 +:2018000008951092F4001092F0001092E8001092ED00EBEEF0E080818E7F80830895809182 +:20182000730188238CF403C08EB38823B1F08091E80082FFF9CF8091E8008B7F8093E80079 +:2018400008958EB3882349F08091E80080FFF9CF8091E8008E7F8093E80008959C0140917A +:20186000790150917A014617570718F4F90120E038C06115710511F0AB01F8CF8091E80080 +:201880008E7F8093E80040E050E0F0CF8091E80083FF02C081E008958091E80082FD2DC091 +:2018A0008EB3882381F18EB3853079F18091E80080FF17C09091F20006C081918093F1002C +:2018C000415050409F5F4115510511F09032A8F320E0903209F421E08091E8008E7F809306 +:2018E000E8004115510591F6222381F606C08EB3882349F08EB3853041F08091E80082FF85 +:20190000F6CF80E0089582E0089583E0089554D056D01EBA1092710184E089BD89B5826006 +:2019200089BD09B400FEFDCF8091D800982F9F779093D80080688093D800809163008E7FC5 +:20194000809363008091D8008F7D8093D8008091E0008E7F8093E0008091E1008E7F80932E +:20196000E1008091E20081608093E2008091E100877F8093E1008091E20088608093E20001 +:201980000895C5DF81E0809372010895C0DFE0EEF0E0808181608083E8EDF0E080818F77B4 +:2019A00080830AD00CD019BCE3E6F0E08081816080831092720108951092E20008951092A6 +:2019C000E10008951F920F920FB60F9211242F933F934F935F936F937F938F939F93AF938A +:2019E000BF93EF93FF938091E10080FF1BC08091E20080FF17C08091E1008E7F8093E100F9 +:201A00008091E2008E7F8093E2008091E20080618093E2008091D80080628093D80019BC7D +:201A20001EBA26D18091E10084FF29C08091E20084FF25C084E089BD89B5826089BD09B451 +:201A400000FEFDCF8091D8008F7D8093D8008091E1008F7E8093E1008091E2008F7E8093D6 +:201A6000E2008091E20081608093E20080917101882311F481E001C084E08EBBF9D08091DF +:201A8000E10083FF22C08091E20083FF1EC08091E100877F8093E10082E08EBB1092710103 +:201AA0008091E1008E7F8093E1008091E2008E7F8093E2008091E20080618093E200A1DEF6 +:201AC00080E060E042E28CDED3D08091E10082FF0AC08091E20082FF06C08091E1008B7FC2 +:201AE0008093E100C5D0FF91EF91BF91AF919F918F917F916F915F914F913F912F910F905E +:201B00000FBE0F901F9018951F93DF93CF9300D0CDB7DEB7E3E7F1E08091F100819381E07C +:201B2000EB37F807C9F79091730180917401853011F1863040F48130B9F0813070F08330EA +:201B400009F081C011C0883009F453C0893009F462C0863009F077C02DC0903809F474C00E +:201B6000923809F070C070C0992309F46DC0923009F069C069C0992309F065C0109175015E +:201B80008091E800877F8093E80049DE04C08EB3882309F459C08091E80080FFF8CF812F6F +:201BA0008F7711F492E001C093E09EBB80688093E3004AC09058923008F045C08091750105 +:201BC0009091760160917701AE014F5F5F4FDFDDBC010097C9F18091E800877F8093E80035 +:201BE00089819A813BDE8091E8008B7F8093E8002BC0903841F58091E800877F8093E800C6 +:201C0000809171018093F1008091E8008E7F8093E80005DE19C09923B1F4909175019230C6 +:201C200098F48091E800877F8093E80090937101F6DD80917101882311F483E001C084E0FB +:201C40008EBB16D001C040DB8091E80083FF0AC08091EB0080628093EB008091E800877F59 +:201C60008093E8000F900F90CF91DF911F91089508958EB3882329F08091E80083FF01C030 +:201C800043CF0895F999FECF92BD81BDF89A992780B50895262FF999FECF1FBA92BD81BD6B +:201CA00020BD0FB6F894FA9AF99A0FBE01960895F894FFCF01021E938220DCFB1201100123 +:201CC00000000020EB03F72F00000001000109021B0001010080320904000000FE010200E6 +:201CE0000921030000000C0001040309042003410072006400750069006E006F002000552C +:101D0000006E006F002000440046005500000000F7 +:00000001FF diff --git a/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.c b/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.c new file mode 100755 index 000000000..7bed831f2 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.c @@ -0,0 +1,728 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Main source file for the DFU class bootloader. This file contains the complete bootloader logic. + */ + +#define INCLUDE_FROM_BOOTLOADER_C +#include "Arduino-usbdfu.h" + +/** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run + * via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application + * jumped to via an indirect jump to location 0x0000 (or other location specified by the host). + */ +bool RunBootloader = true; + +/** Flag to indicate if the bootloader is waiting to exit. When the host requests the bootloader to exit and + * jump to the application address it specifies, it sends two sequential commands which must be properly + * acknowledged. Upon reception of the first the RunBootloader flag is cleared and the WaitForExit flag is set, + * causing the bootloader to wait for the final exit command before shutting down. + */ +bool WaitForExit = false; + +/** Current DFU state machine state, one of the values in the DFU_State_t enum. */ +uint8_t DFU_State = dfuIDLE; + +/** Status code of the last executed DFU command. This is set to one of the values in the DFU_Status_t enum after + * each operation, and returned to the host when a Get Status DFU request is issued. + */ +uint8_t DFU_Status = OK; + +/** Data containing the DFU command sent from the host. */ +DFU_Command_t SentCommand; + +/** Response to the last issued Read Data DFU command. Unlike other DFU commands, the read command + * requires a single byte response from the bootloader containing the read data when the next DFU_UPLOAD command + * is issued by the host. + */ +uint8_t ResponseByte; + +/** Pointer to the start of the user application. By default this is 0x0000 (the reset vector), however the host + * may specify an alternate address when issuing the application soft-start command. + */ +AppPtr_t AppStartPtr = (AppPtr_t)0x0000; + +/** 64-bit flash page number. This is concatenated with the current 16-bit address on USB AVRs containing more than + * 64KB of flash memory. + */ +uint8_t Flash64KBPage = 0; + +/** Memory start address, indicating the current address in the memory being addressed (either FLASH or EEPROM + * depending on the issued command from the host). + */ +uint16_t StartAddr = 0x0000; + +/** Memory end address, indicating the end address to read to/write from in the memory being addressed (either FLASH + * of EEPROM depending on the issued command from the host). + */ +uint16_t EndAddr = 0x0000; + + +/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */ +volatile struct +{ + uint8_t TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */ + uint8_t RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */ + uint8_t PingPongLEDPulse; /**< Milliseconds remaining for enumeration Tx/Rx ping-pong LED pulse */ +} PulseMSRemaining; + +/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously + * runs the bootloader processing routine until instructed to soft-exit, or hard-reset via the watchdog to start + * the loaded application code. + */ +int main(void) +{ + /* Configure hardware required by the bootloader */ + SetupHardware(); + + /* Enable global interrupts so that the USB stack can function */ + sei(); + + /* Run the USB management task while the bootloader is supposed to be running */ + while (RunBootloader || WaitForExit) + USB_USBTask(); + + /* Reset configured hardware back to their original states for the user application */ + ResetHardware(); + + /* Start the user application */ + AppStartPtr(); +} + +/** Configures all hardware required for the bootloader. */ +void SetupHardware(void) +{ + /* Disable watchdog if enabled by bootloader/fuses */ + MCUSR &= ~(1 << WDRF); + wdt_disable(); + + /* Disable clock division */ +// clock_prescale_set(clock_div_1); + + /* Relocate the interrupt vector table to the bootloader section */ + MCUCR = (1 << IVCE); + MCUCR = (1 << IVSEL); + + LEDs_Init(); + + /* Initialize the USB subsystem */ + USB_Init(); +} + +/** Resets all configured hardware required for the bootloader back to their original states. */ +void ResetHardware(void) +{ + /* Shut down the USB subsystem */ + USB_ShutDown(); + + /* Relocate the interrupt vector table back to the application section */ + MCUCR = (1 << IVCE); + MCUCR = 0; +} + +/** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific + * control requests that are not handled internally by the USB library (including the DFU commands, which are + * all issued via the control endpoint), so that they can be handled appropriately for the application. + */ +void EVENT_USB_Device_UnhandledControlRequest(void) +{ + /* Get the size of the command and data from the wLength value */ + SentCommand.DataSize = USB_ControlRequest.wLength; + + /* Turn off TX LED(s) once the TX pulse period has elapsed */ + if (PulseMSRemaining.TxLEDPulse && !(--PulseMSRemaining.TxLEDPulse)) + LEDs_TurnOffLEDs(LEDMASK_TX); + + /* Turn off RX LED(s) once the RX pulse period has elapsed */ + if (PulseMSRemaining.RxLEDPulse && !(--PulseMSRemaining.RxLEDPulse)) + LEDs_TurnOffLEDs(LEDMASK_RX); + + switch (USB_ControlRequest.bRequest) + { + case DFU_DNLOAD: + LEDs_TurnOnLEDs(LEDMASK_RX); + PulseMSRemaining.RxLEDPulse = TX_RX_LED_PULSE_MS; + + Endpoint_ClearSETUP(); + + /* Check if bootloader is waiting to terminate */ + if (WaitForExit) + { + /* Bootloader is terminating - process last received command */ + ProcessBootloaderCommand(); + + /* Turn off TX/RX status LEDs so that they're not left on when application starts */ + LEDs_TurnOffLEDs(LEDMASK_TX); + LEDs_TurnOffLEDs(LEDMASK_RX); + + /* Indicate that the last command has now been processed - free to exit bootloader */ + WaitForExit = false; + } + + /* If the request has a data stage, load it into the command struct */ + if (SentCommand.DataSize) + { + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + + /* First byte of the data stage is the DNLOAD request's command */ + SentCommand.Command = Endpoint_Read_Byte(); + + /* One byte of the data stage is the command, so subtract it from the total data bytes */ + SentCommand.DataSize--; + + /* Load in the rest of the data stage as command parameters */ + for (uint8_t DataByte = 0; (DataByte < sizeof(SentCommand.Data)) && + Endpoint_BytesInEndpoint(); DataByte++) + { + SentCommand.Data[DataByte] = Endpoint_Read_Byte(); + SentCommand.DataSize--; + } + + /* Process the command */ + ProcessBootloaderCommand(); + } + + /* Check if currently downloading firmware */ + if (DFU_State == dfuDNLOAD_IDLE) + { + if (!(SentCommand.DataSize)) + { + DFU_State = dfuIDLE; + } + else + { + /* Throw away the filler bytes before the start of the firmware */ + DiscardFillerBytes(DFU_FILLER_BYTES_SIZE); + + /* Throw away the packet alignment filler bytes before the start of the firmware */ + DiscardFillerBytes(StartAddr % FIXED_CONTROL_ENDPOINT_SIZE); + + /* Calculate the number of bytes remaining to be written */ + uint16_t BytesRemaining = ((EndAddr - StartAddr) + 1); + + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Write flash + { + /* Calculate the number of words to be written from the number of bytes to be written */ + uint16_t WordsRemaining = (BytesRemaining >> 1); + + union + { + uint16_t Words[2]; + uint32_t Long; + } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; + + uint32_t CurrFlashPageStartAddress = CurrFlashAddress.Long; + uint8_t WordsInFlashPage = 0; + + while (WordsRemaining--) + { + /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ + if (!(Endpoint_BytesInEndpoint())) + { + Endpoint_ClearOUT(); + + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + } + + /* Write the next word into the current flash page */ + boot_page_fill(CurrFlashAddress.Long, Endpoint_Read_Word_LE()); + + /* Adjust counters */ + WordsInFlashPage += 1; + CurrFlashAddress.Long += 2; + + /* See if an entire page has been written to the flash page buffer */ + if ((WordsInFlashPage == (SPM_PAGESIZE >> 1)) || !(WordsRemaining)) + { + /* Commit the flash page to memory */ + boot_page_write(CurrFlashPageStartAddress); + boot_spm_busy_wait(); + + /* Check if programming incomplete */ + if (WordsRemaining) + { + CurrFlashPageStartAddress = CurrFlashAddress.Long; + WordsInFlashPage = 0; + + /* Erase next page's temp buffer */ + boot_page_erase(CurrFlashAddress.Long); + boot_spm_busy_wait(); + } + } + } + + /* Once programming complete, start address equals the end address */ + StartAddr = EndAddr; + + /* Re-enable the RWW section of flash */ + boot_rww_enable(); + } + else // Write EEPROM + { + while (BytesRemaining--) + { + /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ + if (!(Endpoint_BytesInEndpoint())) + { + Endpoint_ClearOUT(); + + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + } + + /* Read the byte from the USB interface and write to to the EEPROM */ + eeprom_write_byte((uint8_t*)StartAddr, Endpoint_Read_Byte()); + + /* Adjust counters */ + StartAddr++; + } + } + + /* Throw away the currently unused DFU file suffix */ + DiscardFillerBytes(DFU_FILE_SUFFIX_SIZE); + } + } + + Endpoint_ClearOUT(); + + Endpoint_ClearStatusStage(); + + break; + case DFU_UPLOAD: + Endpoint_ClearSETUP(); + + LEDs_TurnOnLEDs(LEDMASK_TX); + PulseMSRemaining.TxLEDPulse = TX_RX_LED_PULSE_MS; + + while (!(Endpoint_IsINReady())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + + if (DFU_State != dfuUPLOAD_IDLE) + { + if ((DFU_State == dfuERROR) && IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Blank Check + { + /* Blank checking is performed in the DFU_DNLOAD request - if we get here we've told the host + that the memory isn't blank, and the host is requesting the first non-blank address */ + Endpoint_Write_Word_LE(StartAddr); + } + else + { + /* Idle state upload - send response to last issued command */ + Endpoint_Write_Byte(ResponseByte); + } + } + else + { + /* Determine the number of bytes remaining in the current block */ + uint16_t BytesRemaining = ((EndAddr - StartAddr) + 1); + + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Read FLASH + { + /* Calculate the number of words to be written from the number of bytes to be written */ + uint16_t WordsRemaining = (BytesRemaining >> 1); + + union + { + uint16_t Words[2]; + uint32_t Long; + } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; + + while (WordsRemaining--) + { + /* Check if endpoint is full - if so clear it and wait until ready for next packet */ + if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) + { + Endpoint_ClearIN(); + + while (!(Endpoint_IsINReady())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + } + + /* Read the flash word and send it via USB to the host */ + #if (FLASHEND > 0xFFFF) + Endpoint_Write_Word_LE(pgm_read_word_far(CurrFlashAddress.Long)); + #else + Endpoint_Write_Word_LE(pgm_read_word(CurrFlashAddress.Long)); + #endif + + /* Adjust counters */ + CurrFlashAddress.Long += 2; + } + + /* Once reading is complete, start address equals the end address */ + StartAddr = EndAddr; + } + else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x02)) // Read EEPROM + { + while (BytesRemaining--) + { + /* Check if endpoint is full - if so clear it and wait until ready for next packet */ + if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) + { + Endpoint_ClearIN(); + + while (!(Endpoint_IsINReady())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + } + + /* Read the EEPROM byte and send it via USB to the host */ + Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)StartAddr)); + + /* Adjust counters */ + StartAddr++; + } + } + + /* Return to idle state */ + DFU_State = dfuIDLE; + } + + Endpoint_ClearIN(); + + Endpoint_ClearStatusStage(); + break; + case DFU_GETSTATUS: + Endpoint_ClearSETUP(); + + /* Write 8-bit status value */ + Endpoint_Write_Byte(DFU_Status); + + /* Write 24-bit poll timeout value */ + Endpoint_Write_Byte(0); + Endpoint_Write_Word_LE(0); + + /* Write 8-bit state value */ + Endpoint_Write_Byte(DFU_State); + + /* Write 8-bit state string ID number */ + Endpoint_Write_Byte(0); + + Endpoint_ClearIN(); + + Endpoint_ClearStatusStage(); + break; + case DFU_CLRSTATUS: + Endpoint_ClearSETUP(); + + /* Reset the status value variable to the default OK status */ + DFU_Status = OK; + + Endpoint_ClearStatusStage(); + break; + case DFU_GETSTATE: + Endpoint_ClearSETUP(); + + /* Write the current device state to the endpoint */ + Endpoint_Write_Byte(DFU_State); + + Endpoint_ClearIN(); + + Endpoint_ClearStatusStage(); + break; + case DFU_ABORT: + Endpoint_ClearSETUP(); + + /* Turn off TX/RX status LEDs so that they're not left on when application starts */ + LEDs_TurnOffLEDs(LEDMASK_TX); + LEDs_TurnOffLEDs(LEDMASK_RX); + + /* Reset the current state variable to the default idle state */ + DFU_State = dfuIDLE; + + Endpoint_ClearStatusStage(); + break; + } +} + +/** Routine to discard the specified number of bytes from the control endpoint stream. This is used to + * discard unused bytes in the stream from the host, including the memory program block suffix. + * + * \param[in] NumberOfBytes Number of bytes to discard from the host from the control endpoint + */ +static void DiscardFillerBytes(uint8_t NumberOfBytes) +{ + while (NumberOfBytes--) + { + if (!(Endpoint_BytesInEndpoint())) + { + Endpoint_ClearOUT(); + + /* Wait until next data packet received */ + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + } + else + { + Endpoint_Discard_Byte(); + } + } +} + +/** Routine to process an issued command from the host, via a DFU_DNLOAD request wrapper. This routine ensures + * that the command is allowed based on the current secure mode flag value, and passes the command off to the + * appropriate handler function. + */ +static void ProcessBootloaderCommand(void) +{ + /* Check if device is in secure mode */ +// if (IsSecure) +// { +// /* Don't process command unless it is a READ or chip erase command */ +// if (!(((SentCommand.Command == COMMAND_WRITE) && +// IS_TWOBYTE_COMMAND(SentCommand.Data, 0x00, 0xFF)) || +// (SentCommand.Command == COMMAND_READ))) +// { +// /* Set the state and status variables to indicate the error */ +// DFU_State = dfuERROR; +// DFU_Status = errWRITE; +// +// /* Stall command */ +// Endpoint_StallTransaction(); +// +// /* Don't process the command */ +// return; +// } +// } + + /* Dispatch the required command processing routine based on the command type */ + switch (SentCommand.Command) + { + case COMMAND_PROG_START: + ProcessMemProgCommand(); + break; + case COMMAND_DISP_DATA: + ProcessMemReadCommand(); + break; + case COMMAND_WRITE: + ProcessWriteCommand(); + break; + case COMMAND_READ: + ProcessReadCommand(); + break; + case COMMAND_CHANGE_BASE_ADDR: + if (IS_TWOBYTE_COMMAND(SentCommand.Data, 0x03, 0x00)) // Set 64KB flash page command + Flash64KBPage = SentCommand.Data[2]; + break; + } +} + +/** Routine to concatenate the given pair of 16-bit memory start and end addresses from the host, and store them + * in the StartAddr and EndAddr global variables. + */ +static void LoadStartEndAddresses(void) +{ + union + { + uint8_t Bytes[2]; + uint16_t Word; + } Address[2] = {{.Bytes = {SentCommand.Data[2], SentCommand.Data[1]}}, + {.Bytes = {SentCommand.Data[4], SentCommand.Data[3]}}}; + + /* Load in the start and ending read addresses from the sent data packet */ + StartAddr = Address[0].Word; + EndAddr = Address[1].Word; +} + +/** Handler for a Memory Program command issued by the host. This routine handles the preparations needed + * to write subsequent data from the host into the specified memory. + */ +static void ProcessMemProgCommand(void) +{ + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00) || // Write FLASH command + IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Write EEPROM command + { + /* Load in the start and ending read addresses */ + LoadStartEndAddresses(); + + /* If FLASH is being written to, we need to pre-erase the first page to write to */ + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) + { + union + { + uint16_t Words[2]; + uint32_t Long; + } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; + + /* Erase the current page's temp buffer */ + boot_page_erase(CurrFlashAddress.Long); + boot_spm_busy_wait(); + } + + /* Set the state so that the next DNLOAD requests reads in the firmware */ + DFU_State = dfuDNLOAD_IDLE; + } +} + +/** Handler for a Memory Read command issued by the host. This routine handles the preparations needed + * to read subsequent data from the specified memory out to the host, as well as implementing the memory + * blank check command. + */ +static void ProcessMemReadCommand(void) +{ + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00) || // Read FLASH command + IS_ONEBYTE_COMMAND(SentCommand.Data, 0x02)) // Read EEPROM command + { + /* Load in the start and ending read addresses */ + LoadStartEndAddresses(); + + /* Set the state so that the next UPLOAD requests read out the firmware */ + DFU_State = dfuUPLOAD_IDLE; + } + else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Blank check FLASH command + { + uint32_t CurrFlashAddress = 0; + + while (CurrFlashAddress < BOOT_START_ADDR) + { + /* Check if the current byte is not blank */ + #if (FLASHEND > 0xFFFF) + if (pgm_read_byte_far(CurrFlashAddress) != 0xFF) + #else + if (pgm_read_byte(CurrFlashAddress) != 0xFF) + #endif + { + /* Save the location of the first non-blank byte for response back to the host */ + Flash64KBPage = (CurrFlashAddress >> 16); + StartAddr = CurrFlashAddress; + + /* Set state and status variables to the appropriate error values */ + DFU_State = dfuERROR; + DFU_Status = errCHECK_ERASED; + + break; + } + + CurrFlashAddress++; + } + } +} + +/** Handler for a Data Write command issued by the host. This routine handles non-programming commands such as + * bootloader exit (both via software jumps and hardware watchdog resets) and flash memory erasure. + */ +static void ProcessWriteCommand(void) +{ + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x03)) // Start application + { + /* Indicate that the bootloader is terminating */ + WaitForExit = true; + + /* Check if data supplied for the Start Program command - no data executes the program */ + if (SentCommand.DataSize) + { + if (SentCommand.Data[1] == 0x01) // Start via jump + { + union + { + uint8_t Bytes[2]; + AppPtr_t FuncPtr; + } Address = {.Bytes = {SentCommand.Data[4], SentCommand.Data[3]}}; + + /* Load in the jump address into the application start address pointer */ + AppStartPtr = Address.FuncPtr; + } + } + else + { + if (SentCommand.Data[1] == 0x00) // Start via watchdog + { + /* Start the watchdog to reset the AVR once the communications are finalized */ + wdt_enable(WDTO_250MS); + } + else // Start via jump + { + /* Set the flag to terminate the bootloader at next opportunity */ + RunBootloader = false; + } + } + } + else if (IS_TWOBYTE_COMMAND(SentCommand.Data, 0x00, 0xFF)) // Erase flash + { + uint32_t CurrFlashAddress = 0; + + /* Clear the application section of flash */ + while (CurrFlashAddress < BOOT_START_ADDR) + { + boot_page_erase(CurrFlashAddress); + boot_spm_busy_wait(); + boot_page_write(CurrFlashAddress); + boot_spm_busy_wait(); + + CurrFlashAddress += SPM_PAGESIZE; + } + + /* Re-enable the RWW section of flash as writing to the flash locks it out */ + boot_rww_enable(); + + /* Memory has been erased, reset the security bit so that programming/reading is allowed */ +// IsSecure = false; + } +} + +/** Handler for a Data Read command issued by the host. This routine handles bootloader information retrieval + * commands such as device signature and bootloader version retrieval. + */ +static void ProcessReadCommand(void) +{ + const uint8_t BootloaderInfo[3] = {BOOTLOADER_VERSION, BOOTLOADER_ID_BYTE1, BOOTLOADER_ID_BYTE2}; + const uint8_t SignatureInfo[3] = {AVR_SIGNATURE_1, AVR_SIGNATURE_2, AVR_SIGNATURE_3}; + + uint8_t DataIndexToRead = SentCommand.Data[1]; + + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Read bootloader info + ResponseByte = BootloaderInfo[DataIndexToRead]; + else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Read signature byte + ResponseByte = SignatureInfo[DataIndexToRead - 0x30]; +} diff --git a/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.h b/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.h new file mode 100755 index 000000000..4fb236e64 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.h @@ -0,0 +1,220 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Header file for Arduino-usbdfu.c. + */ + +#ifndef _ARDUINO_USB_DFU_BOOTLOADER_H_ +#define _ARDUINO_USB_DFU_BOOTLOADER_H_ + + /* Includes: */ + #include + #include + #include + #include + #include + #include + #include + #include + + #include "Descriptors.h" + + #include + #include + + /* Macros: */ + /** LED mask for the library LED driver, to indicate TX activity. */ + #define LEDMASK_TX LEDS_LED1 + + /** LED mask for the library LED driver, to indicate RX activity. */ + #define LEDMASK_RX LEDS_LED2 + + /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ + #define LEDMASK_ERROR (LEDS_LED1 | LEDS_LED2) + + /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ + #define LEDMASK_BUSY (LEDS_LED1 | LEDS_LED2) + + /** Configuration define. Define this token to true to case the bootloader to reject all memory commands + * until a memory erase has been performed. When used in conjunction with the lockbits of the AVR, this + * can protect the AVR's firmware from being dumped from a secured AVR. When false, memory operations are + * allowed at any time. + */ +// #define SECURE_MODE false + + /** Major bootloader version number. */ + #define BOOTLOADER_VERSION_MINOR 2 + + /** Minor bootloader version number. */ + #define BOOTLOADER_VERSION_REV 0 + + /** Complete bootloader version number expressed as a packed byte, constructed from the + * two individual bootloader version macros. + */ + #define BOOTLOADER_VERSION ((BOOTLOADER_VERSION_MINOR << 4) | BOOTLOADER_VERSION_REV) + + /** First byte of the bootloader identification bytes, used to identify a device's bootloader. */ + #define BOOTLOADER_ID_BYTE1 0xDC + + /** Second byte of the bootloader identification bytes, used to identify a device's bootloader. */ + #define BOOTLOADER_ID_BYTE2 0xFB + + /** Convenience macro, used to determine if the issued command is the given one-byte long command. + * + * \param[in] dataarr Command byte array to check against + * \param[in] cb1 First command byte to check + */ + #define IS_ONEBYTE_COMMAND(dataarr, cb1) (dataarr[0] == (cb1)) + + /** Convenience macro, used to determine if the issued command is the given two-byte long command. + * + * \param[in] dataarr Command byte array to check against + * \param[in] cb1 First command byte to check + * \param[in] cb2 Second command byte to check + */ + #define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == (cb1)) && (dataarr[1] == (cb2))) + + /** Length of the DFU file suffix block, appended to the end of each complete memory write command. + * The DFU file suffix is currently unused (but is designed to give extra file information, such as + * a CRC of the complete firmware for error checking) and so is discarded. + */ + #define DFU_FILE_SUFFIX_SIZE 16 + + /** Length of the DFU file filler block, appended to the start of each complete memory write command. + * Filler bytes are added to the start of each complete memory write command, and must be discarded. + */ + #define DFU_FILLER_BYTES_SIZE 26 + + /** DFU class command request to detach from the host. */ + #define DFU_DETATCH 0x00 + + /** DFU class command request to send data from the host to the bootloader. */ + #define DFU_DNLOAD 0x01 + + /** DFU class command request to send data from the bootloader to the host. */ + #define DFU_UPLOAD 0x02 + + /** DFU class command request to get the current DFU status and state from the bootloader. */ + #define DFU_GETSTATUS 0x03 + + /** DFU class command request to reset the current DFU status and state variables to their defaults. */ + #define DFU_CLRSTATUS 0x04 + + /** DFU class command request to get the current DFU state of the bootloader. */ + #define DFU_GETSTATE 0x05 + + /** DFU class command request to abort the current multi-request transfer and return to the dfuIDLE state. */ + #define DFU_ABORT 0x06 + + /** DFU command to begin programming the device's memory. */ + #define COMMAND_PROG_START 0x01 + + /** DFU command to begin reading the device's memory. */ + #define COMMAND_DISP_DATA 0x03 + + /** DFU command to issue a write command. */ + #define COMMAND_WRITE 0x04 + + /** DFU command to issue a read command. */ + #define COMMAND_READ 0x05 + + /** DFU command to issue a memory base address change command, to set the current 64KB flash page + * that subsequent flash operations should use. */ + #define COMMAND_CHANGE_BASE_ADDR 0x06 + + /* Type Defines: */ + /** Type define for a non-returning function pointer to the loaded application. */ + typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; + + /** Type define for a structure containing a complete DFU command issued by the host. */ + typedef struct + { + uint8_t Command; /**< Single byte command to perform, one of the COMMAND_* macro values */ + uint8_t Data[5]; /**< Command parameters */ + uint16_t DataSize; /**< Size of the command parameters */ + } DFU_Command_t; + + /* Enums: */ + /** DFU bootloader states. Refer to the DFU class specification for information on each state. */ + enum DFU_State_t + { + appIDLE = 0, + appDETACH = 1, + dfuIDLE = 2, + dfuDNLOAD_SYNC = 3, + dfuDNBUSY = 4, + dfuDNLOAD_IDLE = 5, + dfuMANIFEST_SYNC = 6, + dfuMANIFEST = 7, + dfuMANIFEST_WAIT_RESET = 8, + dfuUPLOAD_IDLE = 9, + dfuERROR = 10 + }; + + /** DFU command status error codes. Refer to the DFU class specification for information on each error code. */ + enum DFU_Status_t + { + OK = 0, + errTARGET = 1, + errFILE = 2, + errWRITE = 3, + errERASE = 4, + errCHECK_ERASED = 5, + errPROG = 6, + errVERIFY = 7, + errADDRESS = 8, + errNOTDONE = 9, + errFIRMWARE = 10, + errVENDOR = 11, + errUSBR = 12, + errPOR = 13, + errUNKNOWN = 14, + errSTALLEDPKT = 15 + }; + + /* Function Prototypes: */ + void SetupHardware(void); + void ResetHardware(void); + + void EVENT_USB_Device_UnhandledControlRequest(void); + + #if defined(INCLUDE_FROM_BOOTLOADER_C) + static void DiscardFillerBytes(uint8_t NumberOfBytes); + static void ProcessBootloaderCommand(void); + static void LoadStartEndAddresses(void); + static void ProcessMemProgCommand(void); + static void ProcessMemReadCommand(void); + static void ProcessWriteCommand(void); + static void ProcessReadCommand(void); + #endif + +#endif /* _ARDUINO_USB_DFU_BOOTLOADER_H_ */ diff --git a/hardware/arduino/firmwares/arduino-usbdfu/Board/LEDs.h b/hardware/arduino/firmwares/arduino-usbdfu/Board/LEDs.h new file mode 100755 index 000000000..152e8f571 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbdfu/Board/LEDs.h @@ -0,0 +1,110 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/* + Board LEDs driver for the Benito board, from www.dorkbotpdx.org. +*/ + +#ifndef __LEDS_ARDUINOUNO_H__ +#define __LEDS_ARDUINOUNO_H__ + + /* Includes: */ + #include + +/* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(INCLUDE_FROM_LEDS_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 (1 << 5) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 4) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) + + /** LED mask for the none of the board LEDs */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) + { + PORTD = ((PORTD | ActiveMask) & ~LEDMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif diff --git a/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.c b/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.c new file mode 100755 index 000000000..bb5ecfefe --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.c @@ -0,0 +1,189 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * USB Device Descriptors, for library use when in USB device mode. Descriptors are special + * computer-readable structures which the host requests upon device enumeration, to determine + * the device's capabilities and functions. + */ + +#include "Descriptors.h" + +/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall + * device characteristics, including the supported USB version, control endpoint size and the + * number of device configurations. The descriptor is read out by the USB host when the enumeration + * process begins. + */ +USB_Descriptor_Device_t DeviceDescriptor = +{ + .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, + + .USBSpecification = VERSION_BCD(01.10), + .Class = 0x00, + .SubClass = 0x00, + .Protocol = 0x00, + + .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, + + .VendorID = 0x03EB, + .ProductID = PRODUCT_ID_CODE, + .ReleaseNumber = 0x0000, + + .ManufacturerStrIndex = NO_DESCRIPTOR, + .ProductStrIndex = 0x01, + .SerialNumStrIndex = NO_DESCRIPTOR, + + .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS +}; + +/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage + * of the device in one of its supported configurations, including information about any device interfaces + * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting + * a configuration so that the host may correctly communicate with the USB device. + */ +USB_Descriptor_Configuration_t ConfigurationDescriptor = +{ + .Config = + { + .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, + + .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), + .TotalInterfaces = 1, + + .ConfigurationNumber = 1, + .ConfigurationStrIndex = NO_DESCRIPTOR, + + .ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED, + + .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) + }, + + .DFU_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = 0, + .AlternateSetting = 0, + + .TotalEndpoints = 0, + + .Class = 0xFE, + .SubClass = 0x01, + .Protocol = 0x02, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .DFU_Functional = + { + .Header = {.Size = sizeof(USB_DFU_Functional_Descriptor_t), .Type = DTYPE_DFUFunctional}, + + .Attributes = (ATTR_CAN_UPLOAD | ATTR_CAN_DOWNLOAD), + + .DetachTimeout = 0x0000, + .TransferSize = 0x0c00, + + .DFUSpecification = VERSION_BCD(01.01) + } +}; + +/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests + * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate + * via the language ID table available at USB.org what languages the device supports for its string descriptors. + */ +USB_Descriptor_String_t LanguageString = +{ + .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, + + .UnicodeString = {LANGUAGE_ID_ENG} +}; + +/** Product descriptor string. This is a Unicode string containing the product's details in human readable form, + * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device + * Descriptor. + */ +USB_Descriptor_String_t ProductString = +{ + #if (ARDUINO_MODEL_PID == ARDUINO_UNO_PID) + .Header = {.Size = USB_STRING_LEN(15), .Type = DTYPE_String}, + + .UnicodeString = L"Arduino Uno DFU" + #elif (ARDUINO_MODEL_PID == ARDUINO_MEGA2560_PID) + .Header = {.Size = USB_STRING_LEN(21), .Type = DTYPE_String}, + + .UnicodeString = L"Arduino Mega 2560 DFU" + #endif +}; + +/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" + * documentation) by the application code so that the address and size of a requested descriptor can be given + * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function + * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the + * USB host. + */ +uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + void** const DescriptorAddress) +{ + const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorNumber = (wValue & 0xFF); + + void* Address = NULL; + uint16_t Size = NO_DESCRIPTOR; + + switch (DescriptorType) + { + case DTYPE_Device: + Address = &DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); + break; + case DTYPE_Configuration: + Address = &ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); + break; + case DTYPE_String: + if (!(DescriptorNumber)) + { + Address = &LanguageString; + Size = LanguageString.Header.Size; + } + else + { + Address = &ProductString; + Size = ProductString.Header.Size; + } + + break; + } + + *DescriptorAddress = Address; + return Size; +} diff --git a/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.h b/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.h new file mode 100755 index 000000000..6c93f20cd --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.h @@ -0,0 +1,177 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Header file for Descriptors.c. + */ + +#ifndef _DESCRIPTORS_H_ +#define _DESCRIPTORS_H_ + + /* Includes: */ + #include + + /* Product-specific definitions: */ + #define ARDUINO_UNO_PID 0x0001 + #define ARDUINO_MEGA2560_PID 0x0010 + + /* Macros: */ + /** Descriptor type value for a DFU class functional descriptor. */ + #define DTYPE_DFUFunctional 0x21 + + /** DFU attribute mask, indicating that the DFU device will detach and re-attach when a DFU_DETACH + * command is issued, rather than the host issuing a USB Reset. + */ + #define ATTR_WILL_DETATCH (1 << 3) + + /** DFU attribute mask, indicating that the DFU device can communicate during the manifestation phase + * (memory programming phase). + */ + #define ATTR_MANEFESTATION_TOLLERANT (1 << 2) + + /** DFU attribute mask, indicating that the DFU device can accept DFU_UPLOAD requests to send data from + * the device to the host. + */ + #define ATTR_CAN_UPLOAD (1 << 1) + + /** DFU attribute mask, indicating that the DFU device can accept DFU_DNLOAD requests to send data from + * the host to the device. + */ + #define ATTR_CAN_DOWNLOAD (1 << 0) + + #if defined(__AVR_AT90USB1287__) + #define PRODUCT_ID_CODE 0x2FFB + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x97 + #define AVR_SIGNATURE_3 0x82 + #elif defined(__AVR_AT90USB1286__) + #define PRODUCT_ID_CODE 0x2FFB + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x97 + #define AVR_SIGNATURE_3 0x82 + #elif defined(__AVR_AT90USB647__) + #define PRODUCT_ID_CODE 0x2FF9 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x96 + #define AVR_SIGNATURE_3 0x82 + #elif defined(__AVR_AT90USB646__) + #define PRODUCT_ID_CODE 0x2FF9 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x96 + #define AVR_SIGNATURE_3 0x82 + #elif defined(__AVR_ATmega32U6__) + #define PRODUCT_ID_CODE 0x2FFB + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x95 + #define AVR_SIGNATURE_3 0x88 + #elif defined(__AVR_ATmega32U4__) + #define PRODUCT_ID_CODE 0x2FF4 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x95 + #define AVR_SIGNATURE_3 0x87 + #elif defined(__AVR_ATmega32U2__) + #define PRODUCT_ID_CODE 0x2FF0 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x95 + #define AVR_SIGNATURE_3 0x8A + #elif defined(__AVR_ATmega16U4__) + #define PRODUCT_ID_CODE 0x2FF3 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x94 + #define AVR_SIGNATURE_3 0x88 + #elif defined(__AVR_ATmega16U2__) + #define PRODUCT_ID_CODE 0x2FEF + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x94 + #define AVR_SIGNATURE_3 0x89 + #elif defined(__AVR_AT90USB162__) + #define PRODUCT_ID_CODE 0x2FFA + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x94 + #define AVR_SIGNATURE_3 0x82 + #elif defined(__AVR_AT90USB82__) + #define PRODUCT_ID_CODE 0x2FEE + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x93 + #define AVR_SIGNATURE_3 0x89 + #elif defined(__AVR_ATmega8U2__) + #define PRODUCT_ID_CODE 0x2FF7 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x93 + #define AVR_SIGNATURE_3 0x82 + #else + #error The selected AVR part is not currently supported by this bootloader. + #endif + + #if !defined(PRODUCT_ID_CODE) + #error Current AVR model is not supported by this bootloader. + #endif + + /* Type Defines: */ + /** Type define for a DFU class function descriptor. This descriptor gives DFU class information + * to the host when read, indicating the DFU device's capabilities. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Standard descriptor header structure */ + + uint8_t Attributes; /**< DFU device attributes, a mask comprising of the + * ATTR_* macros listed in this source file + */ + uint16_t DetachTimeout; /**< Timeout in milliseconds between a USB_DETACH + * command being issued and the device detaching + * from the USB bus + */ + uint16_t TransferSize; /**< Maximum number of bytes the DFU device can accept + * from the host in a transaction + */ + uint16_t DFUSpecification; /**< BCD packed DFU specification number this DFU + * device complies with + */ + } USB_DFU_Functional_Descriptor_t; + + /** Type define for the device configuration descriptor structure. This must be defined in the + * application code, as the configuration descriptor contains several sub-descriptors which + * vary between devices, and which describe the device's usage to the host. + */ + typedef struct + { + USB_Descriptor_Configuration_Header_t Config; + USB_Descriptor_Interface_t DFU_Interface; + USB_DFU_Functional_Descriptor_t DFU_Functional; + } USB_Descriptor_Configuration_t; + + /* Function Prototypes: */ + uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + void** const DescriptorAddress) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); + +#endif diff --git a/hardware/arduino/firmwares/arduino-usbdfu/makefile b/hardware/arduino/firmwares/arduino-usbdfu/makefile new file mode 100755 index 000000000..1fb4ed346 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbdfu/makefile @@ -0,0 +1,710 @@ +# Hey Emacs, this is a -*- makefile -*- +#---------------------------------------------------------------------------- +# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. +# >> Modified for use with the LUFA project. << +# +# Released to the Public Domain +# +# Additional material for this makefile was written by: +# Peter Fleury +# Tim Henigan +# Colin O'Flynn +# Reiner Patommel +# Markus Pfaff +# Sander Pool +# Frederik Rouleau +# Carlos Lamas +# Dean Camera +# Opendous Inc. +# Denver Gingerich +# +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device, using avrdude. +# Please customize the avrdude settings below first! +# +# make doxygen = Generate DoxyGen documentation for the project (must have +# DoxyGen installed) +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + + +# MCU name +MCU = atmega8u2 +MCU_AVRDUDE = at90usb82 + +# Specify the Arduino model using the assigned PID. This is used by Descriptors.c +# to set the product descriptor string (for DFU we must use the PID for each +# chip that dfu-bootloader or Flip expect) +# Uno PID: +ARDUINO_MODEL_PID = 0x0001 +# Mega 2560 PID: +#ARDUINO_MODEL_PID = 0x0010 + +# Target board (see library "Board Types" documentation, NONE for projects not requiring +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# "Board" inside the application directory. +BOARD = USER + + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_CLOCK below, as it is sourced by +# F_CLOCK after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# Input clock frequency. +# This will define a symbol, F_CLOCK, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_CLOCK = $(F_CPU) + + +# Starting byte address of the bootloader, as a byte address - computed via the formula +# BOOT_START = ((TOTAL_FLASH_BYTES - BOOTLOADER_SECTION_SIZE_BYTES) * 1024) +# +# Note that the bootloader size and start address given in AVRStudio is in words and not +# bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC. +BOOT_START = 0x1000 + + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + + +# Target file name (without extension). +TARGET = Arduino-usbdfu + + +# Object files directory +# To put object files in current directory, use a dot (.), do NOT make +# this an empty or blank macro! +OBJDIR = . + + +# Path to the LUFA library +LUFA_PATH = ../.. + + +# LUFA library compile-time options and predefined tokens +LUFA_OPTS = -D USB_DEVICE_ONLY +LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0 +LUFA_OPTS += -D CONTROL_ONLY_DEVICE +LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=32 +LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 +LUFA_OPTS += -D USE_RAM_DESCRIPTORS +LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" +LUFA_OPTS += -D NO_INTERNAL_SERIAL +LUFA_OPTS += -D NO_DEVICE_SELF_POWER +LUFA_OPTS += -D NO_DEVICE_REMOTE_WAKEUP +LUFA_OPTS += -D NO_STREAM_CALLBACKS + + +# Create the LUFA source path variables by including the LUFA root makefile +include $(LUFA_PATH)/LUFA/makefile + + +# List C source files here. (C dependencies are automatically generated.) +SRC = $(TARGET).c \ + Descriptors.c \ + $(LUFA_SRC_USB) \ + + +# List C++ source files here. (C dependencies are automatically generated.) +CPPSRC = + + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = + + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) +OPT = s + + +# Debugging format. +# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. +# AVR Studio 4.10 requires dwarf-2. +# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. +DEBUG = dwarf-2 + + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRAINCDIRS = $(LUFA_PATH)/ + + +# Compiler flag to set the C Standard level. +# c89 = "ANSI" C +# gnu89 = c89 plus GCC extensions +# c99 = ISO C99 standard (not yet fully implemented) +# gnu99 = c99 plus GCC extensions +CSTANDARD = -std=c99 + + +# Place -D or -U options here for C sources +CDEFS = -DF_CPU=$(F_CPU)UL +CDEFS += -DARDUINO_MODEL_PID=$(ARDUINO_MODEL_PID) +CDEFS += -DF_CLOCK=$(F_CLOCK)UL +CDEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL +CDEFS += -DTX_RX_LED_PULSE_MS=3 +CDEFS += $(LUFA_OPTS) + + +# Place -D or -U options here for ASM sources +ADEFS = -DF_CPU=$(F_CPU) +ADEFS += -DF_CLOCK=$(F_CLOCK)UL +ADEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL +ADEFS += $(LUFA_OPTS) + +# Place -D or -U options here for C++ sources +CPPDEFS = -DF_CPU=$(F_CPU)UL +CPPDEFS += -DF_CLOCK=$(F_CLOCK)UL +CPPDEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL +CPPDEFS += $(LUFA_OPTS) +#CPPDEFS += -D__STDC_LIMIT_MACROS +#CPPDEFS += -D__STDC_CONSTANT_MACROS + + + +#---------------- Compiler Options C ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CFLAGS = -g$(DEBUG) +CFLAGS += $(CDEFS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char +CFLAGS += -funsigned-bitfields +CFLAGS += -ffunction-sections +CFLAGS += -fno-inline-small-functions +CFLAGS += -fpack-struct +CFLAGS += -fshort-enums +CFLAGS += -fno-strict-aliasing +CFLAGS += -Wall +CFLAGS += -Wstrict-prototypes +#CFLAGS += -mshort-calls +#CFLAGS += -fno-unit-at-a-time +#CFLAGS += -Wundef +#CFLAGS += -Wunreachable-code +#CFLAGS += -Wsign-compare +CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) + + +#---------------- Compiler Options C++ ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CPPFLAGS = -g$(DEBUG) +CPPFLAGS += $(CPPDEFS) +CPPFLAGS += -O$(OPT) +CPPFLAGS += -funsigned-char +CPPFLAGS += -funsigned-bitfields +CPPFLAGS += -fpack-struct +CPPFLAGS += -fshort-enums +CPPFLAGS += -fno-exceptions +CPPFLAGS += -Wall +CPPFLAGS += -Wundef +#CPPFLAGS += -mshort-calls +#CPPFLAGS += -fno-unit-at-a-time +#CPPFLAGS += -Wstrict-prototypes +#CPPFLAGS += -Wunreachable-code +#CPPFLAGS += -Wsign-compare +CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) +CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +#CPPFLAGS += $(CSTANDARD) + + +#---------------- Assembler Options ---------------- +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns: create listing +# -gstabs: have the assembler create line number information; note that +# for use in COFF files, additional information about filenames +# and function names needs to be present in the assembler source +# files -- see avr-libc docs [FIXME: not yet described there] +# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# dump that will be displayed for a given single line of source input. +ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 + + +#---------------- Library Options ---------------- +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +# If this is left blank, then it will use the Standard printf version. +PRINTF_LIB = +#PRINTF_LIB = $(PRINTF_LIB_MIN) +#PRINTF_LIB = $(PRINTF_LIB_FLOAT) + + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +# If this is left blank, then it will use the Standard scanf version. +SCANF_LIB = +#SCANF_LIB = $(SCANF_LIB_MIN) +#SCANF_LIB = $(SCANF_LIB_FLOAT) + + +MATH_LIB = -lm + + +# List any extra directories to look for libraries here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRALIBDIRS = + + + +#---------------- External Memory Options ---------------- + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + + + +#---------------- Linker Options ---------------- +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref +LDFLAGS += -Wl,--section-start=.text=$(BOOT_START) +LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--gc-sections +LDFLAGS += $(EXTMEMOPTS) +LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) +LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +#LDFLAGS += -T linker_script.x + + + +#---------------- Programming Options (avrdude) ---------------- + +# Fuse settings for Arduino Uno DFU bootloader project +AVRDUDE_FUSES = -U efuse:w:0xF4:m -U hfuse:w:0xD9:m -U lfuse:w:0xFF:m + +# Lock settings for Arduino Uno DFU bootloader project +AVRDUDE_LOCK = -U lock:w:0x0F:m + +# Programming hardware +# Type: avrdude -c ? +# to get a full listing. +# +AVRDUDE_PROGRAMMER = avrispmkii + +# com1 = serial port. Use lpt1 to connect to parallel port. +AVRDUDE_PORT = usb + +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FLAGS = -p $(MCU_AVRDUDE) -F -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + + + +#---------------- Debugging Options ---------------- + +# For simulavr only - target MCU frequency. +DEBUG_MFREQ = $(F_CPU) + +# Set the DEBUG_UI to either gdb or insight. +# DEBUG_UI = gdb +DEBUG_UI = insight + +# Set the debugging back-end to either avarice, simulavr. +DEBUG_BACKEND = avarice +#DEBUG_BACKEND = simulavr + +# GDB Init Filename. +GDBINIT_FILE = __avr_gdbinit + +# When using avarice settings for the JTAG +JTAG_DEV = /dev/com1 + +# Debugging port used to communicate between GDB / avarice / simulavr. +DEBUG_PORT = 4242 + +# Debugging host used to communicate between GDB / avarice / simulavr, normally +# just set to localhost unless doing some sort of crazy debugging when +# avarice is running on a different computer. +DEBUG_HOST = localhost + + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +AR = avr-ar rcs +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +REMOVEDIR = rm -rf +COPY = cp +WINSHELL = cmd + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling C: +MSG_COMPILING_CPP = Compiling C++: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: +MSG_CREATING_LIBRARY = Creating library: + + + + +# Define all object files. +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + +# Define all listing files. +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +all: begin gccversion sizebefore build sizeafter end + +# Change the build target to build a HEX file or a library. +build: elf hex eep lss sym +#build: lib + + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym +LIBNAME=lib$(TARGET).a +lib: $(LIBNAME) + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf +MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) +FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) + + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + 2>/dev/null; echo; fi + + + +# Display compiler version information. +gccversion : + @$(CC) --version + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) $(AVRDUDE_FUSES) $(AVRDUDE_LOCK) + + +# Generate avr-gdb config/init file which does the following: +# define the reset signal, load the target file, connect to target, and set +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT = $(OBJCOPY) --debugging +COFFCONVERT += --change-section-address .data-0x800000 +COFFCONVERT += --change-section-address .bss-0x800000 +COFFCONVERT += --change-section-address .noinit-0x800000 +COFFCONVERT += --change-section-address .eeprom-0x810000 + + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S -z $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Create library from object files. +.SECONDARY : $(TARGET).a +.PRECIOUS : $(OBJ) +%.a: $(OBJ) + @echo + @echo $(MSG_CREATING_LIBRARY) $@ + $(AR) $@ $(OBJ) + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +$(OBJDIR)/%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create object files from C++ source files. +$(OBJDIR)/%.o : %.cpp + @echo + @echo $(MSG_COMPILING_CPP) $< + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C++ source files. +%.s : %.cpp + $(CC) -S $(ALL_CPPFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +$(OBJDIR)/%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) $(SRC:.c=.i) + $(REMOVEDIR) .dep + +doxygen: + @echo Generating Project Documentation... + @doxygen Doxygen.conf + @echo Documentation Generation Complete. + +clean_doxygen: + rm -rf Documentation + +# Create object files directory +$(shell mkdir $(OBJDIR) 2>/dev/null) + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff doxygen clean \ +clean_list clean_doxygen program debug gdb-config diff --git a/hardware/arduino/firmwares/arduino-usbdfu/readme.txt b/hardware/arduino/firmwares/arduino-usbdfu/readme.txt new file mode 100644 index 000000000..e376679c2 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbdfu/readme.txt @@ -0,0 +1,7 @@ +To setup the project and program an ATMEG8U2 with the Arduino USB DFU bootloader: +1. unpack the source into LUFA's Bootloader directory +2. set ARDUINO_MODEL_PID in the makefile as appropriate +3. do "make clean; make; make program" + +Check that the board enumerates as either "Arduino Uno DFU" or "Arduino Mega 2560 DFU". Test by uploading the Arduino-usbserial application firmware (see instructions in Arduino-usbserial directory) + diff --git a/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.c b/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.c new file mode 100755 index 000000000..181ffc7b7 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.c @@ -0,0 +1,255 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Main source file for the Arduino-usbserial project. This file contains the main tasks of + * the project and is responsible for the initial application hardware configuration. + */ + +#include "Arduino-usbserial.h" + +/** Circular buffer to hold data from the host before it is sent to the device via the serial port. */ +RingBuff_t USBtoUSART_Buffer; + +/** Circular buffer to hold data from the serial port before it is sent to the host. */ +RingBuff_t USARTtoUSB_Buffer; + +/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */ +volatile struct +{ + uint8_t TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */ + uint8_t RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */ + uint8_t PingPongLEDPulse; /**< Milliseconds remaining for enumeration Tx/Rx ping-pong LED pulse */ +} PulseMSRemaining; + +/** LUFA CDC Class driver interface configuration and state information. This structure is + * passed to all CDC Class driver functions, so that multiple instances of the same class + * within a device can be differentiated from one another. + */ +USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = + { + .Config = + { + .ControlInterfaceNumber = 0, + + .DataINEndpointNumber = CDC_TX_EPNUM, + .DataINEndpointSize = CDC_TXRX_EPSIZE, + .DataINEndpointDoubleBank = false, + + .DataOUTEndpointNumber = CDC_RX_EPNUM, + .DataOUTEndpointSize = CDC_TXRX_EPSIZE, + .DataOUTEndpointDoubleBank = false, + + .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, + .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, + .NotificationEndpointDoubleBank = false, + }, + }; + +/** Main program entry point. This routine contains the overall program flow, including initial + * setup of all components and the main program loop. + */ +int main(void) +{ + SetupHardware(); + + RingBuffer_InitBuffer(&USBtoUSART_Buffer); + RingBuffer_InitBuffer(&USARTtoUSB_Buffer); + + sei(); + + for (;;) + { + /* Read bytes from the USB OUT endpoint into the USART transmit buffer */ + int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); + if (!(ReceivedByte < 0) && !(RingBuffer_IsFull(&USBtoUSART_Buffer))) + RingBuffer_Insert(&USBtoUSART_Buffer, ReceivedByte); + + /* Check if the UART receive buffer flush timer has expired or the buffer is nearly full */ + RingBuff_Count_t BufferCount = RingBuffer_GetCount(&USARTtoUSB_Buffer); + if ((TIFR0 & (1 << TOV0)) || (BufferCount > BUFFER_NEARLY_FULL)) + { + TIFR0 |= (1 << TOV0); + + if (USARTtoUSB_Buffer.Count) { + LEDs_TurnOnLEDs(LEDMASK_TX); + PulseMSRemaining.TxLEDPulse = TX_RX_LED_PULSE_MS; + } + + /* Read bytes from the USART receive buffer into the USB IN endpoint */ + while (BufferCount--) + CDC_Device_SendByte(&VirtualSerial_CDC_Interface, RingBuffer_Remove(&USARTtoUSB_Buffer)); + + /* Turn off TX LED(s) once the TX pulse period has elapsed */ + if (PulseMSRemaining.TxLEDPulse && !(--PulseMSRemaining.TxLEDPulse)) + LEDs_TurnOffLEDs(LEDMASK_TX); + + /* Turn off RX LED(s) once the RX pulse period has elapsed */ + if (PulseMSRemaining.RxLEDPulse && !(--PulseMSRemaining.RxLEDPulse)) + LEDs_TurnOffLEDs(LEDMASK_RX); + } + + /* Load the next byte from the USART transmit buffer into the USART */ + if (!(RingBuffer_IsEmpty(&USBtoUSART_Buffer))) { + Serial_TxByte(RingBuffer_Remove(&USBtoUSART_Buffer)); + + LEDs_TurnOnLEDs(LEDMASK_RX); + PulseMSRemaining.RxLEDPulse = TX_RX_LED_PULSE_MS; + } + + CDC_Device_USBTask(&VirtualSerial_CDC_Interface); + USB_USBTask(); + } +} + +/** Configures the board hardware and chip peripherals for the demo's functionality. */ +void SetupHardware(void) +{ + /* Disable watchdog if enabled by bootloader/fuses */ + MCUSR &= ~(1 << WDRF); + wdt_disable(); + + /* Hardware Initialization */ + Serial_Init(9600, false); + LEDs_Init(); + USB_Init(); + + /* Start the flush timer so that overflows occur rapidly to push received bytes to the USB interface */ + TCCR0B = (1 << CS02); + + /* Pull target /RESET line high */ + AVR_RESET_LINE_PORT |= AVR_RESET_LINE_MASK; + AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK; +} + +/** Event handler for the library USB Connection event. */ +void EVENT_USB_Device_Connect(void) +{ + +} + +/** Event handler for the library USB Disconnection event. */ +void EVENT_USB_Device_Disconnect(void) +{ + +} + +/** Event handler for the library USB Configuration Changed event. */ +void EVENT_USB_Device_ConfigurationChanged(void) +{ + + + if (!(CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface))) + ; +} + +/** Event handler for the library USB Unhandled Control Request event. */ +void EVENT_USB_Device_UnhandledControlRequest(void) +{ + CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); +} + +/** Event handler for the CDC Class driver Line Encoding Changed event. + * + * \param[in] CDCInterfaceInfo Pointer to the CDC class interface configuration structure being referenced + */ +void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + uint8_t ConfigMask = 0; + + switch (CDCInterfaceInfo->State.LineEncoding.ParityType) + { + case CDC_PARITY_Odd: + ConfigMask = ((1 << UPM11) | (1 << UPM10)); + break; + case CDC_PARITY_Even: + ConfigMask = (1 << UPM11); + break; + } + + if (CDCInterfaceInfo->State.LineEncoding.CharFormat == CDC_LINEENCODING_TwoStopBits) + ConfigMask |= (1 << USBS1); + + switch (CDCInterfaceInfo->State.LineEncoding.DataBits) + { + case 6: + ConfigMask |= (1 << UCSZ10); + break; + case 7: + ConfigMask |= (1 << UCSZ11); + break; + case 8: + ConfigMask |= ((1 << UCSZ11) | (1 << UCSZ10)); + break; + } + + /* Must turn off USART before reconfiguring it, otherwise incorrect operation may occur */ + UCSR1B = 0; + UCSR1A = 0; + UCSR1C = 0; + + /* Special case 57600 baud for compatibility with the ATmega328 bootloader. */ + UCSR1A = (CDCInterfaceInfo->State.LineEncoding.BaudRateBPS == 57600) ? 0 : (1 << U2X1); + UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1)); + UCSR1C = ConfigMask; + UBRR1 = (CDCInterfaceInfo->State.LineEncoding.BaudRateBPS == 57600) + ? SERIAL_UBBRVAL(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS) + : SERIAL_2X_UBBRVAL(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS); +} + +/** ISR to manage the reception of data from the serial port, placing received bytes into a circular buffer + * for later transmission to the host. + */ +ISR(USART1_RX_vect, ISR_BLOCK) +{ + uint8_t ReceivedByte = UDR1; + + if (USB_DeviceState == DEVICE_STATE_Configured) + RingBuffer_Insert(&USARTtoUSB_Buffer, ReceivedByte); +} + +/** Event handler for the CDC Class driver Host-to-Device Line Encoding Changed event. + * + * \param[in] CDCInterfaceInfo Pointer to the CDC class interface configuration structure being referenced + */ +void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + bool CurrentDTRState = (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR); + + if (CurrentDTRState) + { + AVR_RESET_LINE_PORT &= ~AVR_RESET_LINE_MASK; + } + else + { + AVR_RESET_LINE_PORT |= AVR_RESET_LINE_MASK; + } +} diff --git a/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.h b/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.h new file mode 100755 index 000000000..99fde3914 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.h @@ -0,0 +1,79 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Header file for Arduino-usbserial.c. + */ + +#ifndef _ARDUINO_USBSERIAL_H_ +#define _ARDUINO_USBSERIAL_H_ + + /* Includes: */ + #include + #include + #include + #include + + #include "Descriptors.h" + + #include "Lib/LightweightRingBuff.h" + + #include + #include + #include + #include + #include + + /* Macros: */ + /** LED mask for the library LED driver, to indicate TX activity. */ + #define LEDMASK_TX LEDS_LED1 + + /** LED mask for the library LED driver, to indicate RX activity. */ + #define LEDMASK_RX LEDS_LED2 + + /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ + #define LEDMASK_ERROR (LEDS_LED1 | LEDS_LED2) + + /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ + #define LEDMASK_BUSY (LEDS_LED1 | LEDS_LED2) + + /* Function Prototypes: */ + void SetupHardware(void); + + void EVENT_USB_Device_Connect(void); + void EVENT_USB_Device_Disconnect(void); + void EVENT_USB_Device_ConfigurationChanged(void); + void EVENT_USB_Device_UnhandledControlRequest(void); + + void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo); + void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo); + +#endif /* _ARDUINO_USBSERIAL_H_ */ diff --git a/hardware/arduino/firmwares/arduino-usbserial/Board/LEDs.h b/hardware/arduino/firmwares/arduino-usbserial/Board/LEDs.h new file mode 100755 index 000000000..152e8f571 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbserial/Board/LEDs.h @@ -0,0 +1,110 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/* + Board LEDs driver for the Benito board, from www.dorkbotpdx.org. +*/ + +#ifndef __LEDS_ARDUINOUNO_H__ +#define __LEDS_ARDUINOUNO_H__ + + /* Includes: */ + #include + +/* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(INCLUDE_FROM_LEDS_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 (1 << 5) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 4) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) + + /** LED mask for the none of the board LEDs */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) + { + PORTD = ((PORTD | ActiveMask) & ~LEDMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif diff --git a/hardware/arduino/firmwares/arduino-usbserial/Descriptors.c b/hardware/arduino/firmwares/arduino-usbserial/Descriptors.c new file mode 100755 index 000000000..ae55c934e --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbserial/Descriptors.c @@ -0,0 +1,277 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * USB Device Descriptors, for library use when in USB device mode. Descriptors are special + * computer-readable structures which the host requests upon device enumeration, to determine + * the device's capabilities and functions. + */ + +#include "Descriptors.h" + +/* On some devices, there is a factory set internal serial number which can be automatically sent to the host as + * the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL. + * This allows the host to track a device across insertions on different ports, allowing them to retain allocated + * resources like COM port numbers and drivers. On demos using this feature, give a warning on unsupported devices + * so that the user can supply their own serial number descriptor instead or remove the USE_INTERNAL_SERIAL value + * from the Device Descriptor (forcing the host to generate a serial number for each device from the VID, PID and + * port location). + */ +#if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR) + #warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor. +#endif + +/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall + * device characteristics, including the supported USB version, control endpoint size and the + * number of device configurations. The descriptor is read out by the USB host when the enumeration + * process begins. + */ +USB_Descriptor_Device_t PROGMEM DeviceDescriptor = +{ + .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, + + .USBSpecification = VERSION_BCD(01.10), + .Class = 0x02, + .SubClass = 0x00, + .Protocol = 0x00, + + .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, + + .VendorID = 0x2341, + + .ProductID = ARDUINO_MODEL_PID, + .ReleaseNumber = 0x0000, + + .ManufacturerStrIndex = 0x01, + .ProductStrIndex = 0x02, + .SerialNumStrIndex = USE_INTERNAL_SERIAL, + + .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS +}; + +/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage + * of the device in one of its supported configurations, including information about any device interfaces + * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting + * a configuration so that the host may correctly communicate with the USB device. + */ +USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = +{ + .Config = + { + .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, + + .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), + .TotalInterfaces = 2, + + .ConfigurationNumber = 1, + .ConfigurationStrIndex = NO_DESCRIPTOR, + + .ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), + + .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) + }, + + .CDC_CCI_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = 0, + .AlternateSetting = 0, + + .TotalEndpoints = 1, + + .Class = 0x02, + .SubClass = 0x02, + .Protocol = 0x01, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .CDC_Functional_IntHeader = + { + .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24}, + .SubType = 0x00, + + .Data = {0x01, 0x10} + }, + + .CDC_Functional_AbstractControlManagement = + { + .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)), .Type = 0x24}, + .SubType = 0x02, + + .Data = {0x06} + }, + + .CDC_Functional_Union = + { + .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24}, + .SubType = 0x06, + + .Data = {0x00, 0x01} + }, + + .CDC_NotificationEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM), + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_NOTIFICATION_EPSIZE, + .PollingIntervalMS = 0xFF + }, + + .CDC_DCI_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = 1, + .AlternateSetting = 0, + + .TotalEndpoints = 2, + + .Class = 0x0A, + .SubClass = 0x00, + .Protocol = 0x00, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .CDC_DataOutEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM), + .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_TXRX_EPSIZE, + .PollingIntervalMS = 0x00 + }, + + .CDC_DataInEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM), + .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_TXRX_EPSIZE, + .PollingIntervalMS = 0x00 + } +}; + +/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests + * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate + * via the language ID table available at USB.org what languages the device supports for its string descriptors. + */ +USB_Descriptor_String_t PROGMEM LanguageString = +{ + .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, + + .UnicodeString = {LANGUAGE_ID_ENG} +}; + +/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable + * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device + * Descriptor. + */ +USB_Descriptor_String_t PROGMEM ManufacturerString = +{ + .Header = {.Size = USB_STRING_LEN(24), .Type = DTYPE_String}, + + .UnicodeString = L"Arduino (www.arduino.cc)" +}; + +/** Product descriptor string. This is a Unicode string containing the product's details in human readable form, + * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device + * Descriptor. + */ +USB_Descriptor_String_t PROGMEM ProductString = +{ + #if (ARDUINO_MODEL_PID == ARDUINO_UNO_PID) + .Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, + + .UnicodeString = L"Arduino Uno" + #elif (ARDUINO_MODEL_PID == ARDUINO_MEGA2560_PID) + .Header = {.Size = USB_STRING_LEN(17), .Type = DTYPE_String}, + + .UnicodeString = L"Arduino Mega 2560" + #endif + +}; + +/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" + * documentation) by the application code so that the address and size of a requested descriptor can be given + * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function + * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the + * USB host. + */ +uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + void** const DescriptorAddress) +{ + const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorNumber = (wValue & 0xFF); + + void* Address = NULL; + uint16_t Size = NO_DESCRIPTOR; + + switch (DescriptorType) + { + case DTYPE_Device: + Address = (void*)&DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); + break; + case DTYPE_Configuration: + Address = (void*)&ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); + break; + case DTYPE_String: + switch (DescriptorNumber) + { + case 0x00: + Address = (void*)&LanguageString; + Size = pgm_read_byte(&LanguageString.Header.Size); + break; + case 0x01: + Address = (void*)&ManufacturerString; + Size = pgm_read_byte(&ManufacturerString.Header.Size); + break; + case 0x02: + Address = (void*)&ProductString; + Size = pgm_read_byte(&ProductString.Header.Size); + break; + } + + break; + } + + *DescriptorAddress = Address; + return Size; +} diff --git a/hardware/arduino/firmwares/arduino-usbserial/Descriptors.h b/hardware/arduino/firmwares/arduino-usbserial/Descriptors.h new file mode 100755 index 000000000..3ac4e5257 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbserial/Descriptors.h @@ -0,0 +1,88 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Header file for Descriptors.c. + */ + +#ifndef _DESCRIPTORS_H_ +#define _DESCRIPTORS_H_ + + /* Includes: */ + #include + + #include + #include + + /* Product-specific definitions: */ + #define ARDUINO_UNO_PID 0x0001 + #define ARDUINO_MEGA2560_PID 0x0010 + + /* Macros: */ + /** Endpoint number of the CDC device-to-host notification IN endpoint. */ + #define CDC_NOTIFICATION_EPNUM 2 + + /** Endpoint number of the CDC device-to-host data IN endpoint. */ + #define CDC_TX_EPNUM 3 + + /** Endpoint number of the CDC host-to-device data OUT endpoint. */ + #define CDC_RX_EPNUM 4 + + /** Size in bytes of the CDC device-to-host notification IN endpoint. */ + #define CDC_NOTIFICATION_EPSIZE 8 + + /** Size in bytes of the CDC data IN and OUT endpoints. */ + #define CDC_TXRX_EPSIZE 64 + + /* Type Defines: */ + /** Type define for the device configuration descriptor structure. This must be defined in the + * application code, as the configuration descriptor contains several sub-descriptors which + * vary between devices, and which describe the device's usage to the host. + */ + typedef struct + { + USB_Descriptor_Configuration_Header_t Config; + USB_Descriptor_Interface_t CDC_CCI_Interface; + CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_IntHeader; + CDC_FUNCTIONAL_DESCRIPTOR(1) CDC_Functional_AbstractControlManagement; + CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_Union; + USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; + USB_Descriptor_Interface_t CDC_DCI_Interface; + USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; + USB_Descriptor_Endpoint_t CDC_DataInEndpoint; + } USB_Descriptor_Configuration_t; + + /* Function Prototypes: */ + uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + void** const DescriptorAddress) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); + +#endif diff --git a/hardware/arduino/firmwares/arduino-usbserial/Lib/LightweightRingBuff.h b/hardware/arduino/firmwares/arduino-usbserial/Lib/LightweightRingBuff.h new file mode 100755 index 000000000..fb48c1f73 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbserial/Lib/LightweightRingBuff.h @@ -0,0 +1,197 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Ultra lightweight ring buffer, for fast insertion/deletion. + */ + +#ifndef _ULW_RING_BUFF_H_ +#define _ULW_RING_BUFF_H_ + + /* Includes: */ + #include + + #include + #include + + /* Defines: */ + /** Size of each ring buffer, in data elements - must be between 1 and 255. */ + #define BUFFER_SIZE 128 + + /** Maximum number of data elements to buffer before forcing a flush. + * Must be less than BUFFER_SIZE + */ + #define BUFFER_NEARLY_FULL 96 + + /** Type of data to store into the buffer. */ + #define RingBuff_Data_t uint8_t + + /** Datatype which may be used to store the count of data stored in a buffer, retrieved + * via a call to \ref RingBuffer_GetCount(). + */ + #if (BUFFER_SIZE <= 0xFF) + #define RingBuff_Count_t uint8_t + #else + #define RingBuff_Count_t uint16_t + #endif + + /* Type Defines: */ + /** Type define for a new ring buffer object. Buffers should be initialized via a call to + * \ref RingBuffer_InitBuffer() before use. + */ + typedef struct + { + RingBuff_Data_t Buffer[BUFFER_SIZE]; /**< Internal ring buffer data, referenced by the buffer pointers. */ + RingBuff_Data_t* In; /**< Current storage location in the circular buffer */ + RingBuff_Data_t* Out; /**< Current retrieval location in the circular buffer */ + RingBuff_Count_t Count; + } RingBuff_t; + + /* Inline Functions: */ + /** Initializes a ring buffer ready for use. Buffers must be initialized via this function + * before any operations are called upon them. Already initialized buffers may be reset + * by re-initializing them using this function. + * + * \param[out] Buffer Pointer to a ring buffer structure to initialize + */ + static inline void RingBuffer_InitBuffer(RingBuff_t* const Buffer) + { + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + Buffer->In = Buffer->Buffer; + Buffer->Out = Buffer->Buffer; + } + } + + /** Retrieves the minimum number of bytes stored in a particular buffer. This value is computed + * by entering an atomic lock on the buffer while the IN and OUT locations are fetched, so that + * the buffer cannot be modified while the computation takes place. This value should be cached + * when reading out the contents of the buffer, so that as small a time as possible is spent + * in an atomic lock. + * + * \note The value returned by this function is guaranteed to only be the minimum number of bytes + * stored in the given buffer; this value may change as other threads write new data and so + * the returned number should be used only to determine how many successive reads may safely + * be performed on the buffer. + * + * \param[in] Buffer Pointer to a ring buffer structure whose count is to be computed + */ + static inline RingBuff_Count_t RingBuffer_GetCount(RingBuff_t* const Buffer) + { + RingBuff_Count_t Count; + + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + Count = Buffer->Count; + } + + return Count; + } + + /** Atomically determines if the specified ring buffer contains any free space. This should + * be tested before storing data to the buffer, to ensure that no data is lost due to a + * buffer overrun. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to insert into + * + * \return Boolean true if the buffer contains no free space, false otherwise + */ + static inline bool RingBuffer_IsFull(RingBuff_t* const Buffer) + { + return (RingBuffer_GetCount(Buffer) == BUFFER_SIZE); + } + + /** Atomically determines if the specified ring buffer contains any data. This should + * be tested before removing data from the buffer, to ensure that the buffer does not + * underflow. + * + * If the data is to be removed in a loop, store the total number of bytes stored in the + * buffer (via a call to the \ref RingBuffer_GetCount() function) in a temporary variable + * to reduce the time spent in atomicity locks. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to insert into + * + * \return Boolean true if the buffer contains no free space, false otherwise + */ + static inline bool RingBuffer_IsEmpty(RingBuff_t* const Buffer) + { + return (RingBuffer_GetCount(Buffer) == 0); + } + + /** Inserts an element into the ring buffer. + * + * \note Only one execution thread (main program thread or an ISR) may insert into a single buffer + * otherwise data corruption may occur. Insertion and removal may occur from different execution + * threads. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to insert into + * \param[in] Data Data element to insert into the buffer + */ + static inline void RingBuffer_Insert(RingBuff_t* const Buffer, + const RingBuff_Data_t Data) + { + *Buffer->In = Data; + + if (++Buffer->In == &Buffer->Buffer[BUFFER_SIZE]) + Buffer->In = Buffer->Buffer; + + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + Buffer->Count++; + } + } + + /** Removes an element from the ring buffer. + * + * \note Only one execution thread (main program thread or an ISR) may remove from a single buffer + * otherwise data corruption may occur. Insertion and removal may occur from different execution + * threads. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to retrieve from + * + * \return Next data element stored in the buffer + */ + static inline RingBuff_Data_t RingBuffer_Remove(RingBuff_t* const Buffer) + { + RingBuff_Data_t Data = *Buffer->Out; + + if (++Buffer->Out == &Buffer->Buffer[BUFFER_SIZE]) + Buffer->Out = Buffer->Buffer; + + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + Buffer->Count--; + } + + return Data; + } + +#endif diff --git a/hardware/arduino/firmwares/arduino-usbserial/makefile b/hardware/arduino/firmwares/arduino-usbserial/makefile new file mode 100755 index 000000000..d02586512 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbserial/makefile @@ -0,0 +1,775 @@ +# Hey Emacs, this is a -*- makefile -*- +#---------------------------------------------------------------------------- +# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. +# >> Modified for use with the LUFA project. << +# +# Released to the Public Domain +# +# Additional material for this makefile was written by: +# Peter Fleury +# Tim Henigan +# Colin O'Flynn +# Reiner Patommel +# Markus Pfaff +# Sander Pool +# Frederik Rouleau +# Carlos Lamas +# Dean Camera +# Opendous Inc. +# Denver Gingerich +# +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device, using avrdude. +# Please customize the avrdude settings below first! +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make doxygen = Generate DoxyGen documentation for the project (must have +# DoxyGen installed) +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + +# MCU name(s) +# Since the ATMEGA8U2 part is not directly supported by the current +# versions of either avrdude or dfu-programmer, we specify a dummy +# part; AT90USB82 which is close enough in memory size and organization +MCU = atmega8u2 +MCU_AVRDUDE = at90usb82 +MCU_DFU = at90usb82 + +# Specify the Arduino model using the assigned PID. This is used by Descriptors.c +# to set PID and product descriptor string +# Uno PID: +ARDUINO_MODEL_PID = 0x0001 +# Mega 2560 PID: +#ARDUINO_MODEL_PID = 0x0010 + + +# Target board (see library "Board Types" documentation, NONE for projects not requiring +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# "Board" inside the application directory. +BOARD = USER + + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_CLOCK below, as it is sourced by +# F_CLOCK after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# Input clock frequency. +# This will define a symbol, F_CLOCK, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_CLOCK = $(F_CPU) + + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + + +# Target file name (without extension). +TARGET = Arduino-usbserial + + +# Object files directory +# To put object files in current directory, use a dot (.), do NOT make +# this an empty or blank macro! +OBJDIR = . + + +# Path to the LUFA library +LUFA_PATH = ../.. + + +# LUFA library compile-time options +LUFA_OPTS = -D USB_DEVICE_ONLY +LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8 +LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 +LUFA_OPTS += -D USE_FLASH_DESCRIPTORS +#LUFA_OPTS += -D INTERRUPT_CONTROL_ENDPOINT +LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" + + +# Create the LUFA source path variables by including the LUFA root makefile +include $(LUFA_PATH)/LUFA/makefile + + +# List C source files here. (C dependencies are automatically generated.) +SRC = $(TARGET).c \ + Descriptors.c \ + $(LUFA_SRC_USB) \ + $(LUFA_SRC_USBCLASS) \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Device.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/HostStandardReq.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Host.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Pipe.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/USBController.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/Events.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/USBInterrupt.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBTask.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/Class/Device/CDC.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/Class/Host/CDC.c + + +# List C++ source files here. (C dependencies are automatically generated.) +CPPSRC = + + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = + + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) +OPT = s + + +# Debugging format. +# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. +# AVR Studio 4.10 requires dwarf-2. +# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. +DEBUG = dwarf-2 + + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRAINCDIRS = $(LUFA_PATH)/ + + +# Compiler flag to set the C Standard level. +# c89 = "ANSI" C +# gnu89 = c89 plus GCC extensions +# c99 = ISO C99 standard (not yet fully implemented) +# gnu99 = c99 plus GCC extensions +CSTANDARD = -std=gnu99 + + +# Place -D or -U options here for C sources +CDEFS = -DF_CPU=$(F_CPU)UL +CDEFS += -DF_CLOCK=$(F_CLOCK)UL +CDEFS += -DARDUINO_MODEL_PID=$(ARDUINO_MODEL_PID) +CDEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += $(LUFA_OPTS) +CDEFS += -DAVR_RESET_LINE_PORT="PORTD" +CDEFS += -DAVR_RESET_LINE_DDR="DDRD" +CDEFS += -DAVR_RESET_LINE_MASK="(1 << 7)" +CDEFS += -DTX_RX_LED_PULSE_MS=3 +CDEFS += -DPING_PONG_LED_PULSE_MS=100 + +# Place -D or -U options here for ASM sources +ADEFS = -DF_CPU=$(F_CPU) +ADEFS += -DF_CLOCK=$(F_CLOCK)UL +ADEFS += -DBOARD=BOARD_$(BOARD) +ADEFS += $(LUFA_OPTS) + +# Place -D or -U options here for C++ sources +CPPDEFS = -DF_CPU=$(F_CPU)UL +CPPDEFS += -DF_CLOCK=$(F_CLOCK)UL +CPPDEFS += -DBOARD=BOARD_$(BOARD) +CPPDEFS += $(LUFA_OPTS) +#CPPDEFS += -D__STDC_LIMIT_MACROS +#CPPDEFS += -D__STDC_CONSTANT_MACROS + + + +#---------------- Compiler Options C ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CFLAGS = -g$(DEBUG) +CFLAGS += $(CDEFS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char +CFLAGS += -funsigned-bitfields +CFLAGS += -ffunction-sections +CFLAGS += -fno-inline-small-functions +CFLAGS += -fpack-struct +CFLAGS += -fshort-enums +CFLAGS += -fno-strict-aliasing +CFLAGS += -Wall +CFLAGS += -Wstrict-prototypes +#CFLAGS += -mshort-calls +#CFLAGS += -fno-unit-at-a-time +#CFLAGS += -Wundef +#CFLAGS += -Wunreachable-code +#CFLAGS += -Wsign-compare +CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) + + +#---------------- Compiler Options C++ ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CPPFLAGS = -g$(DEBUG) +CPPFLAGS += $(CPPDEFS) +CPPFLAGS += -O$(OPT) +CPPFLAGS += -funsigned-char +CPPFLAGS += -funsigned-bitfields +CPPFLAGS += -fpack-struct +CPPFLAGS += -fshort-enums +CPPFLAGS += -fno-exceptions +CPPFLAGS += -Wall +CPPFLAGS += -Wundef +CFLAGS += -Wundef +#CPPFLAGS += -mshort-calls +#CPPFLAGS += -fno-unit-at-a-time +#CPPFLAGS += -Wstrict-prototypes +#CPPFLAGS += -Wunreachable-code +#CPPFLAGS += -Wsign-compare +CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) +CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +#CPPFLAGS += $(CSTANDARD) + + +#---------------- Assembler Options ---------------- +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns: create listing +# -gstabs: have the assembler create line number information; note that +# for use in COFF files, additional information about filenames +# and function names needs to be present in the assembler source +# files -- see avr-libc docs [FIXME: not yet described there] +# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# dump that will be displayed for a given single line of source input. +ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 + + +#---------------- Library Options ---------------- +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +# If this is left blank, then it will use the Standard printf version. +PRINTF_LIB = +#PRINTF_LIB = $(PRINTF_LIB_MIN) +#PRINTF_LIB = $(PRINTF_LIB_FLOAT) + + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +# If this is left blank, then it will use the Standard scanf version. +SCANF_LIB = +#SCANF_LIB = $(SCANF_LIB_MIN) +#SCANF_LIB = $(SCANF_LIB_FLOAT) + + +MATH_LIB = -lm + + +# List any extra directories to look for libraries here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRALIBDIRS = + + + +#---------------- External Memory Options ---------------- + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + + + +#---------------- Linker Options ---------------- +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref +LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--gc-sections +LDFLAGS += $(EXTMEMOPTS) +LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) +LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +#LDFLAGS += -T linker_script.x + + + +#---------------- Programming Options (avrdude) ---------------- + +# Programming hardware +# Type: avrdude -c ? +# to get a full listing. +# +AVRDUDE_PROGRAMMER = avrispmkii + +# com1 = serial port. Use lpt1 to connect to parallel port. +AVRDUDE_PORT = usb + +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FORCE = -F + +AVRDUDE_FLAGS = -p $(MCU_AVRDUDE) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) +AVRDUDE_FLAGS += $(AVRDUDE_FORCE) + + + +#---------------- Debugging Options ---------------- + +# For simulavr only - target MCU frequency. +DEBUG_MFREQ = $(F_CPU) + +# Set the DEBUG_UI to either gdb or insight. +# DEBUG_UI = gdb +DEBUG_UI = insight + +# Set the debugging back-end to either avarice, simulavr. +DEBUG_BACKEND = avarice +#DEBUG_BACKEND = simulavr + +# GDB Init Filename. +GDBINIT_FILE = __avr_gdbinit + +# When using avarice settings for the JTAG +JTAG_DEV = /dev/com1 + +# Debugging port used to communicate between GDB / avarice / simulavr. +DEBUG_PORT = 4242 + +# Debugging host used to communicate between GDB / avarice / simulavr, normally +# just set to localhost unless doing some sort of crazy debugging when +# avarice is running on a different computer. +DEBUG_HOST = localhost + + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +AR = avr-ar rcs +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +REMOVEDIR = rm -rf +COPY = cp +WINSHELL = cmd + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling C: +MSG_COMPILING_CPP = Compiling C++: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: +MSG_CREATING_LIBRARY = Creating library: + + + + +# Define all object files. +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + +# Define all listing files. +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +#all: begin gccversion sizebefore build checkinvalidevents showliboptions showtarget sizeafter end +all: begin gccversion sizebefore build showliboptions showtarget sizeafter end + +# Change the build target to build a HEX file or a library. +build: elf hex eep lss sym asm +#build: lib + + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym +asm: $(TARGET).s +LIBNAME=lib$(TARGET).a +lib: $(LIBNAME) + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf +MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) +FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +#$(LUFA_PATH)/LUFA/LUFA_Events.lst: +# @make -C $(LUFA_PATH)/LUFA/ LUFA_Events.lst + +#checkinvalidevents: $(LUFA_PATH)/LUFA/LUFA_Events.lst +# @echo +# @echo Checking for invalid events... +# @$(shell) avr-nm $(OBJ) | sed -n -e 's/^.*EVENT_/EVENT_/p' | \ +# grep -F -v --file=$(LUFA_PATH)/LUFA/LUFA_Events.lst > InvalidEvents.tmp || true +# @sed -n -e 's/^/ WARNING - INVALID EVENT NAME: /p' InvalidEvents.tmp +# @if test -s InvalidEvents.tmp; then exit 1; fi + +showliboptions: + @echo + @echo ---- Compile Time Library Options ---- + @for i in $(LUFA_OPTS:-D%=%); do \ + echo $$i; \ + done + @echo -------------------------------------- + +showtarget: + @echo + @echo --------- Target Information --------- + @echo AVR Model: $(MCU) + @echo Board: $(BOARD) + @echo Clock: $(F_CPU)Hz CPU, $(F_CLOCK)Hz Master + @echo -------------------------------------- + + +# Display compiler version information. +gccversion : + @$(CC) --version + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + +flip: $(TARGET).hex + batchisp -hardware usb -device $(MCU_DFU) -operation erase f + batchisp -hardware usb -device $(MCU_DFU) -operation loadbuffer $(TARGET).hex program + batchisp -hardware usb -device $(MCU_DFU) -operation start reset 0 + +dfu: $(TARGET).hex + dfu-programmer $(MCU_DFU) erase + dfu-programmer $(MCU_DFU) flash --debug 1 $(TARGET).hex + dfu-programmer $(MCU_DFU) reset + + +flip-ee: $(TARGET).hex $(TARGET).eep + $(COPY) $(TARGET).eep $(TARGET)eep.hex + batchisp -hardware usb -device $(MCU_DFU) -operation memory EEPROM erase + batchisp -hardware usb -device $(MCU_DFU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program + batchisp -hardware usb -device $(MCU_DFU) -operation start reset 0 + $(REMOVE) $(TARGET)eep.hex + +dfu-ee: $(TARGET).hex $(TARGET).eep + dfu-programmer $(MCU_DFU) flash-eeprom --debug 1 --suppress-bootloader-mem $(TARGET).eep + dfu-programmer $(MCU_DFU) reset + + +# Generate avr-gdb config/init file which does the following: +# define the reset signal, load the target file, connect to target, and set +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT = $(OBJCOPY) --debugging +COFFCONVERT += --change-section-address .data-0x800000 +COFFCONVERT += --change-section-address .bss-0x800000 +COFFCONVERT += --change-section-address .noinit-0x800000 +COFFCONVERT += --change-section-address .eeprom-0x810000 + + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S -z $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Create library from object files. +.SECONDARY : $(TARGET).a +.PRECIOUS : $(OBJ) +%.a: $(OBJ) + @echo + @echo $(MSG_CREATING_LIBRARY) $@ + $(AR) $@ $(OBJ) + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +$(OBJDIR)/%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create object files from C++ source files. +$(OBJDIR)/%.o : %.cpp + @echo + @echo $(MSG_COMPILING_CPP) $< + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C++ source files. +%.s : %.cpp + $(CC) -S $(ALL_CPPFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +$(OBJDIR)/%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list clean_binary end + +clean_binary: + $(REMOVE) $(TARGET).hex + +clean_list: + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) $(SRC:.c=.i) + $(REMOVEDIR) .dep + +doxygen: + @echo Generating Project Documentation... + @doxygen Doxygen.conf + @echo Documentation Generation Complete. + +clean_doxygen: + rm -rf Documentation + +# Create object files directory +$(shell mkdir $(OBJDIR) 2>/dev/null) + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff doxygen clean \ +clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ +debug gdb-config diff --git a/hardware/arduino/firmwares/arduino-usbserial/readme.txt b/hardware/arduino/firmwares/arduino-usbserial/readme.txt new file mode 100644 index 000000000..289326b13 --- /dev/null +++ b/hardware/arduino/firmwares/arduino-usbserial/readme.txt @@ -0,0 +1,13 @@ +To setup the project and upload the Arduino usbserial application firmware to an ATMEGA8U2 using the Arduino USB DFU bootloader: +1. unpack the source into LUFA's Projects directory +2. set ARDUINO_MODEL_PID in the makefile as appropriate +3. do "make clean; make" +4. put the 8U2 into USB DFU mode: +4.a. assert and hold the 8U2's RESET line +4.b. assert and hold the 8U2's HWB line +4.c. release the 8U2's RESET line +4.d. release the 8U2's HWB line +5. confirm that the board enumerates as either "Arduino Uno DFU" or "Arduino Mega 2560 DFU" +6. do "make dfu" (OS X or Linux - dfu-programmer must be installed first) or "make flip" (Windows - Flip must be installed first) + +Check that the board enumerates as either "Arduino Uno" or "Arduino Mega 2560". Test by uploading a new Arduino sketch from the Arduino IDE.