From 648dd85e945a7e0a2db284987377a97936ee77e4 Mon Sep 17 00:00:00 2001 From: Zach Eveland Date: Tue, 10 Jan 2012 15:31:56 -0500 Subject: added conditional compilation for HID, removed conditional compilation for CDC (is always used). disabled HID by default. also always enumerates as composite now. the bootloader must always have a CDC interface. HID is optional and not even complete to reduce size. --- bootloaders/diskloader/DiskLoader-Leonardo.hex | 229 ++++++++++++------------- bootloaders/diskloader/src/Platform.h | 5 +- bootloaders/diskloader/src/USBCore.cpp | 10 +- bootloaders/diskloader/src/USBDesc.cpp | 12 +- bootloaders/diskloader/src/USBDesc.h | 43 ++--- 5 files changed, 144 insertions(+), 155 deletions(-) (limited to 'bootloaders') diff --git a/bootloaders/diskloader/DiskLoader-Leonardo.hex b/bootloaders/diskloader/DiskLoader-Leonardo.hex index 9a7ea1e..af819fb 100644 --- a/bootloaders/diskloader/DiskLoader-Leonardo.hex +++ b/bootloaders/diskloader/DiskLoader-Leonardo.hex @@ -1,120 +1,115 @@ -:1078000011241FBECFEFDAE0DEBFCDBF0BC14101B7 +:1078000011241FBECFEFDAE0DEBFCDBFF5C04101CE :1078100042144505560455026403740300001E9586 -:1078200087020110030000C18081C106C0FF0A0069 -:107830000CA10185037508150026FF00954009017C -:107840008102954009029102C0040309041A033021 -:1078500000300030003000300030003000300031A7 -:107860000037003000310038030000000000000045 -:107870000000000000000000000000000000000008 -:1078800000000000000000000000000000000000F8 -:1078900000000000000000000000000000000018D0 -:1078A00003410072006400750069006E006F0020E3 -:1078B000004C004C00430012010002020000404155 -:1078C000235B00000100020301120100020000001E -:1078D0004041235B00000100020301090264000330 -:1078E00001008032080B00020202010009040000BE -:1078F0000102020000052400100105240101010419 -:107900002402020524060001070581031000400936 -:10791000040100020A0000000705020240000007FF -:107920000583024000000904020001030000000971 -:107930002101010001221E000705840340004000D0 -:1079400020918A0130918B012C5F3F4F30938B0146 -:1079500020938A01C901892F99278695982F803411 -:1079600018F08FE7891B982F990F921710F44798FA -:107970000895479A08955D9A289A81E08093E000DF -:107980001092E200EE27FF270994089528E088E18D -:1079900090E00FB6F894A895809360000FBE2093F6 -:1079A0006000FFCF0F931F93CF93DF93982FEB01CE -:1079B000042F10E088E76030780730F411E083E0AE -:1079C000FB0180935700E895892F68E071E0402F14 -:1079D00006D1112311F107B600FCFDCF402F4695CB -:1079E000FE01A8E0B1E020E031E009C08D919D9159 -:1079F0000C0130935700E895112432962F5F24171D -:107A0000A8F385E0FE0180935700E89507B600FCD7 -:107A1000FDCF81E180935700E895DF91CF911F91D1 -:107A20000F91089584B794B7977F94BF98E10FB6EC -:107A3000F89490936000109260000FBE5D9A289AAF -:107A4000479883FF08C0E0E0F0E0859194918F5F54 -:107A50009F4F09F090DF3F9A209A559A90E89093B3 -:107A600061001092610081E885BF95BF9FD084E1DD -:107A70008093880180E180938901E0E0F0E08591C6 -:107A800094918F5F9F4F19F081E080938F01EE24D6 -:107A9000FF24BB24B39454EFC52E51E0D52E1FD242 -:107AA000082F8EE098E7FC012491319602964491CC -:107AB000201711F02223B9F7109291011092900132 -:107AC00082E068E071E08BD0013479F460910801C4 -:107AD0006058633028F0683111F064E001C063E061 -:107AE000C62FD0E0CF5DD7480EC0063571F4809127 -:107AF0000801803311F011E022C080910A01C82FE3 -:107B0000D0E0C25ED74811E022C0053721F413E06F -:107B1000CEE1D8E71CC0053539F4E0900801F090BB -:107B20000901EE0CFF1C0AC0043631F482E0B701F3 -:107B30004091090137DF02C0043721F010E0C5E2AF -:107B4000D8E705C010910901E701E10EF11CC7D18A -:107B50008097B1F483E068E871E041E050E059D0EB -:107B6000112329F0412F50E083E8BE0152D083E475 -:107B700069E871E041E050E04CD0013509F08FCF69 -:107B8000D0929101C0929001B0928F01EE24FF2417 -:107B900086CFFC01289884E680938D0104C08091F3 -:107BA000F100819361506623D1F7089510929101FD -:107BB0001092900110928E0110928F0181E08093BB -:107BC000D70080EA8093D80082E189BD09B400FE25 -:107BD000FDCF80E98093D8001092E0000895FB016A -:107BE0008093E90024E69BE611C08091E80085FFC0 -:107BF000FCCF289820938D018091F1008193809192 -:107C0000E80085FD02C09093E8004150442369F7E5 -:107C10000895982FFB01282F207287708093E90028 -:107C200064E63AE317C08091E80085FFFCCF97FF38 -:107C300002C0849101C080813196211180E05D985D -:107C400060938C018093F1008091E80085FD02C073 -:107C50003093E800415050408FEF4F3F580719F7DD -:107C600096FF03C08AE38093E80008958091930112 -:107C7000813299F45D9884E680938C0120E030E0B5 -:107C800003C080818093F100F901E050FF4F2F5F26 -:107C90003F4F28303105A9F714C0803261F480913C -:107CA000E80082FFFCCF80E091E067E072DF8BEFBD -:107CB0008093E80006C0823221F480919401809381 -:107CC000070181E0089520919501223291F1213040 -:107CD00081F48091980190919901089711F4209373 -:107CE0009A0180919A01882309F059C029EC38E75C -:107CF00058C0223029F484E690E02BED38E71DC00F -:107D0000233009F04AC080919401882319F429E4B2 -:107D100038E747C0823019F427E638E742C083309D -:107D200019F42DE438E73DC08130B9F52FE938E783 -:107D300038C082E090E02BE238E740919801509102 -:107D40009901BC014817590708F4BA0190918C01B8 -:107D500040E050E0AEEF8091E8008570E1F3809163 -:107D6000E80082FD16C0F901E40FF51F4F5F5F4F79 -:107D7000E4915D98E093F100842F8F7311F4A09348 -:107D8000E80094E64617570730F390938C0181E0A2 -:107D9000089590938C0180E0089580E0089527EB8A -:107DA00038E7F901849190E0C8CF1092E900809102 -:107DB000E80083FF61C082E991E068E0EADE82EFDB -:107DC0008093E8008091920187FF05C08091E800D0 -:107DD00080FFFCCF03C08EEF8093E8008091930179 -:107DE000853051F48091E80080FFFCCF80919401B0 -:107DF00080688093E30039C08930E1F48091940178 -:107E000080938E01E7E2F8E791E031E026E390937A -:107E1000E9003093EB0084918093EC002093ED0017 -:107E20009F5F3196953099F78EE78093EA00109224 -:107E3000EA001BC0883049F490918E015D9884E679 -:107E400080938C019093F10010C0882339F45D98E1 -:107E500084E680938C011092F10007C0863011F403 -:107E600032DF01C003DF882321F08EEF8093E8002A -:107E7000089581E28093EB0008958091E1001092D3 -:107E8000E100282F83FF0CC01092E90081E080936D -:107E9000EB001092EC0082E38093ED0010928E01D3 -:107EA00022FF1CC080918C01882331F08150809387 -:107EB0008C01882309F45D9A80918D01882331F02B -:107EC000815080938D01882309F4289A80918F0135 -:107ED000882321F4109291011092900108951F932C -:107EE000CF93DF9312E0C0E9D1E05FDFC6DF1093EC -:107EF000E9008091E80085FF13C0289884E680930C -:107F00008D019091F1008091E80085FD03C08BE622 -:107F10008093E800892F90E0DF91CF911F91089521 -:107F2000809190019091910101979093910180939C -:107F300090018091900190919101892B09F426DDA7 -:0A7F4000CE010197F1F7FCDCD0CF71 -:087F4A0000E10000000000004E +:1078200087020110030000C1808106C0FF0A000C1E +:10783000A10185037508150026FF00954009018107 +:1078400002954009029102C0040309041A033000A2 +:1078500030003000300030003000300030003100A7 +:1078600037003000310038034100720064007500B9 +:1078700069006E006F0020004C0065006F006E0014 +:107880006100720064006F00200062006F006F00F2 +:1078900074006C006F0061006400650072001803E2 +:1078A000410072006400750069006E006F002000E6 +:1078B0004C004C0043001201000202000040412332 +:1078C000340000010002030109024B0002010080A4 +:1078D00032080B000202020100090400000102024A +:1078E0000000052400100105240101010424020206 +:1078F000052406000107058103100040090401006A +:10790000020A00000007050202400000070583028A +:107910004000000020918A0130918B012C5F3F4F85 +:1079200030938B0120938A01C901892F992786956D +:10793000982F803418F08FE7891B982F990F921792 +:1079400010F447980895479A08955D9A289A81E01F +:107950008093E0001092E200EE27FF27099408953B +:1079600028E088E190E00FB6F894A8958093600035 +:107970000FBE20936000FFCF0F931F93CF93DF9331 +:10798000982FEB01042F10E088E76030780730F47F +:1079900011E083E0FB0180935700E895892F68E0B0 +:1079A00071E0402F06D1112311F107B600FCFDCF85 +:1079B000402F4695FE01A8E0B1E020E031E009C08B +:1079C0008D919D910C0130935700E89511243296CA +:1079D0002F5F2417A8F385E0FE0180935700E895F8 +:1079E00007B600FCFDCF81E180935700E895DF9159 +:1079F000CF911F910F91089584B794B7977F94BF4B +:107A000098E10FB6F89490936000109260000FBE5A +:107A10005D9A289A479883FF08C0E0E0F0E08591DE +:107A200094918F5F9F4F09F090DF3F9A209A559A6B +:107A300090E8909361001092610081E885BF95BF46 +:107A40009FD084E18093880180E180938901E0E008 +:107A5000F0E0859194918F5F9F4F19F081E08093C2 +:107A60008F01EE24FF24BB24B39454EFC52E51E0C4 +:107A7000D52E0DD2082F8EE098E7FC012491319687 +:107A800002964491201711F02223B9F71092910128 +:107A90001092900182E068E071E08BD0013479F4BB +:107AA000609108016058633028F0683111F064E09B +:107AB00001C063E0C62FD0E0CF5DD7480EC00635C9 +:107AC00071F480910801803311F011E022C080919F +:107AD0000A01C82FD0E0C25ED74811E022C00537A6 +:107AE00021F413E0CEE1D8E71CC0053539F4E0906D +:107AF0000801F0900901EE0CFF1C0AC0043631F4B5 +:107B000082E0B7014091090137DF02C0043721F05C +:107B100010E0C5E2D8E705C010910901E701E10EC8 +:107B2000F11CB5D18097B1F483E068E871E041E0E1 +:107B300050E059D0112329F0412F50E083E8BE01D5 +:107B400052D083E469E871E041E050E04CD0013567 +:107B500009F08FCFD0929101C0929001B0928F0125 +:107B6000EE24FF2486CFFC01289884E680938D01C3 +:107B700004C08091F100819361506623D1F708958C +:107B8000109291011092900110928E0110928F012B +:107B900081E08093D70080EA8093D80082E189BD9C +:107BA00009B400FEFDCF80E98093D8001092E00078 +:107BB0000895FB018093E90024E69BE611C08091C3 +:107BC000E80085FFFCCF289820938D018091F1007B +:107BD00081938091E80085FD02C09093E8004150B8 +:107BE000442369F70895982FFB01282F207287708E +:107BF0008093E90064E63AE317C08091E80085FFCE +:107C0000FCCF97FF02C0849101C080813196211181 +:107C100080E05D9860938C018093F1008091E80092 +:107C200085FD02C03093E800415050408FEF4F3F38 +:107C3000580719F796FF03C08AE38093E800089578 +:107C400080919301813299F45D9884E680938C0150 +:107C500020E030E003C080818093F100F901E05022 +:107C6000FF4F2F5F3F4F28303105A9F714C08032F6 +:107C700061F48091E80082FFFCCF80E091E067E052 +:107C800072DF8BEF8093E80006C0823221F480918E +:107C900094018093070181E00895809195018232DB +:107CA00019F420E030E024C0813019F426EB38E7E5 +:107CB0001FC0823029F48BE490E028EC38E71BC029 +:107CC000833009F048C080919401882319F428E496 +:107CD00038E70EC0823019F426E638E709C0833051 +:107CE00019F42CE438E704C08130A9F52EE938E70F +:107CF000F901849190E04091980150919901BC0163 +:107D00004817590708F4BA0190918C0140E050E0FF +:107D1000AEEF8091E8008570E1F38091E80082FD8C +:107D200016C0F901E40FF51F4F5F5F4FE4915D98B6 +:107D3000E093F100842F8F7311F4A093E80094E690 +:107D40004617570730F390938C0181E00895909384 +:107D50008C0180E0089580E008951092E900809100 +:107D6000E80083FF61C082E991E068E0FCDE82EF19 +:107D70008093E8008091920187FF05C08091E80020 +:107D800080FFFCCF03C08EEF8093E80080919301C9 +:107D9000853051F48091E80080FFFCCF8091940100 +:107DA00080688093E30039C08930E1F480919401C8 +:107DB00080938E01E7E2F8E791E031E026E39093CB +:107DC000E9003093EB0084918093EC002093ED0068 +:107DD0009F5F3196943099F78EE78093EA00109276 +:107DE000EA001BC0883049F490918E015D9884E6CA +:107DF00080938C019093F10010C0882339F45D9832 +:107E000084E680938C011092F10007C0863011F453 +:107E100044DF01C015DF882321F08EEF8093E80056 +:107E2000089581E28093EB0008958091E100109223 +:107E3000E100282F83FF0CC01092E90081E08093BD +:107E4000EB001092EC0082E38093ED0010928E0123 +:107E500022FF1CC080918C01882331F081508093D7 +:107E60008C01882309F45D9A80918D01882331F07B +:107E7000815080938D01882309F4289A80918F0185 +:107E8000882321F4109291011092900108951F937C +:107E9000CF93DF9312E0C0E9D1E05FDFC6DF10933C +:107EA000E9008091E80085FF13C0289884E680935C +:107EB0008D019091F1008091E80085FD03C08BE673 +:107EC0008093E800892F90E0DF91CF911F91089572 +:107ED00080919001909191010197909391018093ED +:107EE00090018091900190919101892B09F438DDE6 +:0A7EF000CE010197F1F70EDDD0CFAF +:087EFA0000E10000000000009F :040000030000780081 :00000001FF diff --git a/bootloaders/diskloader/src/Platform.h b/bootloaders/diskloader/src/Platform.h index 04c5b79..fcce0a1 100644 --- a/bootloaders/diskloader/src/Platform.h +++ b/bootloaders/diskloader/src/Platform.h @@ -43,7 +43,10 @@ void Transfer(u8 ep, const u8* data, int len); void Recv(u8 ep, u8* dst, u8 len); void Program(u8 ep, u16 page, u8 count); -#define CDC_ENABLED +/* HID is not fully-supported in the bootloader - can be enabled + for testing, but note the descriptor report and other parts are + not complete */ +//#define HID_ENABLED #include "USBCore.h" #include "USBDesc.h" diff --git a/bootloaders/diskloader/src/USBCore.cpp b/bootloaders/diskloader/src/USBCore.cpp index a234596..64f5852 100644 --- a/bootloaders/diskloader/src/USBCore.cpp +++ b/bootloaders/diskloader/src/USBCore.cpp @@ -255,13 +255,13 @@ const u8 _initEndpoints[] = { 0, -#ifdef CDC_ENABLED EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN -#endif +#ifdef HID_ENABLED EP_TYPE_INTERRUPT_IN, // HID_ENDPOINT_INT +#endif }; static void InitEndpoints() @@ -357,13 +357,13 @@ bool SendDescriptor() u8 t = setup.wValueH; if (0x22 == t) { +#ifdef HID_ENABLED desc_addr = _rawHID; desc_length = sizeof(desc_length); +#endif } else if (USB_DEVICE_DESCRIPTOR_TYPE == t) { - if (setup.wLength == 8) - _cdcComposite = 1; - desc_addr = _cdcComposite ? (const u8*)&USB_DeviceDescriptorA : (const u8*)&USB_DeviceDescriptor; + desc_addr = (const u8*)&USB_DeviceDescriptor; } else if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t) { diff --git a/bootloaders/diskloader/src/USBDesc.cpp b/bootloaders/diskloader/src/USBDesc.cpp index ade072a..b143687 100644 --- a/bootloaders/diskloader/src/USBDesc.cpp +++ b/bootloaders/diskloader/src/USBDesc.cpp @@ -47,18 +47,12 @@ const u16 STRING_IMANUFACTURER[12] = { }; -//#ifdef CDC_ENABLED -DeviceDescriptor USB_DeviceDescriptorA = D_DEVICE(0X02,0X00,0X00,64,USB_VID,USB_PID,0x100,0,IPRODUCT,ISERIAL,1); -//#else -DeviceDescriptor USB_DeviceDescriptor = D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,0,IPRODUCT,ISERIAL,1); -//#endif - +DeviceDescriptor USB_DeviceDescriptor = D_DEVICE(0X02,0X00,0X00,64,USB_VID,USB_PID,0x100,0,IPRODUCT,ISERIAL,1); Config USB_ConfigDescriptor = { D_CONFIG(sizeof(Config),INTERFACE_COUNT), -#ifdef CDC_ENABLED // CDC { D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1), @@ -76,12 +70,14 @@ Config USB_ConfigDescriptor = D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0), D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0) }, -#endif + +#ifdef HID_ENABLED // HID { D_INTERFACE(HID_INTERFACE,1,3,0,0), D_HIDREPORT(30), D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x40) } +#endif }; diff --git a/bootloaders/diskloader/src/USBDesc.h b/bootloaders/diskloader/src/USBDesc.h index a970fa4..3a7fc55 100644 --- a/bootloaders/diskloader/src/USBDesc.h +++ b/bootloaders/diskloader/src/USBDesc.h @@ -16,36 +16,31 @@ ** SOFTWARE. */ - -#ifdef CDC_ENABLED - -#define CDC_ACM_INTERFACE 0 // CDC ACM -#define CDC_DATA_INTERFACE 1 // CDC Data -#define CDC_ENDPOINT_ACM 1 -#define CDC_ENDPOINT_OUT 2 -#define CDC_ENDPOINT_IN 3 - -#define HID_INTERFACE 2 // HID Interface -#define HID_ENDPOINT_INT 4 - -#define INTERFACE_COUNT 3 // 2 for cdc + 1 for hid - -#else - -#define HID_INTERFACE 2 // HID Interface -#define HID_ENDPOINT_INT 4 - -#define INTERFACE_COUNT 1 // 1 for hid - -#endif +#ifndef HID_ENABLED // HID is NOT enabled + #define CDC_ACM_INTERFACE 0 // CDC ACM + #define CDC_DATA_INTERFACE 1 // CDC Data + #define CDC_ENDPOINT_ACM 1 + #define CDC_ENDPOINT_OUT 2 + #define CDC_ENDPOINT_IN 3 + #define INTERFACE_COUNT 2 // 2 for CDC +#else // HID is enabled + #define CDC_ACM_INTERFACE 0 // CDC ACM + #define CDC_DATA_INTERFACE 1 // CDC Data + #define CDC_ENDPOINT_ACM 1 + #define CDC_ENDPOINT_OUT 2 + #define CDC_ENDPOINT_IN 3 + #define HID_INTERFACE 2 // HID Interface + #define HID_ENDPOINT_INT 4 + #define INTERFACE_COUNT 3 // 2 for CDC + 1 for hid +#endif typedef struct { ConfigDescriptor config; -#ifdef CDC_ENABLED CDCDescriptor cdc; -#endif +#ifdef HID_ENABLED HIDDescriptor hid; +#endif } Config; extern Config USB_ConfigDescriptor PROGMEM; -- cgit v1.2.3-18-g5258