Compare commits

...

868 Commits

Author SHA1 Message Date
Dean Camera
56c6b594ac Wipe working directory before building Atmel Studio extension. 2013-08-18 21:52:39 +02:00
Dean Camera
3f99d419aa Use a timer prescaler of 256 instead of 1024 in the TempDataLogger project for better accuracy. 2013-08-18 13:56:12 +02:00
Dean Camera
25b0f55d99 Move out class driver modules into seperate AS6 integration modules, add ability to disable host/device/both modes for faster compilation. 2013-08-16 22:21:41 +02:00
Dean Camera
ff8e86ba73 Fix blurry images on the Atmel Studio Getting Started page. 2013-08-14 22:16:47 +02:00
Dean Camera
4f90aeddda Minor documentation updates. 2013-08-14 20:29:06 +02:00
Dean Camera
de366fdbe1 Add host application directories as distributables in Atmel Studio. 2013-08-14 19:18:16 +02:00
Dean Camera
82e606eb3b Archive AndroidAccessoryHost host application code, to prevent errors when distributed in Atmel Studio. 2013-08-14 19:10:20 +02:00
Dean Camera
e24ab1600f Show installed version number on the Getting Started page inside Atmel Studio. 2013-08-13 22:36:38 +02:00
Dean Camera
c02a2c5257 Use seperate ATTR_NON_NULL_PTR_ARG() decorators in the XMEGA TWI driver to prevent Doxygen from choking. 2013-08-13 21:46:41 +02:00
Dean Camera
fd524b0e00 Add XMEGA TWI peripheral driver to the Atmel Studio extension XML. 2013-08-13 21:38:41 +02:00
Dean Camera
23910fa09e Add XMEGA TWI to the ModuleTest build test. 2013-08-13 21:35:21 +02:00
Dean Camera
7c57ad3858 Fix XMEGA TWI driver indentation and style to conform to the rest of the LUFA codebase. 2013-08-13 21:30:34 +02:00
Dean Camera
5fde9e0f0d Merge branch 'xmega-twi' of github.com:jamuraa/lufa into xmega-twi-integration 2013-08-13 21:04:40 +02:00
Dean Camera
ea58513558 Fixed re-enumeration issue of XMEGA architecture targets. 2013-08-13 21:01:42 +02:00
Dean Camera
a4a6958524 Fix broken USART SPI driver for the AVR8 architecture. 2013-08-12 16:27:06 +02:00
Dean Camera
5558b2f221 Minor style tweaks to the Getting Started page of the Atmel Studio extension. 2013-08-11 13:58:15 +02:00
Michael Janssen
6dd0447c12 Bugfixes with the protocol.
- Bitmasks need to be equal, not just result in non-zero
 - Only read status once in case it changes under us
 - Logical and not binary and when checking for acks on sending
 - We need to stop the bus when receiving the last byte
 - Force the bus into idle mode when we are Initing
2013-08-06 23:33:06 -05:00
Michael Janssen
d557744503 Minor bugfixes / missed compile stuff. 2013-07-31 21:47:41 -05:00
Dean Camera
a8a2fe3a23 Fix missing AS6 modules in the USB to Serial Converter project. 2013-07-29 18:57:48 +02:00
Michael Janssen
a403b12b8d Fix NON-NULL attributes, add for TWI_t. 2013-07-24 11:16:55 -05:00
Michael Janssen
50e8fc615d TWI Master has a sub-structure 2013-07-24 11:12:03 -05:00
Michael Janssen
2d21e36dd9 Add TWI Peripheral driver for XMEGA 2013-07-24 11:07:46 -05:00
Dean Camera
15828b1d5f Rename DS1307 driver files to a more generic RTC, as different RTC drivers may be added in the future. 2013-07-20 10:38:25 +02:00
Dean Camera
b4af3f1fc9 Add volatile software RTC to the TempDataLogger application if the dummy RTC mode is enabled. 2013-07-20 10:35:28 +02:00
Dean Camera
fc61e88a8d Fix missing year offset on the TempDataLogger Python host application. 2013-07-16 20:41:33 +02:00
Dean Camera
a899ee0cf4 Fixed incorrect time/date configuration data order in the TempDataLogger host application. 2013-07-16 20:02:33 +02:00
Dean Camera
7cd9e0dbc4 Fixed incorrect USB device state set when a suspended LUFA device is woken while addressed but not configured (thanks to Balaji Krishnan) 2013-07-15 20:47:43 +02:00
Dean Camera
37ba9ec326 Minor documentation improvements. 2013-07-14 15:09:29 +02:00
Dean Camera
e0ab5c5a5a Add missing Studio module to the Class Driver RNDIS Device demo. 2013-07-14 15:09:08 +02:00
Dean Camera
368c9af784 Minor code style improvement to the HID bootloader Python script. 2013-07-14 15:08:38 +02:00
Dean Camera
9fc655f438 Add Python alternative host application for the TempDataLogger project. 2013-07-08 20:14:02 +02:00
Dean Camera
ebc0d8bc94 Refactor the new Python HID bootloader host application code. 2013-07-07 17:09:10 +02:00
Dean Camera
6e79c3ecaf Add new HID bootloader alternative host loader application, written in Python. 2013-07-07 16:54:57 +02:00
Dean Camera
873d288f31 Refactor GenericHID Python test script code to make user specific adjustments easier. 2013-07-07 13:09:26 +02:00
Dean Camera
8d1376bbe9 Clean up Atmel Studio integration Python script according to PEP8 rules. 2013-07-07 13:00:44 +02:00
Dean Camera
e9bf4bc84e Add Python test script using pywinusb for the Class Driver Generic HID Device demo application. 2013-07-07 13:00:09 +02:00
Dean Camera
ddf10cb162 Update Android Accessory Host demo Android code to the last SDK release. 2013-07-06 13:08:12 +02:00
Dean Camera
7b75209b58 Minor documentation improvements. 2013-07-06 13:07:34 +02:00
Dean Camera
b1b109487e Mark the very low RAM devices as being unsupported by the Mass Storage class bootloader. 2013-07-06 12:54:59 +02:00
Dean Camera
8cfa2e8023 Add automatic application start on virtual disk ejection to the Mass Storage class bootloader. 2013-07-06 12:26:33 +02:00
Dean Camera
f0c72df674 Re-added Set Control Line State request handling to the CDC class bootloader. 2013-06-27 20:03:51 +02:00
Dean Camera
8bcc38aa32 Add Atmel Studio support for the XMEGA C3 Xplained board. 2013-06-22 15:31:51 +02:00
Dean Camera
fb9aa5aa81 Add Atmel Studio support for the U2S board. 2013-06-22 15:22:30 +02:00
Dean Camera
c6e1bf87b5 Minor documentation improvements. 2013-06-22 13:25:41 +02:00
Dean Camera
9737a23271 Fix indentation in the AVRISP-MKII AppConfig.h header. 2013-06-22 13:15:03 +02:00
Dean Camera
ed922ff422 Add missing U2S board definition, update build tests and documentation. 2013-06-22 13:13:17 +02:00
Michael
4a4b9d3051 Add U2S board support
Includes board definition files and patch for AVRISPMKII to move the
reset line for pin compatibility.
http://sites.google.com/site/megau2s/
2013-06-22 11:58:25 +02:00
Dean Camera
7362abcd8a Add missing files to the Low Level Device RNDIS demo inside Atmel Studio. 2013-06-18 16:46:09 +02:00
Dean Camera
1d49fc7dd8 Minor documentation improvements. 2013-06-16 15:09:13 +02:00
Dean Camera
1509af922b Add missing include to the Bentio project. 2013-06-12 20:20:07 +02:00
Dean Camera
f7b9ebea02 Update board Dataflash_Init() functions to automatically configure the appropriate communication interface. 2013-06-12 19:51:57 +02:00
Dean Camera
6d58628e85 Fix typos in the XMEGA board LED drivers, use a cleaner change and set implementation. 2013-06-12 18:43:06 +02:00
Dean Camera
1eae43da0c Minor documentation improvements. 2013-06-03 21:41:19 +02:00
Dean Camera
4175fe03ee Force-disable the inbuilt makefile rules as well as suffixes in the core build system makefile. 2013-06-03 20:54:12 +02:00
Dean Camera
24ff863f02 Add maintenance makefile rule to detect oversize code lines. 2013-06-02 22:03:13 +02:00
Dean Camera
c2e7e5783b Clean up Doxygen to Docbook XSLT, update Atmel Studio blob to use the new IDs. 2013-06-02 22:02:38 +02:00
Dean Camera
7941245122 Ensure core library documentation sections use unique IDs. 2013-06-01 21:55:31 +02:00
Dean Camera
16037433a2 Added missing LEDs to the XMEGA A3BU Xplained and XMEGA C3 Xplained board LED drivers 2013-06-01 18:56:03 +02:00
Dean Camera
94b43e2f9d Minor documentation improvements, update integration DLL. 2013-06-01 15:32:57 +02:00
Dean Camera
3ef45fae56 Minor tweak to RNDIS INF files to make them uniform with the style of the CDC INF drivers. 2013-05-25 11:42:02 +02:00
Dean Camera
0d2b3185ea Clean up Studio integration makefile, add more descriptive module names for the various board drivers. 2013-05-25 11:40:04 +02:00
Dean Camera
195af9e530 Synthesize a list of sub-groups (but not sub-sections due to Doxygen producing duplicate IDs) in the HV1 group documentation. 2013-05-24 18:23:45 +02:00
Dean Camera
1a62519c74 Add direct links to changelog, migration notes and known issues to the Atmel Studio Getting Started page. 2013-05-24 17:40:42 +02:00
Dean Camera
085f4d38e8 Synthesize a list of subsections in the HV1 documentation for pages without nested inner pages. 2013-05-24 17:29:05 +02:00
Dean Camera
ac36abd9f0 Update Atmel Studio integration XML to add additional internal module documentation entry points. 2013-05-23 22:48:47 +02:00
Dean Camera
f5882b875e Fix HID descriptor mouse and joystick macros for integer multiples of 8 buttons. 2013-05-23 19:54:42 +02:00
Dean Camera
902d3d9bff Update Atmel Studio project captions. 2013-05-23 16:58:31 +02:00
Dean Camera
b5285c1411 Minor documentation improvements. 2013-05-22 22:33:35 +02:00
Dean Camera
969120070c Fix typo in the Atmel Studio integration Getting Started page. 2013-05-22 22:32:35 +02:00
Dean Camera
c07d670b6c Update to a new XAML GUI based version of the Atmel Studio integration blob. 2013-05-22 16:47:11 +02:00
Dean Camera
f835323682 Merge branch 'XMEGA-Demo-Ports-ClockOnly' 2013-05-20 16:40:26 +02:00
Dean Camera
b37bde5675 Minor documentation improvements. 2013-05-20 13:55:47 +02:00
Dean Camera
10448970e5 Merge branch 'master' into XMEGA-Demo-Ports-ClockOnly 2013-05-20 00:06:37 +02:00
Dean Camera
fdf50e9411 Add support for the XMEGA C3 Xplained board. 2013-05-20 00:06:13 +02:00
Dean Camera
e51c0c84d6 Add missing project dependencies. 2013-05-19 23:17:25 +02:00
Dean Camera
151a1c5888 Port the device mode demos to the XMEGA architecture where applicable. 2013-05-19 22:59:46 +02:00
Dean Camera
329629a316 Pseudo-port the host mode demos for possible later multi-arch support. 2013-05-19 22:40:17 +02:00
Dean Camera
65a8d68c57 Pseudo-port the projects and dual role demos for possible later multi-arch support. 2013-05-19 22:28:02 +02:00
Dean Camera
139fabb6cd Add platform includes to the bootloaders. 2013-05-19 22:13:41 +02:00
Dean Camera
758ddfcc68 Assume 16MHz crystal by default in the AVR8 bootloaders. 2013-05-19 21:52:37 +02:00
Dean Camera
2bb012d4cb Add stub functions to all board drivers, so that demos can be compiled with BOARD=NONE. 2013-05-19 21:49:36 +02:00
Dean Camera
654baf7d60 Add XMEGA support to the class driver demos where possible. 2013-05-19 21:49:13 +02:00
Dean Camera
8474262728 Simplify the Doxygen to Docbook XML transform. 2013-05-19 20:20:08 +02:00
Dean Camera
51bfd9c95c Refactor out the common VSIX XSLT params. 2013-05-19 18:54:11 +02:00
Dean Camera
be5f06d9d3 Minor documentation improvements. 2013-05-19 17:10:58 +02:00
Dean Camera
44ecc034c1 Add Windows INF driver templates and class driver OS support information to the documentation. 2013-05-19 17:06:53 +02:00
Dean Camera
91eb7c34c7 Update Windows RNDIS driver template. 2013-05-19 16:43:27 +02:00
Dean Camera
fbc57f965e Update Doxygen configuration files to the latest version. 2013-05-19 15:47:34 +02:00
Dean Camera
773b6ae979 Add generate_help target to the Studio Integration makefile. 2013-05-18 23:18:14 +02:00
Dean Camera
3a06ef99e6 Fix broken RNDIS device demos when NO_ETHERNET_DECODE was not defined. 2013-05-18 22:45:47 +02:00
Dean Camera
7af4d949e2 Fix up page and group F1 lookup IDs in the Atmel Studio help. Fix struct namespacing in the help. 2013-05-18 17:26:40 +02:00
Dean Camera
06df6a3ea8 Fix up Atmel Studio F1 lookup index terms for Pages and Groups. 2013-05-18 16:58:40 +02:00
Dean Camera
2338189c8d Fix help install info dialog showing under the main Atmel Studio window in some circumstances. 2013-05-18 15:52:07 +02:00
Dean Camera
f6d0cdb817 Simplify LUFA Doxygen to Docbook transform, use parameterized page compounddef template. 2013-05-18 12:07:54 +02:00
Dean Camera
9891bf7cc3 Hide the donation Pledgie image from the HV1 output, as Doxygen incorrectly strips the image URL in the XML output. 2013-05-18 00:34:47 +02:00
Dean Camera
db528b6778 Fix Doxygen to Docbook transform function prototypes not folding (void) argument functions into a single line in some cases. 2013-05-17 21:18:54 +02:00
Dean Camera
85a0e75c60 Improve the BoardDriver build test, check for mismatches board hardware support macros or missing driver macros. 2013-05-17 20:34:13 +02:00
Dean Camera
c8f2269804 Add prefixes to string descriptor ID enum names in the AVRISP and XPLAINBridge projects to avoid conflicts. 2013-05-15 18:44:46 +02:00
Dean Camera
e342ba8f64 Add symbolic names for USB Device String Descriptors within the demos, applications and bootloaders. 2013-05-15 18:40:25 +02:00
Dean Camera
0ad234c194 Fix Printer class bootloader - descriptors are stored in SRAM, not FLASH. 2013-05-14 22:25:03 +02:00
Dean Camera
3d0e6d055b Minor documentation improvements. 2013-05-14 22:23:17 +02:00
Dean Camera
0d80075387 Fix missing bitshift in the AVR8 Pipe_GetBoundEndpointAddress() function. 2013-05-14 16:31:29 +02:00
Dean Camera
4a7405b2cf Remove redundant XSL params from the Studio Integration makefile. 2013-05-13 16:41:48 +02:00
Dean Camera
a3784c5944 Update Atmel Studio getting started page and associated images. 2013-05-12 22:45:11 +02:00
Dean Camera
983a2ed87a Update .gitignore file. 2013-05-12 22:40:10 +02:00
Dean Camera
4bfd45b484 Update Studio Integration blob and scripts to add a menu item for the local help. 2013-05-12 22:38:08 +02:00
Dean Camera
61d1be0cb2 Style improvements in the Atmel Studio Getting Started HTML page. 2013-05-12 21:29:03 +02:00
Dean Camera
1352ebe568 Fix typos in the Atmel Studio Getting Started HTML page. 2013-05-12 21:16:51 +02:00
Dean Camera
5a3baec455 Add basic Android host application to the Android Accessory Host class driver demo. 2013-05-12 12:40:14 +02:00
Dean Camera
707934d9cb Minor documentation improvements. 2013-05-12 12:04:58 +02:00
Dean Camera
6dde585475 Delete obsolete LEDNotifier project host application. 2013-05-10 22:33:21 +02:00
Dean Camera
214d5b39fc Fix Pipe_GetBoundEndpointAddress() returning bad values in some circumstances. 2013-05-10 21:48:42 +02:00
Dean Camera
0223c3668c Update Android Accessory Class driver to be compatible with protocol version 2 devices. 2013-05-10 21:45:37 +02:00
Dean Camera
39603f05b2 Update .gitignore file to not ignore generated VSIX files. 2013-05-10 17:49:50 +02:00
Dean Camera
46bb98d9dc Shrink the size of the Printer class bootloader by refactoring the page flush code into a static function. 2013-05-10 17:48:52 +02:00
Dean Camera
f9a919aa77 Fix typos in the bootloader API table entry names. 2013-05-10 16:59:03 +02:00
Dean Camera
bf6cc44ab1 Add LUFA .gitignore file. 2013-05-09 11:44:47 +02:00
Dean Camera
b7455af965 Remove legacy Programmers Notepad project file. 2013-05-09 11:36:58 +02:00
Dean Camera
9b2ff1d8e8 Remove old information about the SVN repository from the documentation. 2013-05-09 11:13:55 +02:00
Dean Camera
eef7286283 Minor documentation improvements. 2013-05-06 19:35:49 +00:00
Dean Camera
3bf3e53367 Add Printer Device Class source files to the Atmel Studio integration XML. 2013-05-05 21:05:30 +00:00
Dean Camera
7b5b8f199f Tighten up Printer bootloader implementation; fold the IsHEX() function logic into HexToDecimal() and remove redundant state machine state logic to save space in the compiled binary. 2013-05-05 19:34:20 +00:00
Dean Camera
961da384f9 Add proper reset handling to the USB Printer Device Class driver. 2013-05-05 19:32:07 +00:00
Dean Camera
95ba6527a5 Add missing EVENT_PRNT_Device_SoftReset() public function prototype. 2013-05-05 19:13:56 +00:00
Dean Camera
b68a71af38 Update the Printer class bootloader to use the new Printer Device Class driver, rather than implementing the Printer USB class manually. 2013-05-05 19:08:15 +00:00
Dean Camera
9ccf3eafad Add new Printer Device Class driver. 2013-05-05 19:07:20 +00:00
Dean Camera
7f5445c8c6 Revert incorrect XMEGA interrupt disable patch; all flags *except* the interrupt level should be cleared, and not the interrupt level itself. 2013-05-05 14:09:26 +00:00
Dean Camera
7464e40a4b Minor documentation improvements. 2013-05-04 20:54:32 +00:00
Dean Camera
fd5e98d380 Add check to the Doxygen->Docbook transform to warning on untemplated items. Add additional templates to ensure the output documentation does not have unescaped or unformatted entries. 2013-05-04 14:38:11 +00:00
Dean Camera
db929fd4c8 Implement integration binary blob suggestions from AVRFreaks members. 2013-05-03 19:09:10 +00:00
Dean Camera
fdc7c8abce Oops - ensure the Atmel Studio extension package has the same GUID as the one used in the VSIX manifest, to prevent Studio from re-running the pre-/post-install actions every time. 2013-05-01 18:47:54 +00:00
Dean Camera
1949b98e6c Minor documentation improvements. 2013-05-01 11:36:55 +00:00
Dean Camera
16e8fe9878 Fix Serial peripheral driver compile error for XMEGA devices. 2013-04-29 18:35:19 +00:00
Dean Camera
5e55be1004 Use previous Atmel Studio VSIX identifier so that it can upgrade existing installations. 2013-04-29 15:03:09 +00:00
Dean Camera
70dd6bc526 Fix board driver hardware capability definition macro documentation. Fix Doxygen-to-Docbook transform eating the contents of generated tables. 2013-04-28 17:24:37 +00:00
Dean Camera
a24e1cc7d7 Centre images in the Atmel Studio help, apply text formatting styles recursively. 2013-04-28 16:08:33 +00:00
Dean Camera
3908d2e608 Add more information on the integrated Help package to the Atmel Studio Getting Started first-run page. 2013-04-28 12:14:37 +00:00
Dean Camera
15fb6351e5 Move USB mode enum into the top level USB controller header, as it is common to all architectures (even if not all modes are supported). 2013-04-28 11:31:28 +00:00
Dean Camera
c757acf1f7 Allow the title of top level pages to be overridden in the Atmel Studio help. 2013-04-28 11:29:23 +00:00
Dean Camera
41810f6e9e Update AVRISP-MKII Clone programmer project default firmware minor revision number to make it compatible with the Atmel Studio 6.1 public release. 2013-04-27 10:30:09 +00:00
Dean Camera
d3cee5160b Enable full Doxygen backed syntax highlighting in the Atmel Studio integrated help output. 2013-04-27 10:03:02 +00:00
Dean Camera
5cfa1c37c6 Speed up Doxygen-to-Docbook conversion, enable partial syntax highlighting in the MS HV1 output. 2013-04-25 19:46:03 +00:00
Dean Camera
1840e1bbae Add partially complete syntax highlighting to the HV1 transform. 2013-04-24 18:52:08 +00:00
Dean Camera
29bfe7a09c Add move-to-root directives to all ASF XML application modules, to make the code easier to find in the release version of Atmel Studio 6.1. 2013-04-23 20:40:56 +00:00
Dean Camera
9543276111 Fix typo in the XMEGA SerialSPI peripheral driver. 2013-04-23 20:02:41 +00:00
Dean Camera
5dba028aa5 Tweak HV1 help styling and image elements. 2013-04-23 17:54:17 +00:00
Dean Camera
cf8ec8967e Move all Doxygen-to-Docbook rules into a single transform, remove redundant rules/transforms and add support for verbatim and linebreak elements. 2013-04-23 15:08:32 +00:00
Dean Camera
f515e8412f Update Doxygen-to-Docbook transform with the latest transform rules for functions, enums, structs, type definitions and variables. 2013-04-22 19:22:27 +00:00
Dean Camera
cc44591b58 Add basic CSS styling to the Atmel Studio integrated help. 2013-04-22 18:32:26 +00:00
Dean Camera
344cd1a2e8 Use the localized Microsoft Help Viewer path if available when installing help into Atmel Studio. 2013-04-22 17:02:30 +00:00
Dean Camera
1d5b268fd9 Fix Atmel Studio integrated help generation and branding. 2013-04-22 16:35:18 +00:00
Dean Camera
c1ffcd8681 Restrict the Doxygen to Docbook transform to only the relevant items. 2013-04-22 14:54:49 +00:00
Dean Camera
8232721102 Fixed possible register corruption in USB Host mode on AVR8 devices when ORDERED_EP_CONFIG is used (thanks to Martin Aakerberg). 2013-04-21 19:06:34 +00:00
Dean Camera
2fe1d7d170 Add first-run Unsigned Help install information prompt, ensure installed help package is removed correctly when the extension is uninstalled. 2013-04-21 17:10:06 +00:00
Dean Camera
083b5cb143 Add missing indexterm entries to the Atmel Studio help transform. 2013-04-21 16:05:11 +00:00
Dean Camera
3c5acb4d2c Minor documentation improvements. 2013-04-21 15:16:34 +00:00
Dean Camera
9136fe2132 Finish initial Doxygen-to-Docbook transform. 2013-04-21 15:15:47 +00:00
Dean Camera
d540e52505 Add partially complete Doxygen-to-Docbook transform. 2013-04-21 14:18:12 +00:00
Dean Camera
dd723813d9 Add HV1 integration into Atmel Studio (native Help). 2013-04-21 12:15:57 +00:00
Dean Camera
2cd3f843e2 Fix invalid Getting Started page HTML. 2013-04-20 14:43:18 +00:00
Dean Camera
38fa1d5c83 Update Getting Started Atmel Studio start page to make it XHTML compliant. 2013-04-20 11:24:12 +00:00
Dean Camera
5a802b18df Minor documentation improvements. 2013-04-18 20:14:53 +00:00
Dean Camera
fff68762e9 Simplify Atmel Studio integration scripts. 2013-04-18 15:58:13 +00:00
Dean Camera
e5c65f6e25 Add finished initial LUFA Atmel Studio binary blob and supporting files. 2013-04-18 14:53:54 +00:00
Dean Camera
eefbf632d6 Update Atmel Studio blob - use sane method to extract the extension's bundled Getting Started path, use VSCT to generate the menu items. 2013-04-17 21:06:57 +00:00
Dean Camera
7ef41e3c1e Refactor Atmel Studio binary blob internals to be more OO-like. 2013-04-16 18:39:27 +00:00
Dean Camera
196f4868b9 Fix broken Atmel Studio blob - ensure Help menu items are correctly generated. 2013-04-16 17:03:18 +00:00
Dean Camera
0672e4ac6c Update Atmel Studio blob DLL; add links to LUFA related pages in the Help menu. 2013-04-15 20:23:19 +00:00
Dean Camera
5555a43625 Add first-run information page to the Atmel Studio 6.1 extension. 2013-04-15 17:55:15 +00:00
Dean Camera
25224aae7e Minor documentation improvements. 2013-04-14 14:37:44 +00:00
Dean Camera
f2d7f6f674 Move XDK cache generation Python script into the VSIX related packing directory. 2013-04-14 10:31:43 +00:00
Dean Camera
f3a8263842 Restructure Atmel Studio integration files and transforms. 2013-04-14 10:23:59 +00:00
Dean Camera
b6a38164bd Reduce the amount of inlining of core Endpoint functions for XMEGA, to reduce the compiled code size (size/speed tradeoff). 2013-04-14 08:48:55 +00:00
Dean Camera
70c59a7e42 Add Atmel Studio 6.1 binary blob. 2013-04-13 15:21:14 +00:00
Dean Camera
188dea87e3 Oops - fix function prototype attribute. 2013-04-11 17:54:41 +00:00
Dean Camera
334f70aa80 Add some missing function attributes. 2013-04-11 17:39:00 +00:00
Dean Camera
d5e84db5ab Don't generate the full HTML documentation when only needing the XML version for post-processing. 2013-04-11 17:30:14 +00:00
Dean Camera
c10935c80b Add maintenance makefile rule and XSLT transform to generate a unified header of all library functions for analysis purposes. 2013-04-10 20:31:32 +00:00
Dean Camera
91946e6d62 Improve bootloader compile error message text when building without the correct optimization level. 2013-04-08 19:35:00 +00:00
Dean Camera
197e2ed985 Add module help links and descriptions for boards inside Atmel Studio. 2013-04-08 19:31:13 +00:00
Dean Camera
b7f9beefd8 Fix typos in the Arduino Leonardo board drivers. 2013-04-08 19:29:26 +00:00
Dean Camera
ebd059d0eb Update AS integration scripts and transforms - extract out the module description from the Doxygen XML output for the GUI. 2013-04-08 18:59:25 +00:00
Dean Camera
c2f9eba33f Clean repository before packaging into VSIX extensions. 2013-04-08 18:15:09 +00:00
Dean Camera
6ea66a7770 Tweak the VSIX output names to indicate if it is a release or testing version. 2013-04-06 22:08:52 +00:00
Dean Camera
7c3867da33 Added new CONCAT() and CONCAT_EXPANDED() convenience macros. 2013-04-06 22:07:54 +00:00
Dean Camera
7dc77a6abc Update VSIX package generator; allow all newer test builds to be installed over the top of each other without first uninstalling the existing one, but allow all releases to supersede test builds. 2013-04-06 21:21:13 +00:00
Dean Camera
dd08100a7d Clean up bootloader project ASF integration code. 2013-04-06 19:42:46 +00:00
Dean Camera
9aabce09f1 Add bootloader projects for Atmel Studio 6.1 (requires latest AS6.1 trunk). 2013-04-06 14:41:40 +00:00
Dean Camera
ace61d757e Add checks to the bootloaders so that they will give a user-friendly compile error if not compiled with size optimizations. 2013-04-06 14:34:57 +00:00
Dean Camera
09ae9ad004 Minor documentation improvements. 2013-04-04 20:29:40 +00:00
Dean Camera
e40f0eb289 Automatically exit the printer class bootloader and start the application when the end of the HEX file is reached (thanks to Hans Schou). 2013-04-04 20:02:52 +00:00
Dean Camera
646e63b089 Add explicit requirements for the AppConfig.h headers in the various project asf.xml files, to prevent breakage with the latest ASF trunk project generator upgrades. 2013-04-01 07:39:53 +00:00
Dean Camera
7dc5295103 Minor clean up of the Mass Storage bootloader. 2013-03-31 14:15:03 +00:00
Dean Camera
dc389f1c72 Add experimental warnings to the XMEGA and UC3 architectures when used in Atmel Studio 6.1. 2013-03-31 10:28:51 +00:00
Dean Camera
85343a436d Add ATTR_NEVER_INLINE attribute. Add EEPROM byte read/write proxy functions to the Mass Storage bootloader to prevent link errors due to linker relaxations. 2013-03-31 09:37:30 +00:00
Dean Camera
7251da6581 Add EEPROM read/write support to the Mass Storage class bootloader. 2013-03-30 17:16:29 +00:00
Dean Camera
829ecefe41 Clean up the VirtualFAT implementation. 2013-03-30 15:13:42 +00:00
Dean Camera
b956fedeeb Minor cleanup of the Mass Storage bootloader VirtualFAT code. 2013-03-29 13:14:07 +00:00
Dean Camera
ddd6632295 Oops - ensure the SCSI transfer length is correct in the Mass Storage bootloader. 2013-03-29 10:40:40 +00:00
Dean Camera
907cb2459c Minor documentation improvements. 2013-03-29 10:29:11 +00:00
Dean Camera
83d5c4729e Update Mass Storage bootloader for Linux compatibility, and to reduce the compiled bootloader size. Linux appears to replace files with a cluster offset on the disk rather than re-using the same disk clusters (unlike Windows) so the file offset needs to be tracked and compensated for. 2013-03-29 10:23:09 +00:00
Dean Camera
148b434228 Minor documentation improvements. 2013-03-28 14:59:32 +00:00
Dean Camera
d18f12bf42 Added additional MIDI command definitions to the MIDI class driver (thanks to Daniel Dreibrodt). 2013-03-28 14:59:19 +00:00
Dean Camera
8cd249c342 Add BIN build system target information to the documentation. 2013-03-28 09:30:37 +00:00
Dean Camera
4ba4097716 Fixed race condition in the DFU class bootloader causing failed device reprogramming in some circumstances (thanks to Luis Mendes). 2013-03-27 18:55:30 +00:00
Dean Camera
f2e974954b Minor documentation improvements. 2013-03-26 18:59:45 +00:00
Dean Camera
3bc066cd69 Clean up the Mass Storage bootloader virtual FAT directory entry definitions. 2013-03-25 21:09:55 +00:00
Dean Camera
169f21fbb1 Add Long File Name (VFAT) entry to the Mass Storage class bootloader, so that systems such as Linux that load a VFAT filesystem driver instead of the legacy MSDOS filesystem do not corrupt the volume by trying to write a LFN entry. 2013-03-25 20:58:33 +00:00
Dean Camera
654217548b Fix incorrect Interrupt disable function for the XMEGA architecture (thanks to Simon Küppers). 2013-03-23 21:53:56 +00:00
Dean Camera
31d3984d8d Fixed Low Speed USB devices broken when using the library HID Class driver (thanks to Michael). 2013-03-23 12:01:25 +00:00
Dean Camera
141f24b4a1 Add known-issues documentation section to the various LUFA bootloaders. 2013-03-22 23:24:02 +00:00
Dean Camera
54e46d7818 Add smaller AVR8 targets to the Mass Storage bootloader target list in the Bootloader build test. 2013-03-20 20:03:00 +00:00
Dean Camera
04feb435ed Fix broken core library Doxygen version number makefile macro. 2013-03-20 19:56:35 +00:00
Dean Camera
9d988fdc22 Make the Mass Storage bootloader compatible with the original (green) XPLAIN boards. 2013-03-20 19:08:54 +00:00
Dean Camera
199cf8f183 Significantly reduce the size of the Mass Storage class bootloader, by removing dependencies on large LUFA internal functions. 2013-03-20 19:02:29 +00:00
Dean Camera
6e8642185a Fix corrupted disassembly listing (LSS) files due to linker relaxations; pass -mrelax to the compiler to make it aware of, and able to compensate for, linker relaxations. 2013-03-20 17:50:56 +00:00
Dean Camera
b2e49663f6 Minor documentation improvements. 2013-03-19 17:03:31 +00:00
Dean Camera
262b7d7b7b Make Mass Storage bootloader makefile variable naming consistent. 2013-03-18 19:25:36 +00:00
Dean Camera
03cdb09071 Minor documentation improvements. 2013-03-18 19:24:55 +00:00
Dean Camera
88bcc6fde5 Speed up Mass Storage bootloader by turning off the internal clock divider, as there is enough FLASH space to do so. 2013-03-18 17:27:18 +00:00
Dean Camera
1703283893 Ensure bootloader makefile calculation functions are uniform across all bootloaders. 2013-03-18 17:21:02 +00:00
Dean Camera
be33d3a515 Update Mass Storage bootloader so that it can support devices with only 4KB bootloader sections by creating a special AUX section before the real bootloader section to store part of the bootloader code. 2013-03-18 17:18:11 +00:00
Dean Camera
f8a1dc7424 Minor documentation improvements. 2013-03-18 17:04:33 +00:00
Dean Camera
f429975e01 Tweak the LUFA config for the Mass Storage class bootloader to reduce the compiled size slightly by removing unused features. 2013-03-17 16:37:00 +00:00
Dean Camera
dd1e18b264 Minor documentation improvements. 2013-03-17 16:34:33 +00:00
Dean Camera
6dd4d0a9f1 Fixed incorrect HID report descriptor generated for 16-bit axis ranges by the HID_DESCRIPTOR_MOUSE() and HID_DESCRIPTOR_JOYSTICK() macros (thanks to Guillaume Germaine) 2013-03-17 13:52:12 +00:00
Dean Camera
d1155a9a27 Enable C++ compatibility check warnings in the ModuleTest build test. 2013-03-14 21:09:14 +00:00
Dean Camera
1575ca57bb Minor documentation improvements. 2013-03-14 21:08:53 +00:00
Dean Camera
e635872612 Small size improvement in the Printer and Mass Storage class bootloaders. 2013-03-13 21:19:31 +00:00
Dean Camera
cb4e4a711e Fix invalid definition of STDOUT_ASSERT(). 2013-03-13 21:18:53 +00:00
Dean Camera
9e8bf8c0cf Fix "grep: Version.h: No such file or directory" error when including the core LUFA library makefile in a legacy makefile. 2013-03-12 16:53:16 +00:00
Dean Camera
cc8b12f1cb Add missing module dependency to the USBtoSerial project. Minor documentation corrections. 2013-03-12 15:17:53 +00:00
Dean Camera
61d396b555 Minor documentation improvements. 2013-03-10 20:25:26 +00:00
Dean Camera
68c317c4e9 Fix off-by-one error in the Mass Storage bootloader file size, add missing Volume Label directory entry. Remove incorrect reference to "printer" in the bootloader documentation. 2013-03-10 19:53:48 +00:00
Dean Camera
de9d05f32a Enable Mass Storage bootloader builds in the BootloaderTest build test. 2013-03-10 09:42:12 +00:00
Dean Camera
0b1f33e2a2 Move out the Mass Storage class bootloader to the main Bootloader directory now that it is functional. 2013-03-10 09:35:43 +00:00
Dean Camera
ef7b6a274c Fix Printer bootloader top level documentation. 2013-03-10 09:34:28 +00:00
Dean Camera
32fcf1ec53 Remove compiled BIN files when running "make clean" with the BUILD build system module. 2013-03-10 09:34:13 +00:00
Dean Camera
3f52d6ee06 Add top level documentation to the Mass Storage class bootloader. 2013-03-10 09:32:03 +00:00
Dean Camera
dddb709c43 Oops - fix broken FAT_DATE() and FAT_TIME() macros. 2013-03-10 09:21:57 +00:00
Dean Camera
df9b04c87f Add documentation to the incomplete Mass Storage class bootloader, update the virtual FAT file entry so that the bootloader section is omitted (not user readable/writable). Fix some minor documentation errors in the Printer class bootloader. 2013-03-10 09:20:55 +00:00
Dean Camera
6c9632ae38 Minor optimizations and corrections to the incomplete Mass Storage class bootloader. 2013-03-10 08:38:47 +00:00
Dean Camera
d5cff25cd1 Update Bootloader buld test to generate bootloaders using the new Printer class bootloader. Optimize incomplete Mass Storage bootloader LUFA configuration. 2013-03-09 11:11:05 +00:00
Dean Camera
e62e50c663 Add dummy handler for SCSI_CMD_START_STOP_UNIT in all project SCSI handling routines, to prevent ejection errors on *nix systems due to an unknown SCSI command. 2013-03-09 10:59:53 +00:00
Dean Camera
d5d83b8e8f Add LED flashing to the incomplete Mass Storage class bootloader. Clean up virtual FAT implementation. 2013-03-09 10:51:19 +00:00
Dean Camera
726b325c73 Update BUILD build system module to produce BIN files as well as HEX. 2013-03-09 10:37:12 +00:00
Dean Camera
bb8754e2b8 Add FLASH writing routine to the VirtualFAT layer of the incomplete Mass Storage class bootloader. 2013-03-09 10:32:17 +00:00
Dean Camera
63e1fc6e6c Make the VirtualFAT firmware file read from device flash when opened by the host in the incomplete Mass Storage class bootloader. 2013-03-09 09:24:26 +00:00
Dean Camera
d5d9ff73e5 Remove debug code from the incomplete Mass Storage class bootloader, rename main source files. 2013-03-09 09:17:42 +00:00
Dean Camera
0f0f9638a3 Use real firmware file size in the VirtualFAT layer, clean up FAT12 chain update function. 2013-03-09 09:13:44 +00:00
Dean Camera
f00754ed97 FAT heuristics mean a disk as small as the one emulated in the incomplete Mass Storage bootloader *must* be FAT12, not FAT16. Update to use a FAT12 cluster chain. 2013-03-09 08:48:00 +00:00
Dean Camera
6da1677bc3 Fix off-by-one in the VirtualFAT cluster chain generator. 2013-03-09 08:08:31 +00:00
Dean Camera
7f5dab4f26 Refactor macros in the VirtualFAT implementation of the incomplete Mass Storage bootloader. 2013-03-09 08:00:22 +00:00
Dean Camera
f0c7a11670 Corrections and debug channel in the Incomplete Mass Storage class bootloader. 2013-03-09 07:49:46 +00:00
Dean Camera
4753528b9e Add APIs to the incomplete Mass Storage bootloader. 2013-03-08 15:52:05 +00:00
Dean Camera
64f17a679f Add the start of a new Mass Storage class bootloader. 2013-03-08 15:50:12 +00:00
Dean Camera
57071dea22 Minor documentation fixes. 2013-03-07 17:55:59 +00:00
Dean Camera
7d4062fa54 Use a temporary variable for the Printer bootloader HEX parser when combining the current and previous data tokens to form a data word, to simplify the code. 2013-03-06 19:48:27 +00:00
Dean Camera
2e7fc37ad2 Fix incorrect HEX extended address parsing in the Printer class bootloader. 2013-03-04 17:44:41 +00:00
Dean Camera
d999ca8f30 Fix incorrect Bootloader documentation. 2013-03-04 16:43:32 +00:00
Dean Camera
0c40ef8897 Add documentation to the Printer class bootloader, add LED flash when the bootloader is active. 2013-03-03 14:34:07 +00:00
Dean Camera
041bdf8954 Add bootloader API functions to the Printer class bootloader. 2013-03-03 14:14:45 +00:00
Dean Camera
63e80bea08 Add additional comments to the Printer class bootloader, fix incorrect VID/PID values. 2013-03-03 14:10:13 +00:00
Dean Camera
8a43da6b37 Add new Printer class USB bootloader. 2013-03-03 13:35:46 +00:00
Dean Camera
d88c6edea4 Reset version information now that the LUFA-130303 release has been tagged. 2013-03-03 10:57:45 +00:00
Dean Camera
d8b81e76f6 Commit for the LUFA-130303 release. 2013-03-03 10:33:49 +00:00
Dean Camera
71e28def27 Minor documentation updates. 2013-03-03 10:27:35 +00:00
Dean Camera
3383487deb Clean up Studio Integration cache generation script. Re-indent integration VSIX XML files. 2013-03-01 21:48:18 +00:00
Dean Camera
6019754b7a Use dedicated -mrelax linker option in the Atmel Studio integration toolchain configurations, rather than a freeform linker switch. 2013-03-01 21:44:38 +00:00
Dean Camera
39ffce948a Fixed incorrect output in the HIDReportViewer project when no device is connected (thanks to Pavel Kuzmin). 2013-02-28 15:29:05 +00:00
Dean Camera
280fc85d1b Use a slightly less insane/redundant toolchain configuration from within Atmel Studio. 2013-02-27 22:10:22 +00:00
Dean Camera
fa2a8fca69 Fixed potential NULL pointer dereference in the HID Host mode Class Driver (thanks to Pavel Kuzmin). 2013-02-27 19:57:28 +00:00
Dean Camera
95fd3bf0fe Fix incorrect memory space usage on the Device Descriptor in the device mode project template. 2013-02-26 16:51:46 +00:00
Dean Camera
cfa48f5987 Changed all *_SendByte() function prototypes to accept a void pointer for the input buffer (thanks to Simon Küppers) instead of a uint8_t pointer. 2013-02-24 15:46:58 +00:00
Dean Camera
2b4658de2c Fix swapped product IDs for the ATMEGA8U2 and AT90USB82 in the DFU class bootloader. 2013-02-24 14:17:46 +00:00
Dean Camera
8703edc724 Fixed swapped LED3 and LED4 masks for the Olimex-32U4 development board LED driver. 2013-02-19 21:07:55 +00:00
Dean Camera
6c531a10c0 Update author information. 2013-02-17 19:06:08 +00:00
Dean Camera
4bd36a9775 Reset XMEGA NVM read command to the symbolic NO_OPERATION constant rather than a hard-coded zero. 2013-02-13 19:50:30 +00:00
Dean Camera
300a05d6c6 Remove CPPCheck suppressions for unused functions, disable checking for them in the StaticAnalysisTest build test as it can't cope with GCC aliasing and mixed library/application code. 2013-02-05 20:57:49 +00:00
Dean Camera
7ce76f2d81 Update extension XML format to match latest XDK schema. 2013-02-02 08:53:39 +00:00
Dean Camera
3d2c39d267 Tweak Atmel Studio VSIX extension script output filename to contain the release version. 2013-01-29 21:20:12 +00:00
Dean Camera
5b089fbbf3 Whitespace fixes in the LUFA configuration files. 2013-01-29 19:59:52 +00:00
Dean Camera
8d22cedfc4 Minor documentation improvements. 2013-01-29 19:40:30 +00:00
Dean Camera
da42e8840d Suppress unused function parameter warnings in the USB driver. 2013-01-27 19:48:29 +00:00
Dean Camera
fb18c315d0 Fix broken XMEGA USB support. 2013-01-27 19:35:40 +00:00
Dean Camera
f8f8ac0b1a Fix typos in the new board hardware information header files. 2013-01-27 16:09:27 +00:00
Dean Camera
2cd4c5aaa1 Update Programmers Notepad project file to ensure it is current. 2013-01-27 15:57:53 +00:00
Dean Camera
0e64a9d0c2 Update Atmel Studio core board templates to use different templates for each driver, so that the project caption contains the architecture. Update individual board modules to include the relevant board hardware drivers. 2013-01-27 15:48:09 +00:00
Dean Camera
3929cae00e Fix typo in the board hardware info dispatch driver header file. 2013-01-27 15:40:07 +00:00
Dean Camera
a05dd56239 Add code template for the new board hardware information driver. 2013-01-27 15:28:17 +00:00
Dean Camera
bc8e686e51 Added new Board Hardware Information board driver. 2013-01-27 15:27:02 +00:00
Dean Camera
22b04429e6 Fixed incorrectly issuing STALL response to unsupported control request SETUP packets, rather than in the data/status stage. 2013-01-27 13:07:48 +00:00
Dean Camera
5937a134ab Fix missing references to the ANSI terminal driver codes in the USART peripheral driver module. 2013-01-27 12:00:04 +00:00
Dean Camera
0878957241 Fix device support typo preventing the XMEGA A3BU from being allowed as a device target in the Atmel Studio extension. 2013-01-26 14:56:41 +00:00
Dean Camera
2413d114b7 Upgrade Doxygen configuration files to the latest version. 2013-01-20 13:58:53 +00:00
Dean Camera
3059a33db2 Fix incorrect URLs for the Stange-ISP board. 2013-01-19 23:09:20 +00:00
Dean Camera
b8d07ffb24 Fix typo in the Host RNDISEthernet low level demo. 2013-01-19 17:05:10 +00:00
Dean Camera
180180e234 Add support for the Dimex Stange-ISP programmer board (thanks to Gerhard Wesser). 2013-01-19 17:04:32 +00:00
Dean Camera
5fea1abd22 Switch extension inner archive to store compression mode and switch outer VSIX archive to maximum compression, to improve project generation speed within Atmel Studio. 2013-01-19 10:04:10 +00:00
Dean Camera
2709627970 Clean up VSIX generation scripts. 2013-01-17 20:07:19 +00:00
Dean Camera
af241316de Fix oops - forgot to save changelog after previous update. 2013-01-15 19:41:59 +00:00
Dean Camera
730db924c9 Fixed bug in the TWI peripheral driver for the AVR8 devices causing incorrect failure codes to be returned in some cases (thanks to Peter K). 2013-01-15 19:34:35 +00:00
Dean Camera
f51c87b916 Code style fixes to the AVRISP-MKII Clone programmer project. 2013-01-14 20:57:04 +00:00
Dean Camera
7eaf3d18d2 Offline help is currently ignored in AS6 extensions - reduce extension size by omitting it from the generated extension VSIX. 2013-01-13 18:22:05 +00:00
Dean Camera
397d77cb44 Updated AVRISP-MKII Clone Programmer project so that the SCK clock period is saved in EEPROM (thanks to Gerhard Wesser). 2013-01-13 12:46:23 +00:00
Dean Camera
f2c2415480 Move out dummy board module and add strong-references to it in each project, so that the correct project caption is generated inside Atmel Studio. 2013-01-12 22:23:58 +00:00
Dean Camera
184efdaba6 Add Atmel Studio keywords to all project XML files. 2013-01-12 16:54:26 +00:00
Dean Camera
c791413fbc Ensure the demo and project main text files are distributed in Atmel Studio projects. 2013-01-11 23:35:17 +00:00
Dean Camera
33bc48fa46 Check referenced distribute build files in the project XML files, as well as C source and header files. 2013-01-11 23:10:25 +00:00
Dean Camera
ed372b031c Alter VSIX build script to verify all referenced filenames in all modules and projects, rather than just the core modules. Fix discovered errors in the project XML files. 2013-01-11 22:43:17 +00:00
Dean Camera
cff8a751bb Fix mistakes in the board XML module file paths. 2013-01-11 22:10:59 +00:00
Dean Camera
cae97e1ac3 Add board definitions to the pseudo-board selector module in the Atmel Studio integration files. Make sure all projects require the base board module, so that it appears as a top level module in the project ASF explorer for easy board switching. 2013-01-11 22:05:12 +00:00
Dean Camera
5cdc29616c Update and add missing Atmel Studio project description XML files. 2013-01-10 21:09:53 +00:00
Dean Camera
bdd74a5ed9 Fix invalid module IDs and update VSIX packing script to ensure the database cache files are always updated. 2013-01-10 20:14:38 +00:00
Dean Camera
5b5957f9ea Add and update more Atmel Studio project description XML files. 2013-01-10 20:08:31 +00:00
Dean Camera
bbffe94a9d Ensure the VSIX Python script aborts if the ASF project generator is missing. 2013-01-09 20:42:14 +00:00
Dean Camera
eac6205747 Make sure the INF driver file is distributed in Atmel Studio projects that require them. 2013-01-09 20:26:34 +00:00
Dean Camera
77af37a587 Add class driver host mode demo ASF module XML files. 2013-01-09 19:46:36 +00:00
Dean Camera
0254a7e980 Clean up VSIX generation scripts. 2013-01-09 19:01:28 +00:00
Dean Camera
132de6ed22 Add Python script and update VSIX generator rules to pre-generate the Atmel Studio cache files required to make the extension visible. 2013-01-08 20:35:27 +00:00
Dean Camera
8e11439f91 Fix incorrect module ID in the RNDIS device demo ASF.xml file. 2013-01-08 20:30:52 +00:00
Dean Camera
482cb097e8 Add FDK project descriptions for the class driver Device mode examples. 2013-01-08 19:35:43 +00:00
Dean Camera
841bb33e36 Add ASF provider manifest file and adjust VSIX packing to compress the library contents. 2013-01-07 20:39:25 +00:00
Dean Camera
48e87c8e8f Add device and host mode template projects. 2013-01-07 16:27:33 +00:00
Dean Camera
30545fdec7 Fix up broken Studio pseudo-board configuration module, add missing USB driver files. 2013-01-07 16:27:17 +00:00
Dean Camera
3edd686a05 No Studio UI to switch boards yet, so make a dummy board that is used by all projects, and have a Select-By-Config module select the actual board drivers. 2013-01-07 16:05:21 +00:00
Dean Camera
09b2254b33 Minor clean up of maintenance and integrations scripts. 2013-01-06 19:47:30 +00:00
Dean Camera
fc876438f6 Minor documentation improvements. 2013-01-06 13:41:23 +00:00
Dean Camera
c50072c3c4 Use nicer LUFA documentation links in the VSIX extension, rather than direct FourWalledCubicle links. 2013-01-06 13:41:03 +00:00
Dean Camera
1da700e4fb Add licence to VSIX extension. 2013-01-05 16:07:09 +00:00
Dean Camera
ab8ae60058 Fixed incorrect ordering of the linker options in the build system causing link failures in some cases. 2013-01-05 15:45:27 +00:00
Dean Camera
26015d432d Make VSIX packing quiet, increase compression to the maximum level allowed. 2013-01-05 14:01:01 +00:00
Dean Camera
9603de1398 Fix up invalid device configurations in the BootloaderTest build test. 2013-01-05 13:55:16 +00:00
Dean Camera
f644ffe873 Minor documentation improvements. 2013-01-05 13:28:14 +00:00
Dean Camera
fbab860902 Add transform to update the VSIX extension version automatically when built. 2013-01-05 13:11:49 +00:00
Dean Camera
78e6e4f4c2 Add Atmel Studio Extension (VSIX) packaging files and scripts. 2013-01-05 11:18:49 +00:00
Dean Camera
56f03a793c Move out Studio Integration XML transform files to their own directory for neatness. 2013-01-03 16:16:45 +00:00
Dean Camera
5386a5a7ff Update Studio Integration XML transform files to add top-level descriptions for each transform. Update module transform to remove spacing between modules in the generated document and to remove the unused doxygen-entry-point nodes once they have been converted into online and offline documentation nodes. 2013-01-03 16:08:44 +00:00
Dean Camera
340b2dc0bc Ensure that the core USB driver source filenames are not duplicated in the LUFA_SRC_USB makefile variable of the LUFA sources build module, so that parallel builds still work. 2013-01-03 14:09:26 +00:00
Dean Camera
4167f3aa6b Split up USB source files in lufa_sources.mk build system module so that applications can pull in mode-specific USB support rather than having to compile all files even if it is known they will not be used. 2013-01-03 13:44:00 +00:00
Dean Camera
5724b28151 Minor documentation improvements. 2013-01-03 12:11:02 +00:00
Dean Camera
a016942a3e Add missing include to the USB driver core mode header file. 2013-01-03 12:07:16 +00:00
Dean Camera
bd2f3c0250 Update maintenence validation target to also generate Atmel Studio integration files. 2013-01-03 11:42:25 +00:00
Dean Camera
de0df8b162 Update copyright year to 2013. 2013-01-03 11:37:33 +00:00
Dean Camera
13dd494cfe Upgrade Doxygen configuration files to the latest Doxygen version. 2013-01-03 11:32:19 +00:00
Dean Camera
1ab7e11ddb Remove unsupported devices from the BootloaderTest build test. 2013-01-03 11:30:57 +00:00
Dean Camera
2608fd1dd4 Fixed hardware race condition that could cause failed device enumerations for AVR8 and UC3 architectures (thanks to Mike Beyhs).
Fixed incorrect Minimus board LED definitions (thanks to Joonas Lahtinen).

Fixed incorrect LED masks for received data display in the Device GenericHID demos (thanks to Denys Berkovskyy).
2013-01-03 10:53:47 +00:00
Dean Camera
7d037c7db8 Remove support for devices that were not put into production. 2013-01-03 10:49:44 +00:00
Dean Camera
04d13d264c Add Atmel Studio integration files. 2013-01-03 10:40:35 +00:00
Dean Camera
aa61ee1c11 Minor typo corrections. 2013-01-02 19:31:08 +00:00
Dean Camera
2957f2bc8c Minor documentation improvements. 2012-11-12 18:45:59 +00:00
Dean Camera
c786d8a0b7 Remove dependency on the "bc" command line calculator tool in the bootloaders to make compiling on Windows easier with only MinGW. 2012-11-10 16:47:04 +00:00
Dean Camera
9740d3a55f Make "HighByte" variable in the CDC Bootloader a uint8_t rather than a bool to be more semantically correct, since it is bitwise ORed to obtain a byte address in the AVR's flash memory. 2012-10-28 13:56:14 +00:00
Dean Camera
2b43a6d7df Add troubleshooting page to the build system section of the documentation. 2012-10-28 13:53:55 +00:00
Dean Camera
fe49fd51b2 Increased throughput in the USBtoSerial project now that data transmission is non-blocking (thanks to Joseph Lacerte). 2012-10-20 11:31:24 +00:00
Dean Camera
1f33bc2fd3 Minor cleanup of the CDC bootloader. 2012-10-20 11:27:18 +00:00
Dean Camera
72fc4a204d Clean up unnecessary CPPCheck static analysis suppression comments, force Doxygen and GCC compiler specific macros as being always undefined when performing a static analysis of the code. 2012-10-14 20:18:46 +00:00
Dean Camera
826a77e90c Fixed maximum allowed keyboard key code usage of 0x65 rather than 0xFF for the HID_DESCRIPTOR_KEYBOARD() macro (thanks to David Monro) 2012-10-14 13:58:08 +00:00
Dean Camera
9a04475c23 Fixed incorrect definitions of HID_KEYBOARD_LED_KANA, HID_KEYBOARD_SC_KEYPAD_EQUAL_SIGN and HID_KEYBOARD_SC_KEYPAD_EQUAL_SIGN_AS400 and added a missing definition for HID_KEYBOARD_SC_APPLICATION (thanks to David Monro). 2012-10-14 11:51:57 +00:00
Dean Camera
eee252603b Minor documentation improvements. 2012-10-05 20:22:19 +00:00
Dean Camera
4641acc691 Add LINKER_RELAXATIONS option to the LUFA BUILD build system module. 2012-09-30 14:01:30 +00:00
Dean Camera
4cd80263ff Minor documentation improvements. Remove AS4 project generator script as it is buggy; replace with a better system in the future for both AS4 and AS6. 2012-09-23 11:09:09 +00:00
Dean Camera
217f1eebc1 Minor documentation improvements. 2012-09-22 12:30:50 +00:00
Dean Camera
e471f7c78d Add CPPCheck supression in the Webserver project, as the latest CPPCheck development code appears to falsely warn on the global uip_len variable when it is tested multiple times. 2012-09-22 12:30:37 +00:00
Dean Camera
9da01ee78b Fix flip-ee DFU build target accidentally erasing the target FLASH memory space. 2012-09-22 12:29:39 +00:00
Dean Camera
97046965ee Add missing preprocessor logic to the USBKEY board Dataflash driver so that DATAFLASH_TOTALCHIPS parameter for the board could theoretically be changed to 1 and have the code still work. 2012-09-21 21:16:50 +00:00
Dean Camera
f3049d958e Fixed incorrect Dataflash functionality in the USBKEY board if the driver is modified for a single Dataflash chip (thanks to Jonathan Oakley). 2012-09-19 19:12:52 +00:00
Dean Camera
7fd2349e1a Minor documentation corrections. 2012-09-19 18:57:05 +00:00
Dean Camera
e1803e3adb Enable sorting of the member functions in the Doxygen output, so that functions in the documentation are listed in alphabetical order rather than order of definition. 2012-09-19 18:47:13 +00:00
Dean Camera
5f6235b195 Fix missing briefs in the documentation for several modules, fix up invalid documentation references. 2012-09-19 18:43:56 +00:00
Dean Camera
7d259eac4c Rename AVR32CLK_*() clock management functions to UC3CLK_*() to be in line with the naming scheme of the rest of the platform modules. 2012-09-19 18:42:31 +00:00
Dean Camera
11fa17a7db Add architecture test for the non-standard avr-size patch, so that it is not tested on architectures where the patch isn't available. 2012-09-18 16:00:49 +00:00
Dean Camera
1eefbf9041 Use the framework provided GlobalInterruptEnable() function instead of the AVR8/XMEGA specific sei() macro, for future demo/project portability. 2012-09-17 21:00:59 +00:00
Dean Camera
92ee5ad826 Enable strict prototype matching in the library Doxygen configuration file, to ensure all documentation references are as correct as possible. 2012-09-17 20:59:20 +00:00
Dean Camera
a032d77d0e Fix up some missing target dependencies and output messages in the LUFA build system makefiles. 2012-09-17 20:58:47 +00:00
Dean Camera
e186907e39 Fixed lengthy timeouts in the USBtoSerial project if no application on the host is consuming data (thanks to Nicolas Saugnier).
Fixed lengthy automatic data flushing in the CDC and MIDI device class drivers.
2012-09-16 18:18:07 +00:00
Dean Camera
3e1f3869c1 Clean up the BoardDriverTest mapping file, fix up USB2AX MCU mappings. 2012-09-16 11:41:21 +00:00
Dean Camera
fc2cbe0700 Shorten the product string descriptors in the CDC and DFU bootloaders to ensure that differences in the toolchain version don't push it over a binary size boundary. 2012-09-15 22:13:51 +00:00
Dean Camera
c8f7cf7621 Fix up the StaticAnalysis build test so that it does not report invalid configurations. 2012-09-15 14:52:15 +00:00
Dean Camera
45a56b4df7 Added support for the Xevelabs USB2AX revision 3.1 board. 2012-09-15 13:47:00 +00:00
Dean Camera
5f1428bb50 Add error message for debugging purposes to the low level AudioInputHost and AudioOutputHost demos, if the request to set the audio sample rate fails. 2012-09-14 15:19:43 +00:00
Dean Camera
df14c97519 Make CPPCheck tool happy by altering the program flow in the low level keyboard example, so that the SendReport variable is not overwritten before its first read access. 2012-09-13 20:30:00 +00:00
Dean Camera
c93259fbdb Remove incorrect PROGMEM qualifier on the Manufacturer string descriptors in the DFU and CDC class bootloaders (thanks to Oliver Zander). 2012-09-13 20:26:32 +00:00
Dean Camera
cd40797a4d Fixed possible rounding in the VERSION_BCD() macros for some 0.01 step increments (thanks to Oliver Zander). 2012-09-12 17:23:53 +00:00
Dean Camera
6936fcbd60 Minor build system tweaks for platform compatibility. 2012-09-11 19:48:22 +00:00
Dean Camera
ce5f5bd1c3 Update ModuleTest build test to enable new warnings supported in the latest Atmel Toolchain release's included AVR-GCC version. 2012-09-09 14:44:17 +00:00
Dean Camera
5f614861a6 Minor documentation improvements. 2012-09-09 14:00:23 +00:00
Dean Camera
7a51e97c3b Update LUFA core to be compatible with the AVR-GCC -Wswitch-default warning switch. 2012-09-09 14:00:03 +00:00
Dean Camera
0284385b4e Update BoardDriverTest to prevent redundant assignment warnings in the static analysis check. 2012-09-09 13:26:07 +00:00
Dean Camera
7aa8dc1de0 Add support for the Atmel UC3-A3 Xplained board. 2012-09-08 09:16:41 +00:00
Dean Camera
1adf8174cf Add additional driver documentation to the AVRISP-MKII clone programmer project. 2012-09-03 20:52:40 +00:00
Dean Camera
b01ebe2d37 Alter the AVRISP-MKII clone project code to report a different serial number in libUSB compatibility mode, so that both the Jungo drivers and the libUSB drivers can be installed at the same time (and switched back and forth based on the current compatibility mode). 2012-09-03 20:26:34 +00:00
Dean Camera
b5d9239111 Fix outdated Programmers Notepad project file. 2012-09-02 21:06:05 +00:00
Dean Camera
80dc196031 Remove incomplete Microsoft Sideshow device demo. 2012-09-01 23:50:10 +00:00
Dean Camera
b9f3ff39a4 Use an early-abort in the USB_DeviceTask() function rather than wrapping the entire implementation in a conditional. 2012-09-01 22:55:56 +00:00
Dean Camera
c4aeb6d5ab Update FatFS library copies to the latest R0.09a version. 2012-09-01 22:55:15 +00:00
Dean Camera
376160e2c0 Add human readable license information and add some missing module documentation briefs. 2012-09-01 22:08:59 +00:00
Dean Camera
43658f336e Remove unused check-source rule from the BUILD build system module. 2012-08-29 20:14:20 +00:00
Dean Camera
4b194592aa Fix incorrect string length in the USBtoSerial demo descriptors (thanks to Oliver Zander). 2012-08-28 20:10:11 +00:00
Dean Camera
44aea22949 Fixed logic hole breaking USB operations on a USB controller with only one supported USB mode and no USB_DEVICE_ONLY or USB_HOST_ONLY configuration token set. 2012-08-28 20:09:14 +00:00
Dean Camera
e225de8a83 Fix include path of the LUFA SOURCES build module from the master build module when used in a legacy LUFA project makefile. 2012-08-27 18:53:58 +00:00
Dean Camera
ff00644cb8 Minor documentation corrections. 2012-08-27 16:55:52 +00:00
Dean Camera
9eef78d21e Fixed incompatibility in the CDC class bootloader on some systems (thanks to Sylvain Munaut). 2012-08-27 16:39:06 +00:00
Dean Camera
603a7d86e9 Add human readable definitions for the AVR109 protocol commands in the CDC class bootloader. 2012-08-27 16:38:00 +00:00
Dean Camera
302ec480cc Remove broken settings info output from the AVRDUDE build module. 2012-08-20 21:02:48 +00:00
Dean Camera
a69a0cbeb8 Minor documentation improvements. 2012-08-20 21:02:17 +00:00
Dean Camera
1cb60c1214 Spell-check latest trunk source code. 2012-08-18 14:54:37 +00:00
Dean Camera
8d8e5c06b9 Added new doxygen_upgrade and doxygen_create targets to the DOXYGEN build system module. Clean up CORE build system module. 2012-08-18 12:07:05 +00:00
Dean Camera
7750783809 Minor documentation improvements. 2012-08-18 10:58:52 +00:00
Dean Camera
0598d622d8 Fix broken Doxygen documentation due to lack of HTML encoding. 2012-08-18 10:51:14 +00:00
Dean Camera
7375c789e1 Document build system targets. Add a rule to the BUILD module that is run if a source file does not exist to show an error to the user, rather than running the check-source rule before each build (slightly faster/more portable and the generated error is then a true make error). 2012-08-18 10:45:29 +00:00
Dean Camera
3e50a59486 Fix up non-unique DFU/CDC bootloader signatures. 2012-08-16 19:18:07 +00:00
Dean Camera
84fadb255e Clean up BUILD module info output formatting, remove explicit gcc-version target and add ability to generate assembly listings of compiled source files for debug purposes. 2012-08-16 19:17:26 +00:00
Dean Camera
1ba60b4a18 Fixed missing Win-32bit compatibility sections in the LUFA INF driver files (thanks to Christan Beharrell). 2012-08-16 19:15:18 +00:00
Dean Camera
00ab25d321 Update the BUILD build system module to early abort and display an error if needed before trying to create the OBJDIR output object file directory. 2012-08-15 16:40:25 +00:00
Dean Camera
1f1bd69b85 Minor documentation and formatting updates. 2012-08-15 16:39:44 +00:00
Dean Camera
94f5f31f10 Upgrade Doxygen configuration files, custom style CSS and DOXYGEN build module for the latest Doxygen release. 2012-08-13 05:11:27 +00:00
Dean Camera
63fb35f319 Fix incorrect LED masks for the Olimex 32U4 and Leonardo boards. 2012-08-12 18:00:04 +00:00
Dean Camera
e92a9845d3 Leonardo LEDs are RX/TX active Low and USER active high, not the other way around. 2012-08-12 17:29:50 +00:00
Dean Camera
40755d4fde Fixed inverted LED driving code for the Arduino Leonardo board. Fixed inverted LEDs_GetLEDs() function implementation for the Benito, Minimus and Arduino UNO boards. 2012-08-12 17:25:39 +00:00
Dean Camera
6fb6c628fa Fix typo in the LED dispatch header, breaking builds for Leonardo board or boards without a LUFA provided LED driver. 2012-08-12 14:11:41 +00:00
Dean Camera
f0e5425208 Added support for the Arduino Leonardo board. Swap Olimex 32U4 RX/TX LED masks so that it lines up with the Arduino boards. 2012-08-12 14:03:57 +00:00
Dean Camera
ffbb30e0f8 Added workaround for broken VBUS detection on AVR8 devices when a bootloader starts the application via a software jump without first turning off the OTG pad (thanks to Simon Inns) 2012-08-12 13:46:24 +00:00
Dean Camera
fa664f8b46 Fixed broken RESET_TOGGLES_LIBUSB_COMPAT compile time option in the AVRISP-MKII project. 2012-08-12 13:25:27 +00:00
Dean Camera
9c590e41d7 Add help text to the project makefiles to help new users get information on the improved build system. 2012-08-11 11:51:43 +00:00
Dean Camera
a5abb0eb3f Clean up CORE build system mode makefile. 2012-08-11 11:45:02 +00:00
Dean Camera
f1a2bca684 Minor documentation improvements. 2012-08-11 11:35:47 +00:00
Dean Camera
a148d63e8b Minor documentation fixes. 2012-08-08 18:35:05 +00:00
Dean Camera
fb917b7016 Revert the default DEBUG_LEVEL setting from 3 to 2, as this is apparently causing segfaults on some builds of binutils-avr. 2012-08-01 20:01:56 +00:00
Dean Camera
85f4f2c2b1 Minor code style and documentation changes. 2012-07-31 17:13:43 +00:00
Dean Camera
af3c001cba Reset to placeholder version values in the library after the 120730 release. 2012-07-30 17:52:34 +00:00
Dean Camera
e90eeb791d Commit for the 120730 release. 2012-07-30 16:59:38 +00:00
Dean Camera
bcc45e24aa Fix broken code sample section spacing in the Doxygen documentation due to a missing line-height CSS property. 2012-07-29 15:28:54 +00:00
Dean Camera
e5781d172e Upgrade Doxygen configuration files to 1.8.1.2. 2012-07-29 15:18:21 +00:00
Dean Camera
db3f8565b8 Enhance bootloader descriptor strings in the CDC and DFU bootloaders. 2012-07-29 15:14:56 +00:00
Dean Camera
33f832b958 Add missing source URL for the HID DLL library use in the TempDataLogger application. 2012-07-28 12:43:31 +00:00
Dean Camera
cf48972f5a Add OLIMEX AVR-ISP-MK2 board to the BoardDriverTest build test. 2012-07-26 20:00:06 +00:00
Dean Camera
a002487140 Add hack to the XPLAINBridge project to allow it to compile even if an identical OBJDIR directory exists in the dependant AVRISP-MKII clone project folder. 2012-07-26 19:57:02 +00:00
Dean Camera
16cd7c6896 Add support for the Olimex AVR-ISP-MK2 board. 2012-07-26 19:23:15 +00:00
Dean Camera
5a0bd85330 Fix errors in some board driver LED_Disable() functions. 2012-07-26 19:16:58 +00:00
Dean Camera
efa5d54093 Minor documentation fixes. 2012-07-26 14:59:29 +00:00
Dean Camera
9f0cd5ebb8 Split out bootloader HEX generation into separate directories for each bootloader in the maintenance script. 2012-07-25 15:47:24 +00:00
Dean Camera
b8807e9928 Extend bootloader build test to include all supported configurations including the special XPLAIN board configuration and possible F_USB values. 2012-07-24 15:43:39 +00:00
Dean Camera
61d52c9fff Force the maintenance script to built bootloaders with F_USB values of 8MHz and 16Mhz - fix when additional architecture bootloaders are available. 2012-07-24 05:13:06 +00:00
Dean Camera
c90b9b507d Add missing UC3 architecture F_USB configuration checks. 2012-07-24 05:03:11 +00:00
Dean Camera
bfee7f8c56 Add missing supported bootloader configurations to the BootloaderTest build test. 2012-07-23 20:00:32 +00:00
Dean Camera
5b6bae3445 Make the bootloader generation maintenance script copy over the project license text when generation is complete. 2012-07-23 19:19:34 +00:00
Dean Camera
07f4f8e990 Update bootloader build test with bootloader target board information. 2012-07-23 19:13:52 +00:00
Dean Camera
8820b1f6cc Add a "make_bootloaders" target to the Maintenance makefile, to generate all possible bootloaders and archive them for separate distribution. 2012-07-23 19:04:01 +00:00
Dean Camera
c0da7660fc Add missing INTC_GetInterruptHandler() function prototype. 2012-07-22 14:00:58 +00:00
Dean Camera
badbca5791 Fixed endianess issues in the RNDIS host class driver for UC3 devices (thanks to Andrew Chu). Fix broken build for UC3 devices when ORDERED_EP_CONFIG compile time option is set. 2012-07-22 13:32:39 +00:00
Dean Camera
8e1328dc6a Commit for the LUFA-120730-BETA release. 2012-07-16 17:07:47 +00:00
Dean Camera
5b8b5018f2 Minor documentation improvements. 2012-07-15 18:49:42 +00:00
Dean Camera
3ca025f214 Add DEBUG_FORMAT and DEBUG_LEVEL optional parameters to the BUILD module. Turn off generation of debug information when performing a validation build, and when running the build tests. 2012-07-15 09:59:35 +00:00
Dean Camera
3c1b28cf5f Use immediate variable expansion in the second-deepest level makefile scripts to prevent multiple evaluation of the PROJECT_DIRECTORIES variable. 2012-07-14 23:04:37 +00:00
Dean Camera
a57ed1abfb Update makefile template with the new build module filenames. 2012-07-14 16:14:17 +00:00
Dean Camera
79122426c9 Fix up main library core makefile include paths. 2012-07-14 13:24:59 +00:00
Dean Camera
b7e3c86e4e Rename build system module makefiles from "lufa.MODULE.in" to "lufa_MODULE.mk" to prevent makefile from assuming the include is an old style build rule, slowing down the build process.
Prevent the BUILD module from shell-executing multiple processes to determine the avr-size flags to speed up the build, unless the size rule is invoked.

Add warnings and set warnings as errors to the SingleUSBModeTest build test makefile.
2012-07-14 13:18:13 +00:00
Dean Camera
d4980e58d4 Rename hid-teensy and hid-teensy-ee targets to teensy and teensy-ee to be in line with the DFU module target names. 2012-07-14 12:59:53 +00:00
Dean Camera
1faa5ba70a Fix project makefiles - remove trailing slash from LUFA_PATH entries and the XPLAINBridge project AVRISP file include path to prevent build errors. 2012-07-11 19:57:19 +00:00
Dean Camera
a9b6852603 Oops - override OBJDIR with "." not blank for the XPLAINBridge project. 2012-07-10 21:16:17 +00:00
Dean Camera
22eeb9b4e9 Override the OBJDIR setting for the XPLAINBridge project, as this currently doesn't work. Turn off check-config test in the StaticAnalysisTest build test to save time - if the standard build fails this can be run manually to determine the problem cause. 2012-07-10 21:13:09 +00:00
Dean Camera
0da99447d3 Mark build test makefiles as being incompatible with parallel make builds, as they re-use the same object directories. 2012-07-10 20:49:03 +00:00
Dean Camera
e3578113c9 Fix Maintenance makefile calling "make" directly rather than using $(MAKE). 2012-07-10 20:15:48 +00:00
Dean Camera
3bf7ce15d5 Fix up makefile .NOTPARALLEL heuristics so that linear building is only enforced if no object folder set and the "all" target is run. Rename library "ConfigDescriptor.c" file to "ConfigDescriptors.c" to ensure that object filenames are unique. 2012-07-10 19:33:39 +00:00
Dean Camera
b2920402b4 Add check and error to the BUILD module if OBJDIR option is set but object filenames are not unique. 2012-07-10 18:51:21 +00:00
Dean Camera
7f29c468d7 Slightly better method of recursive make - use proper make dependencies to allow for parallel builds. 2012-07-10 18:30:41 +00:00
Dean Camera
fafb52118d Fix broken builds when OBJDIR is specified in the BUILD build system module. 2012-07-09 16:17:57 +00:00
Dean Camera
73a87a8c7b Remove unnecessary build system modules from the HID EEPROM Loader shim application makefile. 2012-07-09 16:17:20 +00:00
Dean Camera
5087e6c303 Clean up HID EEPROM loader shim application code, simplify project makefile. Ensure shim application is properly rebuild by explicitly cleaning it before requesting a rebuild. 2012-07-08 19:38:38 +00:00
Dean Camera
c4da1929cd Update BUILD build system module with OBJECT_FILES variable, for additional user-specified object files. Update HID build module with a small shim application to reprogram the EEPROM of a target. 2012-07-08 10:24:39 +00:00
Dean Camera
56d368f2de Reduce bootloader magic key to 16 bits to save FLASH space. 2012-07-07 15:30:35 +00:00
Dean Camera
10944d9ddf Update CDC driver INF files so that they should work even on systems without usbser.sys extracted by default (see MS KB entry 837637). 2012-07-07 13:43:15 +00:00
Dean Camera
8881e5a52d Minor documentation improvements. 2012-07-06 20:16:22 +00:00
Dean Camera
f7ad67cf18 Fix LUFA_SRC_PLATFORM makefile variable in the SOURCES build module to use LUFA_ROOT_PATH rather than LUFA_PATH. 2012-07-05 18:32:50 +00:00
Dean Camera
865529adea Minor documentation improvements. 2012-07-03 16:00:31 +00:00
Dean Camera
4b8a46193e Fixed incorrect Micropendous board LED driver LEDs_SetAllLEDs() and LEDs_ChangeLEDs() function implementations (thanks to MitchJS). 2012-07-03 15:54:17 +00:00
Dean Camera
34c1b49cd1 Minor documentation improvements. 2012-07-03 15:53:44 +00:00
Dean Camera
5d9403fde4 Fix up non-relative header file include paths (thanks to Kim Blomqvist). 2012-07-01 13:20:16 +00:00
Dean Camera
2e27cc2670 Fixed CDC and DFU bootloaders API page erase and write function failures (thanks to Martin Lambert). 2012-06-29 04:55:44 +00:00
Dean Camera
579fbb68fc Fixed invalid configuration descriptor in the low level KeyboardMouse device demo (thanks to Jun Wako). 2012-06-27 19:41:30 +00:00
Dean Camera
6f90d45684 Fix accidental struct copies on the stack in the old RNDISEthernet demo TCP code. 2012-06-26 18:53:30 +00:00
Dean Camera
c9ba8f2a2c Clean up bootloader makefiles to make them a bit more readable. 2012-06-26 17:54:04 +00:00
Dean Camera
80fab49e1d Add "mostlyclean" makefile target to the BUILD build system module. 2012-06-26 17:37:25 +00:00
Dean Camera
aba33a0334 Don't enforce silent output on submake - pass down the value set by the user implicitly instead. 2012-06-24 19:38:37 +00:00
Dean Camera
3f4efc6159 Make sure dependency files are generated for assembly files too in the BUILD build system module. Minor code cleanups. 2012-06-24 15:48:30 +00:00
Dean Camera
8b985b44b5 Fix hard-coded cross-arch utility name in the BUILD build system module. 2012-06-24 13:32:39 +00:00
Dean Camera
6655815b32 Clean up DOXYGEN and SOURCES build system modules - use non-recursively evaluated make variables. 2012-06-23 17:03:01 +00:00
Dean Camera
43e10d666b Clean up BuildTest and Maintenance makefiles - use non-recursively evaluated make variables. 2012-06-23 17:02:15 +00:00
Dean Camera
90b6bf9e25 Clean up BUILD build system module, expose "check-source" target for use in user applications. 2012-06-23 17:01:08 +00:00
Dean Camera
e5cf169469 Move out BUILD build system module start and end messages to the respective targets, as they are only used once. 2012-06-23 15:18:16 +00:00
Dean Camera
bf5b49ecf5 Add ability to archive build object files into a .a library file to the BUILD build system module. 2012-06-23 15:15:52 +00:00
Dean Camera
924edb2f9a Oops - fix HID build system module documentation error. 2012-06-21 21:22:05 +00:00
Dean Camera
ef06eefc8b Add svn:eol-style property on all source files where it was missing. Fix line endings of all makefile, *.c and *.h files. 2012-06-21 20:27:00 +00:00
Dean Camera
393fc71d8e Add HID bootloader build module (thanks to Stefan Hellermann). 2012-06-21 20:24:29 +00:00
Dean Camera
532b3a18f1 Add additional sanity checks to the inputs of several AVR32 platform clock management driver functions. 2012-06-21 20:21:06 +00:00
Dean Camera
8ccc2b2272 Minor build system improvements - force default shell. 2012-06-21 20:06:10 +00:00
Dean Camera
cce71a74e7 Enable GCC's -pipe option by default, to build projects using intermediary logical OS pipes rather than temporary files on disk. 2012-06-19 19:36:03 +00:00
Dean Camera
1d2f231cc1 Add extra human readable output to the build test makefile scripts. 2012-06-19 19:35:12 +00:00
Dean Camera
7e65340c31 Revert change to assembly file comment syntax; this apparently breaks on the current AVR32 GNU assembler. 2012-06-19 19:31:01 +00:00
Dean Camera
6fa8da4e56 Minor makefile fixes - add phony targets, remove silence switch from the root makefile and add missing build modules to the ClassDriver VirtualSerial device demo. 2012-06-18 20:36:51 +00:00
Dean Camera
d8621ee8f4 Oops - forgot to fix up the command timeout reset code in the AVRISP-MKII clone programmer. 2012-06-17 15:35:17 +00:00
Dean Camera
7d83e10b7f Re-add in DFU bootloader Manufacturer string, as the dfu-programmer utility breaks if it is not present. 2012-06-17 12:55:50 +00:00
Dean Camera
c128d8783e Minor build system improvements - move out AVRDUDE base flags into a makefile variable, clean up BUILD module. 2012-06-17 11:40:50 +00:00
Dean Camera
751806458b Replace C style comments in assembly code with true assembly comments for consistency and to prevent it from confusing syntax highlighters. 2012-06-17 10:59:49 +00:00
Dean Camera
4da2ba9f1c Modify CDC and DFU bootloaders so that the various BootloaderAPI components are in unique sections and mapped explicitly - this will ensure the API and signature entries are always linked at the correct explicit address. 2012-06-15 16:02:19 +00:00
Dean Camera
c4ebddd27a Add missing <math.h> include for the UC3 devices, hide CDC class driver stream functions for unsupported platforms. 2012-06-12 19:49:15 +00:00
Dean Camera
deb6fce7bc Remove unused makefile macro from the DFU bootloader. 2012-06-12 17:10:24 +00:00
Dean Camera
3d39cbe94b Add ability to generate SYM files in the BUILD module. Clean up build system output to be slightly more human readable. 2012-06-11 18:58:14 +00:00
Dean Camera
2351c46f0b Fix broken StaticAnalysisTest build test due to the changes to the CPPCHECK build module. 2012-06-10 20:08:02 +00:00
Dean Camera
e7e45baef1 Minor documentation improvements. 2012-06-10 20:02:52 +00:00
Dean Camera
c41bbf9fcc Add checks to the endpoint and pipe configure functions and fail if the requested endpoint or pipe number is above the maximum for that device. 2012-06-10 19:53:20 +00:00
Dean Camera
9ab445518a Add OBJDIR optional build variable to the BULD build system module, to allow the user project to relocate the output object and dependency files to a different directory. 2012-06-10 19:39:40 +00:00
Dean Camera
fe3a5c2462 Fix up core library makefile clean target to properly remove dependency files. 2012-06-10 18:40:39 +00:00
Dean Camera
49424ce6b1 Make sure the main library core makefile does not interfere with the Doxygen module configuration if included in a legacy makefile. 2012-06-10 18:35:57 +00:00
Dean Camera
fae71b5780 Minor correction to the UC3 USB clock division formula (thanks to Kim Blomqvist). 2012-06-10 15:59:09 +00:00
Dean Camera
857641b98e Update CORE build system module to convert the sorted module data lists into printable lists, substituting in a "(None)" entry when no data is available. 2012-06-10 15:37:49 +00:00
Dean Camera
44ff0af68c Add a list of module provided make variables and macros to the build system modules. 2012-06-10 15:31:03 +00:00
Dean Camera
b9952f4809 Add Build System documentation to the library manual. Update CPPCHECK build system module so that it uses the SRC variable rather than just the project directory. 2012-06-10 14:59:13 +00:00
Dean Camera
678cb3c2bf Minor tweak to the BuildTest master makefile for better console output. 2012-06-10 13:10:07 +00:00
Dean Camera
21a6acff83 Add MAX_ENDPOINT_INDEX compile time option for the XMEGA devices. 2012-06-10 13:09:39 +00:00
Dean Camera
67a8f54a6e Fix BoardDriverTest build test clean target. 2012-06-10 11:42:11 +00:00
Dean Camera
59056ce544 Add compile time warnings for experimental architectures, for those that don't read the manual. 2012-06-10 10:59:13 +00:00
Dean Camera
6dc85e4023 Minor build system sanity check fixes. 2012-06-10 10:31:38 +00:00
Dean Camera
53be52922f Change the build system build module makefiles to have a set of sanity check macros they can call to verify user data. Add additional sanity checks. 2012-06-10 08:06:13 +00:00
Dean Camera
3808f5c36d Spell check source code, fix mistakes. 2012-06-09 20:33:56 +00:00
Dean Camera
544027da18 Fix RESET_TOGGLES_LIBUSB_COMPAT option not being applied in the AVRISP-MKII descriptors. 2012-06-09 19:47:14 +00:00
Dean Camera
61b5740a25 Clean up bootloader makefile comments. 2012-06-09 13:39:56 +00:00
Dean Camera
cd0bd7bf90 Added new JTAG_ENABLE() macro for the AVR8 architecture. Fixed the JTAG_DISABLE() macro clearing all other bits in MCUSR when called.
Moved the XPLAIN board specific bootloader entry condition code to the Application_Jump_Check() function of the DFU bootloader, added support for the original XPLAIN board to the CDC class bootloader.
2012-06-09 13:00:56 +00:00
Dean Camera
7abaafb3ca Minor documentation changes. 2012-06-07 20:50:03 +00:00
Dean Camera
6e29655b54 Update SVN line endings property on newer source files to native. 2012-06-07 20:49:47 +00:00
Dean Camera
082537f5bd Oops - really fix logic errors in USBMode.h. 2012-06-06 19:58:51 +00:00
Dean Camera
940145ca6d Fix errors in the SingleUSBModeTest build test. Fix logic errors in USBMode.h. 2012-06-06 19:39:38 +00:00
Dean Camera
0c012ede5f Fix BUILD module so that user flags are applied after all auto-generated flags, ensure dependency files are generated with a .d extension rather than a .o.d extension, allow use of full part names ("at32uc3a0256") instead of GCC truncted part names ("uc3a0256"). 2012-06-06 19:24:22 +00:00
Dean Camera
3f82cb8dc3 Simplify AVRDUDE build module, ensure that the correct target names for FLASH and EEPROM writing are passed to the programmer tool. 2012-06-06 19:22:20 +00:00
Dean Camera
94a1b4da06 Add optional CPPCHECK_FLAGS parameter to the CPPCHECK build module, for miscellaneous user flags. Ensure the user flags are applied after all auto-generated flags. 2012-06-06 19:21:40 +00:00
Dean Camera
28a2739fa3 Improve DFU build module to use symbolic names for the target HEX and EEP filenames. 2012-06-06 19:12:21 +00:00
Dean Camera
511348fb13 Improve ATPROGRAM build module to support UC3 devices and use intelligent erase for XMEGA and UC3. 2012-06-06 19:10:52 +00:00
Dean Camera
fab1678602 Fix typo in the UC3 host pipe driver. Improve library TAR export exclusion filetype filter. 2012-06-06 19:09:06 +00:00
Dean Camera
000c4c6c5c Strip out BuildTest sub-makefile contents as much as possible. Remove old UC3 build test makefile from the ModuleTest build test. Add platform module to the example LUFA makefile. 2012-06-05 18:35:05 +00:00
Dean Camera
d887c0c73c Fix typos in recursive make rules. 2012-06-04 17:09:44 +00:00
Dean Camera
49ca5c3c83 Add new ATPROGRAM build system module. Add ATPROGRAM and CPPCHECK modules to all application makefiles. 2012-06-04 16:31:50 +00:00
Dean Camera
32f2d59bc0 Add default project template to the Doxygen manual of the library. 2012-06-04 15:39:06 +00:00
Dean Camera
7d9467e431 Add symbol-sizes target to the BUILD build system module to print a size-sorted list of symbols from a compiled application, in decimal bytes. 2012-06-04 15:38:45 +00:00
Dean Camera
a57c4eabae Add emergency aborts to the recursive makefiles to prevent system failures due to infinite recursion if something happens while building the project lists. 2012-06-04 15:38:05 +00:00
Dean Camera
4124534144 Don't show a list of object/dependency files in the human friendly output of the BUILD module clean command. Use a unique message prefix for assembling vs. compiling. 2012-06-03 20:34:46 +00:00
Dean Camera
60a2147a51 Correct BuildTest makefiles to use LUFA_PATH rather than LUFA_ROOT_PATH. 2012-06-03 20:06:21 +00:00
Dean Camera
c7344c22ac Switch StaticAnalysisTest build test to use the new build system CPPCHECK module. Update additional build tests to all include the core build system module. 2012-06-03 19:44:15 +00:00
Dean Camera
41b4c5b645 Add new CPPCHECK build system module for static code analysis of projects. 2012-06-03 19:43:36 +00:00
Dean Camera
8f8f347891 Quiet initial recursive makefile invocation for all projects. 2012-06-03 15:20:51 +00:00
Dean Camera
316cae29b5 Use auto-detection of project directories for the demo, project and bootloader makefiles. 2012-06-03 15:04:10 +00:00
Dean Camera
00aaf1cb41 Disable inbuilt make rules in the LUFA build system for speedups when compiling many projects recursively. 2012-06-03 14:32:29 +00:00
Dean Camera
5af18ba288 Add explicit blank checks in the build system for user-set but blank variables that must not be blank. 2012-06-03 12:39:53 +00:00
Dean Camera
88425d7dab Add .PHONY targets in all build system modules. Alter BUILD module so that the existence of source files are checked before the build is started. 2012-06-03 12:17:37 +00:00
Dean Camera
9f7f595382 Add $(MAKEFILE_LIST) as a dependency on build rules that could be altered by changes to the makefiles - if the user alters the project makefile, require that all modules are rebuilt. 2012-06-03 11:00:38 +00:00
Dean Camera
fc0ff2f976 Update CORE build module to print out additional help information. 2012-06-02 22:14:24 +00:00
Dean Camera
7197893006 Rename program_ee AVRDUDE module target to program-ee. Update CORE build module to print out lists one item per line, rather than all on one line. 2012-06-02 21:58:24 +00:00
Dean Camera
d0737f6ad5 Fix AVRDUDE and BUILD build system module comments. 2012-06-02 21:47:16 +00:00
Dean Camera
7655205aac Clean up CORE build system module, use simple rather than recursive make variables for internal constants and $(shell) derived values. 2012-06-02 21:45:51 +00:00
Dean Camera
450ff51b7e Add platform driver dispatch header and makefile module source variable. 2012-06-02 19:56:50 +00:00
Dean Camera
0d888458e1 Fix incorrect bank mask in Endpoint_ConfigureEndpoint() for the UC3 devices. 2012-06-02 19:34:10 +00:00
Dean Camera
85579e12e4 Clean up BUILD build system module - seperate architecture utility prefix code and sanity check from the CC_FLAGS construction code. Add target to print GCC version. 2012-06-02 19:24:02 +00:00
Dean Camera
719a0e7f78 Add dependency file tracking to the BUILD build system module. 2012-06-02 16:49:28 +00:00
Dean Camera
4913678695 Fix UC3 support in the BUILD build system module. Fix bug in the EVK1101 board buttons driver. 2012-06-02 16:35:29 +00:00
Dean Camera
5ce60f25e6 Ensure that USB_DEVICE_ONLY or USB_HOST_ONLY is properly set for devices that physically do not support a particular mode. Fix main LUFA library makefile default target. 2012-06-02 15:50:10 +00:00
Dean Camera
a9bb2d5488 Minor documentation improvements. 2012-06-02 14:14:56 +00:00
Dean Camera
6a3a5f40da Update library documentation on the standard LUFA makefile template configuration. 2012-06-02 14:10:02 +00:00
Dean Camera
ecdffe2e41 Remove any variables in the optional build variable list that are marked as mandatory by one or more included build system modules in the CORE build system module. Alter DOXYGEN build system module to by default override the Doxygen configuration file stylesheet and replace it with the LUFA Doxygen stylesheet. 2012-06-02 13:14:31 +00:00
Dean Camera
0b262c569f Remove space padding on the current time when automatically generating AVR Studio 4 project creation/modification timestamps. 2012-06-02 13:00:55 +00:00
Dean Camera
e24993c13a Ensure build tests use the system provided $(MAKE) variable to determine the command to invoke make, rather than a hard-coded name. Strip off excess whitespace from the list of object files when printing them out to the shell in the build system BUILD module. 2012-06-02 13:00:22 +00:00
Dean Camera
fcf0b8a5bb Ensure the BULD build system module produces a LSS listing file output when the "all" target is invoked. 2012-06-02 12:38:36 +00:00
Dean Camera
59ca4ec0ec Strip trailing slash from the user-supplied LUFA_PATH directory, to prevent double slashes from appearing in the commands/output. 2012-06-02 12:29:36 +00:00
Dean Camera
7c75623e43 Add EEPROM programming target to the AVRDUDE build system module. Correct message output test for the BUILD build system module. Clean up DOXYGEN build system module logic. 2012-06-02 12:21:14 +00:00
Dean Camera
fc3768733e Clean up ordering of build system module sanity checks. 2012-06-02 12:04:34 +00:00
Dean Camera
29874f6db7 Simplify build system mandatory parameter/variable sanity checks. 2012-06-02 12:00:51 +00:00
Dean Camera
276eb35d68 Don't print out full object file paths in the build system when cleaning object files. 2012-06-02 11:41:25 +00:00
Dean Camera
79ee9e755f Add build system targets for lists of mandatory and optional parameters/variables. 2012-06-02 11:38:12 +00:00
Dean Camera
924c0eb6ac Add C_FLAGS, CPP_FLAGS and ASM_FLAGS variables to the build system BUILD module to allow for language-specific compiler/assembler flags. 2012-06-02 11:18:28 +00:00
Dean Camera
8031d97a4f Oops - fix accidental negation in the BUILD module architecture detection code. Add error if an unsupported architecture is requested. 2012-06-02 10:53:35 +00:00
Dean Camera
4453133d3c Disable linker relaxations for the UC3 architecture, as this does not appear to be supported in the linker. 2012-06-02 10:50:38 +00:00
Dean Camera
2b332d3231 Replace architecture specific makefiles in the BuildTests with the new common build system makefiles. 2012-06-02 10:46:25 +00:00
Dean Camera
26cc2e9fa8 Make BUILD build system module not destroy C++ source files, and support multiple architectures. 2012-06-01 23:23:18 +00:00
Dean Camera
56e792c95b Switch over Demos, Bootloaders and Projects to the new and improved build system. 2012-06-01 22:32:43 +00:00
Dean Camera
e309f42af3 Minor documentation improvements. 2012-05-29 20:03:43 +00:00
Dean Camera
8f2e82bd61 Minor cleanup to Attributes.h spacing and rename old multiple-inclusion macro guard. 2012-05-29 20:03:21 +00:00
Dean Camera
851fcd0c2f Make sure that LUFAConfig.h is included *after* the common submodules, so that the architecture and other defines are available to the configuration header. 2012-05-29 20:01:04 +00:00
Dean Camera
d4684b29b9 Ensure the DFU bootloader disables and clears the activity LED toggle timer when a soft-reset to application space is used. 2012-05-29 19:40:05 +00:00
Dean Camera
2ff1370221 Merge in AppConfigHeaders branch to trunk, altering all projects and demos to use configuration headers for application and LUFA compile time settings, rather than defines in the project makefiles. 2012-05-27 19:12:07 +00:00
Dean Camera
1e42f7bd46 AppConfigHeaders: Add missing AppConfig.h file includes. 2012-05-27 18:31:53 +00:00
Dean Camera
0389288e27 AppConfigHeaders: Merge in latest trunk. 2012-05-27 17:24:09 +00:00
Dean Camera
b017b41e91 Don't generate dependency files or a MAP file when running BuildTests where possible. 2012-05-27 17:23:41 +00:00
Dean Camera
96462ac746 Oops - shell variables can't use the += operator - must reference the existing value in the new value to append. 2012-05-27 17:11:43 +00:00
Dean Camera
c3dd6ac781 AppConfigHeaders: Merge in latest trunk. 2012-05-27 16:48:19 +00:00
Dean Camera
7d65c54eef Remove legacy AS4 project files, now that they can be automatically generated by the new maintenance script. 2012-05-27 16:36:37 +00:00
Dean Camera
4a09e4b2ee Add maintenance script to automatically generate legacy AS4 project files. 2012-05-27 16:30:40 +00:00
Dean Camera
b5e850ffd6 Add missing documentation to custom BuiltTest hardware mapping files. Fix up old copyright years on some makefiles. 2012-05-27 14:42:30 +00:00
Dean Camera
1fe8e29ab3 Minor documentation improvements. 2012-05-27 14:30:46 +00:00
Dean Camera
910fd08ea1 Minor documentation improvements. 2012-05-27 14:28:07 +00:00
Dean Camera
a9d8af99e4 Minor documentation improvements. 2012-05-27 11:17:38 +00:00
Dean Camera
18d91ece3b AppConfigHeaders: Merge in latest trunk. 2012-05-26 16:03:05 +00:00
Dean Camera
35564bb1a7 Fixed swapped Little Endian/Big Endian endpoint and pipe write code for the UC3 devices (thanks to Andrew Chu). 2012-05-26 16:02:20 +00:00
Dean Camera
f235021abe Fix incorrect definition for the XMEGA Endpoint_BytesInEndpoint() function when used on OUT endpoints. 2012-05-26 15:06:00 +00:00
Dean Camera
5ec9d04bca AppConfigHeaders: Merge in latest trunk. 2012-05-21 20:48:57 +00:00
Dean Camera
55283475d3 Oops - mask out the endpoint address direction when comparing the IN and OUT endpoint indexes in the AVRISP-MKII clone and XPLAINBridge projects. 2012-05-21 20:45:16 +00:00
Dean Camera
aba30ac2a0 Fix AVRISP-MKII clone and XPLAINBridge projects not properly configuring the AVRISP IN endpoint when needed if RESET_TOGGLES_LIBUSB_COMPAT compile time option is used. 2012-05-21 20:42:56 +00:00
Dean Camera
615d34f1b7 Turn off watchdog before jumping to the user application in the DFU and CDC based bootloaders, for the specific case of /HWB being low during reset (where the bootloader will re-enter). 2012-05-21 16:37:34 +00:00
Dean Camera
5f709e281e Merge in latest trunk. 2012-05-20 17:16:21 +00:00
Dean Camera
5833b27f80 Alter the XPLAINBridge and AVRISP-MKII clone projects so that the descriptors from the AVRISP-MKII clone project can be directly used in the XPLAINBridge project. Add support for RESET_TOGGLES_LIBUSB_COMPAT option in the XPLAINBridge project. 2012-05-20 17:09:39 +00:00
Dean Camera
32cfb8cf4f Minor documentation improvements. 2012-05-20 15:48:18 +00:00
Dean Camera
28967ef2e8 Add missing AppConfig.h includes to project Descriptors.h files. 2012-05-20 15:45:53 +00:00
Dean Camera
063474561d Merge in latest trunk. 2012-05-20 15:43:51 +00:00
Dean Camera
b181cf4fb8 Minor documentation improvements. 2012-05-20 15:35:01 +00:00
Dean Camera
d4f00fe7d5 Added new RESET_TOGGLES_LIBUSB_COMPAT compile time option to the AVRISP-MKII clone programmer project (thanks to Robert Spitzenpfeil). 2012-05-20 15:34:47 +00:00
Dean Camera
82162c710c Additional fixes to the MIDI host driver due to not unfreezing/re-freezing pipes correctly (thanks to Michael Brown). 2012-05-20 13:04:26 +00:00
Dean Camera
f2ae4dc255 Upgrade Doxygen configuration files for Doxygen 1.8.1, fix broken stylesheet and footer HTML, add explicit spacing into documentation code fragments to prevent Doxygen from removing empty lines in the output. 2012-05-20 10:55:59 +00:00
Dean Camera
c9b3468f1e Add missing CPPCheck unusedFunction check suppressions on the USB template functions. 2012-05-19 22:14:06 +00:00
Dean Camera
c31fdbd03e Minor documentation adjustments to the demos, projects and bootloaders to ensure correct formatting of application device support. 2012-05-18 18:39:35 +00:00
Dean Camera
8cfb3d9f09 Update project Doxygen and makefiles so that the resulting project documentation hides the unused version value, and uses the same HTML CSS stylesheet as the library core. 2012-05-17 21:08:53 +00:00
Dean Camera
cca24c8dc9 Update CDC and DFU class bootloader documentation with a device memory map illustration. 2012-05-17 20:07:16 +00:00
Dean Camera
666088a388 AppConfigHeaders: Fix branch validation error. 2012-05-15 21:01:40 +00:00
Dean Camera
cb9e7392c5 AppConfigHeaders: Make sure that in applications using an AppConfig.h configuration file, all application headers include the configuration file. 2012-05-15 19:51:41 +00:00
Dean Camera
e9e6730d49 AppConfigHeaders: Move out the last of the demo/app configurations into new AppConfig.h header files. 2012-05-13 21:01:23 +00:00
Dean Camera
80e278acde Clean up and speed up build tests by turning off expensive and slow size optimizations, and generation of assembly listings (*.lst) for each compiled source file. 2012-05-13 19:10:46 +00:00
Dean Camera
ae6a514929 AppConfigHeaders: Fix branch validation errors. 2012-05-13 18:42:12 +00:00
Dean Camera
9a373c4094 AppConfigHeaders: Switch class driver Device mode demos to use LUFAConfig.h configuration header files. 2012-05-13 17:17:45 +00:00
Dean Camera
7f4462267a AppConfigHeaders: Oops - fix up AppConfig.h for the low level AudioOutput and AudioInput demos. 2012-05-13 15:11:57 +00:00
Dean Camera
11ed8be175 AppConfigHeaders: Merge in latest main. 2012-05-13 15:04:50 +00:00
Dean Camera
0a00ee4037 Minor tweaks to the build tests to ensure that they will operate properly on all systems. 2012-05-13 15:03:56 +00:00
Dean Camera
13085a3351 AppConfigHeaders: Switch low level Device mode demos to use LUFAConfig.h configuration header files. 2012-05-13 15:03:17 +00:00
Dean Camera
64d00efd91 AppConfigHeaders: Switch class driver Host mode demos to use LUFAConfig.h configuration header files. 2012-05-13 14:19:52 +00:00
Dean Camera
a9f0369fac AppConfigHeaders: Switch DualRole and low level Host mode demos to use LUFAConfig.h configuration header files. 2012-05-13 14:07:00 +00:00
Dean Camera
f9fb44b01c AppConfigHeaders: Remove outdated incomplete BluetoothHost demo - updated Bluetooth stack code is in the ExplorerBot project (http://www.fourwalledcubicle.com/ExplorerBot.php). 2012-05-13 14:04:29 +00:00
Dean Camera
5cba3ce3a4 AppConfigHeaders: Merge in latest trunk. 2012-05-13 13:13:45 +00:00
Dean Camera
998009c490 Fix incorrectly names build test directory references. 2012-05-13 13:11:04 +00:00
Dean Camera
380f014c4c Added build test to verify correct compilation of all bootloaders using all supported devices.
Fixed compile error with the unreleased ATMEGA32U6 device.
2012-05-13 13:06:11 +00:00
Dean Camera
96fd39eda8 Fixed CDC and DFU bootloaders API function offsets incorrect on some devices (thanks to Rod DeMay). 2012-05-13 10:13:24 +00:00
Dean Camera
40fd566dba AppConfigHeaders: Fix broken documentation in the HID class bootloader. 2012-05-12 16:21:17 +00:00
Dean Camera
70fd816b09 Fix broken documentation in the HID class bootloader. 2012-05-12 16:20:21 +00:00
Dean Camera
383eb6da84 AppConfigHeaders: Merge in minor changes from trunk. 2012-05-12 16:13:16 +00:00
Dean Camera
a268a570b1 AppConfigHeaders: Update project file for Programmers Notepad. 2012-05-12 15:44:50 +00:00
Dean Camera
802910d49f AppConfigHeaders: Update several additional user projects to use configuration header files, rather than makefile defines. Remove compile time warnings for projects lacking device serial support, remove incomplete StandaloneProgrammer project. 2012-05-12 15:32:53 +00:00
Dean Camera
3e7e02c6dd Minor documentation improvements. 2012-05-12 15:07:31 +00:00
Dean Camera
33d9a75b03 AppConfigHeaders: Update several additional user projects to use configuration header files, rather than makefile defines. 2012-05-10 20:28:39 +00:00
Dean Camera
926a83bbc1 AppConfigHeaders: Update several user projects to use configuration header files, rather than makefile defines. 2012-05-10 20:11:47 +00:00
Dean Camera
74fb2d895e AppConfigHeaders: Update bootloaders to use configuration header files, rather than makefile defines. 2012-05-10 19:42:42 +00:00
Dean Camera
b601043e17 Fix broken documentation in the CDC and DFU class bootloaders due to Doxygen's confusion over the ATTR_NO_INIT attribute macro. 2012-05-10 19:33:38 +00:00
Dean Camera
359fbfe14d Add branch for the conversion of demos to use standard C header files for configuration, rather than makefile defined macros. 2012-05-10 19:24:58 +00:00
Dean Camera
7a7ee6a908 Speed up build tests by only building each test to the ELF output stage (when all files are compiled and linked), rather than to the full HEX output stage as the resulting binary is not actually required. 2012-05-07 17:42:49 +00:00
Dean Camera
e5a7fa201e Add support for the ATXMEGA384C3. 2012-05-07 17:40:52 +00:00
Dean Camera
f0af2e4a02 Improve BoardDriverTest build test so that it will work regardless of native line endings. 2012-05-06 16:02:45 +00:00
Dean Camera
2afa026866 Complete BoardDriverTest build test. 2012-05-06 15:01:40 +00:00
Dean Camera
44f348e7ff Add partially complete BoardDriverTest build test. 2012-05-06 14:26:18 +00:00
Dean Camera
9207e8b2fd Changed board LED driver implementations of LEDs_ToggleLEDs() for the AVR8 architecture to use the fast PIN register toggle alternative function for speed. 2012-05-06 12:19:03 +00:00
Dean Camera
395e4287a1 Added support for the Olimex AVR-USB-32U4 and Olimex AVR-USB-T32U4 boards. 2012-05-06 12:10:30 +00:00
Dean Camera
1007317c5f Fixed broken MIDI host driver MIDI_Host_ReceiveEventPacket() function due to not unfreezing the MIDI data IN pipe before use (thanks to Michael Brown). 2012-05-06 11:11:33 +00:00
Dean Camera
590d9b5ff8 Increased endpoint polling interval for all demos and projects to 5ms, as 1ms was causing some enumeration issues on some machines (thanks to Riku Salminen). 2012-05-06 11:10:25 +00:00
Dean Camera
430973263b Fix bootloaders to make the StaticAnalysis build test happy. 2012-05-05 21:27:07 +00:00
Dean Camera
0e434c8f8f Add additional preprocessor sanity checks for the XMEGA platform based on the USB controller input clock speed. 2012-05-05 19:46:20 +00:00
Dean Camera
2d98e5499b Fixed possible deadlock in the CDC device driver if the USB connection is dropped while the CDC_REQ_SetLineEncoding control request is being processed by the stack (thanks to Jonathan Hudgins). 2012-05-05 19:43:06 +00:00
Dean Camera
46d511c021 Fixed incorrect DFU version number reported to the host in the DFU bootloader descriptors. Fixed incorrect version hundredths value encoding in VERSION_BCD() macro (thanks to Georg Glock). 2012-05-05 15:25:27 +00:00
Dean Camera
04740d680e The library bootloaders will now correctly start the user application after a watchdog-based application start, even if the /HWB line is held low externally during the reset phase. 2012-04-29 17:15:06 +00:00
Dean Camera
cc959c945b Oops - fix broken MIDIToneGenerator project due to MIDI class API changes. 2012-04-25 18:50:00 +00:00
Dean Camera
69ecaae732 Added support for the DorkbotPDX Duce board. 2012-04-25 18:42:33 +00:00
Dean Camera
bd6123e2c1 Fixed inverted LED logic in the USB2AX board LED driver (thanks to Nicolas Saugnier). 2012-04-25 18:32:55 +00:00
Dean Camera
e875d7cf9f Changed MIDI event structure MIDI_EventPacket_t to use a single field for the combined virtual cable index and command ID, to prevent bitfield packing issues on some architectures (thanks to Darren Gibbs). 2012-04-25 18:28:56 +00:00
Dean Camera
5b5b73ce58 Add basic hardware mapping information for all supported boards. 2012-04-25 18:27:27 +00:00
Dean Camera
c7bfcf2cbb Fix documentation of the board LED driver (thanks to Karl Lunt). 2012-04-23 17:39:53 +00:00
Dean Camera
cfa399a533 Remove an unused variable in the HID loader CLI application. Update known issues list. 2012-04-19 19:55:16 +00:00
Dean Camera
c48da94605 Add known issues to the documentation. 2012-04-18 20:06:18 +00:00
Dean Camera
1ab76048c9 Alter the bootloader section sizes to all be 8KB, to be in line with the default AT90USB1287 fuses, as that is the default target MCU. Add instructions to the documentation to clarify this for the user (thanks to Georg Glock). 2012-04-18 18:59:40 +00:00
Dean Camera
b42642a5d6 Fix up static analysis build test so that inline suppressions for missing header files are not required in the XPLAINBridge project. 2012-04-16 20:43:30 +00:00
Dean Camera
56aed4b3e6 Fixed AVRISP-MKII programmer project reset line polarity inverted when the generated EEP file is loaded into the USB AVR's EEPROM and avr-dude is used. 2012-04-16 17:03:07 +00:00
Dean Camera
e39f3378a2 Remove non-functional maintenance link check. 2012-04-16 17:01:08 +00:00
Dean Camera
cf7859e2f2 Minor documentation improvements. 2012-04-15 19:23:00 +00:00
Dean Camera
ce3db96d9a Make sure CRC value is pre-zeroed before reading from the XMEGA target device, to prevent corrupt data from being returned to the host in the AVRISP-MKII Clone project. 2012-04-15 19:15:35 +00:00
Dean Camera
3703d50580 Minor documentation improvements. 2012-04-15 19:06:04 +00:00
Dean Camera
02120ebc38 Minor documentation improvements. 2012-04-15 13:51:11 +00:00
Dean Camera
c0841d98c5 Fixed incorrect reponse to GET STATUS requests in device mode if NO_DEVICE_SELF_POWER or NO_DEVICE_REMOTE_WAKEUP tokens are defined (thanks to Georg Glock). 2012-04-15 13:34:11 +00:00
Dean Camera
e7670d06e0 Minor formatting updates to the SerialToLCD project - remove unused variable. 2012-04-15 10:00:14 +00:00
Dean Camera
bd3f6794dd Minor formatting updates to the SerialToLCD project. 2012-04-14 21:47:02 +00:00
Dean Camera
2e757d8c38 Added new SerialToLCD user project contributed by Simon Foster. 2012-04-14 21:35:25 +00:00
Dean Camera
47f6a35013 Reintegrate the FullEPAddresses development branch into trunk. 2012-04-14 14:41:17 +00:00
Dean Camera
e8570c4a37 Fixed CDC and DFU bootloaders failing to compile when the bootloader section size is 8KB or more (thanks to Georg Glock). 2012-04-14 10:09:45 +00:00
Dean Camera
a19dc3d20c Fix typos in the LUFAConfig.h header file. Add missing modules to the AVR8 architecture ModuleTest build test makefile. 2012-04-09 13:20:40 +00:00
Dean Camera
9add0d100d Ensure Temperature.c and TWI_AVR8.c can be compiled silently in projects with non-supported hardware - produce errors only if the user application includes the module header files. 2012-04-09 12:45:49 +00:00
Dean Camera
d771099f62 Remove outdated documentation from the library, minor documentation improvements. 2012-04-09 10:32:59 +00:00
Dean Camera
3211b35a4c Make Doxygen fail for any Doxygen output other than unsupported tags (as these are somewhat benign).
Improve exclusion list for the main library export_tar rule to exclude any compiled library files from the export.
2012-04-09 10:04:40 +00:00
Dean Camera
b2fe539d1c Removed the old pseudo-scheduler from the library as it was unused and deprecated since the 090810 release. 2012-04-08 21:48:46 +00:00
Dean Camera
f11826fc47 Minor documentation improvements. 2012-04-08 21:43:36 +00:00
Dean Camera
a25a6dfd56 Minor documentation improvements. 2012-04-08 21:38:07 +00:00
Dean Camera
fde181a830 Minor documentation improvements. 2012-04-08 19:36:46 +00:00
Dean Camera
60d724e398 Move out Doxygen style assets into a seperate folder. 2012-04-08 18:52:00 +00:00
Dean Camera
3008f8ce13 Doxygen documentation style changes. Minor documentation corrections. 2012-04-08 18:46:56 +00:00
Dean Camera
512b4d87cc Add additional specific sub-family parts to the ModuleTest build test as these may have minor header file differences to their standard family cousins.
Clean up of main library Makefile to extract out the library version once into a make variable for easy reference.
2012-04-08 14:22:47 +00:00
Dean Camera
f1bf7e1816 Move documentation images into a dedicated sub-folder. 2012-04-08 14:21:13 +00:00
Dean Camera
292df85620 Add guide for importing LUFA into an AS5/AS6 project. 2012-04-08 14:14:45 +00:00
Dean Camera
b04de2f2f4 Pull out common options in the StaticAnalysisTest build test makefile into a seperate make variable for clarity.
Add missing cppcheck inline suppression comment.
2012-04-08 11:30:28 +00:00
Dean Camera
b9a486efe7 Oops - fix broken makefile tar rule. 2012-04-07 17:40:16 +00:00
Dean Camera
ae91ccc048 Fix up Doxygen documentation directives to allow for generation of documentation when the library code root folder is not "LUFA". 2012-04-07 17:38:30 +00:00
Dean Camera
8f4f48d963 Add architecture guards to all architecture-specific files, so that they can be bulk-added to existing IDE projects without having to exclude unused architecture files. 2012-04-07 17:01:46 +00:00
Dean Camera
d4b45e8502 Add extra LUFA TAR archive export exclusions. 2012-04-07 16:46:45 +00:00
Dean Camera
0fb92f0441 Add main library makefile target "export_tar" to export a copy of the library codebase in TAR format, for each integration into user applications. 2012-04-07 16:40:20 +00:00
Dean Camera
8b4fe84163 Minor documentation improvements. 2012-04-05 17:37:10 +00:00
Dean Camera
55b315b00f Clean up Bootloader API tables. 2012-04-01 13:55:49 +00:00
Dean Camera
25ac76a251 Reverted AVRISP-MKII clone project watchdog based command timeout patch in favour of a hardware timer, to allow for use in devices with WDTRST fuse programmed. 2012-04-01 13:39:04 +00:00
Dean Camera
89f16f5d7f Minor documentation improvements. 2012-04-01 13:37:08 +00:00
Dean Camera
1cc62c9282 Oops - typos in alterations to HID_DESCRIPTOR_JOYSTICK(). 2012-03-29 19:52:18 +00:00
Dean Camera
bb055c24e3 Oops - fix compile errors in the AudioInput/AudioOutput class driver demos. 2012-03-29 19:47:37 +00:00
Dean Camera
b3aaffb792 Removed variable axis support from the HID_DESCRIPTOR_JOYSTICK() macro due to OS incompatibilities, replaced with fixed 3-axis joystick report structure. 2012-03-29 19:41:05 +00:00
Dean Camera
7cac5e22d7 Added additional bootloader API data to expose the bootloader start address and class to the DFU and CDC class bootloaders. 2012-03-29 19:35:40 +00:00
Dean Camera
5e5b7cf2ca Tweak static analysis check BuildTest makefile argument order to make the call differences easier to determine. 2012-03-25 12:29:15 +00:00
Dean Camera
00b6b0140f Re-enable cppcheck static analysis unused function checks after adding in special-case suppressions to the event stub functions. Add missing function prototypes to the AudioInput and AudioOutput class driver device demos. 2012-03-25 12:12:08 +00:00
Dean Camera
0424bd4dbc Add automated link checking script to the Maintenance script makefile. 2012-03-23 22:12:16 +00:00
Dean Camera
bbf9d14bf9 Fixed AVRISP-MKII programmer project failing to compile for the U4 chips when VTARGET_ADC_CHANNEL is defined to an invalid channel and NO_VTARGET_DETECT is defined (thanks to Steven Morehouse). 2012-03-20 20:44:01 +00:00
Dean Camera
a77c3edc37 Fixed inverted LED logic in the OLIMEX162 board LED driver. 2012-03-20 06:18:41 +00:00
Dean Camera
e58915344d Fixed error in the AVRISP-MKII programmer when ISP mode is used at 64KHz (thanks to Ben R. Porter). 2012-03-18 16:51:52 +00:00
Dean Camera
01d5af3d6c Add XMEGA C3 family to the ModuleTest build test.
Remove unnecessary GCC_MEMORY_BARRIER() at the end of GetGlobalInterruptMask().

Minor documentation improvements.
2012-03-17 10:22:58 +00:00
Dean Camera
1971a415e5 Fixed compile error if LEDs_Disable() is called and BOARD=NONE is set (thanks to Sam Lin). 2012-03-17 10:21:40 +00:00
Dean Camera
f87aec2264 Fixed incorrect call to the user callback CALLBACK_Audio_Device_GetSetInterfaceProperty() in the Audio Class device driver (thanks to Tiit Ratsep). 2012-03-15 19:11:26 +00:00
Dean Camera
77adb2ba52 Audio Device Class driver changed to also require the index of the Audio Control interface within the device, for SET/GET/CUR/MIN/MAX/RES property adjustments. 2012-03-14 22:12:40 +00:00
Dean Camera
c0f763db04 Reorder manual documentation sections, remove useless "AboutLUFA" section. 2012-03-13 17:30:14 +00:00
Dean Camera
d5291c2e10 Only abort Doxygen documentation generation if a non-unsupported tag warning is encountered. 2012-03-09 22:36:56 +00:00
Dean Camera
3ea356a720 Added Dataflash operational checks and aborts to all projects using the Dataflash to ensure it is working correctly before use. 2012-03-09 22:02:29 +00:00
Dean Camera
8de8d7ab5a Update maintenance scripts to add targets to validate the current branch for complete correctness. Add maintenance script target for checking for release suitability. 2012-03-09 21:30:01 +00:00
Dean Camera
663f9bd5f5 Update Doxygen documentation build scripts to fail if any warnings are generated. 2012-03-09 21:28:44 +00:00
Dean Camera
62c5a14fbb Fix corrupt Doxygen configuration files, update project names. 2012-03-08 19:17:11 +00:00
Dean Camera
eb2431ecd8 Update Doxygen configuration files to disable Markdown support. 2012-03-08 16:59:55 +00:00
Dean Camera
915b4d2346 Update maintenance scripts to disable Doxygen Markdown support. 2012-03-08 16:59:20 +00:00
Dean Camera
65019e4408 Prevent the first maintenance script rule from running if no target is specified to the maintenance script. 2012-03-08 06:18:54 +00:00
Dean Camera
fa49bc152c Update maintenance scripts to abort if the check-release target fails to complete. 2012-03-08 06:16:02 +00:00
Dean Camera
ceed4e680f Fix incorrect Doxygen references in the Audio Input/Output ClassDriver demos. 2012-03-07 19:11:24 +00:00
Dean Camera
dba5004684 Update Doxygen configuration files for all projects. 2012-03-07 19:11:15 +00:00
Dean Camera
e3124bb90b Add library maintenance scripts. 2012-03-07 19:08:12 +00:00
Dean Camera
0d4a9a895b Minor documentation improvements. 2012-03-06 19:34:46 +00:00
Dean Camera
17f104cbe8 Fixed compile error for the UC3 architecture when INTERRUPT_CONTROL_ENDPOINT is specified (thanks to Andrus Aaslaid). 2012-03-06 14:50:59 +00:00
Dean Camera
6ee79029d5 Raised the guard bits in the AVRISP-MKII clone project when in PDI and TPI to 32, to prevent communication errors on low quality connections to a target. 2012-03-05 20:25:46 +00:00
Dean Camera
5c3623a7c5 Minor documentation improvements. 2012-03-04 18:21:54 +00:00
Dean Camera
9ffeac6992 Update code and StaticAnlysisTest so that missingInclude warnings do not have to be suppressed, and so that all code except for third party libraries can be checked.
Update SingleUSBModeTest makefile to separate out the messages from the test commands.
2012-03-04 16:15:59 +00:00
Dean Camera
e408f92b26 Minor documentation improvements. 2012-03-04 14:43:30 +00:00
Dean Camera
eb1275890a Update ModuleTest to compile for each sub-family within each architecture, to ensure that the code compiles for all devices (not just for one device in each architecture). 2012-03-04 14:43:14 +00:00
Dean Camera
7416ebd7c6 Update StaticAnalysisTest to check for missing header files. Fix found incorrect header file paths in the demos and projects. 2012-02-29 17:04:04 +00:00
Dean Camera
bb85d083a7 Fix warnings and errors found by the new cppcheck provided static code analysis. 2012-02-28 20:40:24 +00:00
Dean Camera
b762780343 Add source static analysis build test using "cppcheck". 2012-02-28 20:07:52 +00:00
Dean Camera
f5c155cf05 Minor documentation improvements. 2012-02-26 15:03:03 +00:00
Dean Camera
8a9e30a0cb Fixed possible enumeration error if the user application selects the non-Control pipe between the Powered and Default states of the host state machine. 2012-02-26 15:01:36 +00:00
Dean Camera
7cbea39c42 Remove Library Apps overview page from the documentation. 2012-02-25 17:20:42 +00:00
Dean Camera
0456dfeb88 Update main library documentation organisation for Doxygen 1.8.0. 2012-02-25 17:07:33 +00:00
Dean Camera
f70fd6d6ed Update author information. 2012-02-25 16:36:34 +00:00
Dean Camera
6a9d1eab2d Modified the CDC Host demos to set a default CDC Line Encoding on enumerated devices. 2012-02-24 20:28:27 +00:00
Dean Camera
63a65a9598 Minor documentation fixes - change \note entries to \warning where appropriate and remove/update old documentation. 2012-02-24 20:26:19 +00:00
Dean Camera
e406140f11 Minor documentation fixes - change \note entries to \warning where appropriate and remove/update old documentation. 2012-02-24 20:25:36 +00:00
Dean Camera
5561524a8f Added support for the BitWizard Multio and Big-Multio boards. 2012-02-22 21:31:18 +00:00
Dean Camera
1dcc1fe527 Update the Android Accessory Host ClassDriver demo to use the updated class configuration API.
Enable -Wcast-align warning for the UC3 architecture in the ModuleTest build test now that the test passes with it.

Minor documentation improvements.
2012-02-20 22:07:25 +00:00
Dean Camera
4068efbd18 Remove potentially unaligned uint32_t access in HIDParser.c, replace with standard C bit shifts. 2012-02-20 18:47:25 +00:00
Dean Camera
6c738343ae Update trunk post-120219 release. 2012-02-19 17:05:10 +00:00
Dean Camera
9a6c6c786e Commit for the 120219 release. 2012-02-19 17:00:46 +00:00
Dean Camera
84ff878fd7 Fix errors uncovered by the new build test compile warnings; fix UC3 pipe configuration function broken, redundant function prototypes and unused parameters. 2012-02-19 15:26:42 +00:00
Dean Camera
50ff97f378 All USB Class Driver configuration struct values are now non-const, to allow for run-time modifications if required before configuring an instance. 2012-02-19 15:24:05 +00:00
Dean Camera
bbe7c77b91 Update ModuleTest build test to use as many compile warnings as possible. Set -Werror so that any generated warnings produce an error. 2012-02-19 15:02:28 +00:00
Dean Camera
0e4ece1d1d Update build test "ModuleTest" to check platform drivers where possible. Add missing copyright/license headers. 2012-02-19 13:30:08 +00:00
Dean Camera
b7f4370c8e Oops - don't reset AVRISP-MKII timeout in XPROG mode, as this is synchronous serial and data is always received regardless of attached or non-attached target. 2012-02-19 01:30:53 +00:00
Dean Camera
2f036ae2bf Add build test for forced single USB modes.
Fix UC3 Interrupt Management platform driver not compiling under C++.
2012-02-19 01:17:54 +00:00
Dean Camera
1132488e8f Add build tests to verify correct compilation of as many modules as possible under as many architectures as possible.
Fix broken compilation of LUFA under C++ compilers when the Serial peripheral module header file is included in a C++ source file.

Fix missing semicolon in the UC3 architecture host pipe functions.

Fix failed compilation for the XMEGA architecture if USB_DEVICE_ONLY us not specified.
2012-02-18 23:33:12 +00:00
Dean Camera
04b8360b15 Minor documentation improvements. 2012-02-18 16:06:43 +00:00
Dean Camera
9d2e7aeff4 Add missing file Subversion EOL-style properties. 2012-02-13 20:13:35 +00:00
Dean Camera
7a8b038687 Fix Dataflash driver for the XMEGA-B1 XPLAINED - the Dataflash is connected to the USART module, but requires physical port remapping. 2012-02-13 19:59:31 +00:00
Dean Camera
01a80df6c2 Minor documentation improvements. 2012-02-12 20:47:57 +00:00
Dean Camera
5051df08d7 Minor documentation improvements. 2012-02-12 20:39:57 +00:00
Dean Camera
09d2be0dc1 Add new Master SPI Mode USART serial peripheral driver for the XMEGA and AVR8 architectures.
Modify board Dataflash drivers so that each individual board is responsible for including the correct peripheral driver (SPI or SerialSPI) based on the board connections to the Dataflash chip.

Complete A3BU-XPLAINED and B1-XPLAINED board Dataflash drivers.
2012-02-12 20:34:33 +00:00
Dean Camera
f45d60f768 Added Serial USART peripheral driver for the XMEGA platform.
Fix XMEGA SPI peripheral driver's incorrect const-ness on the SPI peripheral struct.
2012-02-12 11:48:24 +00:00
Dean Camera
82fdedc192 Minor documentation improvements. 2012-02-11 22:35:06 +00:00
Dean Camera
81bd8f2f83 Clean up the Audio Device class driver control request Endpoint match logic. 2012-02-11 20:39:33 +00:00
Dean Camera
2180f57d17 Altered the HID class driver to only try to construct at maximum one packet per USB frame, to reduce CPU usage. 2012-02-09 20:30:27 +00:00
Dean Camera
385ffb6de3 Fix XMEGA architecture not correctly resetting the device address and endpoints in response to a USB bus reset from the host. 2012-02-09 20:27:03 +00:00
Dean Camera
a2d18e46f8 Update XMEGA board drivers to use the port inversion feature of the XMEGA architecture rather than performing the inversion in software. Add partially completed XMEGA-B1-XPLAINED Dataflash board driver and revert implementation of the XMEGA-A3BU-XPLAINED Dataflash driver as the chip is connected to the USART, not the SPI interface. 2012-02-09 20:26:13 +00:00
Dean Camera
7a1033025b Minor documentation fixes.
Make an explicit constant name for the CMDEX bit of the target's NVM command register in the AVRISP-MKII Clone project.
2012-02-08 21:31:03 +00:00
Dean Camera
c60897df39 Allow serial strings to be generated on the older AVR8 devices which do not explicitly state they contain unique values in the datasheet, as this appears to be implemented in hardware. 2012-02-08 18:35:16 +00:00
Dean Camera
18b82b3575 Updated the AVRISP-MKII Clone programmer project to be compatible with the latest version of AVR Studio (version 5.1).
Changed the AVRISP-MKII Clone programmer project to report a fixed 3.3V VTARGET voltage on USB AVRs lacking an ADC instead of 5V to prevent warnings in AVR Studio 5.1 when programming XMEGA devices.
2012-02-08 18:29:17 +00:00
Dean Camera
1482f77826 Oops - XMEGA-B1 Xplained LEDs are on PORTB and PORTE, not PORTF and PORTE. 2012-02-06 17:10:42 +00:00
Dean Camera
4d131de85b Add board driver support for the Atmel XMEGA-B1 Xplained board.
Fix Dataflash driver for the A3BU-Xplained board.

Minor documentation improvements.
2012-02-06 17:05:33 +00:00
Dean Camera
fdab3aef86 Add (still preliminary) support for the ATXMEGA64A4 and ATXMEGA128A4. Fix minor error in the AVRISP-MKII clone project descriptors. 2012-02-05 21:59:35 +00:00
Dean Camera
fe8326855a Revert changed version files in /trunk/ now that the LUFA-120219-BETA version has been released. 2012-02-05 16:02:14 +00:00
Dean Camera
5a2d815722 Commit for the 120219-BETA release. 2012-02-05 15:53:31 +00:00
Dean Camera
da676f0f70 Add support for the Micropendous (Arduino-like) series of boards (revisions 1 and 2). 2012-02-05 15:50:09 +00:00
Dean Camera
0e8e70153a Update LUFAConfig.h with the new compile time options, re-format Doxygen documentation for all compile time options. 2012-02-05 15:28:41 +00:00
Dean Camera
a677254026 Added INVERTED_VBUS_ENABLE_LINE and NO_AUTO_VBUS_MANAGEMENT compile time options (thanks to Opendous Inc.). 2012-02-05 15:19:01 +00:00
Dean Camera
252bd7bb2c Fixed invalid PID value used in the TempDataLogger project host application (thanks to Anupam Pathak). 2012-02-05 13:16:08 +00:00
Dean Camera
e55946f972 Add missing svn:eol-style properties to /trunk/. 2012-02-04 23:00:22 +00:00
Dean Camera
f1b6ddb710 Update file contributor copyrights for 2012. 2012-02-04 22:38:44 +00:00
Dean Camera
2c806f6cee Update file header copyrights for 2012. 2012-02-04 22:32:30 +00:00
Dean Camera
64e9361298 Minor corrections to the XMEGA USB controller implementation. 2012-02-04 22:16:34 +00:00
Dean Camera
df33278d91 Minor documentation corrections. 2012-02-04 15:17:49 +00:00
Dean Camera
43a3350981 Add API support signature to the CDC and DFU class bootloaders, so that the application can detect the bootloader's API support. 2012-02-03 21:49:36 +00:00
Dean Camera
3dacb73af3 Fix errors in the new Micropendous board drivers. Reorder the board definition macro indexes so that misspelled board names default to BOARD_USER rather then BOARD_USBKEY. 2012-02-03 21:10:07 +00:00
Dean Camera
10a56f6105 Add support for the Micropendous series of USB AVR8 boards. 2012-02-03 20:20:11 +00:00
Dean Camera
8d2cb61a5b Minor documentation fixes. 2012-02-03 19:09:37 +00:00
Dean Camera
a436fbb612 Minor documentation improvements. 2012-02-02 20:17:22 +00:00
Dean Camera
fc4d3ab400 Minor documentation improvements. 2012-02-01 21:28:25 +00:00
Dean Camera
956f9e3709 Fixed AVRISP-MKII Clone timing out on long programming commands such as programming the EEPROM on an ATMEGA8 (thanks to Martin Kelling). 2012-01-30 16:54:09 +00:00
Dean Camera
401ff1cef1 Add missing reference to the BootloaderAPI.S source file in the DFU and CDC class bootloader AVRStudio 4 project files. 2012-01-29 14:42:18 +00:00
Dean Camera
9f99c7fa03 Fixed DFU class bootloader not resetting the LED pins as high impedance inputs when a software jump to the user applications is requested. 2012-01-29 14:37:30 +00:00
Dean Camera
5563da6a62 Added new LEDs_Disable(), Buttons_Disable() and Joystick_Disable() functions to the board hardware drivers. 2012-01-29 14:33:36 +00:00
Dean Camera
a147cee95f Added new CALLBACK_Audio_Device_GetSetInterfaceProperty() callback to the Audio Device Class driver. 2012-01-28 18:07:35 +00:00
Dean Camera
dd312cead4 Make all AVRISP-MKII programmer parameters readable, since there's no real good reason to restrict parameter reads. Fix misspelt target reset polarity EEPROM variable. 2012-01-23 20:28:34 +00:00
Dean Camera
bc3db793e9 Minor bootloader tweaks; make some functions static where possible to reduce the compiled binary size, add additional comments to the makefiles. 2012-01-15 14:07:14 +00:00
Dean Camera
3038ea1c6e USB_CONFIG_ATTR_BUSPOWERED constant renamed to USB_CONFIG_ATTR_RESERVED, as this was misnamed (thanks to NXP Semiconductors). 2012-01-02 05:43:23 +00:00
Dean Camera
154d28e39f Fixed incorrect implementation of LEDs_ToggleLEDs() for the Adafruit-U4 board (thanks to Caroline Saliman). 2011-12-26 13:23:43 +00:00
Dean Camera
f201f6697b Run wspurify script on /trunk/ and /branches/ C source files, to remove any trailing whitespace at the end of each line. 2011-12-23 01:51:39 +00:00
Dean Camera
77f354609f Fixed compiler warning on GCC with -wundef compile flag is used (thanks to Georg Glock). 2011-12-20 13:15:36 +00:00
Dean Camera
676de74d9b Don't validate the Device Descriptor's vendor ID when validating that a device is an Android Accessory device; the Product ID and (later) Accessory protocol support is enough to probe AOA class support without having to maintain a list of Android device manufacture VID values. 2011-12-14 02:52:42 +00:00
Dean Camera
84a739ae72 Minor XMEGA USB driver fixes. 2011-12-13 03:40:51 +00:00
Dean Camera
ec3e47a7d0 Change PIPE_PIPENUM_MASK from 0x07 to the more generic 0x0F to allow for full pipe address support in USB host architectures other than the current AVR8 devices. Minor documentation improvements. 2011-12-11 03:04:16 +00:00
Dean Camera
ecba8bcecf Fix incorrect Capabilities value in the CDC class Bootloader descriptors. 2011-12-01 08:40:14 +00:00
Dean Camera
0c59d5993e Altered the Mass Storage Host class driver so that SCSI data STALLs from the attached device can be recovered from automatically without having to reset the Mass Storage interface.
Altered the Mass Storage Host LowLevel demo so that SCSI data STALLs from the attached device can be recovered from automatically without having to reset the Mass Storage interface.
2011-12-01 08:39:43 +00:00
Dean Camera
798cc84ff5 Fixed AVRISP-MKII Clone failing to start application firmware once a TPI programming session is exited. 2011-11-29 13:33:28 +00:00
Dean Camera
259a3c9854 Fix typo in the Joystick board driver documentation example code. 2011-11-29 11:31:00 +00:00
Dean Camera
24ca2d49fe Bit-bang ISP in the AVRISP-MKII clone project needs to set MOSI pin to the MSB of the data byte on startup, not the LSB. 2011-11-29 11:30:25 +00:00
Dean Camera
70f3d8e933 Add support for the Paranoid Studio USB2AX boards (hardware revisions 1-3). 2011-11-28 23:43:58 +00:00
Dean Camera
2b23318357 Add dummy board documentation nodes for the XPLAIN_REV1 and TEENSY2 meta board targets. 2011-11-28 13:15:27 +00:00
Dean Camera
057972bd25 Remove unnecessary ErrorCode variable initializations from the LowLevel Host mode demos. 2011-11-28 13:14:51 +00:00
Dean Camera
b0a258722d Add missing const qualifier to bootloader API function parameters. 2011-11-28 13:14:15 +00:00
Dean Camera
cdd4e11fa8 Oops - fix incorrect value of AOA_CSCP_AOADataSubclass in the Android Open Accessory class driver. 2011-11-24 21:35:22 +00:00
Dean Camera
38d7cdf803 Minor Doxygen documentation improvements.
Add missing ATTR_NON_NULL_PTR_ARG and const decorations.
2011-11-24 11:59:52 +00:00
Dean Camera
3b99abb5fc Add new USB_Host_GetDescriptor() function. Alter the USB_Host_GetDeviceDescriptor() and USB_Host_GetDeviceStringDescriptor() convenience functions so that they wrap the new function. 2011-11-24 11:46:04 +00:00
Dean Camera
e915d968a5 Added new USB_Host_GetDeviceConfiguration() and USB_Host_GetInterfaceAltSetting() functions. 2011-11-24 11:33:10 +00:00
Dean Camera
7f8dbb4908 Convert the LowLevel AndroidAccessory demo to use the new class driver constants to reduce code duplication.
Add missing Doxygen documentation.
2011-11-24 01:31:31 +00:00
Dean Camera
8b5aa61601 Add new Android Open Accessory class driver to the library core and add a new Android Open Accessory Host ClassDriver demo. 2011-11-24 01:24:01 +00:00
Dean Camera
075538abb9 Use the proper "-Wl,--undefined=BootloaderAPI_JumpTable" linker command line parameter in the bootloaders to ensure that the API jump tables are not discarded, rather than the previous C volatile pointer hack (thanks to Opendous Inc.). 2011-11-23 14:09:01 +00:00
Dean Camera
d619214854 Update library to indicate support for the Android Accessory Host demo. 2011-11-23 06:59:27 +00:00
Dean Camera
08f448407b Move out Android Accessory Host demo to the Host mode LowLevel directory now that it is functionally complete. 2011-11-23 06:50:50 +00:00
Dean Camera
e9802253e2 Add const-correctness to the Android_SendString() function of the Android Accessory Host demo. 2011-11-23 06:46:19 +00:00
Dean Camera
4f223302b1 Oops: Typo on the new TEENSY2 board support. 2011-11-23 00:25:20 +00:00
Dean Camera
c704131be4 Fix interface protocol match value for the Android Accessory Host demo interface configuration parser code (thanks to Opendous Inc.). 2011-11-23 00:16:33 +00:00
Dean Camera
a81ccd83fd Added support for version 2 of the Teensy boards (thanks to Christoph Redecker). 2011-11-23 00:15:58 +00:00
Dean Camera
09577fe541 Add XMEGA compile time tokens to the LUFAConfig.h code template.
Add additional compile time errors to the XMEGA and AVR8 architectures if multiple USE_*_DESCRIPTORS compile time tokens are enabled.

Add support for the NO_INTERNAL_SERIAL compile time token on the XMEGA targets.
2011-11-23 00:04:16 +00:00
Dean Camera
b711b7d6a4 Fixed broken AVR32 endpoint/pipe communications when ORDERED_EP_CONFIG compile time option is not enabled (thanks to Matthias).
Fixed broken compilation for the AVR32 devices if the NO_SOF_EVENTS compile time option was not enabled (thanks to Matthias).
2011-11-22 08:06:52 +00:00
Dean Camera
eb2e883fd3 Added Class, ClassDevice, ClassHost and ClassCommon to the internal class driver source filenames to prevent ambiguities. 2011-11-18 06:26:51 +00:00
Dean Camera
3e04487279 Fixed misspelled HID_KEYBOARD_MODIFIER_* macros in the HID class driver (thanks to Laszlo Monda). 2011-11-16 08:19:34 +00:00
Dean Camera
dc09ccab8b Minor corrections for the XMEGA USB controller. Add compile time warning if the USB clock frequency is provably incorrect. 2011-11-14 07:31:40 +00:00
Dean Camera
e30be658c9 Add missing SVN eol-style property to ensure that source code line endings and converted to the native values on checkout. 2011-11-09 23:35:16 +00:00
Dean Camera
46aea9d4ce Update the incomplete StandaloneProgrammer project to be compatible with the latest LUFA core API. 2011-11-09 23:24:11 +00:00
Dean Camera
b057041660 Use strcat() in the HTTPServer project instead of using strcpy() and strlen(). 2011-11-09 12:47:15 +00:00
Dean Camera
6564416479 Update host C# applications for VS2010. Make LEDNotifier project host applications only display valid COM port names for the PC it is run on, rather than all possible port names. Add missing property files to the TempDataLogger project host application. 2011-11-09 12:45:10 +00:00
Dean Camera
8df0cf3241 Fixed race conditions in the CDC, HID and Mass Storage class drivers when processing some control requests. 2011-11-09 12:29:14 +00:00
Dean Camera
2b54cd984d Fix typos in makefile templates. 2011-11-09 12:09:13 +00:00
Dean Camera
0ad6f1fb53 Add partial support for the Atmel A3BU Xplained's Dataflash IC (physical USART-as-SPI transport driver still pending). 2011-11-01 06:06:41 +00:00
Dean Camera
cb7f7a8241 Fix XMEGA core USB driver endpoint code to prevent incorrect STALL determination. 2011-11-01 06:05:54 +00:00
Dean Camera
139c1afeeb Add XMEGA SPI peripheral driver. 2011-10-31 04:30:47 +00:00
Dean Camera
7992202603 Add support for the new MEGA B series devices. 2011-10-31 03:39:12 +00:00
Dean Camera
00ad509061 Add support for the Atmel XMEGA A3BU Xplained board.
More XMEGA USB core fixes.
2011-10-31 03:31:00 +00:00
Dean Camera
0304916356 Fix XMEGA core USB driver so that device mode enumerates correctly on the host PC. 2011-10-31 02:26:21 +00:00
Dean Camera
eb5b8a32e4 Added INVERTED_ISP_MISO compile time option to the AVRISP-MKII clone project (thanks to Chuck Rohs). 2011-10-30 14:12:11 +00:00
Dean Camera
1e0c3bc69a Namespace out the internal endpoint globals in the XMEGA architecture. 2011-10-30 14:05:34 +00:00
Dean Camera
fe87b8a225 Update ENDPOINT_EPNUM_MASK to be 0x0F, the maximum possible USB endpoint number within a device, rather than just the maximum number for the AVR8 and UC3 targets of 0x07. 2011-10-30 14:04:47 +00:00
Dean Camera
72717825e5 Namespace out the internal endpoint and pipe globals in the UC3 architecture. 2011-10-30 14:03:53 +00:00
Dean Camera
b714ffbfa0 Update XMEGA clock management so that the correct 16-bit calibration is used when requested. Fix endpoint descriptor table so that the frame number is stored into the correct location. Add compile time option to source the USB clock from the PLL rather than the internal 32MHz RC oscillator. 2011-10-30 12:06:02 +00:00
Dean Camera
c739974292 Fix error in XMEGA clock platform driver for the DFLL calibration byte order. 2011-10-30 07:43:13 +00:00
Dean Camera
ab43251bf9 Minor documentation fixes. 2011-10-30 07:09:44 +00:00
Dean Camera
028a3c4ab3 XMEGA port improvements; connection and disconnection are now detected correctly. Fixed incorrect interrupt priority levels being set for XMEGA devices. 2011-10-30 07:09:20 +00:00
Dean Camera
6519aaa571 Fix incorrect Android Accessory Host interface descriptor subclass value (thanks to Opendous Inc.). 2011-10-28 05:16:38 +00:00
Dean Camera
f1543ae8ff Fixed CDC class drivers not saving and sending all 16-bits of the control line states (thanks to Matthew Swabey). 2011-10-26 06:51:07 +00:00
Dean Camera
bc14c1a7f6 Update XMEGA platform clock management example code to suit the currently released silicon.
Cleanups to the UC3 endpoint/pipe multi byte read code.
2011-10-25 04:28:22 +00:00
Dean Camera
e9029d49d5 Rename the Doxygen page source directory from ManPages/ to DoxygenPages/ to prevent user confusion with the actual *nix Man tool. 2011-10-18 11:35:04 +00:00
Dean Camera
3aa8a69246 Fixed AVRISP-MKII Clone compile warning on AVR8 U4 targets even when NO_VTARGET_DETECT is enabled. 2011-10-18 11:31:03 +00:00
Dean Camera
738c9203fc Fixed ring buffer size limited to 255 elements, instead of the intended 65535 elements. 2011-10-18 11:23:23 +00:00
Dean Camera
c6d6bdae0a Added reliability patches to the AVRISP-MKII Clone project's PDI/TPI protocols (thanks to Justin Mattair). 2011-10-12 05:31:35 +00:00
Dean Camera
c15eaa5dae When automatic PLL management mode is enabled on the U4 series AVR8 chips, the PLL is now configured for 48MHz and not a divided 96MHz, to lower power consumption and to keep the system within the datasheet specs for 3.3V operation (thanks to Scott Vitale). 2011-10-12 02:27:22 +00:00
Dean Camera
1a4a26271e Added User Application APIs to the CDC and DFU class bootloaders. 2011-10-11 06:20:18 +00:00
1503 changed files with 106466 additions and 97381 deletions

13
.gitignore vendored Normal file
View File

@@ -0,0 +1,13 @@
*.o
*.d
*.elf
*.hex
*.eep
*.sym
*.bin
*.lss
*.map
*.bak
*.class
LUFA/StudioIntegration/ProjectGenerator/*
LUFA/StudioIntegration/DocBook/*

View File

@@ -0,0 +1,75 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
*
* Bootloader user application API functions.
*/
#include "BootloaderAPI.h"
void BootloaderAPI_ErasePage(const uint32_t Address)
{
boot_page_erase_safe(Address);
boot_spm_busy_wait();
boot_rww_enable();
}
void BootloaderAPI_WritePage(const uint32_t Address)
{
boot_page_write_safe(Address);
boot_spm_busy_wait();
boot_rww_enable();
}
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
{
boot_page_fill_safe(Address, Word);
}
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
{
return boot_signature_byte_get(Address);
}
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
{
return boot_lock_fuse_bits_get(Address);
}
uint8_t BootloaderAPI_ReadLock(void)
{
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
}
void BootloaderAPI_WriteLock(const uint8_t LockBits)
{
boot_lock_bits_set_safe(LockBits);
}

View File

@@ -0,0 +1,58 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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 BootloaderAPI.c.
*/
#ifndef _BOOTLOADER_API_H_
#define _BOOTLOADER_API_H_
/* Includes: */
#include <avr/io.h>
#include <avr/boot.h>
#include <stdbool.h>
#include <LUFA/Common/Common.h>
#include "Config/AppConfig.h"
/* Function Prototypes: */
void BootloaderAPI_ErasePage(const uint32_t Address);
void BootloaderAPI_WritePage(const uint32_t Address);
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
uint8_t BootloaderAPI_ReadLock(void);
void BootloaderAPI_WriteLock(const uint8_t LockBits);
#endif

View File

@@ -0,0 +1,91 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 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 disclaims 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.
*/
; Trampolines to actual API implementations if the target address is outside the
; range of a rjmp instruction (can happen with large bootloader sections)
.section .apitable_trampolines, "ax"
.global BootloaderAPI_Trampolines
BootloaderAPI_Trampolines:
BootloaderAPI_ErasePage_Trampoline:
jmp BootloaderAPI_ErasePage
BootloaderAPI_WritePage_Trampoline:
jmp BootloaderAPI_WritePage
BootloaderAPI_FillWord_Trampoline:
jmp BootloaderAPI_FillWord
BootloaderAPI_ReadSignature_Trampoline:
jmp BootloaderAPI_ReadSignature
BootloaderAPI_ReadFuse_Trampoline:
jmp BootloaderAPI_ReadFuse
BootloaderAPI_ReadLock_Trampoline:
jmp BootloaderAPI_ReadLock
BootloaderAPI_WriteLock_Trampoline:
jmp BootloaderAPI_WriteLock
BootloaderAPI_UNUSED1:
ret
BootloaderAPI_UNUSED2:
ret
BootloaderAPI_UNUSED3:
ret
BootloaderAPI_UNUSED4:
ret
BootloaderAPI_UNUSED5:
ret
; API function jump table
.section .apitable_jumptable, "ax"
.global BootloaderAPI_JumpTable
BootloaderAPI_JumpTable:
rjmp BootloaderAPI_ErasePage_Trampoline
rjmp BootloaderAPI_WritePage_Trampoline
rjmp BootloaderAPI_FillWord_Trampoline
rjmp BootloaderAPI_ReadSignature_Trampoline
rjmp BootloaderAPI_ReadFuse_Trampoline
rjmp BootloaderAPI_ReadLock_Trampoline
rjmp BootloaderAPI_WriteLock_Trampoline
rjmp BootloaderAPI_UNUSED1 ; UNUSED ENTRY 1
rjmp BootloaderAPI_UNUSED2 ; UNUSED ENTRY 2
rjmp BootloaderAPI_UNUSED3 ; UNUSED ENTRY 3
rjmp BootloaderAPI_UNUSED4 ; UNUSED ENTRY 4
rjmp BootloaderAPI_UNUSED5 ; UNUSED ENTRY 5
; Bootloader table signatures and information
.section .apitable_signatures, "ax"
.global BootloaderAPI_Signatures
BootloaderAPI_Signatures:
.long BOOT_START_ADDR ; Start address of the bootloader
.word 0xDF00 ; Signature for the CDC class bootloader
.word 0xDCFB ; Signature for a LUFA class bootloader

View File

@@ -1 +0,0 @@
<AVRStudio><MANAGEMENT><ProjectName>BootloaderCDC</ProjectName><Created>13-Jul-2010 14:41:25</Created><LastEdit>13-Jul-2010 14:42:12</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:41:25</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderCDC.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderCDC.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderCDC.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderCDC.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\BootloaderCDC.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\BootloaderCDC.c</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -56,6 +56,55 @@ static uint32_t CurrAddress;
*/
static bool RunBootloader = true;
/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
* will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
* low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
* \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
*/
uint16_t MagicBootKey ATTR_NO_INIT;
/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
* start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
* this will force the user application to start via a software jump.
*/
void Application_Jump_Check(void)
{
bool JumpToApplication = false;
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
/* Disable JTAG debugging */
JTAG_DISABLE();
/* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */
PORTF |= (1 << 4);
Delay_MS(10);
/* If the TCK pin is not jumpered to ground, start the user application instead */
JumpToApplication |= ((PINF & (1 << 4)) != 0);
/* Re-enable JTAG debugging */
JTAG_ENABLE();
#endif
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
JumpToApplication |= true;
/* If a request has been made to jump to the user application, honor it */
if (JumpToApplication)
{
/* Turn off the watchdog */
MCUSR &= ~(1<<WDRF);
wdt_disable();
/* Clear the boot key and jump to the user application */
MagicBootKey = 0;
// cppcheck-suppress constStatement
((void (*)(void))0x0000)();
}
}
/** 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
@@ -70,7 +119,7 @@ int main(void)
LEDs_SetAllLEDs(LEDS_LED1);
/* Enable global interrupts so that the USB stack can function */
sei();
GlobalInterruptEnable();
while (RunBootloader)
{
@@ -81,6 +130,9 @@ int main(void)
/* Disconnect from the host - USB interface will be reset later along with the AVR */
USB_Detach();
/* Unlock the forced application start mode of the bootloader if it is restarted */
MagicBootKey = MAGIC_BOOT_KEY;
/* Enable the watchdog and force a timeout to reset the AVR */
wdt_enable(WDTO_250MS);
@@ -88,7 +140,7 @@ int main(void)
}
/** Configures all hardware required for the bootloader. */
void SetupHardware(void)
static void SetupHardware(void)
{
/* Disable watchdog if enabled by bootloader/fuses */
MCUSR &= ~(1 << WDRF);
@@ -101,13 +153,13 @@ void SetupHardware(void)
MCUCR = (1 << IVCE);
MCUCR = (1 << IVSEL);
/* Initialize USB Subsystem */
/* Initialize the USB and other board hardware drivers */
USB_Init();
LEDs_Init();
/* Bootloader active LED toggle timer initialization */
TIMSK1 = (1 << TOIE1);
TCCR1B = ((1 << CS11) | (1 << CS10));
TCCR1B = ((1 << CS11) | (1 << CS10));
}
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
@@ -122,17 +174,12 @@ ISR(TIMER1_OVF_vect, ISR_BLOCK)
void EVENT_USB_Device_ConfigurationChanged(void)
{
/* Setup CDC Notification, Rx and Tx Endpoints */
Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT,
ENDPOINT_DIR_IN, CDC_NOTIFICATION_EPSIZE,
ENDPOINT_BANK_SINGLE);
Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPADDR, EP_TYPE_INTERRUPT,
CDC_NOTIFICATION_EPSIZE, 1);
Endpoint_ConfigureEndpoint(CDC_TX_EPNUM, EP_TYPE_BULK,
ENDPOINT_DIR_IN, CDC_TXRX_EPSIZE,
ENDPOINT_BANK_SINGLE);
Endpoint_ConfigureEndpoint(CDC_TX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1);
Endpoint_ConfigureEndpoint(CDC_RX_EPNUM, EP_TYPE_BULK,
ENDPOINT_DIR_OUT, CDC_TXRX_EPSIZE,
ENDPOINT_BANK_SINGLE);
Endpoint_ConfigureEndpoint(CDC_RX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1);
}
/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
@@ -176,6 +223,14 @@ void EVENT_USB_Device_ControlRequest(void)
}
break;
case CDC_REQ_SetControlLineState:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{
Endpoint_ClearSETUP();
Endpoint_ClearStatusStage();
}
break;
}
}
@@ -190,7 +245,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
uint16_t BlockSize;
char MemoryType;
bool HighByte = false;
uint8_t HighByte = 0;
uint8_t LowByte = 0;
BlockSize = (FetchNextCommandByte() << 8);
@@ -198,7 +253,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
MemoryType = FetchNextCommandByte();
if ((MemoryType != 'E') && (MemoryType != 'F'))
if ((MemoryType != MEMORY_TYPE_FLASH) && (MemoryType != MEMORY_TYPE_EEPROM))
{
/* Send error byte back to the host */
WriteNextResponseByte('?');
@@ -206,15 +261,15 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
return;
}
/* Check if command is to read memory */
if (Command == 'g')
/* Check if command is to read a memory block */
if (Command == AVR109_COMMAND_BlockRead)
{
/* Re-enable RWW section */
boot_rww_enable();
while (BlockSize--)
{
if (MemoryType == 'F')
if (MemoryType == MEMORY_TYPE_FLASH)
{
/* Read the next FLASH byte from the current FLASH page */
#if (FLASHEND > 0xFFFF)
@@ -243,7 +298,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
{
uint32_t PageStartAddress = CurrAddress;
if (MemoryType == 'F')
if (MemoryType == MEMORY_TYPE_FLASH)
{
boot_page_erase(PageStartAddress);
boot_spm_busy_wait();
@@ -251,7 +306,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
while (BlockSize--)
{
if (MemoryType == 'F')
if (MemoryType == MEMORY_TYPE_FLASH)
{
/* If both bytes in current word have been written, increment the address counter */
if (HighByte)
@@ -266,7 +321,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
{
LowByte = FetchNextCommandByte();
}
HighByte = !HighByte;
}
else
@@ -280,7 +335,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
}
/* If in FLASH programming mode, commit the page after writing */
if (MemoryType == 'F')
if (MemoryType == MEMORY_TYPE_FLASH)
{
/* Commit the flash page to memory */
boot_page_write(PageStartAddress);
@@ -303,7 +358,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
static uint8_t FetchNextCommandByte(void)
{
/* Select the OUT endpoint so that the next data byte can be read */
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
Endpoint_SelectEndpoint(CDC_RX_EPADDR);
/* If OUT endpoint empty, clear it and wait for the next packet from the host */
while (!(Endpoint_IsReadWriteAllowed()))
@@ -329,7 +384,7 @@ static uint8_t FetchNextCommandByte(void)
static void WriteNextResponseByte(const uint8_t Response)
{
/* Select the IN endpoint so that the next data byte can be written */
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
Endpoint_SelectEndpoint(CDC_TX_EPADDR);
/* If IN endpoint full, clear it and wait until ready for the next packet to the host */
if (!(Endpoint_IsReadWriteAllowed()))
@@ -350,10 +405,10 @@ static void WriteNextResponseByte(const uint8_t Response)
/** Task to read in AVR910 commands from the CDC data OUT endpoint, process them, perform the required actions
* and send the appropriate response back to the host.
*/
void CDC_Task(void)
static void CDC_Task(void)
{
/* Select the OUT endpoint */
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
Endpoint_SelectEndpoint(CDC_RX_EPADDR);
/* Check if endpoint has a command in it sent from the host */
if (!(Endpoint_IsOUTReceived()))
@@ -362,71 +417,72 @@ void CDC_Task(void)
/* Read in the bootloader command (first byte sent from host) */
uint8_t Command = FetchNextCommandByte();
if (Command == 'E')
if (Command == AVR109_COMMAND_ExitBootloader)
{
RunBootloader = false;
/* Send confirmation byte back to the host */
WriteNextResponseByte('\r');
}
else if (Command == 'T')
else if ((Command == AVR109_COMMAND_SetLED) || (Command == AVR109_COMMAND_ClearLED) ||
(Command == AVR109_COMMAND_SelectDeviceType))
{
FetchNextCommandByte();
/* Send confirmation byte back to the host */
WriteNextResponseByte('\r');
}
else if ((Command == 'L') || (Command == 'P'))
else if ((Command == AVR109_COMMAND_EnterProgrammingMode) || (Command == AVR109_COMMAND_LeaveProgrammingMode))
{
/* Send confirmation byte back to the host */
WriteNextResponseByte('\r');
}
else if (Command == 't')
else if (Command == AVR109_COMMAND_ReadPartCode)
{
/* Return ATMEGA128 part code - this is only to allow AVRProg to use the bootloader */
WriteNextResponseByte(0x44);
WriteNextResponseByte(0x00);
}
else if (Command == 'a')
else if (Command == AVR109_COMMAND_ReadAutoAddressIncrement)
{
/* Indicate auto-address increment is supported */
WriteNextResponseByte('Y');
}
else if (Command == 'A')
else if (Command == AVR109_COMMAND_SetCurrentAddress)
{
/* Set the current address to that given by the host */
/* Set the current address to that given by the host (translate 16-bit word address to byte address) */
CurrAddress = (FetchNextCommandByte() << 9);
CurrAddress |= (FetchNextCommandByte() << 1);
/* Send confirmation byte back to the host */
WriteNextResponseByte('\r');
}
else if (Command == 'p')
else if (Command == AVR109_COMMAND_ReadBootloaderInterface)
{
/* Indicate serial programmer back to the host */
WriteNextResponseByte('S');
}
else if (Command == 'S')
else if (Command == AVR109_COMMAND_ReadBootloaderIdentifier)
{
/* Write the 7-byte software identifier to the endpoint */
for (uint8_t CurrByte = 0; CurrByte < 7; CurrByte++)
WriteNextResponseByte(SOFTWARE_IDENTIFIER[CurrByte]);
}
else if (Command == 'V')
else if (Command == AVR109_COMMAND_ReadBootloaderSWVersion)
{
WriteNextResponseByte('0' + BOOTLOADER_VERSION_MAJOR);
WriteNextResponseByte('0' + BOOTLOADER_VERSION_MINOR);
}
else if (Command == 's')
else if (Command == AVR109_COMMAND_ReadSignature)
{
WriteNextResponseByte(AVR_SIGNATURE_3);
WriteNextResponseByte(AVR_SIGNATURE_2);
WriteNextResponseByte(AVR_SIGNATURE_1);
}
else if (Command == 'e')
else if (Command == AVR109_COMMAND_EraseFLASH)
{
/* Clear the application section of flash */
for (uint32_t CurrFlashAddress = 0; CurrFlashAddress < BOOT_START_ADDR; CurrFlashAddress += SPM_PAGESIZE)
for (uint32_t CurrFlashAddress = 0; CurrFlashAddress < (uint32_t)BOOT_START_ADDR; CurrFlashAddress += SPM_PAGESIZE)
{
boot_page_erase(CurrFlashAddress);
boot_spm_busy_wait();
@@ -438,7 +494,7 @@ void CDC_Task(void)
WriteNextResponseByte('\r');
}
#if !defined(NO_LOCK_BYTE_WRITE_SUPPORT)
else if (Command == 'l')
else if (Command == AVR109_COMMAND_WriteLockbits)
{
/* Set the lock bits to those given by the host */
boot_lock_bits_set(FetchNextCommandByte());
@@ -447,24 +503,24 @@ void CDC_Task(void)
WriteNextResponseByte('\r');
}
#endif
else if (Command == 'r')
else if (Command == AVR109_COMMAND_ReadLockbits)
{
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_LOCK_BITS));
}
else if (Command == 'F')
else if (Command == AVR109_COMMAND_ReadLowFuses)
{
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS));
}
else if (Command == 'N')
else if (Command == AVR109_COMMAND_ReadHighFuses)
{
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS));
}
else if (Command == 'Q')
else if (Command == AVR109_COMMAND_ReadExtendedFuses)
{
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS));
}
#if !defined(NO_BLOCK_SUPPORT)
else if (Command == 'b')
else if (Command == AVR109_COMMAND_GetBlockWriteSupport)
{
WriteNextResponseByte('Y');
@@ -472,14 +528,14 @@ void CDC_Task(void)
WriteNextResponseByte(SPM_PAGESIZE >> 8);
WriteNextResponseByte(SPM_PAGESIZE & 0xFF);
}
else if ((Command == 'B') || (Command == 'g'))
else if ((Command == AVR109_COMMAND_BlockWrite) || (Command == AVR109_COMMAND_BlockRead))
{
/* Delegate the block write/read to a separate function for clarity */
ReadWriteMemoryBlock(Command);
}
#endif
#if !defined(NO_FLASH_BYTE_SUPPORT)
else if (Command == 'C')
else if (Command == AVR109_COMMAND_FillFlashPageWordHigh)
{
/* Write the high byte to the current flash page */
boot_page_fill(CurrAddress, FetchNextCommandByte());
@@ -487,7 +543,7 @@ void CDC_Task(void)
/* Send confirmation byte back to the host */
WriteNextResponseByte('\r');
}
else if (Command == 'c')
else if (Command == AVR109_COMMAND_FillFlashPageWordLow)
{
/* Write the low byte to the current flash page */
boot_page_fill(CurrAddress | 0x01, FetchNextCommandByte());
@@ -498,7 +554,7 @@ void CDC_Task(void)
/* Send confirmation byte back to the host */
WriteNextResponseByte('\r');
}
else if (Command == 'm')
else if (Command == AVR109_COMMAND_WriteFlashPage)
{
/* Commit the flash page to memory */
boot_page_write(CurrAddress);
@@ -509,7 +565,7 @@ void CDC_Task(void)
/* Send confirmation byte back to the host */
WriteNextResponseByte('\r');
}
else if (Command == 'R')
else if (Command == AVR109_COMMAND_ReadFLASHWord)
{
#if (FLASHEND > 0xFFFF)
uint16_t ProgramWord = pgm_read_word_far(CurrAddress);
@@ -522,7 +578,7 @@ void CDC_Task(void)
}
#endif
#if !defined(NO_EEPROM_BYTE_SUPPORT)
else if (Command == 'D')
else if (Command == AVR109_COMMAND_WriteEEPROM)
{
/* Read the byte from the endpoint and write it to the EEPROM */
eeprom_write_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte());
@@ -533,7 +589,7 @@ void CDC_Task(void)
/* Send confirmation byte back to the host */
WriteNextResponseByte('\r');
}
else if (Command == 'd')
else if (Command == AVR109_COMMAND_ReadEEPROM)
{
/* Read the EEPROM byte and write it to the endpoint */
WriteNextResponseByte(eeprom_read_byte((uint8_t*)((intptr_t)(CurrAddress >> 1))));
@@ -542,14 +598,14 @@ void CDC_Task(void)
CurrAddress += 2;
}
#endif
else if (Command != 27)
else if (Command != AVR109_COMMAND_Sync)
{
/* Unknown (non-sync) command, return fail code */
WriteNextResponseByte('?');
}
/* Select the IN endpoint */
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
Endpoint_SelectEndpoint(CDC_TX_EPADDR);
/* Remember if the endpoint is completely full before clearing it */
bool IsEndpointFull = !(Endpoint_IsReadWriteAllowed());
@@ -577,7 +633,7 @@ void CDC_Task(void)
}
/* Select the OUT endpoint */
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
Endpoint_SelectEndpoint(CDC_RX_EPADDR);
/* Acknowledge the command from the host */
Endpoint_ClearOUT();

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -46,9 +46,17 @@
#include <stdbool.h>
#include "Descriptors.h"
#include "BootloaderAPI.h"
#include "Config/AppConfig.h"
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Platform/Platform.h>
/* Preprocessor Checks: */
#if !defined(__OPTIMIZE_SIZE__)
#error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
#endif
/* Macros: */
/** Version major of the CDC bootloader. */
@@ -63,16 +71,64 @@
/** Hardware version minor of the CDC bootloader. */
#define BOOTLOADER_HWVERSION_MINOR 0x00
/** Eight character bootloader firmware identifier reported to the host when requested */
/** Eight character bootloader firmware identifier reported to the host when requested. */
#define SOFTWARE_IDENTIFIER "LUFACDC"
/** Magic bootloader key to unlock forced application start mode. */
#define MAGIC_BOOT_KEY 0xDC42
/* Enums: */
/** Possible memory types that can be addressed via the bootloader. */
enum AVR109_Memories
{
MEMORY_TYPE_FLASH = 'F',
MEMORY_TYPE_EEPROM = 'E',
};
/** Possible commands that can be issued to the bootloader. */
enum AVR109_Commands
{
AVR109_COMMAND_Sync = 27,
AVR109_COMMAND_ReadEEPROM = 'd',
AVR109_COMMAND_WriteEEPROM = 'D',
AVR109_COMMAND_ReadFLASHWord = 'R',
AVR109_COMMAND_WriteFlashPage = 'm',
AVR109_COMMAND_FillFlashPageWordLow = 'c',
AVR109_COMMAND_FillFlashPageWordHigh = 'C',
AVR109_COMMAND_GetBlockWriteSupport = 'b',
AVR109_COMMAND_BlockWrite = 'B',
AVR109_COMMAND_BlockRead = 'g',
AVR109_COMMAND_ReadExtendedFuses = 'Q',
AVR109_COMMAND_ReadHighFuses = 'N',
AVR109_COMMAND_ReadLowFuses = 'F',
AVR109_COMMAND_ReadLockbits = 'r',
AVR109_COMMAND_WriteLockbits = 'l',
AVR109_COMMAND_EraseFLASH = 'e',
AVR109_COMMAND_ReadSignature = 's',
AVR109_COMMAND_ReadBootloaderSWVersion = 'V',
AVR109_COMMAND_ReadBootloaderHWVersion = 'v',
AVR109_COMMAND_ReadBootloaderIdentifier = 'S',
AVR109_COMMAND_ReadBootloaderInterface = 'p',
AVR109_COMMAND_SetCurrentAddress = 'A',
AVR109_COMMAND_ReadAutoAddressIncrement = 'a',
AVR109_COMMAND_ReadPartCode = 't',
AVR109_COMMAND_EnterProgrammingMode = 'P',
AVR109_COMMAND_LeaveProgrammingMode = 'L',
AVR109_COMMAND_SelectDeviceType = 'T',
AVR109_COMMAND_SetLED = 'x',
AVR109_COMMAND_ClearLED = 'y',
AVR109_COMMAND_ExitBootloader = 'E',
};
/* Type Defines: */
/** Type define for a non-returning pointer to the start of the loaded application in flash memory. */
typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
/* Function Prototypes: */
void CDC_Task(void);
void SetupHardware(void);
static void CDC_Task(void);
static void SetupHardware(void);
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
void EVENT_USB_Device_ConfigurationChanged(void);

View File

@@ -10,10 +10,10 @@
*
* The following list indicates what microcontrollers are compatible with this demo.
*
* - Series 7 USB AVRs (AT90USBxxx7)
* - Series 6 USB AVRs (AT90USBxxx6)
* - Series 4 USB AVRs (ATMEGAxxU4)
* - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
* \li Series 7 USB AVRs (AT90USBxxx7)
* \li Series 6 USB AVRs (AT90USBxxx6)
* \li Series 4 USB AVRs (ATMEGAxxU4)
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
*
* \section Sec_Info USB Information:
*
@@ -37,7 +37,7 @@
* <td>USBIF CDC Class Standard</td>
* </tr>
* <tr>
* <td><b>Usable Speeds:</b></td>
* <td><b>Supported USB Speeds:</b></td>
* <td>Full Speed Mode</td>
* </tr>
* </table>
@@ -47,9 +47,9 @@
* This bootloader enumerates to the host as a CDC Class device (virtual serial port), allowing for AVR109
* protocol compatible programming software to load firmware onto the AVR.
*
* Out of the box this bootloader builds for the USB1287, and will fit into 4KB of bootloader space. If
* you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU
* values in the accompanying makefile.
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
* into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
*
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
* bootloader from the normal user application.
@@ -86,32 +86,132 @@
*
* Refer to the AVRDude project documentation for additional usage instructions.
*
* \section Sec_API User Application API
*
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
*
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
* following layout:
*
* \code
* #define BOOTLOADER_API_TABLE_SIZE 32
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
*
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
*
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
*
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
* #define BOOTLOADER_CDC_SIGNATURE 0xDF00
*
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
* #define BOOTLOADER_ADDRESS_LENGTH 4
* \endcode
*
* From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
* \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
* can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
* to the value \c BOOTLOADER_CDC_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH
* memory starting from address \c BOOTLOADER_ADDRESS_START.
*
* \subsection SSec_API_MemLayout Device Memory Map
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
*
* \verbatim
* +----------------------------+ 0x0000
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | User Application |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
* | |
* | Bootloader Application |
* | (Not User App. Accessible) |
* | |
* +----------------------------+ FLASHEND - 96
* | API Table Trampolines |
* | (Not User App. Accessible) |
* +----------------------------+ FLASHEND - 32
* | Bootloader API Table |
* | (User App. Accessible) |
* +----------------------------+ FLASHEND - 8
* | Bootloader ID Constants |
* | (User App. Accessible) |
* +----------------------------+ FLASHEND
* \endverbatim
*
* \section Sec_KnownIssues Known Issues:
*
* \par On Linux machines, the CDC bootloader is unstable or inaccessible.
* A change to the \c ModemManager module in many Linux distributions causes
* this module to try to take control over inserted CDC devices, corrupting the
* datastream. A UDEV rule is required to prevent this.
* See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
*
* \par On Linux machines, the CDC bootloader is inaccessible.
* On many Linux systems, non-root users do not have automatic access to newly
* inserted CDC devices. Root privileges or a UDEV rule is required to gain
* access.
* See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
*
* \par After loading an application, it is not run automatically on startup.
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
* to run automatically when the device is reset. In most cases, the BOOTRST
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
* when needed.
*
* \section Sec_Options Project Options
*
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
*
* <table>
* <tr>
* <th><b>Define Name:</b></th>
* <th><b>Location:</b></th>
* <th><b>Description:</b></th>
* </tr>
* <tr>
* <td>NO_BLOCK_SUPPORT</td>
* <td>Makefile LUFA_OPTS</td>
* <td>AppConfig.h</td>
* <td>Define to disable memory block read/write support in the bootloader, requiring all reads and writes to be made
* using the byte-level commands.</td>
* </tr>
* <tr>
* <td>NO_EEPROM_BYTE_SUPPORT</td>
* <td>Makefile LUFA_OPTS</td>
* <td>AppConfig.h</td>
* <td>Define to disable EEPROM memory byte read/write support in the bootloader, requiring all EEPROM reads and writes
* to be made using the block-level commands.</td>
* </tr>
* <tr>
* <td>NO_FLASH_BYTE_SUPPORT</td>
* <td>Makefile LUFA_OPTS</td>
* <td>AppConfig.h</td>
* <td>Define to disable FLASH memory byte read/write support in the bootloader, requiring all FLASH reads and writes
* to be made using the block-level commands.</td>
* </tr>
* <tr>
* <td>NO_LOCK_BYTE_WRITE_SUPPORT</td>
* <td>Makefile LUFA_OPTS</td>
* <td>AppConfig.h</td>
* <td>Define to disable lock byte write support in the bootloader, preventing the lock bits from being set programmatically.</td>
* </tr>
* </table>

View File

@@ -0,0 +1,50 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief Application Configuration Header File
*
* This is a header file which is be used to configure LUFA's
* compile time options, as an alternative to the compile time
* constants supplied through a makefile.
*
* For information on what each token does, refer to the
* \ref Sec_Options section of the application documentation.
*/
#ifndef _APP_CONFIG_H_
#define _APP_CONFIG_H_
// #define NO_BLOCK_SUPPORT
// #define NO_EEPROM_BYTE_SUPPORT
// #define NO_FLASH_BYTE_SUPPORT
// #define NO_LOCK_BYTE_WRITE_SUPPORT
#endif

View File

@@ -0,0 +1,93 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief LUFA Library Configuration Header File
*
* This header file is used to configure LUFA's compile time options,
* as an alternative to the compile time constants supplied through
* a makefile.
*
* For information on what each token does, refer to the LUFA
* manual section "Summary of Compile Tokens".
*/
#ifndef _LUFA_CONFIG_H_
#define _LUFA_CONFIG_H_
#if (ARCH == ARCH_AVR8)
/* Non-USB Related Configuration Tokens: */
// #define DISABLE_TERMINAL_CODES
/* USB Class Driver Related Tokens: */
// #define HID_HOST_BOOT_PROTOCOL_ONLY
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
// #define HID_MAX_COLLECTIONS {Insert Value Here}
// #define HID_MAX_REPORTITEMS {Insert Value Here}
// #define HID_MAX_REPORT_IDS {Insert Value Here}
// #define NO_CLASS_DRIVER_AUTOFLUSH
/* General USB Driver Related Tokens: */
#define ORDERED_EP_CONFIG
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
#define USB_DEVICE_ONLY
// #define USB_HOST_ONLY
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
// #define NO_LIMITED_CONTROLLER_CONNECT
#define NO_SOF_EVENTS
/* USB Device Mode Driver Related Tokens: */
#define USE_RAM_DESCRIPTORS
// #define USE_FLASH_DESCRIPTORS
// #define USE_EEPROM_DESCRIPTORS
#define NO_INTERNAL_SERIAL
#define FIXED_CONTROL_ENDPOINT_SIZE 8
#define DEVICE_STATE_AS_GPIOR 0
#define FIXED_NUM_CONFIGURATIONS 1
// #define CONTROL_ONLY_DEVICE
// #define INTERRUPT_CONTROL_ENDPOINT
#define NO_DEVICE_REMOTE_WAKEUP
#define NO_DEVICE_SELF_POWER
/* USB Host Mode Driver Related Tokens: */
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
// #define NO_AUTO_VBUS_MANAGEMENT
// #define INVERTED_VBUS_ENABLE_LINE
#else
#error Unsupported architecture for this LUFA configuration file.
#endif
#endif

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -55,10 +55,10 @@ const USB_Descriptor_Device_t DeviceDescriptor =
.VendorID = 0x03EB,
.ProductID = 0x204A,
.ReleaseNumber = VERSION_BCD(00.01),
.ReleaseNumber = VERSION_BCD(01.00),
.ManufacturerStrIndex = NO_DESCRIPTOR,
.ProductStrIndex = 0x01,
.ManufacturerStrIndex = STRING_ID_Manufacturer,
.ProductStrIndex = STRING_ID_Product,
.SerialNumStrIndex = NO_DESCRIPTOR,
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
@@ -81,7 +81,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
.ConfigurationNumber = 1,
.ConfigurationStrIndex = NO_DESCRIPTOR,
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
},
@@ -115,7 +115,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
.Subtype = 0x02,
.Capabilities = 0x04,
.Capabilities = 0x02,
},
.CDC_Functional_Union =
@@ -131,7 +131,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
{
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
.EndpointAddress = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM),
.EndpointAddress = CDC_NOTIFICATION_EPADDR,
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
.PollingIntervalMS = 0xFF
@@ -157,20 +157,20 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
{
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
.EndpointAddress = (ENDPOINT_DIR_OUT | CDC_RX_EPNUM),
.EndpointAddress = CDC_RX_EPADDR,
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = CDC_TXRX_EPSIZE,
.PollingIntervalMS = 0x01
.PollingIntervalMS = 0x05
},
.CDC_DataInEndpoint =
{
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
.EndpointAddress = (ENDPOINT_DIR_IN | CDC_TX_EPNUM),
.EndpointAddress = CDC_TX_EPADDR,
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = CDC_TXRX_EPSIZE,
.PollingIntervalMS = 0x01
.PollingIntervalMS = 0x05
}
};
@@ -185,15 +185,26 @@ const USB_Descriptor_String_t LanguageString =
.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.
*/
const USB_Descriptor_String_t ManufacturerString =
{
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
.UnicodeString = L"Dean Camera"
};
/** 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.
*/
const USB_Descriptor_String_t ProductString =
{
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
.Header = {.Size = USB_STRING_LEN(8), .Type = DTYPE_String},
.UnicodeString = L"AVR CDC Bootloader"
.UnicodeString = L"LUFA CDC"
};
/** This function is called by the library when in device mode, and must be overridden (see LUFA library "USB Descriptors"
@@ -223,12 +234,17 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
Size = sizeof(USB_Descriptor_Configuration_t);
break;
case DTYPE_String:
if (!(DescriptorNumber))
if (DescriptorNumber == STRING_ID_Language)
{
Address = &LanguageString;
Size = LanguageString.Header.Size;
}
else
else if (DescriptorNumber == STRING_ID_Manufacturer)
{
Address = &ManufacturerString;
Size = ManufacturerString.Header.Size;
}
else if (DescriptorNumber == STRING_ID_Product)
{
Address = &ProductString;
Size = ProductString.Header.Size;

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -39,6 +39,8 @@
/* Includes: */
#include <LUFA/Drivers/USB/USB.h>
#include "Config/AppConfig.h"
/* Macros: */
#if defined(__AVR_AT90USB1287__)
#define AVR_SIGNATURE_1 0x1E
@@ -56,10 +58,6 @@
#define AVR_SIGNATURE_1 0x1E
#define AVR_SIGNATURE_2 0x96
#define AVR_SIGNATURE_3 0x82
#elif defined(__AVR_ATmega32U6__)
#define AVR_SIGNATURE_1 0x1E
#define AVR_SIGNATURE_2 0x95
#define AVR_SIGNATURE_3 0x88
#elif defined(__AVR_ATmega32U4__)
#define AVR_SIGNATURE_1 0x1E
#define AVR_SIGNATURE_2 0x95
@@ -92,14 +90,14 @@
#error The selected AVR part is not currently supported by this bootloader.
#endif
/** Endpoint number for the CDC control interface event notification endpoint. */
#define CDC_NOTIFICATION_EPNUM 2
/** Endpoint address for the CDC control interface event notification endpoint. */
#define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 2)
/** Endpoint number for the CDC data interface TX (data IN) endpoint. */
#define CDC_TX_EPNUM 3
/** Endpoint address for the CDC data interface TX (data IN) endpoint. */
#define CDC_TX_EPADDR (ENDPOINT_DIR_IN | 3)
/** Endpoint number for the CDC data interface RX (data OUT) endpoint. */
#define CDC_RX_EPNUM 4
/** Endpoint address for the CDC data interface RX (data OUT) endpoint. */
#define CDC_RX_EPADDR (ENDPOINT_DIR_OUT | 4)
/** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */
#define CDC_TXRX_EPSIZE 16
@@ -115,20 +113,31 @@
typedef struct
{
USB_Descriptor_Configuration_Header_t Config;
// CDC Control Interface
USB_Descriptor_Interface_t CDC_CCI_Interface;
USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header;
USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM;
USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union;
USB_Descriptor_Endpoint_t CDC_NotificationEndpoint;
// CDC Data Interface
USB_Descriptor_Interface_t CDC_DCI_Interface;
USB_Descriptor_Endpoint_t CDC_DataOutEndpoint;
USB_Descriptor_Endpoint_t CDC_DataInEndpoint;
} USB_Descriptor_Configuration_t;
/** Enum for the device string descriptor IDs within the device. Each string descriptor should
* have a unique ID index associated with it, which can be used to refer to the string from
* other descriptors.
*/
enum StringDescriptors_t
{
STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
STRING_ID_Product = 2, /**< Product string ID */
};
/* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,

File diff suppressed because it is too large Load Diff

View File

@@ -1,78 +1,36 @@
;************************************************************
; Windows USB CDC ACM Setup File
; Copyright (c) 2000 Microsoft Corporation
;************************************************************
[Version]
Signature="$Windows NT$"
Class=Ports
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
Provider=%MFGNAME%
LayoutFile=layout.inf
CatalogFile=%MFGFILENAME%.cat
DriverVer=11/15/2007,5.1.2600.0
DriverVer=7/1/2012,10.0.0.0
[Manufacturer]
%MFGNAME%=DeviceList, NTamd64
%MFGNAME%=DeviceList, NTx86, NTamd64, NTia64
[SourceDisksNames]
[SourceDisksFiles]
[DestinationDirs]
DefaultDestDir=12
[DriverInstall]
Include=mdmcpq.inf
CopyFiles=FakeModemCopyFileSection
AddReg=DriverInstall.AddReg
;------------------------------------------------------------------------------
; Windows 2000/XP/Vista-32bit Sections
;------------------------------------------------------------------------------
[DriverInstall.nt]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.nt
AddReg=DriverInstall.nt.AddReg
[DriverCopyFiles.nt]
usbser.sys,,,0x20
[DriverInstall.nt.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
[DriverInstall.nt.Services]
AddService=usbser, 0x00000002, DriverService.nt
[DriverService.nt]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\%DRIVERFILENAME%.sys
;------------------------------------------------------------------------------
; Vista-64bit Sections
;------------------------------------------------------------------------------
[DriverInstall.NTamd64]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.NTamd64
AddReg=DriverInstall.NTamd64.AddReg
[DriverCopyFiles.NTamd64]
%DRIVERFILENAME%.sys,,,0x20
[DriverInstall.NTamd64.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
[DriverInstall.NTamd64.Services]
AddService=usbser, 0x00000002, DriverService.NTamd64
[DriverService.NTamd64]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\%DRIVERFILENAME%.sys
[DriverInstall.Services]
Include=mdmcpq.inf
AddService=usbser, 0x00000002, LowerFilter_Service_Inst
[DriverInstall.AddReg]
HKR,,EnumPropPages32,,"msports.dll,SerialPortPropPageProvider"
;------------------------------------------------------------------------------
; Vendor and Product ID Definitions
@@ -83,14 +41,17 @@ ServiceBinary=%12%\%DRIVERFILENAME%.sys
; Note: One INF file can be used for multiple devices with different VID and PIDs.
; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
;------------------------------------------------------------------------------
[SourceDisksFiles]
[SourceDisksNames]
[DeviceList]
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A
[DeviceList.NTx86]
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A
[DeviceList.NTamd64]
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A
[DeviceList.NTia64]
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A
;------------------------------------------------------------------------------
; String Definitions
@@ -98,9 +59,5 @@ ServiceBinary=%12%\%DRIVERFILENAME%.sys
;Modify these strings to customize your device
;------------------------------------------------------------------------------
[Strings]
MFGFILENAME="CDC_vista"
DRIVERFILENAME ="usbser"
MFGNAME="http://www.lufa-lib.org"
INSTDISK="LUFA CDC Bootloader Driver Installer"
DESCRIPTION="Communications Port"
SERVICE="USB RS-232 Emulation Driver"
DESCRIPTION="LUFA CDC Class Bootloader"

160
Bootloaders/CDC/asf.xml Normal file
View File

@@ -0,0 +1,160 @@
<asf xmlversion="1.0">
<project caption="CDC Bootloader - 128KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.cdc.avr8.128_4" force-caption="true" workspace-name="lufa_cdc_128kb_4kb_">
<require idref="lufa.bootloaders.cdc"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="at90usb1287"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x1F000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1F000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FFA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FFE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FFF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="CDC Bootloader - 64KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.cdc.avr8.64_4" force-caption="true" workspace-name="lufa_cdc_64kb_4kb_">
<require idref="lufa.bootloaders.cdc"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="at90usb647"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0xF000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0xF000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0xFFA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0xFFE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0xFFF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="CDC Bootloader - 32KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.cdc.avr8.32_4" force-caption="true" workspace-name="lufa_cdc_32kb_4kb_">
<require idref="lufa.bootloaders.cdc"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega32u4"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x7000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x7000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x7FA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x7FE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x7FF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="CDC Bootloader - 16KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.cdc.avr8.16_4" force-caption="true" workspace-name="lufa_cdc_16kb_4kb_">
<require idref="lufa.bootloaders.cdc"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega16u2"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x3000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x3000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x3FA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x3FE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x3FF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="CDC Bootloader - 8KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.cdc.avr8.8_4" force-caption="true" workspace-name="lufa_cdc_8kb_4kb_">
<require idref="lufa.bootloaders.cdc"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega8u2"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x1000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<module type="application" id="lufa.bootloaders.cdc" caption="CDC Bootloader">
<info type="description" value="summary">
CDC Class Bootloader, capable of reprogramming a device using avrdude or other AVR109 protocol compliant software when plugged into a host.
</info>
<info type="gui-flag" value="move-to-root"/>
<info type="keyword" value="Technology">
<keyword value="Bootloaders"/>
<keyword value="USB Device"/>
</info>
<device-support-alias value="lufa_avr8"/>
<device-support-alias value="lufa_xmega"/>
<device-support-alias value="lufa_uc3"/>
<build type="include-path" value="."/>
<build type="c-source" value="BootloaderCDC.c"/>
<build type="header-file" value="BootloaderCDC.h"/>
<build type="c-source" value="Descriptors.c"/>
<build type="header-file" value="Descriptors.h"/>
<build type="c-source" value="BootloaderAPI.c"/>
<build type="header-file" value="BootloaderAPI.h"/>
<build type="asm-source" value="BootloaderAPITable.S"/>
<build type="module-config" subtype="path" value="Config"/>
<build type="header-file" value="Config/LUFAConfig.h"/>
<build type="header-file" value="Config/AppConfig.h"/>
<build type="distribute" subtype="user-file" value="BootloaderCDC.txt"/>
<build type="distribute" subtype="user-file" value="LUFA CDC Bootloader.inf"/>
<require idref="lufa.common"/>
<require idref="lufa.platform"/>
<require idref="lufa.drivers.usb"/>
<require idref="lufa.drivers.board"/>
<require idref="lufa.drivers.board.leds"/>
</module>
</asf>

View File

@@ -1,717 +1,55 @@
# 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
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# 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
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
#----------------------------------------------------------------------------
# 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 = at90usb1287
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# 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 = USBKEY
# 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_USB below, as it is sourced by
# F_USB 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 = 8000000
# Input clock frequency.
# This will define a symbol, F_USB, 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_USB = $(F_CPU)
# Starting byte address of the bootloader, as a byte address - computed via the formula
# BOOT_START = ((FLASH_SIZE_KB - BOOT_SECTION_SIZE_KB) * 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.
FLASH_SIZE_KB = 128
BOOT_SECTION_SIZE_KB = 4
BOOT_START = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc)
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
# Target file name (without extension).
TARGET = BootloaderCDC
# 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 ORDERED_EP_CONFIG
LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
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_SOF_EVENTS
#LUFA_OPTS += -D NO_BLOCK_SUPPORT
#LUFA_OPTS += -D NO_EEPROM_BYTE_SUPPORT
#LUFA_OPTS += -D NO_FLASH_BYTE_SUPPORT
#LUFA_OPTS += -D NO_LOCK_BYTE_WRITE_SUPPORT
# 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 += -DF_USB=$(F_USB)UL
CDEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
CDEFS += $(LUFA_OPTS)
# Place -D or -U options here for ASM sources
ADEFS = -DF_CPU=$(F_CPU)
ADEFS += -DF_USB=$(F_USB)UL
ADEFS += -DBOARD=BOARD_$(BOARD)
ADEFS += -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_USB=$(F_USB)UL
CPPDEFS += -DBOARD=BOARD_$(BOARD)
CPPDEFS += -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) ----------------
# Programming hardware
# Type: avrdude -c ?
# to get a full listing.
#
AVRDUDE_PROGRAMMER = jtagmkII
# 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 <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_VERBOSE = -v -v
AVRDUDE_FLAGS = -p $(MCU) -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)
# 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) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
$(REMOVE) $(SRC:.c=.i)
$(REMOVEDIR) .dep
doxygen:
@echo Generating Project Documentation \($(TARGET)\)...
@doxygen Doxygen.conf
@echo Documentation Generation Complete.
clean_doxygen:
rm -rf Documentation
checksource:
@for f in $(SRC) $(CPPSRC) $(ASRC); do \
if [ -f $$f ]; then \
echo "Found Source File: $$f" ; \
else \
echo "Source File Not Found: $$f" ; \
fi; done
# 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 checksource
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------
# Run "make help" for target help.
MCU = at90usb1287
ARCH = AVR8
BOARD = USBKEY
F_CPU = 8000000
F_USB = $(F_CPU)
OPTIMIZATION = s
TARGET = BootloaderCDC
SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S $(LUFA_SRC_USB)
LUFA_PATH = ../../LUFA
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DBOOT_START_ADDR=$(BOOT_START_OFFSET)
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAGS)
# Flash size and bootloader section sizes of the target, in KB. These must
# match the target's total FLASH size and the bootloader size set in the
# device's fuses.
FLASH_SIZE_KB = 128
BOOT_SECTION_SIZE_KB = 8
# Bootloader address calculation formulas
# Do not modify these macros, but rather modify the dependent values above.
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
# Bootloader linker section flags for relocating the API table sections to
# known FLASH addresses - these should not normally be user-edited.
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
# Default target
all:
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk
include $(LUFA_PATH)/Build/lufa_sources.mk
include $(LUFA_PATH)/Build/lufa_build.mk
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
include $(LUFA_PATH)/Build/lufa_doxygen.mk
include $(LUFA_PATH)/Build/lufa_avrdude.mk
include $(LUFA_PATH)/Build/lufa_atprogram.mk

View File

@@ -0,0 +1,76 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
*
* Bootloader user application API functions.
*/
#include "BootloaderAPI.h"
void BootloaderAPI_ErasePage(const uint32_t Address)
{
boot_page_erase_safe(Address);
boot_spm_busy_wait();
boot_rww_enable();
}
void BootloaderAPI_WritePage(const uint32_t Address)
{
boot_page_write_safe(Address);
boot_spm_busy_wait();
boot_rww_enable();
}
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
{
boot_page_fill_safe(Address, Word);
}
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
{
return boot_signature_byte_get(Address);
}
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
{
return boot_lock_fuse_bits_get(Address);
}
uint8_t BootloaderAPI_ReadLock(void)
{
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
}
void BootloaderAPI_WriteLock(const uint8_t LockBits)
{
boot_lock_bits_set_safe(LockBits);
}

View File

@@ -0,0 +1,58 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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 BootloaderAPI.c.
*/
#ifndef _BOOTLOADER_API_H_
#define _BOOTLOADER_API_H_
/* Includes: */
#include <avr/io.h>
#include <avr/boot.h>
#include <stdbool.h>
#include <LUFA/Common/Common.h>
#include "Config/AppConfig.h"
/* Function Prototypes: */
void BootloaderAPI_ErasePage(const uint32_t Address);
void BootloaderAPI_WritePage(const uint32_t Address);
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
uint8_t BootloaderAPI_ReadLock(void);
void BootloaderAPI_WriteLock(const uint8_t LockBits);
#endif

View File

@@ -0,0 +1,91 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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.
*/
; Trampolines to actual API implementations if the target address is outside the
; range of a rjmp instruction (can happen with large bootloader sections)
.section .apitable_trampolines, "ax"
.global BootloaderAPI_Trampolines
BootloaderAPI_Trampolines:
BootloaderAPI_ErasePage_Trampoline:
jmp BootloaderAPI_ErasePage
BootloaderAPI_WritePage_Trampoline:
jmp BootloaderAPI_WritePage
BootloaderAPI_FillWord_Trampoline:
jmp BootloaderAPI_FillWord
BootloaderAPI_ReadSignature_Trampoline:
jmp BootloaderAPI_ReadSignature
BootloaderAPI_ReadFuse_Trampoline:
jmp BootloaderAPI_ReadFuse
BootloaderAPI_ReadLock_Trampoline:
jmp BootloaderAPI_ReadLock
BootloaderAPI_WriteLock_Trampoline:
jmp BootloaderAPI_WriteLock
BootloaderAPI_UNUSED1:
ret
BootloaderAPI_UNUSED2:
ret
BootloaderAPI_UNUSED3:
ret
BootloaderAPI_UNUSED4:
ret
BootloaderAPI_UNUSED5:
ret
; API function jump table
.section .apitable_jumptable, "ax"
.global BootloaderAPI_JumpTable
BootloaderAPI_JumpTable:
rjmp BootloaderAPI_ErasePage_Trampoline
rjmp BootloaderAPI_WritePage_Trampoline
rjmp BootloaderAPI_FillWord_Trampoline
rjmp BootloaderAPI_ReadSignature_Trampoline
rjmp BootloaderAPI_ReadFuse_Trampoline
rjmp BootloaderAPI_ReadLock_Trampoline
rjmp BootloaderAPI_WriteLock_Trampoline
rjmp BootloaderAPI_UNUSED1 ; UNUSED ENTRY 1
rjmp BootloaderAPI_UNUSED2 ; UNUSED ENTRY 2
rjmp BootloaderAPI_UNUSED3 ; UNUSED ENTRY 3
rjmp BootloaderAPI_UNUSED4 ; UNUSED ENTRY 4
rjmp BootloaderAPI_UNUSED5 ; UNUSED ENTRY 5
; Bootloader table signatures and information
.section .apitable_signatures, "ax"
.global BootloaderAPI_Signatures
BootloaderAPI_Signatures:
.long BOOT_START_ADDR ; Start address of the bootloader
.word 0xDF10 ; Signature for the DFU class bootloader, V1
.word 0xDCFB ; Signature for a LUFA class bootloader

View File

@@ -1 +0,0 @@
<AVRStudio><MANAGEMENT><ProjectName>BootloaderDFU</ProjectName><Created>13-Jul-2010 14:42:28</Created><LastEdit>13-Jul-2010 14:46:54</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:42:28</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderDFU.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\DFU\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderDFU.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderDFU.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderDFU.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -92,6 +92,55 @@ static uint16_t StartAddr = 0x0000;
*/
static uint16_t EndAddr = 0x0000;
/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
* will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
* low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
* \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
*/
uint16_t MagicBootKey ATTR_NO_INIT;
/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
* start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
* this will force the user application to start via a software jump.
*/
void Application_Jump_Check(void)
{
bool JumpToApplication = false;
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
/* Disable JTAG debugging */
JTAG_DISABLE();
/* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */
PORTF |= (1 << 4);
Delay_MS(10);
/* If the TCK pin is not jumpered to ground, start the user application instead */
JumpToApplication |= ((PINF & (1 << 4)) != 0);
/* Re-enable JTAG debugging */
JTAG_ENABLE();
#endif
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
JumpToApplication |= true;
/* If a request has been made to jump to the user application, honor it */
if (JumpToApplication)
{
/* Turn off the watchdog */
MCUSR &= ~(1<<WDRF);
wdt_disable();
/* Clear the boot key and jump to the user application */
MagicBootKey = 0;
// cppcheck-suppress constStatement
((void (*)(void))0x0000)();
}
}
/** 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
@@ -102,28 +151,11 @@ int main(void)
/* Configure hardware required by the bootloader */
SetupHardware();
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
/* Disable JTAG debugging */
MCUCR |= (1 << JTD);
MCUCR |= (1 << JTD);
/* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */
PORTF |= (1 << 4);
Delay_MS(10);
/* If the TCK pin is not jumpered to ground, start the user application instead */
RunBootloader = (!(PINF & (1 << 4)));
/* Re-enable JTAG debugging */
MCUCR &= ~(1 << JTD);
MCUCR &= ~(1 << JTD);
#endif
/* Turn on first LED on the board to indicate that the bootloader has started */
LEDs_SetAllLEDs(LEDS_LED1);
/* Enable global interrupts so that the USB stack can function */
sei();
GlobalInterruptEnable();
/* Run the USB management task while the bootloader is supposed to be running */
while (RunBootloader || WaitForExit)
@@ -137,7 +169,7 @@ int main(void)
}
/** Configures all hardware required for the bootloader. */
void SetupHardware(void)
static void SetupHardware(void)
{
/* Disable watchdog if enabled by bootloader/fuses */
MCUSR &= ~(1 << WDRF);
@@ -150,20 +182,25 @@ void SetupHardware(void)
MCUCR = (1 << IVCE);
MCUCR = (1 << IVSEL);
/* Initialize the USB subsystem */
/* Initialize the USB and other board hardware drivers */
USB_Init();
LEDs_Init();
/* Bootloader active LED toggle timer initialization */
TIMSK1 = (1 << TOIE1);
TCCR1B = ((1 << CS11) | (1 << CS10));
}
/** Resets all configured hardware required for the bootloader back to their original states. */
void ResetHardware(void)
static void ResetHardware(void)
{
/* Shut down the USB subsystem */
/* Shut down the USB and other board hardware drivers */
USB_Disable();
LEDs_Disable();
/* Disable Bootloader active LED toggle timer */
TIMSK1 = 0;
TCCR1B = 0;
/* Relocate the interrupt vector table back to the application section */
MCUCR = (1 << IVCE);
@@ -181,7 +218,7 @@ ISR(TIMER1_OVF_vect, ISR_BLOCK)
* internally.
*/
void EVENT_USB_Device_ControlRequest(void)
{
{
/* Ignore any requests that aren't directed to the DFU interface */
if ((USB_ControlRequest.bmRequestType & (CONTROL_REQTYPE_TYPE | CONTROL_REQTYPE_RECIPIENT)) !=
(REQTYPE_CLASS | REQREC_INTERFACE))
@@ -452,6 +489,12 @@ void EVENT_USB_Device_ControlRequest(void)
case DFU_REQ_GETSTATUS:
Endpoint_ClearSETUP();
while (!(Endpoint_IsINReady()))
{
if (USB_DeviceState == DEVICE_STATE_Unattached)
return;
}
/* Write 8-bit status value */
Endpoint_Write_8(DFU_Status);
@@ -480,6 +523,12 @@ void EVENT_USB_Device_ControlRequest(void)
case DFU_REQ_GETSTATE:
Endpoint_ClearSETUP();
while (!(Endpoint_IsINReady()))
{
if (USB_DeviceState == DEVICE_STATE_Unattached)
return;
}
/* Write the current device state to the endpoint */
Endpoint_Write_8(DFU_State);
@@ -640,7 +689,7 @@ static void ProcessMemReadCommand(void)
{
uint32_t CurrFlashAddress = 0;
while (CurrFlashAddress < BOOT_START_ADDR)
while (CurrFlashAddress < (uint32_t)BOOT_START_ADDR)
{
/* Check if the current byte is not blank */
#if (FLASHEND > 0xFFFF)
@@ -694,6 +743,9 @@ static void ProcessWriteCommand(void)
{
if (SentCommand.Data[1] == 0x00) // Start via watchdog
{
/* Unlock the forced application start mode of the bootloader if it is restarted */
MagicBootKey = MAGIC_BOOT_KEY;
/* Start the watchdog to reset the AVR once the communications are finalized */
wdt_enable(WDTO_250MS);
}
@@ -709,7 +761,7 @@ static void ProcessWriteCommand(void)
uint32_t CurrFlashAddress = 0;
/* Clear the application section of flash */
while (CurrFlashAddress < BOOT_START_ADDR)
while (CurrFlashAddress < (uint32_t)BOOT_START_ADDR)
{
boot_page_erase(CurrFlashAddress);
boot_spm_busy_wait();

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -48,24 +48,28 @@
#include <stdbool.h>
#include "Descriptors.h"
#include "BootloaderAPI.h"
#include "Config/AppConfig.h"
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Platform/Platform.h>
/* Preprocessor Checks: */
#if !defined(__OPTIMIZE_SIZE__)
#error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
#endif
/* Macros: */
/** 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
/** Magic bootloader key to unlock forced application start mode. */
#define MAGIC_BOOT_KEY 0xDC42
/** Complete bootloader version number expressed as a packed byte, constructed from the
* two individual bootloader version macros.
*/
@@ -147,7 +151,7 @@
/** 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 Command; /**< Single byte command to perform, one of the \c COMMAND_* macro values */
uint8_t Data[5]; /**< Command parameters */
uint16_t DataSize; /**< Size of the command parameters */
} DFU_Command_t;
@@ -191,8 +195,8 @@
};
/* Function Prototypes: */
void SetupHardware(void);
void ResetHardware(void);
static void SetupHardware(void);
static void ResetHardware(void);
void EVENT_USB_Device_ControlRequest(void);
@@ -206,5 +210,7 @@
static void ProcessReadCommand(void);
#endif
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
#endif

View File

@@ -10,10 +10,10 @@
*
* The following list indicates what microcontrollers are compatible with this demo.
*
* - Series 7 USB AVRs (AT90USBxxx7)
* - Series 6 USB AVRs (AT90USBxxx6)
* - Series 4 USB AVRs (ATMEGAxxU4)
* - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
* \li Series 7 USB AVRs (AT90USBxxx7)
* \li Series 6 USB AVRs (AT90USBxxx6)
* \li Series 4 USB AVRs (ATMEGAxxU4) - <i>See \ref SSec_Aux_Space</i>
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) - <i>See \ref SSec_Aux_Space</i>
*
* \section Sec_Info USB Information:
*
@@ -37,8 +37,9 @@
* <td>USBIF DFU Class Standard, Atmel USB Bootloader Datasheet</td>
* </tr>
* <tr>
* <td><b>Usable Speeds:</b></td>
* <td>Full Speed Mode</td>
* <td><b>Supported USB Speeds:</b></td>
* <td>Low Speed Mode \n
* Full Speed Mode</td>
* </tr>
* </table>
*
@@ -47,9 +48,9 @@
* This bootloader enumerates to the host as a DFU Class device, allowing for DFU-compatible programming
* software to load firmware onto the AVR.
*
* Out of the box this bootloader builds for the USB1287, and should fit into 4KB of bootloader space. If
* you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU
* values in the accompanying makefile.
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
* into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
*
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
* bootloader from the normal user application.
@@ -67,7 +68,7 @@
* manually change them in Descriptors.c and alter your driver's INF file accordingly.
*
* \section Sec_HostApp Host Controller Application
*
*
* This bootloader is compatible with Atmel's FLIP utility on Windows machines, and dfu-programmer on Linux machines.
*
* \subsection SSec_FLIP FLIP (Windows)
@@ -89,22 +90,127 @@
* dfu-programmer at90usb1287 erase flash Mouse.hex
* \endcode
*
* \section Sec_API User Application API
*
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
*
* \warning The APIs exposed by the DFU class bootloader are \b NOT compatible with the API exposed by the official Atmel DFU bootloader.
*
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
* following layout:
*
* \code
* #define BOOTLOADER_API_TABLE_SIZE 32
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
*
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
*
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
*
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
* #define BOOTLOADER_DFU_SIGNATURE 0xDF10
*
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
* #define BOOTLOADER_ADDRESS_LENGTH 4
* \endcode
*
* From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
* \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
* can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
* to the value \c BOOTLOADER_DFU_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH
* memory starting from address \c BOOTLOADER_ADDRESS_START.
*
* \subsection SSec_API_MemLayout Device Memory Map
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
*
* \verbatim
* +----------------------------+ 0x0000
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | User Application |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* +----------------------------+ FLASHEND - BOOT_AUX_SECTION_SIZE
* | Booloader Start Trampoline |
* | (Not User App. Accessible) |
* +----------------------------+ FLASHEND - (BOOT_AUX_SECTION_SIZE - 4)
* | |
* | Auxillery Bootloader |
* | Space for Smaller Devices |
* | (Not User App. Accessible) |
* | |
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
* | |
* | Bootloader Application |
* | (Not User App. Accessible) |
* | |
* +----------------------------+ FLASHEND - 96
* | API Table Trampolines |
* | (Not User App. Accessible) |
* +----------------------------+ FLASHEND - 32
* | Bootloader API Table |
* | (User App. Accessible) |
* +----------------------------+ FLASHEND - 8
* | Bootloader ID Constants |
* | (User App. Accessible) |
* +----------------------------+ FLASHEND
* \endverbatim
*
* \subsection SSec_Aux_Space Auxiliary Bootloader Section
* To make the bootloader function on smaller devices (those with a physical
* bootloader section of smaller than 6KB)
*
* \section Sec_KnownIssues Known Issues:
*
* \par On Linux machines, the DFU bootloader is inaccessible.
* On many Linux systems, non-root users do not have automatic access to newly
* inserted DFU devices. Root privileges or a UDEV rule is required to gain
* access.
* See <a href=https://groups.google.com/d/msg/lufa-support/CP9cy2bc8yo/kBqsOu-RBeMJ>here</a> for resolution steps.
*
* \par After loading an application, it is not run automatically on startup.
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
* to run automatically when the device is reset. In most cases, the BOOTRST
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
* when needed.
*
* \section Sec_Options Project Options
*
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
*
* <table>
* <tr>
* <td><b>Define Name:</b></td>
* <td><b>Location:</b></td>
* <td><b>Description:</b></td>
* <th><b>Define Name:</b></th>
* <th><b>Location:</b></th>
* <th><b>Description:</b></th>
* </tr>
* <tr>
* <td>SECURE_MODE</td>
* <td>BootloaderDFU.h</td>
* <td>If defined to true, the bootloader will not accept any memory commands other than a chip erase on start-up, until an
* <td>AppConfig.h</td>
* <td>If defined to \c true, the bootloader will not accept any memory commands other than a chip erase on start-up, until an
* erase has been performed. This can be used in conjunction with the AVR's lockbits to prevent the AVRs firmware from
* being dumped by unauthorized persons.</td>
* being dumped by unauthorized persons. When false, all memory operations are allowed at any time.</td>
* </tr>
* </table>
*/

View File

@@ -0,0 +1,48 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief Application Configuration Header File
*
* This is a header file which is be used to configure some of
* the application's compile time options, as an alternative to
* specifying the compile time constants supplied through a
* makefile or build system.
*
* For information on what each token does, refer to the
* \ref Sec_Options section of the application documentation.
*/
#ifndef _APP_CONFIG_H_
#define _APP_CONFIG_H_
#define SECURE_MODE false
#endif

View File

@@ -0,0 +1,93 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief LUFA Library Configuration Header File
*
* This header file is used to configure LUFA's compile time options,
* as an alternative to the compile time constants supplied through
* a makefile.
*
* For information on what each token does, refer to the LUFA
* manual section "Summary of Compile Tokens".
*/
#ifndef _LUFA_CONFIG_H_
#define _LUFA_CONFIG_H_
#if (ARCH == ARCH_AVR8)
/* Non-USB Related Configuration Tokens: */
// #define DISABLE_TERMINAL_CODES
/* USB Class Driver Related Tokens: */
// #define HID_HOST_BOOT_PROTOCOL_ONLY
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
// #define HID_MAX_COLLECTIONS {Insert Value Here}
// #define HID_MAX_REPORTITEMS {Insert Value Here}
// #define HID_MAX_REPORT_IDS {Insert Value Here}
// #define NO_CLASS_DRIVER_AUTOFLUSH
/* General USB Driver Related Tokens: */
// #define ORDERED_EP_CONFIG
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
#define USB_DEVICE_ONLY
// #define USB_HOST_ONLY
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
// #define NO_LIMITED_CONTROLLER_CONNECT
#define NO_SOF_EVENTS
/* USB Device Mode Driver Related Tokens: */
#define USE_RAM_DESCRIPTORS
// #define USE_FLASH_DESCRIPTORS
// #define USE_EEPROM_DESCRIPTORS
#define NO_INTERNAL_SERIAL
#define FIXED_CONTROL_ENDPOINT_SIZE 32
#define DEVICE_STATE_AS_GPIOR 0
#define FIXED_NUM_CONFIGURATIONS 1
#define CONTROL_ONLY_DEVICE
// #define INTERRUPT_CONTROL_ENDPOINT
#define NO_DEVICE_REMOTE_WAKEUP
#define NO_DEVICE_SELF_POWER
/* USB Host Mode Driver Related Tokens: */
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
// #define NO_AUTO_VBUS_MANAGEMENT
// #define INVERTED_VBUS_ENABLE_LINE
#else
#error Unsupported architecture for this LUFA configuration file.
#endif
#endif

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -57,8 +57,8 @@ const USB_Descriptor_Device_t DeviceDescriptor =
.ProductID = PRODUCT_ID_CODE,
.ReleaseNumber = VERSION_BCD(00.00),
.ManufacturerStrIndex = NO_DESCRIPTOR,
.ProductStrIndex = 0x01,
.ManufacturerStrIndex = STRING_ID_Manufacturer,
.ProductStrIndex = STRING_ID_Product,
.SerialNumStrIndex = NO_DESCRIPTOR,
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
@@ -81,7 +81,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
.ConfigurationNumber = 1,
.ConfigurationStrIndex = NO_DESCRIPTOR,
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
},
@@ -111,7 +111,7 @@ const USB_Descriptor_Configuration_t ConfigurationDescriptor =
.DetachTimeout = 0x0000,
.TransferSize = 0x0C00,
.DFUSpecification = VERSION_BCD(01.01)
.DFUSpecification = VERSION_BCD(01.10)
}
};
@@ -126,15 +126,26 @@ const USB_Descriptor_String_t LanguageString =
.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.
*/
const USB_Descriptor_String_t ManufacturerString =
{
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
.UnicodeString = L"Dean Camera"
};
/** 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.
*/
const USB_Descriptor_String_t ProductString =
{
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
.Header = {.Size = USB_STRING_LEN(8), .Type = DTYPE_String},
.UnicodeString = L"AVR DFU Bootloader"
.UnicodeString = L"LUFA DFU"
};
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
@@ -159,25 +170,30 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
Address = &DeviceDescriptor;
Size = sizeof(USB_Descriptor_Device_t);
break;
case DTYPE_Configuration:
case DTYPE_Configuration:
Address = &ConfigurationDescriptor;
Size = sizeof(USB_Descriptor_Configuration_t);
break;
case DTYPE_String:
if (!(DescriptorNumber))
case DTYPE_String:
if (DescriptorNumber == STRING_ID_Language)
{
Address = &LanguageString;
Size = LanguageString.Header.Size;
}
else
else if (DescriptorNumber == STRING_ID_Manufacturer)
{
Address = &ManufacturerString;
Size = ManufacturerString.Header.Size;
}
else if (DescriptorNumber == STRING_ID_Product)
{
Address = &ProductString;
Size = ProductString.Header.Size;
}
break;
}
*DescriptorAddress = Address;
return Size;
}

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -39,6 +39,8 @@
/* Includes: */
#include <LUFA/Drivers/USB/USB.h>
#include "Config/AppConfig.h"
/* Macros: */
/** Descriptor type value for a DFU class functional descriptor. */
#define DTYPE_DFUFunctional 0x21
@@ -83,11 +85,6 @@
#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
@@ -114,12 +111,12 @@
#define AVR_SIGNATURE_2 0x94
#define AVR_SIGNATURE_3 0x82
#elif defined(__AVR_ATmega8U2__)
#define PRODUCT_ID_CODE 0x2FF7
#define PRODUCT_ID_CODE 0x2FEE
#define AVR_SIGNATURE_1 0x1E
#define AVR_SIGNATURE_2 0x93
#define AVR_SIGNATURE_3 0x89
#elif defined(__AVR_AT90USB82__)
#define PRODUCT_ID_CODE 0x2FEE
#define PRODUCT_ID_CODE 0x2FF7
#define AVR_SIGNATURE_1 0x1E
#define AVR_SIGNATURE_2 0x94
#define AVR_SIGNATURE_3 0x82
@@ -161,12 +158,23 @@
typedef struct
{
USB_Descriptor_Configuration_Header_t Config;
// DFU Interface
USB_Descriptor_Interface_t DFU_Interface;
USB_Descriptor_DFU_Functional_t DFU_Functional;
} USB_Descriptor_Configuration_t;
/** Enum for the device string descriptor IDs within the device. Each string descriptor should
* have a unique ID index associated with it, which can be used to refer to the string from
* other descriptors.
*/
enum StringDescriptors_t
{
STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
STRING_ID_Product = 2, /**< Product string ID */
};
/* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,

File diff suppressed because it is too large Load Diff

155
Bootloaders/DFU/asf.xml Normal file
View File

@@ -0,0 +1,155 @@
<asf xmlversion="1.0">
<project caption="DFU Bootloader - 128KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.dfu.avr8.128_4" force-caption="true" workspace-name="lufa_dfu_128kb_4kb_">
<require idref="lufa.bootloaders.dfu"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="at90usb1287"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x1F000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1F000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FFA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FFE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FFF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="DFU Bootloader - 64KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.dfu.avr8.64_4" force-caption="true" workspace-name="lufa_dfu_64kb_4kb_">
<require idref="lufa.bootloaders.dfu"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="at90usb647"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0xF000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0xF000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0xFFA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0xFFE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0xFFF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="DFU Bootloader - 32KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.dfu.avr8.32_4" force-caption="true" workspace-name="lufa_dfu_32kb_4kb_">
<require idref="lufa.bootloaders.dfu"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega32u4"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x7000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x7000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x7FA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x7FE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x7FF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="DFU Bootloader - 16KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.dfu.avr8.16_4" force-caption="true" workspace-name="lufa_dfu_16kb_4kb_">
<require idref="lufa.bootloaders.dfu"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega16u2"/>
<config name="lufa.drivers.board.name" value="none"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x3000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x3000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x3FA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x3FE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x3FF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="DFU Bootloader - 8KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.dfu.avr8.8_4" force-caption="true" workspace-name="lufa_dfu_8kb_4kb_">
<require idref="lufa.bootloaders.dfu"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega8u2"/>
<config name="lufa.drivers.board.name" value="none"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x1000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<module type="application" id="lufa.bootloaders.dfu" caption="DFU Bootloader">
<info type="description" value="summary">
DFU Class Bootloader, capable of reprogramming a device using the Atmel FLIP or other AVR DFU programming software when plugged into a host.
</info>
<info type="gui-flag" value="move-to-root"/>
<info type="keyword" value="Technology">
<keyword value="Bootloaders"/>
<keyword value="USB Device"/>
</info>
<device-support-alias value="lufa_avr8"/>
<device-support-alias value="lufa_xmega"/>
<device-support-alias value="lufa_uc3"/>
<build type="include-path" value="."/>
<build type="c-source" value="BootloaderDFU.c"/>
<build type="header-file" value="BootloaderDFU.h"/>
<build type="c-source" value="Descriptors.c"/>
<build type="header-file" value="Descriptors.h"/>
<build type="c-source" value="BootloaderAPI.c"/>
<build type="header-file" value="BootloaderAPI.h"/>
<build type="asm-source" value="BootloaderAPITable.S"/>
<build type="module-config" subtype="path" value="Config"/>
<build type="header-file" value="Config/LUFAConfig.h"/>
<build type="header-file" value="Config/AppConfig.h"/>
<build type="distribute" subtype="user-file" value="BootloaderDFU.txt"/>
<require idref="lufa.common"/>
<require idref="lufa.platform"/>
<require idref="lufa.drivers.usb"/>
<require idref="lufa.drivers.board"/>
<require idref="lufa.drivers.board.leds"/>
</module>
</asf>

View File

@@ -1,712 +1,55 @@
# 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
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# 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
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
#----------------------------------------------------------------------------
# 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 = at90usb1287
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# 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 = USBKEY
# 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_USB below, as it is sourced by
# F_USB 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 = 8000000
# Input clock frequency.
# This will define a symbol, F_USB, 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_USB = $(F_CPU)
# Starting byte address of the bootloader, as a byte address - computed via the formula
# BOOT_START = ((FLASH_SIZE_KB - BOOT_SECTION_SIZE_KB) * 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.
FLASH_SIZE_KB = 128
BOOT_SECTION_SIZE_KB = 4
BOOT_START = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc)
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
# Target file name (without extension).
TARGET = BootloaderDFU
# 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_SOF_EVENTS
# 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 += -DF_USB=$(F_USB)UL
CDEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
CDEFS += $(LUFA_OPTS)
# Place -D or -U options here for ASM sources
ADEFS = -DF_CPU=$(F_CPU)
ADEFS += -DF_USB=$(F_USB)UL
ADEFS += -DBOARD=BOARD_$(BOARD)
ADEFS += -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_USB=$(F_USB)UL
CPPDEFS += -DBOARD=BOARD_$(BOARD)
CPPDEFS += -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) ----------------
# Programming hardware
# Type: avrdude -c ?
# to get a full listing.
#
AVRDUDE_PROGRAMMER = jtagmkII
# 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 <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_VERBOSE = -v -v
AVRDUDE_FLAGS = -p $(MCU) -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)
# 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) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
$(REMOVE) $(SRC:.c=.i)
$(REMOVEDIR) .dep
doxygen:
@echo Generating Project Documentation \($(TARGET)\)...
@doxygen Doxygen.conf
@echo Documentation Generation Complete.
clean_doxygen:
rm -rf Documentation
checksource:
@for f in $(SRC) $(CPPSRC) $(ASRC); do \
if [ -f $$f ]; then \
echo "Found Source File: $$f" ; \
else \
echo "Source File Not Found: $$f" ; \
fi; done
# 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 checksource
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------
# Run "make help" for target help.
MCU = at90usb1287
ARCH = AVR8
BOARD = USBKEY
F_CPU = 8000000
F_USB = $(F_CPU)
OPTIMIZATION = s
TARGET = BootloaderDFU
SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S $(LUFA_SRC_USB)
LUFA_PATH = ../../LUFA
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DBOOT_START_ADDR=$(BOOT_START_OFFSET)
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAGS)
# Flash size and bootloader section sizes of the target, in KB. These must
# match the target's total FLASH size and the bootloader size set in the
# device's fuses.
FLASH_SIZE_KB = 128
BOOT_SECTION_SIZE_KB = 8
# Bootloader address calculation formulas
# Do not modify these macros, but rather modify the dependent values above.
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
# Bootloader linker section flags for relocating the API table sections to
# known FLASH addresses - these should not normally be user-edited.
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
# Default target
all:
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk
include $(LUFA_PATH)/Build/lufa_sources.mk
include $(LUFA_PATH)/Build/lufa_build.mk
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
include $(LUFA_PATH)/Build/lufa_doxygen.mk
include $(LUFA_PATH)/Build/lufa_avrdude.mk
include $(LUFA_PATH)/Build/lufa_atprogram.mk

View File

@@ -1 +0,0 @@
<AVRStudio><MANAGEMENT><ProjectName>BootloaderHID</ProjectName><Created>15-Jan-2011 21:49:00</Created><LastEdit>15-Jan-2011 21:49:00</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:41:25</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderHID.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderHID.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderHID.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderCDC.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\BootloaderHID.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\Descriptors.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\BootloaderHID.c</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>

View File

@@ -1,24 +1,24 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
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
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
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
The author disclaims 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
@@ -32,7 +32,7 @@
*
* Main source file for the HID class bootloader. This file contains the complete bootloader logic.
*/
#include "BootloaderHID.h"
/** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run
@@ -41,23 +41,50 @@
*/
static bool RunBootloader = true;
/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously
/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
* will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
* low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
* \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
*/
uint16_t MagicBootKey ATTR_NO_INIT;
/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
* start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
* this will force the user application to start via a software jump.
*/
void Application_Jump_Check(void)
{
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
{
MagicBootKey = 0;
// cppcheck-suppress constStatement
((void (*)(void))0x0000)();
}
}
/** 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.
*/
int main(void)
{
/* Setup hardware required for the bootloader */
SetupHardware();
/* Enable global interrupts so that the USB stack can function */
sei();
GlobalInterruptEnable();
while (RunBootloader)
USB_USBTask();
/* Disconnect from the host - USB interface will be reset later along with the AVR */
USB_Detach();
/* Unlock the forced application start mode of the bootloader if it is restarted */
MagicBootKey = MAGIC_BOOT_KEY;
/* Enable the watchdog and force a timeout to reset the AVR */
wdt_enable(WDTO_250MS);
@@ -65,7 +92,7 @@ int main(void)
}
/** Configures all hardware required for the bootloader. */
void SetupHardware(void)
static void SetupHardware(void)
{
/* Disable watchdog if enabled by bootloader/fuses */
MCUSR &= ~(1 << WDRF);
@@ -85,9 +112,7 @@ void SetupHardware(void)
void EVENT_USB_Device_ConfigurationChanged(void)
{
/* Setup HID Report Endpoint */
Endpoint_ConfigureEndpoint(HID_IN_EPNUM, EP_TYPE_INTERRUPT,
ENDPOINT_DIR_IN, HID_IN_EPSIZE,
ENDPOINT_BANK_SINGLE);
Endpoint_ConfigureEndpoint(HID_IN_EPADDR, EP_TYPE_INTERRUPT, HID_IN_EPSIZE, 1);
}
/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
@@ -108,17 +133,17 @@ void EVENT_USB_Device_ControlRequest(void)
{
case HID_REQ_SetReport:
Endpoint_ClearSETUP();
/* Wait until the command has been sent by the host */
while (!(Endpoint_IsOUTReceived()));
/* Read in the write destination address */
#if (FLASHEND > 0xFFFF)
uint32_t PageAddress = ((uint32_t)Endpoint_Read_16_LE() << 8);
#else
uint16_t PageAddress = Endpoint_Read_16_LE();
#endif
/* Check if the command is a program page command, or a start application command */
#if (FLASHEND > 0xFFFF)
if ((uint16_t)(PageAddress >> 8) == COMMAND_STARTAPPLICATION)
@@ -133,9 +158,9 @@ void EVENT_USB_Device_ControlRequest(void)
/* Erase the given FLASH page, ready to be programmed */
boot_page_erase(PageAddress);
boot_spm_busy_wait();
/* Write each of the FLASH page's bytes in sequence */
for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++)
for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++)
{
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if (!(Endpoint_BytesInEndpoint()))
@@ -162,3 +187,4 @@ void EVENT_USB_Device_ControlRequest(void)
break;
}
}

View File

@@ -1,24 +1,24 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Copyright 2013 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
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
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
The author disclaims 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
@@ -30,11 +30,11 @@
/** \file
*
* Header file for TeensyHID.c.
* Header file for BootloaderHID.c.
*/
#ifndef _TEENSYHID_H_
#define _TEENSYHID_H_
#ifndef _BOOTLOADERHID_H_
#define _BOOTLOADERHID_H_
/* Includes: */
#include <avr/io.h>
@@ -47,15 +47,27 @@
#include "Descriptors.h"
#include <LUFA/Drivers/USB/USB.h>
/* Macros: */
#include <LUFA/Platform/Platform.h>
/* Preprocessor Checks: */
#if !defined(__OPTIMIZE_SIZE__)
#error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
#endif
/* Macros: */
/** Bootloader special address to start the user application */
#define COMMAND_STARTAPPLICATION 0xFFFF
/** Magic bootloader key to unlock forced application start mode. */
#define MAGIC_BOOT_KEY 0xDC42
/* Function Prototypes: */
void SetupHardware(void);
static void SetupHardware(void);
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
void EVENT_USB_Device_ConfigurationChanged(void);
void EVENT_USB_Device_UnhandledControlRequest(void);
#endif

View File

@@ -3,17 +3,17 @@
* This file contains special DoxyGen information for the generation of the main page and other special
* documentation pages. It is not a project source file.
*/
/** \mainpage HID Class USB AVR Bootloader
*
* \section SSec_Compat Demo Compatibility:
*
* The following list indicates what microcontrollers are compatible with this demo.
*
* - Series 7 USB AVRs (AT90USBxxx7)
* - Series 6 USB AVRs (AT90USBxxx6)
* - Series 4 USB AVRs (ATMEGAxxU4)
* - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
* \li Series 7 USB AVRs (AT90USBxxx7)
* \li Series 6 USB AVRs (AT90USBxxx6)
* \li Series 4 USB AVRs (ATMEGAxxU4)
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
*
* \section SSec_Info USB Information:
*
@@ -28,7 +28,7 @@
* <td><b>USB Class:</b></td>
* <td>Human Interface Device Class (HID)</td>
* </tr>
* <tr>
* <tr>
* <td><b>USB Subclass:</b></td>
* <td>N/A</td>
* </tr>
@@ -38,23 +38,23 @@
* Teensy Programming Protocol Specification</td>
* </tr>
* <tr>
* <td><b>Usable Speeds:</b></td>
* <td><b>Supported USB Speeds:</b></td>
* <td>Low Speed Mode \n
* Full Speed Mode</td>
* </tr>
* </table>
*
* \section SSec_Description Project Description:
* \section SSec_Description Project Description:
*
* This bootloader enumerates to the host as a HID Class device, allowing for device FLASH programming through
* the supplied command line software, which is a modified version of Paul's TeensyHID Command Line loader code
* from PJRC (used with permission). This bootloader is deliberatley non-compatible with the properietary PJRC
* HalfKay bootloader GUI; only the command line interface software accompanying this bootloader will work with it.
*
* Out of the box this bootloader builds for the USB1287, and will fit into 2KB of bootloader space for the
* Series 2 USB AVRs (ATMEGAxxU2, AT90USBxx2) or 4KB of bootloader space for all other models. If you wish to
* enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU values in the
* accompanying makefile.
*
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
* into 2KB of bootloader space for the Series 2 USB AVRs (ATMEGAxxU2, AT90USBxx2) or 4KB of bootloader space for
* all other models. If you wish to alter this size and/or change the AVR model, you will need to edit the MCU,
* FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
*
* \section Sec_Installation Driver Installation
*
@@ -74,6 +74,14 @@
* hid_bootloader_cli -mmcu=at90usb1287 Mouse.hex
* \endcode
*
* \section Sec_KnownIssues Known Issues:
*
* \par After loading an application, it is not run automatically on startup.
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
* to run automatically when the device is reset. In most cases, the BOOTRST
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
* when needed.
*
* \section SSec_Options Project Options
*
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.

View File

@@ -0,0 +1,93 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief LUFA Library Configuration Header File
*
* This header file is used to configure LUFA's compile time options,
* as an alternative to the compile time constants supplied through
* a makefile.
*
* For information on what each token does, refer to the LUFA
* manual section "Summary of Compile Tokens".
*/
#ifndef _LUFA_CONFIG_H_
#define _LUFA_CONFIG_H_
#if (ARCH == ARCH_AVR8)
/* Non-USB Related Configuration Tokens: */
// #define DISABLE_TERMINAL_CODES
/* USB Class Driver Related Tokens: */
// #define HID_HOST_BOOT_PROTOCOL_ONLY
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
// #define HID_MAX_COLLECTIONS {Insert Value Here}
// #define HID_MAX_REPORTITEMS {Insert Value Here}
// #define HID_MAX_REPORT_IDS {Insert Value Here}
// #define NO_CLASS_DRIVER_AUTOFLUSH
/* General USB Driver Related Tokens: */
#define ORDERED_EP_CONFIG
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
#define USB_DEVICE_ONLY
// #define USB_HOST_ONLY
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
// #define NO_LIMITED_CONTROLLER_CONNECT
#define NO_SOF_EVENTS
/* USB Device Mode Driver Related Tokens: */
#define USE_RAM_DESCRIPTORS
// #define USE_FLASH_DESCRIPTORS
// #define USE_EEPROM_DESCRIPTORS
#define NO_INTERNAL_SERIAL
#define FIXED_CONTROL_ENDPOINT_SIZE 8
#define DEVICE_STATE_AS_GPIOR 0
#define FIXED_NUM_CONFIGURATIONS 1
// #define CONTROL_ONLY_DEVICE
// #define INTERRUPT_CONTROL_ENDPOINT
#define NO_DEVICE_REMOTE_WAKEUP
#define NO_DEVICE_SELF_POWER
/* USB Host Mode Driver Related Tokens: */
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
// #define NO_AUTO_VBUS_MANAGEMENT
// #define INVERTED_VBUS_ENABLE_LINE
#else
#error Unsupported architecture for this LUFA configuration file.
#endif
#endif

View File

@@ -1,24 +1,24 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Copyright 2013 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
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
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
The author disclaims 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
@@ -30,9 +30,9 @@
/** \file
*
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
* 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.
* the device's capabilities and functions.
*/
#include "Descriptors.h"
@@ -52,12 +52,12 @@ const USB_Descriptor_HIDReport_Datatype_t HIDReport[] =
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(16, (sizeof(uint16_t) + SPM_PAGESIZE)),
HID_RI_REPORT_COUNT(16, (sizeof(uint16_t) + SPM_PAGESIZE)),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
};
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
/** Device descriptor structure. This descriptor, located in SRAM 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.
@@ -84,63 +84,63 @@ const USB_Descriptor_Device_t DeviceDescriptor =
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
};
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
/** Configuration descriptor structure. This descriptor, located in SRAM 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.
*/
const USB_Descriptor_Configuration_t ConfigurationDescriptor =
{
.Config =
.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,
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
},
.HID_Interface =
.HID_Interface =
{
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
.InterfaceNumber = 0x00,
.AlternateSetting = 0x00,
.TotalEndpoints = 1,
.Class = HID_CSCP_HIDClass,
.SubClass = HID_CSCP_NonBootSubclass,
.Protocol = HID_CSCP_NonBootProtocol,
.InterfaceStrIndex = NO_DESCRIPTOR
},
.HID_VendorHID =
{
.HID_VendorHID =
{
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
.HIDSpec = VERSION_BCD(01.11),
.CountryCode = 0x00,
.TotalReportDescriptors = 1,
.HIDReportType = HID_DTYPE_Report,
.HIDReportLength = sizeof(HIDReport)
},
.HID_ReportINEndpoint =
.HID_ReportINEndpoint =
{
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
.EndpointAddress = (ENDPOINT_DIR_IN | HID_IN_EPNUM),
.EndpointAddress = HID_IN_EPADDR,
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = HID_IN_EPSIZE,
.PollingIntervalMS = 0x01
.PollingIntervalMS = 0x05
},
};
@@ -158,17 +158,17 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const void* Address = NULL;
uint16_t Size = NO_DESCRIPTOR;
/* If/Else If chain compiles slightly smaller than a switch case */
if (DescriptorType == DTYPE_Device)
{
Address = &DeviceDescriptor;
Size = sizeof(USB_Descriptor_Device_t);
Size = sizeof(USB_Descriptor_Device_t);
}
else if (DescriptorType == DTYPE_Configuration)
{
Address = &ConfigurationDescriptor;
Size = sizeof(USB_Descriptor_Configuration_t);
Size = sizeof(USB_Descriptor_Configuration_t);
}
else if (DescriptorType == HID_DTYPE_HID)
{
@@ -184,3 +184,4 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
*DescriptorAddress = Address;
return Size;
}

View File

@@ -1,24 +1,24 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Copyright 2013 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
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
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
The author disclaims 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
@@ -47,18 +47,18 @@
typedef struct
{
USB_Descriptor_Configuration_Header_t Config;
// Generic HID Interface
USB_Descriptor_Interface_t HID_Interface;
USB_HID_Descriptor_HID_t HID_VendorHID;
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
} USB_Descriptor_Configuration_t;
/* Macros: */
/** Endpoint number of the HID data IN endpoint. */
#define HID_IN_EPNUM 1
/** Size in bytes of the HID reporting IN endpoint. */
/* Macros: */
/** Endpoint address of the HID data IN endpoint. */
#define HID_IN_EPADDR (ENDPOINT_DIR_IN | 1)
/** Size in bytes of the HID reporting IN endpoint. */
#define HID_IN_EPSIZE 64
/* Function Prototypes: */
@@ -68,3 +68,4 @@
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -195,7 +195,9 @@ usb_dev_handle * open_usb_device(int vid, int pid)
struct usb_bus *bus;
struct usb_device *dev;
usb_dev_handle *h;
#ifdef LIBUSB_HAS_GET_DRIVER_NP
char buf[128];
#endif
int r;
usb_init();
@@ -390,21 +392,9 @@ int write_usb_device(HANDLE h, void *buf, int len, int timeout)
if (r != WAIT_OBJECT_0) return 0;
}
if (!GetOverlappedResult(h, &ov, &n, FALSE)) return 0;
if (n <= 0) return 0;
return 1;
}
void print_win32_err(void)
{
char buf[256];
DWORD err;
err = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
0, buf, sizeof(buf), NULL);
printf("err %ld: %s\n", err, buf);
}
static HANDLE win32_teensy_handle = NULL;
int teensy_open(void)
@@ -667,6 +657,11 @@ int hard_reboot(void)
#include <dev/usb/usb_ioctl.h>
#endif
#ifndef USB_GET_DEVICEINFO
# define USB_GET_DEVICEINFO 0
# error The USB_GET_DEVICEINFO ioctl() value is not defined for your system.
#endif
int open_usb_device(int vid, int pid)
{
int r, fd;
@@ -710,10 +705,10 @@ int teensy_open(void)
{
teensy_close();
uhid_teensy_fd = open_usb_device(0x16C0, 0x0478);
if (uhid_teensy_fd < 0)
uhid_teensy_fd = open_usb_device(0x03eb, 0x2067);
if (uhid_teensy_fd < 0) return 0;
return 1;
}
@@ -722,7 +717,7 @@ int teensy_write(void *buf, int len, double timeout)
{
int r;
// TODO: imeplement timeout... how??
// TODO: implement timeout... how??
r = write(uhid_teensy_fd, buf, len);
if (r == len) return 1;
return 0;
@@ -801,6 +796,7 @@ int read_intel_hex(const char *filename)
if (*buf) {
if (parse_hex_line(buf) == 0) {
//printf("Warning, parse error line %d\n", lineno);
fclose(fp);
return -2;
}
}
@@ -816,7 +812,7 @@ int read_intel_hex(const char *filename)
/* parses a line of intel hex code, stores the data in bytes[] */
/* and the beginning address in addr, and returns a 1 if the */
/* line was valid, or a 0 if an error occured. The variable */
/* line was valid, or a 0 if an error occurred. The variable */
/* num gets the number of bytes that were stored into bytes[] */
@@ -826,7 +822,7 @@ parse_hex_line(char *line)
int addr, code, num;
int sum, len, cksum, i;
char *ptr;
num = 0;
if (line[0] != ':') return 0;
if (strlen(line) < 11) return 0;
@@ -979,13 +975,9 @@ void parse_options(int argc, char **argv)
} else if (strncmp(arg, "-mmcu=", 6) == 0) {
arg += 6;
uint8_t valid_prefix = 0;
if (strncmp(arg, "at90usb", 7) == 0) {
valid_prefix = 1;
arg += 7;
} else if (strncmp(arg, "atmega", 6) == 0) {
valid_prefix = 1;
arg += 6;
} else {
die("Unknown MCU type\n");

View File

@@ -0,0 +1,120 @@
"""
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
"""
"""
Front-end programmer for the LUFA HID class bootloader.
Usage:
python hid_bootloader_loader.py <Device> <Input>.hex
Example:
python hid_bootloader_loader.py at90usb1287 Mouse.hex
Requires the pywinusb (https://pypi.python.org/pypi/pywinusb/) and
IntelHex (http://bialix.com/intelhex/) libraries.
"""
import sys
from pywinusb import hid
from intelhex import IntelHex
# Device information table
device_info_map = dict()
device_info_map['at90usb1287'] = {'page_size': 256, 'flash_kb': 128}
device_info_map['at90usb1286'] = {'page_size': 256, 'flash_kb': 128}
device_info_map['at90usb647'] = {'page_size': 256, 'flash_kb': 64}
device_info_map['at90usb646'] = {'page_size': 256, 'flash_kb': 64}
device_info_map['atmega32u4'] = {'page_size': 128, 'flash_kb': 32}
device_info_map['atmega32u2'] = {'page_size': 128, 'flash_kb': 32}
device_info_map['atmega16u4'] = {'page_size': 128, 'flash_kb': 16}
device_info_map['atmega16u2'] = {'page_size': 128, 'flash_kb': 16}
device_info_map['at90usb162'] = {'page_size': 128, 'flash_kb': 16}
device_info_map['atmega8u2'] = {'page_size': 128, 'flash_kb': 8}
device_info_map['at90usb82'] = {'page_size': 128, 'flash_kb': 8}
def get_hid_device_handle():
hid_device_filter = hid.HidDeviceFilter(vendor_id=0x03EB,
product_id=0x2067)
valid_hid_devices = hid_device_filter.get_devices()
if len(valid_hid_devices) is 0:
return None
else:
return valid_hid_devices[0]
def send_page_data(hid_device, address, data):
# Bootloader page data should be the HID Report ID (always zero) followed
# by the starting address to program, then one device's flash page worth
# of data
output_report_data = [0]
output_report_data.extend([address & 0xFF, address >> 8])
output_report_data.extend(data)
hid_device.send_output_report(output_report_data)
def program_device(hex_data, device_info):
hid_device = get_hid_device_handle()
if hid_device is None:
print("No valid HID device found.")
sys.exit(1)
try:
hid_device.open()
print("Connected to bootloader.")
# Program in all data from the loaded HEX file, in a number of device
# page sized chunks
for addr in range(0, hex_data.maxaddr(), device_info['page_size']):
# Compute the address range of the current page in the device
current_page_range = range(addr, addr+device_info['page_size'])
# Extract the data from the hex file at the specified start page
# address and convert it to a regular list of bytes
page_data = [hex_data[i] for i in current_page_range]
print("Writing address 0x%04X-0x%04X" % (current_page_range[0], current_page_range[-1]))
# Devices with more than 64KB of flash should shift down the page
# address so that it is 16-bit (page size is guaranteed to be
# >= 256 bytes so no non-zero address bits are discarded)
if device_info['flash_kb'] < 64:
send_page_data(hid_device, addr, page_data)
else:
send_page_data(hid_device, addr >> 8, page_data)
# Once programming is complete, start the application via a dummy page
# program to the page address 0xFFFF
print("Programming complete, starting application.")
send_page_data(hid_device, 0xFFFF, [0] * device_info['page_size'])
finally:
hid_device.close()
if __name__ == '__main__':
# Load the specified HEX file
try:
hex_data = IntelHex(sys.argv[2])
except:
print("Could not open the specified HEX file.")
sys.exit(1)
# Retrieve the device information entry for the specified device
try:
device_info = device_info_map[sys.argv[1]]
except:
print("Unknown device name specified.")
sys.exit(1)
program_device(hex_data, device_info)

122
Bootloaders/HID/asf.xml Normal file
View File

@@ -0,0 +1,122 @@
<asf xmlversion="1.0">
<project caption="HID Bootloader - 128KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.hid.avr8.128_4" force-caption="true" workspace-name="lufa_hid_128kb_4kb_">
<require idref="lufa.bootloaders.hid"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="at90usb1287"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x1F000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1F000"/>
</project>
<project caption="HID Bootloader - 64KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.hid.avr8.64_4" force-caption="true" workspace-name="lufa_hid_64kb_4kb_">
<require idref="lufa.bootloaders.hid"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="at90usb647"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0xF000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0xF000"/>
</project>
<project caption="HID Bootloader - 32KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.hid.avr8.32_4" force-caption="true" workspace-name="lufa_hid_32kb_4kb_">
<require idref="lufa.bootloaders.hid"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega32u4"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x7000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x7000"/>
</project>
<project caption="HID Bootloader - 16KB FLASH / 2KB Boot - AVR8 Architecture" id="lufa.bootloaders.hid.avr8.16_2" force-caption="true" workspace-name="lufa_hid_16kb_2kb_">
<require idref="lufa.bootloaders.hid"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega16u2"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x3800"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x3800"/>
</project>
<project caption="HID Bootloader - 8KB FLASH / 2KB Boot - AVR8 Architecture" id="lufa.bootloaders.hid.avr8.8_2" force-caption="true" workspace-name="lufa_hid_8kb_2kb_">
<require idref="lufa.bootloaders.hid"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega8u2"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x1800"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1800"/>
</project>
<module type="application" id="lufa.bootloaders.hid" caption="HID Bootloader">
<info type="description" value="summary">
HID Class Bootloader, capable of reprogramming a device via a custom cross-platform command line utility when plugged into a host.
</info>
<info type="gui-flag" value="move-to-root"/>
<info type="keyword" value="Technology">
<keyword value="Bootloaders"/>
<keyword value="USB Device"/>
</info>
<device-support-alias value="lufa_avr8"/>
<device-support-alias value="lufa_xmega"/>
<device-support-alias value="lufa_uc3"/>
<build type="include-path" value="."/>
<build type="c-source" value="BootloaderHID.c"/>
<build type="header-file" value="BootloaderHID.h"/>
<build type="c-source" value="Descriptors.c"/>
<build type="header-file" value="Descriptors.h"/>
<build type="module-config" subtype="path" value="Config"/>
<build type="header-file" value="Config/LUFAConfig.h"/>
<build type="distribute" subtype="user-file" value="BootloaderHID.txt"/>
<build type="distribute" subtype="directory" value="HostLoaderApp"/>
<build type="distribute" subtype="directory" value="HostLoaderApp_Python"/>
<require idref="lufa.common"/>
<require idref="lufa.platform"/>
<require idref="lufa.drivers.usb"/>
<require idref="lufa.drivers.board"/>
<require idref="lufa.drivers.board.leds"/>
</module>
</asf>

View File

@@ -1,712 +1,48 @@
# 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
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# 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
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
#----------------------------------------------------------------------------
# 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 = at90usb1287
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# 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 = USBKEY
# 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_USB below, as it is sourced by
# F_USB 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 = 8000000
# Input clock frequency.
# This will define a symbol, F_USB, 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_USB = $(F_CPU)
# Starting byte address of the bootloader, as a byte address - computed via the formula
# BOOT_START = ((FLASH_SIZE_KB - BOOT_SECTION_SIZE_KB) * 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.
FLASH_SIZE_KB = 128
BOOT_SECTION_SIZE_KB = 4
BOOT_START = 0x$(shell echo "obase=16; ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024" | bc)
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
# Target file name (without extension).
TARGET = BootloaderHID
# 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 ORDERED_EP_CONFIG
LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
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_SOF_EVENTS
# 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 += -DF_USB=$(F_USB)UL
CDEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL
CDEFS += $(LUFA_OPTS)
# Place -D or -U options here for ASM sources
ADEFS = -DF_CPU=$(F_CPU)
ADEFS += -DF_USB=$(F_USB)UL
ADEFS += -DBOARD=BOARD_$(BOARD)
ADEFS += -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_USB=$(F_USB)UL
CPPDEFS += -DBOARD=BOARD_$(BOARD)
CPPDEFS += -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) ----------------
# Programming hardware
# Type: avrdude -c ?
# to get a full listing.
#
AVRDUDE_PROGRAMMER = jtagmkII
# 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 <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_VERBOSE = -v -v
AVRDUDE_FLAGS = -p $(MCU) -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)
# 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) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
$(REMOVE) $(SRC:.c=.i)
$(REMOVEDIR) .dep
doxygen:
@echo Generating Project Documentation \($(TARGET)\)...
@doxygen Doxygen.conf
@echo Documentation Generation Complete.
clean_doxygen:
rm -rf Documentation
checksource:
@for f in $(SRC) $(CPPSRC) $(ASRC); do \
if [ -f $$f ]; then \
echo "Found Source File: $$f" ; \
else \
echo "Source File Not Found: $$f" ; \
fi; done
# 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 checksource
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------
# Run "make help" for target help.
MCU = at90usb1287
ARCH = AVR8
BOARD = USBKEY
F_CPU = 8000000
F_USB = $(F_CPU)
OPTIMIZATION = s
TARGET = BootloaderHID
SRC = $(TARGET).c Descriptors.c $(LUFA_SRC_USB)
LUFA_PATH = ../../LUFA
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET)
# Flash size and bootloader section sizes of the target, in KB. These must
# match the target's total FLASH size and the bootloader size set in the
# device's fuses.
FLASH_SIZE_KB := 128
BOOT_SECTION_SIZE_KB := 8
# Bootloader address calculation formulas
# Do not modify these macros, but rather modify the dependent values above.
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
# Default target
all:
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk
include $(LUFA_PATH)/Build/lufa_sources.mk
include $(LUFA_PATH)/Build/lufa_build.mk
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
include $(LUFA_PATH)/Build/lufa_doxygen.mk
include $(LUFA_PATH)/Build/lufa_avrdude.mk
include $(LUFA_PATH)/Build/lufa_atprogram.mk

View File

@@ -0,0 +1,76 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
*
* Bootloader user application API functions.
*/
#include "BootloaderAPI.h"
void BootloaderAPI_ErasePage(const uint32_t Address)
{
boot_page_erase_safe(Address);
boot_spm_busy_wait();
boot_rww_enable();
}
void BootloaderAPI_WritePage(const uint32_t Address)
{
boot_page_write_safe(Address);
boot_spm_busy_wait();
boot_rww_enable();
}
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
{
boot_page_fill_safe(Address, Word);
}
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
{
return boot_signature_byte_get(Address);
}
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
{
return boot_lock_fuse_bits_get(Address);
}
uint8_t BootloaderAPI_ReadLock(void)
{
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
}
void BootloaderAPI_WriteLock(const uint8_t LockBits)
{
boot_lock_bits_set_safe(LockBits);
}

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -28,36 +28,36 @@
this software.
*/
#ifndef _SIDESHOW_APPLICATIONS_H_
#define _SIDESHOW_APPLICATIONS_H_
/** \file
*
* Header file for BootloaderAPI.c.
*/
#ifndef _BOOTLOADER_API_H_
#define _BOOTLOADER_API_H_
/* Includes: */
#include <avr/io.h>
#include <string.h>
#include <avr/boot.h>
#include <stdbool.h>
#include "SideshowCommon.h"
#include <LUFA/Common/Common.h>
/* Type Defines: */
typedef struct
{
bool InUse;
GUID_t ApplicationID;
GUID_t EndpointID;
UNICODE_STRING_t(50) ApplicationName;
uint32_t CachePolicy;
uint32_t OnlineOnly;
bool HaveContent;
uint32_t CurrentContentID;
uint8_t CurrentContent[MAX_CONTENTBUFFER_PER_APP];
} SideShow_Application_t;
/* External Variables: */
extern SideShow_Application_t InstalledApplications[MAX_APPLICATIONS];
/* Macros: */
#if AUX_BOOT_SECTION_SIZE > 0
#define AUX_BOOT_SECTION __attribute__((section(".boot_aux")))
#else
#define AUX_BOOT_SECTION
#endif
/* Function Prototypes: */
SideShow_Application_t* SideShow_GetFreeApplication(void);
SideShow_Application_t* SideShow_GetApplicationFromGUID(GUID_t* const GUID);
void BootloaderAPI_ErasePage(const uint32_t Address);
void BootloaderAPI_WritePage(const uint32_t Address);
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
uint8_t BootloaderAPI_ReadLock(void);
void BootloaderAPI_WriteLock(const uint8_t LockBits);
#endif

View File

@@ -0,0 +1,102 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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.
*/
#if AUX_BOOT_SECTION_SIZE > 0
#warning Using a AUX bootloader section in addition to the defined bootloader space (see documentation).
; Trampoline to jump over the AUX bootloader section to the start of the bootloader,
; on devices where an AUX bootloader section is used.
.section .boot_aux_trampoline, "ax"
.global Boot_AUX_Trampoline
Boot_AUX_Trampoline:
jmp BOOT_START_ADDR
#endif
; Trampolines to actual API implementations if the target address is outside the
; range of a rjmp instruction (can happen with large bootloader sections)
.section .apitable_trampolines, "ax"
.global BootloaderAPI_Trampolines
BootloaderAPI_Trampolines:
BootloaderAPI_ErasePage_Trampoline:
jmp BootloaderAPI_ErasePage
BootloaderAPI_WritePage_Trampoline:
jmp BootloaderAPI_WritePage
BootloaderAPI_FillWord_Trampoline:
jmp BootloaderAPI_FillWord
BootloaderAPI_ReadSignature_Trampoline:
jmp BootloaderAPI_ReadSignature
BootloaderAPI_ReadFuse_Trampoline:
jmp BootloaderAPI_ReadFuse
BootloaderAPI_ReadLock_Trampoline:
jmp BootloaderAPI_ReadLock
BootloaderAPI_WriteLock_Trampoline:
jmp BootloaderAPI_WriteLock
BootloaderAPI_UNUSED1:
ret
BootloaderAPI_UNUSED2:
ret
BootloaderAPI_UNUSED3:
ret
BootloaderAPI_UNUSED4:
ret
BootloaderAPI_UNUSED5:
ret
; API function jump table
.section .apitable_jumptable, "ax"
.global BootloaderAPI_JumpTable
BootloaderAPI_JumpTable:
rjmp BootloaderAPI_ErasePage_Trampoline
rjmp BootloaderAPI_WritePage_Trampoline
rjmp BootloaderAPI_FillWord_Trampoline
rjmp BootloaderAPI_ReadSignature_Trampoline
rjmp BootloaderAPI_ReadFuse_Trampoline
rjmp BootloaderAPI_ReadLock_Trampoline
rjmp BootloaderAPI_WriteLock_Trampoline
rjmp BootloaderAPI_UNUSED1 ; UNUSED ENTRY 1
rjmp BootloaderAPI_UNUSED2 ; UNUSED ENTRY 2
rjmp BootloaderAPI_UNUSED3 ; UNUSED ENTRY 3
rjmp BootloaderAPI_UNUSED4 ; UNUSED ENTRY 4
rjmp BootloaderAPI_UNUSED5 ; UNUSED ENTRY 5
; Bootloader table signatures and information
.section .apitable_signatures, "ax"
.global BootloaderAPI_Signatures
BootloaderAPI_Signatures:
.long BOOT_START_ADDR ; Start address of the bootloader
.word 0xDF30 ; Signature for the MS class bootloader, V1
.word 0xDCFB ; Signature for a LUFA class bootloader

View File

@@ -0,0 +1,238 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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 Mass Storage class bootloader. This file contains the complete bootloader logic.
*/
#define INCLUDE_FROM_BOOTLOADER_MASSSTORAGE_C
#include "BootloaderMassStorage.h"
/** LUFA Mass Storage Class driver interface configuration and state information. This structure is
* passed to all Mass Storage Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
USB_ClassInfo_MS_Device_t Disk_MS_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.DataINEndpoint =
{
.Address = MASS_STORAGE_IN_EPADDR,
.Size = MASS_STORAGE_IO_EPSIZE,
.Banks = 1,
},
.DataOUTEndpoint =
{
.Address = MASS_STORAGE_OUT_EPADDR,
.Size = MASS_STORAGE_IO_EPSIZE,
.Banks = 1,
},
.TotalLUNs = 1,
},
};
/** 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
* started via a forced watchdog reset.
*/
bool RunBootloader = true;
/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
* will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
* low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
* \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
*/
uint16_t MagicBootKey ATTR_NO_INIT;
/** Indicates if the bootloader is allowed to exit immediately if \ref RunBootloader is \c false. During shutdown all
* pending commands must be processed before jumping to the user-application, thus this tracks the main program loop
* iterations since a SCSI command from the host was received.
*/
static uint8_t TicksSinceLastCommand = 0;
/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
* start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
* this will force the user application to start via a software jump.
*/
void Application_Jump_Check(void)
{
bool JumpToApplication = false;
#if (BOARD == BOARD_LEONARDO)
/* Enable pull-up on the IO13 pin so we can use it to select the mode */
PORTC |= (1 << 7);
Delay_MS(10);
/* If IO13 is not jumpered to ground, start the user application instead */
JumpToApplication |= ((PINC & (1 << 7)) != 0);
/* Disable pull-up after the check has completed */
PORTC &= ~(1 << 7);
#elif ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
/* Disable JTAG debugging */
JTAG_DISABLE();
/* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */
PORTF |= (1 << 4);
Delay_MS(10);
/* If the TCK pin is not jumpered to ground, start the user application instead */
JumpToApplication |= ((PINF & (1 << 4)) != 0);
/* Re-enable JTAG debugging */
JTAG_ENABLE();
#endif
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
{
MagicBootKey = 0;
JumpToApplication = true;
}
if (JumpToApplication)
{
// cppcheck-suppress constStatement
((void (*)(void))0x0000)();
}
}
/** Main program entry point. This routine configures the hardware required by the application, then
* enters a loop to run the application tasks in sequence.
*/
int main(void)
{
SetupHardware();
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
GlobalInterruptEnable();
while (RunBootloader || TicksSinceLastCommand++ < 0xFF)
{
MS_Device_USBTask(&Disk_MS_Interface);
USB_USBTask();
}
/* Disconnect from the host - USB interface will be reset later along with the AVR */
USB_Detach();
/* Unlock the forced application start mode of the bootloader if it is restarted */
MagicBootKey = MAGIC_BOOT_KEY;
/* Enable the watchdog and force a timeout to reset the AVR */
wdt_enable(WDTO_250MS);
for (;;);
}
/** Configures the board hardware and chip peripherals for the demo's functionality. */
static 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);
/* Hardware Initialization */
LEDs_Init();
USB_Init();
/* Bootloader active LED toggle timer initialization */
TIMSK1 = (1 << TOIE1);
TCCR1B = ((1 << CS11) | (1 << CS10));
}
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
ISR(TIMER1_OVF_vect, ISR_BLOCK)
{
LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
}
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
void EVENT_USB_Device_Connect(void)
{
/* Indicate USB enumerating */
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
}
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
* the status LEDs and stops the Mass Storage management task.
*/
void EVENT_USB_Device_Disconnect(void)
{
/* Indicate USB not ready */
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
}
/** Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
{
bool ConfigSuccess = true;
/* Setup Mass Storage Data Endpoints */
ConfigSuccess &= MS_Device_ConfigureEndpoints(&Disk_MS_Interface);
/* Indicate endpoint configuration success or failure */
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
}
/** Event handler for the library USB Control Request reception event. */
void EVENT_USB_Device_ControlRequest(void)
{
MS_Device_ProcessControlRequest(&Disk_MS_Interface);
}
/** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed.
*
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface configuration structure being referenced
*/
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
bool CommandSuccess;
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
LEDs_SetAllLEDs(LEDMASK_USB_READY);
/* Signal that a command was processed, must not exit bootloader yet */
TicksSinceLastCommand = 0;
return CommandSuccess;
}

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -30,30 +30,32 @@
/** \file
*
* Header file for StandaloneProgrammer.c.
* Header file for BootloaderMassStorage.c.
*/
#ifndef _STANDALONE_PROG_H_
#define _STANDALONE_PROG_H_
#ifndef _BOOTLOADER_MASS_STORAGE_H_
#define _BOOTLOADER_MASS_STORAGE_H_
/* Includes: */
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <string.h>
#include "DiskDevice.h"
#include "DiskHost.h"
#include "Descriptors.h"
#include "Config/AppConfig.h"
#include "Lib/SCSI.h"
#include "Lib/DataflashManager.h"
#include "Lib/ProgrammerConfig.h"
#include "Lib/PetiteFATFs/pff.h"
#include <LUFA/Version.h>
#include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Platform/Platform.h>
/* Preprocessor Checks: */
#if !defined(__OPTIMIZE_SIZE__)
#error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
#endif
/* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
@@ -71,19 +73,27 @@
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
#define LEDMASK_USB_BUSY LEDS_LED2
/* External Variables: */
extern FILE DiskStream;
extern FATFS DiskFATState;
/** Magic bootloader key to unlock forced application start mode. */
#define MAGIC_BOOT_KEY 0xDC42
/* Global Variables: */
extern bool RunBootloader;
/* Function Prototypes: */
#if defined(INCLUDE_FROM_STANDALONEPROG_C)
static int Disk_getchar(FILE* Stream);
int main(void) AUX_BOOT_SECTION;
void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
void EVENT_USB_Device_Connect(void) AUX_BOOT_SECTION;
void EVENT_USB_Device_Disconnect(void) AUX_BOOT_SECTION;
void EVENT_USB_Device_ConfigurationChanged(void) AUX_BOOT_SECTION;
void EVENT_USB_Device_ControlRequest(void) AUX_BOOT_SECTION;
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
#if defined(INCLUDE_FROM_BOOTLOADER_MASSSTORAGE_C)
static void SetupHardware(void) AUX_BOOT_SECTION;
#endif
void EVENT_USB_UIDChange(void);
void SetupHardware(void);
void Programmer_Task(void);
#endif

View File

@@ -0,0 +1,206 @@
/** \file
*
* This file contains special DoxyGen information for the generation of the main page and other special
* documentation pages. It is not a project source file.
*/
/** \mainpage Mass Storage Class USB AVR Bootloader
*
* \section Sec_Compat Demo Compatibility:
*
* The following list indicates what microcontrollers are compatible with this demo.
*
* \li Series 7 USB AVRs (AT90USBxxx7)
* \li Series 6 USB AVRs (AT90USBxxx6)
* \li Series 4 USB AVRs (ATMEGAxxU4) - <i>See \ref SSec_Aux_Space</i>
* \li ATMEGA32U2 - <i>See \ref SSec_Aux_Space</i>
*
* \section Sec_Info USB Information:
*
* The following table gives a rundown of the USB utilization of this demo.
*
* <table>
* <tr>
* <td><b>USB Mode:</b></td>
* <td>Device</td>
* </tr>
* <tr>
* <td><b>USB Class:</b></td>
* <td>Mass Storage Device</td>
* </tr>
* <tr>
* <td><b>USB Subclass:</b></td>
* <td>Bulk-Only Transport</td>
* </tr>
* <tr>
* <td><b>Relevant Standards:</b></td>
* <td>USBIF Mass Storage Standard \n
* USB Bulk-Only Transport Standard \n
* SCSI Primary Commands Specification \n
* SCSI Block Commands Specification</td>
* </tr>
* <tr>
* <td><b>Supported USB Speeds:</b></td>
* <td>Full Speed Mode</td>
* </tr>
* </table>
*
* \section Sec_Description Project Description:
*
* This bootloader enumerates to the host as a Mass Storage device, capable of reading and writing a new binary
* firmware image file, to load firmware onto the AVR.
*
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
* into 6KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
*
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
* bootloader from the normal user application.
*
* \section Sec_Installation Driver Installation
*
* This bootloader uses the Mass Storage drivers inbuilt into all modern operating systems, thus no additional
* drivers need to be supplied for correct operation.
*
* \section Sec_HostApp Host Controller Application
*
* This bootloader is compatible with all operating systems that support the FAT12 file system format. To reprogram the
* device, overwrite a file stored on the virtual FAT filesystem with a new binary (BIN format) image. Remember to safely
* remove your device from the host using the host OS's ejection APIs, to ensure all data is correctly flushed to the
* bootloader's virtual filesystem and not cached in the OS's file system driver.
*
* The current device firmware can be read from the device by reading a file from the virtual FAT filesystem.
*
* \warning This bootloader is currently <b>incompatible with the Apple MacOS X OS Finder GUI</b>, due to the
* large amount of meta files this OS attempts to write to the disk along with the new binaries. On
* this platform, firmwares must be copied to the disk via the Terminal application only to prevent
* firmware corruption.
*
* \section Sec_API User Application API
*
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
*
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
* following layout:
*
* \code
* #define BOOTLOADER_API_TABLE_SIZE 32
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
*
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
*
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
*
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
* #define BOOTLOADER_MASS_STORAGE_SIGNATURE 0xDF30
*
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
* #define BOOTLOADER_ADDRESS_LENGTH 4
* \endcode
*
* From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
* \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
* can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
* to the value \c BOOTLOADER_MASS_STORAGE_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes
* of FLASH memory starting from address \c BOOTLOADER_ADDRESS_START.
*
* \subsection SSec_Aux_Space Auxiliary Bootloader Section
* To make the bootloader function on smaller devices (those with a physical bootloader section of smaller than 6KB) a second
* section of memory (called the <i>Auxiliary Bootloader Section</i>) is added before the start of the real bootloader section,
* and is filled with a portion of the bootloader code. This allows smaller devices to run the bootloader, at the cost of an
* additional portion of the device's FLASH (the bootloader section size in KB subtracted from the 6KB total size). A small
* trampoline is inserted at the start of the auxiliary section so that the bootloader will run normally in the case of a blank
* application section.
*
* On devices supporting a 8KB bootloader section size, the AUX section is not created in the final binary.
*
* \subsection SSec_API_MemLayout Device Memory Map
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
*
* \verbatim
* +----------------------------+ 0x0000
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | User Application |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE - BOOT_AUX_SECTION_SIZE
* | Booloader Start Trampoline |
* | (Not User App. Accessible) |
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE - BOOT_AUX_SECTION_SIZE + 4
* | |
* | Auxiliary Bootloader |
* | Space for Smaller Devices |
* | (Not User App. Accessible) |
* | |
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
* | |
* | Bootloader Application |
* | (Not User App. Accessible) |
* | |
* +----------------------------+ FLASHEND - 96
* | API Table Trampolines |
* | (Not User App. Accessible) |
* +----------------------------+ FLASHEND - 32
* | Bootloader API Table |
* | (User App. Accessible) |
* +----------------------------+ FLASHEND - 8
* | Bootloader ID Constants |
* | (User App. Accessible) |
* +----------------------------+ FLASHEND
* \endverbatim
*
* \section Sec_KnownIssues Known Issues:
*
* \par In some cases, the application is not fully loaded into the device.
* Write-caching on some operating systems may interfere with the normal
* operation of the bootloader. Write caching should be disabled when using the
* Mass Storage bootloader, or the file system synced via an appropriate command
* (such as the OS's normal disk ejection command) before disconnecting the device.
*
* \par After loading an application, it is not run automatically on startup.
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
* to run automatically when the device is reset. In most cases, the BOOTRST
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
* when needed.
*
* \section Sec_Options Project Options
*
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
*
* <table>
* <tr>
* <th><b>Define Name:</b></th>
* <th><b>Location:</b></th>
* <th><b>Description:</b></th>
* </tr>
* <tr>
* <td>NO_APP_START_ON_EJECT</td>
* <td>AppConfig.h</td>
* <td>Define to disable automatic start of the loaded application when the virtual
* Mass Storage disk is ejected on the host.</td>
* </tr>
* </table>
*/

View File

@@ -0,0 +1,47 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief Application Configuration Header File
*
* This is a header file which is be used to configure LUFA's
* compile time options, as an alternative to the compile time
* constants supplied through a makefile.
*
* For information on what each token does, refer to the
* \ref Sec_Options section of the application documentation.
*/
#ifndef _APP_CONFIG_H_
#define _APP_CONFIG_H_
// #define NO_APP_START_ON_EJECT
#endif

View File

@@ -0,0 +1,93 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief LUFA Library Configuration Header File
*
* This header file is used to configure LUFA's compile time options,
* as an alternative to the compile time constants supplied through
* a makefile.
*
* For information on what each token does, refer to the LUFA
* manual section "Summary of Compile Tokens".
*/
#ifndef _LUFA_CONFIG_H_
#define _LUFA_CONFIG_H_
#if (ARCH == ARCH_AVR8)
/* Non-USB Related Configuration Tokens: */
// #define DISABLE_TERMINAL_CODES
/* USB Class Driver Related Tokens: */
// #define HID_HOST_BOOT_PROTOCOL_ONLY
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
// #define HID_MAX_COLLECTIONS {Insert Value Here}
// #define HID_MAX_REPORTITEMS {Insert Value Here}
// #define HID_MAX_REPORT_IDS {Insert Value Here}
// #define NO_CLASS_DRIVER_AUTOFLUSH
/* General USB Driver Related Tokens: */
#define ORDERED_EP_CONFIG
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
#define USB_DEVICE_ONLY
// #define USB_HOST_ONLY
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
// #define NO_LIMITED_CONTROLLER_CONNECT
#define NO_SOF_EVENTS
/* USB Device Mode Driver Related Tokens: */
#define USE_RAM_DESCRIPTORS
// #define USE_FLASH_DESCRIPTORS
// #define USE_EEPROM_DESCRIPTORS
#define NO_INTERNAL_SERIAL
#define FIXED_CONTROL_ENDPOINT_SIZE 8
#define DEVICE_STATE_AS_GPIOR 0
#define FIXED_NUM_CONFIGURATIONS 1
// #define CONTROL_ONLY_DEVICE
#define INTERRUPT_CONTROL_ENDPOINT
#define NO_DEVICE_REMOTE_WAKEUP
#define NO_DEVICE_SELF_POWER
/* USB Host Mode Driver Related Tokens: */
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
// #define NO_AUTO_VBUS_MANAGEMENT
// #define INVERTED_VBUS_ENABLE_LINE
#else
#error Unsupported architecture for this LUFA configuration file.
#endif
#endif

View File

@@ -0,0 +1,157 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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 SRAM 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.
*/
const USB_Descriptor_Device_t DeviceDescriptor =
{
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
.USBSpecification = VERSION_BCD(01.10),
.Class = USB_CSCP_NoDeviceClass,
.SubClass = USB_CSCP_NoDeviceSubclass,
.Protocol = USB_CSCP_NoDeviceProtocol,
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
.VendorID = 0x03EB,
.ProductID = 0x2045,
.ReleaseNumber = VERSION_BCD(00.01),
.ManufacturerStrIndex = NO_DESCRIPTOR,
.ProductStrIndex = NO_DESCRIPTOR,
.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.
*/
const 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_RESERVED,
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
},
.MS_Interface =
{
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
.InterfaceNumber = 0,
.AlternateSetting = 0,
.TotalEndpoints = 2,
.Class = MS_CSCP_MassStorageClass,
.SubClass = MS_CSCP_SCSITransparentSubclass,
.Protocol = MS_CSCP_BulkOnlyTransportProtocol,
.InterfaceStrIndex = NO_DESCRIPTOR
},
.MS_DataInEndpoint =
{
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
.EndpointAddress = MASS_STORAGE_IN_EPADDR,
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = MASS_STORAGE_IO_EPSIZE,
.PollingIntervalMS = 0x05
},
.MS_DataOutEndpoint =
{
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
.EndpointAddress = MASS_STORAGE_OUT_EPADDR,
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = MASS_STORAGE_IO_EPSIZE,
.PollingIntervalMS = 0x05
}
};
/** 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,
const void** const DescriptorAddress)
{
const uint8_t DescriptorType = (wValue >> 8);
const void* Address = NULL;
uint16_t Size = NO_DESCRIPTOR;
/* If/Else If chain compiles slightly smaller than a switch case */
if (DescriptorType == DTYPE_Device)
{
Address = &DeviceDescriptor;
Size = sizeof(USB_Descriptor_Device_t);
}
else if (DescriptorType == DTYPE_Configuration)
{
Address = &ConfigurationDescriptor;
Size = sizeof(USB_Descriptor_Configuration_t);
}
*DescriptorAddress = Address;
return Size;
}

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -41,23 +41,17 @@
#include <LUFA/Drivers/USB/USB.h>
#include "BootloaderAPI.h"
/* Macros: */
#if !defined(LIBUSB_DRIVER_COMPAT)
/** Endpoint number of the AVRISP data OUT endpoint. */
#define AVRISP_DATA_OUT_EPNUM 2
/** Endpoint address of the Mass Storage device-to-host data IN endpoint. */
#define MASS_STORAGE_IN_EPADDR (ENDPOINT_DIR_IN | 3)
/** Endpoint number of the AVRISP data IN endpoint. */
#define AVRISP_DATA_IN_EPNUM 2
#else
/** Endpoint number of the AVRISP data OUT endpoint. */
#define AVRISP_DATA_OUT_EPNUM 2
/** Endpoint address of the Mass Storage host-to-device data OUT endpoint. */
#define MASS_STORAGE_OUT_EPADDR (ENDPOINT_DIR_OUT | 4)
/** Endpoint number of the AVRISP data IN endpoint. */
#define AVRISP_DATA_IN_EPNUM 3
#endif
/** Size in bytes of the AVRISP data endpoint. */
#define AVRISP_DATA_EPSIZE 64
/** Size in bytes of the Mass Storage data endpoints. */
#define MASS_STORAGE_IO_EPSIZE 64
/* Type Defines: */
/** Type define for the device configuration descriptor structure. This must be defined in the
@@ -66,19 +60,19 @@
*/
typedef struct
{
USB_Descriptor_Configuration_Header_t Config;
// Atmel AVRISP-MKII Interface
USB_Descriptor_Interface_t AVRISP_Interface;
USB_Descriptor_Endpoint_t AVRISP_DataInEndpoint;
USB_Descriptor_Endpoint_t AVRISP_DataOutEndpoint;
USB_Descriptor_Configuration_Header_t Config;
// Mass Storage Interface
USB_Descriptor_Interface_t MS_Interface;
USB_Descriptor_Endpoint_t MS_DataInEndpoint;
USB_Descriptor_Endpoint_t MS_DataOutEndpoint;
} USB_Descriptor_Configuration_t;
/* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,
const void** const DescriptorAddress)
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3) AUX_BOOT_SECTION;
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -38,7 +38,6 @@
#define INCLUDE_FROM_SCSI_C
#include "SCSI.h"
#if defined(USB_CAN_BE_DEVICE)
/** Structure to hold the SCSI response data to a SCSI INQUIRY command. This gives information about the device's
* features and capabilities.
*/
@@ -67,7 +66,7 @@ static const SCSI_Inquiry_Response_t InquiryData =
.RelAddr = false,
.VendorID = "LUFA",
.ProductID = "Dataflash Disk",
.ProductID = "Bootloader",
.RevisionID = {'0','.','0','0'},
};
@@ -87,7 +86,7 @@ static SCSI_Request_Sense_Response_t SenseData =
*
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
*
* \return Boolean true if the command completed successfully, false otherwise
* \return Boolean \c true if the command completed successfully, \c false otherwise
*/
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
@@ -105,9 +104,6 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
case SCSI_CMD_READ_CAPACITY_10:
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
break;
case SCSI_CMD_SEND_DIAGNOSTIC:
CommandSuccess = SCSI_Command_Send_Diagnostic(MSInterfaceInfo);
break;
case SCSI_CMD_WRITE_10:
CommandSuccess = SCSI_Command_ReadWrite_10(MSInterfaceInfo, DATA_WRITE);
break;
@@ -117,6 +113,12 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
case SCSI_CMD_MODE_SENSE_6:
CommandSuccess = SCSI_Command_ModeSense_6(MSInterfaceInfo);
break;
case SCSI_CMD_START_STOP_UNIT:
#if !defined(NO_APP_START_ON_EJECT)
/* If the user ejected the volume, signal bootloader exit at next opportunity. */
RunBootloader = ((MSInterfaceInfo->State.CommandBlock.SCSICommandData[4] & 0x03) != 0x02);
#endif
case SCSI_CMD_SEND_DIAGNOSTIC:
case SCSI_CMD_TEST_UNIT_READY:
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
case SCSI_CMD_VERIFY_10:
@@ -150,7 +152,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
*
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
*
* \return Boolean true if the command completed successfully, false otherwise.
* \return Boolean \c true if the command completed successfully, \c false otherwise.
*/
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
@@ -188,12 +190,12 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
*
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
*
* \return Boolean true if the command completed successfully, false otherwise.
* \return Boolean \c true if the command completed successfully, \c false otherwise.
*/
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
uint8_t BytesTransferred = MIN(AllocationLength, sizeof(SenseData));
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
uint8_t BytesTransferred = MIN(AllocationLength, sizeof(SenseData));
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NULL);
Endpoint_Null_Stream((AllocationLength - BytesTransferred), NULL);
@@ -210,15 +212,12 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
*
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
*
* \return Boolean true if the command completed successfully, false otherwise.
* \return Boolean \c true if the command completed successfully, \c false otherwise.
*/
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
uint32_t LastBlockAddressInLUN = (VIRTUAL_MEMORY_BLOCKS - 1);
uint32_t MediaBlockSize = VIRTUAL_MEMORY_BLOCK_SIZE;
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NULL);
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NULL);
Endpoint_Write_32_BE(LUN_MEDIA_BLOCKS - 1);
Endpoint_Write_32_BE(SECTOR_SIZE_BYTES);
Endpoint_ClearIN();
/* Succeed the command and update the bytes transferred counter */
@@ -227,44 +226,6 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
return true;
}
/** Command processing for an issued SCSI SEND DIAGNOSTIC command. This command performs a quick check of the Dataflash ICs on the
* board, and indicates if they are present and functioning correctly. Only the Self-Test portion of the diagnostic command is
* supported.
*
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
*
* \return Boolean true if the command completed successfully, false otherwise.
*/
static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
/* Check to see if the SELF TEST bit is not set */
if (!(MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & (1 << 2)))
{
/* Only self-test supported - update SENSE key and fail the command */
SCSI_SET_SENSE(SCSI_SENSE_KEY_ILLEGAL_REQUEST,
SCSI_ASENSE_INVALID_FIELD_IN_CDB,
SCSI_ASENSEQ_NO_QUALIFIER);
return false;
}
/* Check to see if all attached Dataflash ICs are functional */
if (!(DataflashManager_CheckDataflashOperation()))
{
/* Update SENSE key with a hardware error condition and return command fail */
SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
SCSI_ASENSEQ_NO_QUALIFIER);
return false;
}
/* Succeed the command and update the bytes transferred counter */
MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
return true;
}
/** Command processing for an issued SCSI READ (10) or WRITE (10) command. This command reads in the block start address
* and total number of blocks to process, then calls the appropriate low-level Dataflash routine to handle the actual
* reading and writing of the data.
@@ -272,25 +233,14 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInte
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
* \param[in] IsDataRead Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE)
*
* \return Boolean true if the command completed successfully, false otherwise.
* \return Boolean \c true if the command completed successfully, \c false otherwise.
*/
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
const bool IsDataRead)
{
uint32_t BlockAddress;
uint16_t BlockAddress;
uint16_t TotalBlocks;
/* Check if the disk is write protected or not */
if ((IsDataRead == DATA_WRITE) && DISK_READ_ONLY)
{
/* Block address is invalid, update SENSE key and return command fail */
SCSI_SET_SENSE(SCSI_SENSE_KEY_DATA_PROTECT,
SCSI_ASENSE_WRITE_PROTECTED,
SCSI_ASENSEQ_NO_QUALIFIER);
return false;
}
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
BlockAddress = SwapEndian_32(*(uint32_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[2]);
@@ -298,7 +248,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
TotalBlocks = SwapEndian_16(*(uint16_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[7]);
/* Check if the block address is outside the maximum allowable value for the LUN */
if (BlockAddress >= VIRTUAL_MEMORY_BLOCKS)
if (BlockAddress >= LUN_MEDIA_BLOCKS)
{
/* Block address is invalid, update SENSE key and return command fail */
SCSI_SET_SENSE(SCSI_SENSE_KEY_ILLEGAL_REQUEST,
@@ -307,15 +257,18 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
return false;
}
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
if (IsDataRead == DATA_READ)
DataflashManager_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
else
DataflashManager_WriteBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
for (uint16_t i = 0; i < TotalBlocks; i++)
{
if (IsDataRead == DATA_READ)
VirtualFAT_ReadBlock(BlockAddress + i);
else
VirtualFAT_WriteBlock(BlockAddress + i);
}
/* Update the bytes transferred counter and succeed the command */
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * SECTOR_SIZE_BYTES);
return true;
}
@@ -325,15 +278,12 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
*
* \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
*
* \return Boolean true if the command completed successfully, false otherwise.
* \return Boolean \c true if the command completed successfully, \c false otherwise.
*/
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
/* Send an empty header response with the Write Protect flag status */
Endpoint_Write_8(0x00);
Endpoint_Write_8(0x00);
Endpoint_Write_8(DISK_READ_ONLY ? 0x80 : 0x00);
Endpoint_Write_8(0x00);
/* Send an empty header response indicating Write Protect flag is off */
Endpoint_Write_32_LE(0);
Endpoint_ClearIN();
/* Update the bytes transferred counter and succeed the command */
@@ -341,4 +291,4 @@ static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfac
return true;
}
#endif

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -42,9 +42,9 @@
#include <LUFA/Drivers/USB/USB.h>
#include "StandaloneProgrammer.h"
#include "Descriptors.h"
#include "DataflashManager.h"
#include "../BootloaderMassStorage.h"
#include "../Descriptors.h"
#include "VirtualFAT.h"
/* Macros: */
/** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This
@@ -68,22 +68,16 @@
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a Block Media device. */
#define DEVICE_TYPE_BLOCK 0x00
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a CD-ROM device. */
#define DEVICE_TYPE_CDROM 0x05
/* Function Prototypes: */
#if defined(USB_CAN_BE_DEVICE)
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
#if defined(INCLUDE_FROM_SCSI_C)
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
const bool IsDataRead);
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
#endif
#if defined(INCLUDE_FROM_SCSI_C)
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
const bool IsDataRead) AUX_BOOT_SECTION;
static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) AUX_BOOT_SECTION;
#endif
#endif

View File

@@ -0,0 +1,482 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
*
* Virtualized FAT12 filesystem implementation, to perform self-programming
* in response to read and write requests to the virtual filesystem by the
* host PC.
*/
#define INCLUDE_FROM_VIRTUAL_FAT_C
#include "VirtualFAT.h"
/** FAT filesystem boot sector block, must be the first sector on the physical
* disk so that the host can identify the presence of a FAT filesystem. This
* block is truncated; normally a large bootstrap section is located near the
* end of the block for booting purposes however as this is not meant to be a
* bootable disk it is omitted for space reasons.
*
* \note When returning the boot block to the host, the magic signature 0xAA55
* must be added to the very end of the block to identify it as a boot
* block.
*/
static const FATBootBlock_t BootBlock =
{
.Bootstrap = {0xEB, 0x3C, 0x90},
.Description = "mkdosfs",
.SectorSize = SECTOR_SIZE_BYTES,
.SectorsPerCluster = SECTOR_PER_CLUSTER,
.ReservedSectors = 1,
.FATCopies = 2,
.RootDirectoryEntries = (SECTOR_SIZE_BYTES / sizeof(FATDirectoryEntry_t)),
.TotalSectors16 = LUN_MEDIA_BLOCKS,
.MediaDescriptor = 0xF8,
.SectorsPerFAT = 1,
.SectorsPerTrack = (LUN_MEDIA_BLOCKS % 64),
.Heads = (LUN_MEDIA_BLOCKS / 64),
.HiddenSectors = 0,
.TotalSectors32 = 0,
.PhysicalDriveNum = 0,
.ExtendedBootRecordSig = 0x29,
.VolumeSerialNumber = 0x12345678,
.VolumeLabel = "LUFA BOOT ",
.FilesystemIdentifier = "FAT12 ",
};
/** FAT 8.3 style directory entry, for the virtual FLASH contents file. */
static FATDirectoryEntry_t FirmwareFileEntries[] =
{
/* Root volume label entry; disk label is contained in the Filename and
* Extension fields (concatenated) with a special attribute flag - other
* fields are ignored. Should be the same as the label in the boot block.
*/
[DISK_FILE_ENTRY_VolumeID] =
{
.MSDOS_Directory =
{
.Name = "LUFA BOOT ",
.Attributes = FAT_FLAG_VOLUME_NAME,
.Reserved = {0},
.CreationTime = 0,
.CreationDate = 0,
.StartingCluster = 0,
.Reserved2 = 0,
}
},
/* VFAT Long File Name entry for the virtual firmware file; required to
* prevent corruption from systems that are unable to detect the device
* as being a legacy MSDOS style FAT12 volume. */
[DISK_FILE_ENTRY_FLASH_LFN] =
{
.VFAT_LongFileName =
{
.Ordinal = 1 | FAT_ORDINAL_LAST_ENTRY,
.Attribute = FAT_FLAG_LONG_FILE_NAME,
.Reserved1 = 0,
.Reserved2 = 0,
.Checksum = FAT_CHECKSUM('F','L','A','S','H',' ',' ',' ','B','I','N'),
.Unicode1 = 'F',
.Unicode2 = 'L',
.Unicode3 = 'A',
.Unicode4 = 'S',
.Unicode5 = 'H',
.Unicode6 = '.',
.Unicode7 = 'B',
.Unicode8 = 'I',
.Unicode9 = 'N',
.Unicode10 = 0,
.Unicode11 = 0,
.Unicode12 = 0,
.Unicode13 = 0,
}
},
/* MSDOS file entry for the virtual Firmware image. */
[DISK_FILE_ENTRY_FLASH_MSDOS] =
{
.MSDOS_File =
{
.Filename = "FLASH ",
.Extension = "BIN",
.Attributes = 0,
.Reserved = {0},
.CreationTime = FAT_TIME(1, 1, 0),
.CreationDate = FAT_DATE(14, 2, 1989),
.StartingCluster = 2,
.FileSizeBytes = FLASH_FILE_SIZE_BYTES,
}
},
[DISK_FILE_ENTRY_EEPROM_LFN] =
{
.VFAT_LongFileName =
{
.Ordinal = 1 | FAT_ORDINAL_LAST_ENTRY,
.Attribute = FAT_FLAG_LONG_FILE_NAME,
.Reserved1 = 0,
.Reserved2 = 0,
.Checksum = FAT_CHECKSUM('E','E','P','R','O','M',' ',' ','B','I','N'),
.Unicode1 = 'E',
.Unicode2 = 'E',
.Unicode3 = 'P',
.Unicode4 = 'R',
.Unicode5 = 'O',
.Unicode6 = 'M',
.Unicode7 = '.',
.Unicode8 = 'B',
.Unicode9 = 'I',
.Unicode10 = 'N',
.Unicode11 = 0,
.Unicode12 = 0,
.Unicode13 = 0,
}
},
[DISK_FILE_ENTRY_EEPROM_MSDOS] =
{
.MSDOS_File =
{
.Filename = "EEPROM ",
.Extension = "BIN",
.Attributes = 0,
.Reserved = {0},
.CreationTime = FAT_TIME(1, 1, 0),
.CreationDate = FAT_DATE(14, 2, 1989),
.StartingCluster = 2 + FILE_CLUSTERS(FLASH_FILE_SIZE_BYTES),
.FileSizeBytes = EEPROM_FILE_SIZE_BYTES,
}
},
};
/** Starting cluster of the virtual FLASH.BIN file on disk, tracked so that the
* offset from the start of the data sector can be determined. On Windows
* systems files are usually replaced using the original file's disk clusters,
* while Linux appears to overwrite with an offset which must be compensated for.
*/
static const uint16_t* FLASHFileStartCluster = &FirmwareFileEntries[DISK_FILE_ENTRY_FLASH_MSDOS].MSDOS_File.StartingCluster;
/** Starting cluster of the virtual EEPROM.BIN file on disk, tracked so that the
* offset from the start of the data sector can be determined. On Windows
* systems files are usually replaced using the original file's disk clusters,
* while Linux appears to overwrite with an offset which must be compensated for.
*/
static const uint16_t* EEPROMFileStartCluster = &FirmwareFileEntries[DISK_FILE_ENTRY_EEPROM_MSDOS].MSDOS_File.StartingCluster;
/** Reads a byte of EEPROM out from the EEPROM memory space.
*
* \note This function is required as the avr-libc EEPROM functions do not cope
* with linker relaxations, and a jump longer than 4K of FLASH on the
* larger USB AVRs will break the linker. This function is marked as
* never inlinable and placed into the normal text segment so that the
* call to the EEPROM function will be short even if the AUX boot section
* is used.
*
* \param[in] Address Address of the EEPROM location to read from
*
* \return Read byte of EEPROM data.
*/
static uint8_t ReadEEPROMByte(const uint8_t* const Address)
{
return eeprom_read_byte(Address);
}
/** Writes a byte of EEPROM out to the EEPROM memory space.
*
* \note This function is required as the avr-libc EEPROM functions do not cope
* with linker relaxations, and a jump longer than 4K of FLASH on the
* larger USB AVRs will break the linker. This function is marked as
* never inlinable and placed into the normal text segment so that the
* call to the EEPROM function will be short even if the AUX boot section
* is used.
*
* \param[in] Address Address of the EEPROM location to write to
* \param[in] Data New data to write to the EEPROM location
*/
static void WriteEEPROMByte(uint8_t* const Address,
const uint8_t Data)
{
eeprom_update_byte(Address, Data);
}
/** Updates a FAT12 cluster entry in the FAT file table with the specified next
* chain index. If the cluster is the last in the file chain, the magic value
* \c 0xFFF should be used.
*
* \note FAT data cluster indexes are offset by 2, so that cluster 2 is the
* first file data cluster on the disk. See the FAT specification.
*
* \param[out] FATTable Pointer to the FAT12 allocation table
* \param[in] Index Index of the cluster entry to update
* \param[in] ChainEntry Next cluster index in the file chain
*/
static void UpdateFAT12ClusterEntry(uint8_t* const FATTable,
const uint16_t Index,
const uint16_t ChainEntry)
{
/* Calculate the starting offset of the cluster entry in the FAT12 table */
uint8_t FATOffset = (Index + (Index >> 1));
bool UpperNibble = ((Index & 1) != 0);
/* Check if the start of the entry is at an upper nibble of the byte, fill
* out FAT12 entry as required */
if (UpperNibble)
{
FATTable[FATOffset] = (FATTable[FATOffset] & 0x0F) | ((ChainEntry & 0x0F) << 4);
FATTable[FATOffset + 1] = (ChainEntry >> 4);
}
else
{
FATTable[FATOffset] = ChainEntry;
FATTable[FATOffset + 1] = (FATTable[FATOffset] & 0xF0) | (ChainEntry >> 8);
}
}
/** Updates a FAT12 cluster chain in the FAT file table with a linear chain of
* the specified length.
*
* \note FAT data cluster indexes are offset by 2, so that cluster 2 is the
* first file data cluster on the disk. See the FAT specification.
*
* \param[out] FATTable Pointer to the FAT12 allocation table
* \param[in] Index Index of the start of the cluster chain to update
* \param[in] ChainLength Length of the chain to write, in clusters
*/
static void UpdateFAT12ClusterChain(uint8_t* const FATTable,
const uint16_t Index,
const uint8_t ChainLength)
{
for (uint8_t i = 0; i < ChainLength; i++)
{
uint16_t CurrentCluster = Index + i;
uint16_t NextCluster = CurrentCluster + 1;
/* Mark last cluster as end of file */
if (i == (ChainLength - 1))
NextCluster = 0xFFF;
UpdateFAT12ClusterEntry(FATTable, CurrentCluster, NextCluster);
}
}
/** Reads or writes a block of data from/to the physical device FLASH using a
* block buffer stored in RAM, if the requested block is within the virtual
* firmware file's sector ranges in the emulated FAT file system.
*
* \param[in] BlockNumber Physical disk block to read from/write to
* \param[in,out] BlockBuffer Pointer to the start of the block buffer in RAM
* \param[in] Read If \c true, the requested block is read, if
* \c false, the requested block is written
*/
static void ReadWriteFLASHFileBlock(const uint16_t BlockNumber,
uint8_t* BlockBuffer,
const bool Read)
{
uint16_t FileStartBlock = DISK_BLOCK_DataStartBlock + (*FLASHFileStartCluster - 2) * SECTOR_PER_CLUSTER;
uint16_t FileEndBlock = FileStartBlock + (FILE_SECTORS(FLASH_FILE_SIZE_BYTES) - 1);
/* Range check the write request - abort if requested block is not within the
* virtual firmware file sector range */
if (!((BlockNumber >= FileStartBlock) && (BlockNumber <= FileEndBlock)))
return;
#if (FLASHEND > 0xFFFF)
uint32_t FlashAddress = (uint32_t)(BlockNumber - FileStartBlock) * SECTOR_SIZE_BYTES;
#else
uint16_t FlashAddress = (uint16_t)(BlockNumber - FileStartBlock) * SECTOR_SIZE_BYTES;
#endif
if (Read)
{
/* Read out the mapped block of data from the device's FLASH */
for (uint16_t i = 0; i < SECTOR_SIZE_BYTES; i++)
{
#if (FLASHEND > 0xFFFF)
BlockBuffer[i] = pgm_read_byte_far(FlashAddress++);
#else
BlockBuffer[i] = pgm_read_byte(FlashAddress++);
#endif
}
}
else
{
/* Write out the mapped block of data to the device's FLASH */
for (uint16_t i = 0; i < SECTOR_SIZE_BYTES; i += 2)
{
if ((FlashAddress % SPM_PAGESIZE) == 0)
{
/* Erase the given FLASH page, ready to be programmed */
BootloaderAPI_ErasePage(FlashAddress);
}
/* Write the next data word to the FLASH page */
BootloaderAPI_FillWord(FlashAddress, (BlockBuffer[i + 1] << 8) | BlockBuffer[i]);
FlashAddress += 2;
if ((FlashAddress % SPM_PAGESIZE) == 0)
{
/* Write the filled FLASH page to memory */
BootloaderAPI_WritePage(FlashAddress - SPM_PAGESIZE);
}
}
}
}
/** Reads or writes a block of data from/to the physical device EEPROM using a
* block buffer stored in RAM, if the requested block is within the virtual
* firmware file's sector ranges in the emulated FAT file system.
*
* \param[in] BlockNumber Physical disk block to read from/write to
* \param[in,out] BlockBuffer Pointer to the start of the block buffer in RAM
* \param[in] Read If \c true, the requested block is read, if
* \c false, the requested block is written
*/
static void ReadWriteEEPROMFileBlock(const uint16_t BlockNumber,
uint8_t* BlockBuffer,
const bool Read)
{
uint16_t FileStartBlock = DISK_BLOCK_DataStartBlock + (*EEPROMFileStartCluster - 2) * SECTOR_PER_CLUSTER;
uint16_t FileEndBlock = FileStartBlock + (FILE_SECTORS(EEPROM_FILE_SIZE_BYTES) - 1);
/* Range check the write request - abort if requested block is not within the
* virtual firmware file sector range */
if (!((BlockNumber >= FileStartBlock) && (BlockNumber <= FileEndBlock)))
return;
uint16_t EEPROMAddress = (uint16_t)(BlockNumber - FileStartBlock) * SECTOR_SIZE_BYTES;
if (Read)
{
/* Read out the mapped block of data from the device's EEPROM */
for (uint16_t i = 0; i < SECTOR_SIZE_BYTES; i++)
BlockBuffer[i] = ReadEEPROMByte((uint8_t*)EEPROMAddress++);
}
else
{
/* Write out the mapped block of data to the device's EEPROM */
for (uint16_t i = 0; i < SECTOR_SIZE_BYTES; i++)
WriteEEPROMByte((uint8_t*)EEPROMAddress++, BlockBuffer[i]);
}
}
/** Writes a block of data to the virtual FAT filesystem, from the USB Mass
* Storage interface.
*
* \param[in] BlockNumber Index of the block to write.
*/
void VirtualFAT_WriteBlock(const uint16_t BlockNumber)
{
uint8_t BlockBuffer[SECTOR_SIZE_BYTES];
/* Buffer the entire block to be written from the host */
Endpoint_Read_Stream_LE(BlockBuffer, sizeof(BlockBuffer), NULL);
Endpoint_ClearOUT();
switch (BlockNumber)
{
case DISK_BLOCK_BootBlock:
case DISK_BLOCK_FATBlock1:
case DISK_BLOCK_FATBlock2:
/* Ignore writes to the boot and FAT blocks */
break;
case DISK_BLOCK_RootFilesBlock:
/* Copy over the updated directory entries */
memcpy(FirmwareFileEntries, BlockBuffer, sizeof(FirmwareFileEntries));
break;
default:
ReadWriteFLASHFileBlock(BlockNumber, BlockBuffer, false);
ReadWriteEEPROMFileBlock(BlockNumber, BlockBuffer, false);
break;
}
}
/** Reads a block of data from the virtual FAT filesystem, and sends it to the
* host via the USB Mass Storage interface.
*
* \param[in] BlockNumber Index of the block to read.
*/
void VirtualFAT_ReadBlock(const uint16_t BlockNumber)
{
uint8_t BlockBuffer[SECTOR_SIZE_BYTES];
memset(BlockBuffer, 0x00, sizeof(BlockBuffer));
switch (BlockNumber)
{
case DISK_BLOCK_BootBlock:
memcpy(BlockBuffer, &BootBlock, sizeof(FATBootBlock_t));
/* Add the magic signature to the end of the block */
BlockBuffer[SECTOR_SIZE_BYTES - 2] = 0x55;
BlockBuffer[SECTOR_SIZE_BYTES - 1] = 0xAA;
break;
case DISK_BLOCK_FATBlock1:
case DISK_BLOCK_FATBlock2:
/* Cluster 0: Media type/Reserved */
UpdateFAT12ClusterEntry(BlockBuffer, 0, 0xF00 | BootBlock.MediaDescriptor);
/* Cluster 1: Reserved */
UpdateFAT12ClusterEntry(BlockBuffer, 1, 0xFFF);
/* Cluster 2 onwards: Cluster chain of FLASH.BIN */
UpdateFAT12ClusterChain(BlockBuffer, *FLASHFileStartCluster, FILE_CLUSTERS(FLASH_FILE_SIZE_BYTES));
/* Cluster 2+n onwards: Cluster chain of EEPROM.BIN */
UpdateFAT12ClusterChain(BlockBuffer, *EEPROMFileStartCluster, FILE_CLUSTERS(EEPROM_FILE_SIZE_BYTES));
break;
case DISK_BLOCK_RootFilesBlock:
memcpy(BlockBuffer, FirmwareFileEntries, sizeof(FirmwareFileEntries));
break;
default:
ReadWriteFLASHFileBlock(BlockNumber, BlockBuffer, true);
ReadWriteEEPROMFileBlock(BlockNumber, BlockBuffer, true);
break;
}
/* Write the entire read block Buffer to the host */
Endpoint_Write_Stream_LE(BlockBuffer, sizeof(BlockBuffer), NULL);
Endpoint_ClearIN();
}

View File

@@ -0,0 +1,302 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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.
*/
#ifndef _VIRTUALFAT_H_
#define _VIRTUALFAT_H_
/* Includes: */
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h>
#include "../BootloaderAPI.h"
/* Macros: */
/** Size of the virtual FLASH.BIN file in bytes. */
#define FLASH_FILE_SIZE_BYTES (FLASHEND - (FLASHEND - BOOT_START_ADDR) - AUX_BOOT_SECTION_SIZE)
/** Size of the virtual EEPROM.BIN file in bytes. */
#define EEPROM_FILE_SIZE_BYTES E2END
/** Number of sectors that comprise a single logical disk cluster. */
#define SECTOR_PER_CLUSTER 4
/** Size of a single logical sector on the disk. */
#define SECTOR_SIZE_BYTES 512
/** Size of a logical cluster on the disk, in bytes */
#define CLUSTER_SIZE_BYTES (SECTOR_PER_CLUSTER * SECTOR_SIZE_BYTES)
/** Number of sectors required to store a given size in bytes.
*
* \param[in] size Size of the data that needs to be stored
*
* \return Number of sectors required to store the given data on the disk.
*/
#define FILE_SECTORS(size) ((size / SECTOR_SIZE_BYTES) + ((size % SECTOR_SIZE_BYTES) ? 1 : 0))
/** Number of clusters required to store a given size in bytes.
*
* \param[in] size Size of the data that needs to be stored
*
* \return Number of clusters required to store the given data on the disk.
*/
#define FILE_CLUSTERS(size) ((size / CLUSTER_SIZE_BYTES) + ((size % CLUSTER_SIZE_BYTES) ? 1 : 0))
/** Total number of logical sectors/blocks on the disk. */
#define LUN_MEDIA_BLOCKS (FILE_SECTORS(FLASH_FILE_SIZE_BYTES) + FILE_SECTORS(EEPROM_FILE_SIZE_BYTES) + 32)
/** Converts a given time in HH:MM:SS format to a FAT filesystem time.
*
* \note The minimum seconds resolution of FAT is 2, thus odd seconds
* will be truncated to the previous integer multiple of 2 seconds.
*
* \param[in] hh Hours (0-23)
* \param[in] mm Minutes (0-59)
* \param[in] ss Seconds (0-59)
*
* \return Given time encoded as a FAT filesystem timestamp
*/
#define FAT_TIME(hh, mm, ss) ((hh << 11) | (mm << 5) | (ss >> 1))
/** Converts a given date in DD/MM/YYYY format to a FAT filesystem date.
*
* \param[in] dd Days in the month (1-31)
* \param[in] mm Months in the year (1-12)
* \param[in] yyyy Year (1980 - 2107)
*
* \return Given date encoded as a FAT filesystem datestamp
*/
#define FAT_DATE(dd, mm, yyyy) (((yyyy - 1980) << 9) | (mm << 5) | (dd << 0))
/** Bit-rotates a given 8-bit value once to the right.
*
* \param x Value to rotate right once
*
* \return Bit-rotated input value, rotated once to the right.
*/
#define _ROT8(x) ((((x) & 0xFE) >> 1) | (((x) & 1) ? 0x80 : 0x00))
/** Computes the LFN entry checksum of a MSDOS 8.3 format file entry,
* to associate a LFN entry with its short file entry.
*
* \param n0 MSDOS Filename character 1
* \param n1 MSDOS Filename character 2
* \param n2 MSDOS Filename character 3
* \param n3 MSDOS Filename character 4
* \param n4 MSDOS Filename character 5
* \param n5 MSDOS Filename character 6
* \param n6 MSDOS Filename character 7
* \param n7 MSDOS Filename character 8
* \param e0 MSDOS Extension character 1
* \param e1 MSDOS Extension character 2
* \param e2 MSDOS Extension character 3
*
* \return LFN checksum of the given MSDOS 8.3 filename.
*/
#define FAT_CHECKSUM(n0, n1, n2, n3, n4, n5, n6, n7, e0, e1, e2) \
(uint8_t)(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(_ROT8(n0)+n1)+n2)+n3)+n4)+n5)+n6)+n7)+e0)+e1)+e2)
/** \name FAT Filesystem Flags */
//@{
/** FAT attribute flag to indicate a read-only file. */
#define FAT_FLAG_READONLY (1 << 0)
/** FAT attribute flag to indicate a hidden file. */
#define FAT_FLAG_HIDDEN (1 << 1)
/** FAT attribute flag to indicate a system file. */
#define FAT_FLAG_SYSTEM (1 << 2)
/** FAT attribute flag to indicate a Volume name entry. */
#define FAT_FLAG_VOLUME_NAME (1 << 3)
/** FAT attribute flag to indicate a directory entry. */
#define FAT_FLAG_DIRECTORY (1 << 4)
/** FAT attribute flag to indicate a file ready for archiving. */
#define FAT_FLAG_ARCHIVE (1 << 5)
/** FAT pseudo-attribute flag to indicate a Long File Name entry. */
#define FAT_FLAG_LONG_FILE_NAME 0x0F
/** Ordinal flag marker for FAT Long File Name entries to mark the last entry. */
#define FAT_ORDINAL_LAST_ENTRY (1 << 6)
//@}
/* Enums: */
/** Enum for the Root FAT file entry indexes on the disk. This can be used
* to retrieve the current contents of a known directory entry.
*/
enum
{
/** Volume ID directory entry, giving the name of the virtual disk. */
DISK_FILE_ENTRY_VolumeID = 0,
/** Long File Name FAT file entry of the virtual FLASH.BIN image file. */
DISK_FILE_ENTRY_FLASH_LFN = 1,
/** Legacy MSDOS FAT file entry of the virtual FLASH.BIN image file. */
DISK_FILE_ENTRY_FLASH_MSDOS = 2,
/** Long File Name FAT file entry of the virtual EEPROM.BIN image file. */
DISK_FILE_ENTRY_EEPROM_LFN = 3,
/** Legacy MSDOS FAT file entry of the virtual EEPROM.BIN image file. */
DISK_FILE_ENTRY_EEPROM_MSDOS = 4,
};
/** Enum for the physical disk blocks of the virtual disk. */
enum
{
/** Boot sector disk block. */
DISK_BLOCK_BootBlock = 0,
/** First copy of the FAT table block. */
DISK_BLOCK_FATBlock1 = 1,
/** Second copy of the FAT table block. */
DISK_BLOCK_FATBlock2 = 2,
/** Root file and directory entries block. */
DISK_BLOCK_RootFilesBlock = 3,
/** Start block of the disk data section. */
DISK_BLOCK_DataStartBlock = 4,
};
/* Type Definitions: */
/** FAT boot block structure definition, used to identify the core
* parameters of a FAT file system stored on a disk.
*
* \note This definition is truncated to save space; the magic signature
* \c 0xAA55 must be appended to the very end of the block for it
* to be detected by the host as a valid boot block.
*/
typedef struct
{
uint8_t Bootstrap[3];
uint8_t Description[8];
uint16_t SectorSize;
uint8_t SectorsPerCluster;
uint16_t ReservedSectors;
uint8_t FATCopies;
uint16_t RootDirectoryEntries;
uint16_t TotalSectors16;
uint8_t MediaDescriptor;
uint16_t SectorsPerFAT;
uint16_t SectorsPerTrack;
uint16_t Heads;
uint32_t HiddenSectors;
uint32_t TotalSectors32;
uint16_t PhysicalDriveNum;
uint8_t ExtendedBootRecordSig;
uint32_t VolumeSerialNumber;
uint8_t VolumeLabel[11];
uint8_t FilesystemIdentifier[8];
/* uint8_t BootstrapProgram[448]; */
/* uint16_t MagicSignature; */
} FATBootBlock_t;
/** FAT directory entry structure, for the various kinds of File and
* directory descriptors on a FAT disk.
*/
typedef union
{
/** VFAT Long File Name file entry. */
struct
{
uint8_t Ordinal;
uint16_t Unicode1;
uint16_t Unicode2;
uint16_t Unicode3;
uint16_t Unicode4;
uint16_t Unicode5;
uint8_t Attribute;
uint8_t Reserved1;
uint8_t Checksum;
uint16_t Unicode6;
uint16_t Unicode7;
uint16_t Unicode8;
uint16_t Unicode9;
uint16_t Unicode10;
uint16_t Unicode11;
uint16_t Reserved2;
uint16_t Unicode12;
uint16_t Unicode13;
} VFAT_LongFileName;
/** Legacy FAT MSDOS 8.3 file entry. */
struct
{
uint8_t Filename[8];
uint8_t Extension[3];
uint8_t Attributes;
uint8_t Reserved[10];
uint16_t CreationTime;
uint16_t CreationDate;
uint16_t StartingCluster;
uint32_t FileSizeBytes;
} MSDOS_File;
/** Legacy FAT MSDOS (sub-)directory entry. */
struct
{
uint8_t Name[11];
uint8_t Attributes;
uint8_t Reserved[10];
uint16_t CreationTime;
uint16_t CreationDate;
uint16_t StartingCluster;
uint32_t Reserved2;
} MSDOS_Directory;
} FATDirectoryEntry_t;
/* Function Prototypes: */
#if defined(INCLUDE_FROM_VIRTUAL_FAT_C)
static uint8_t ReadEEPROMByte(const uint8_t* const Address) ATTR_NEVER_INLINE;
static void WriteEEPROMByte(uint8_t* const Address,
const uint8_t Data) ATTR_NEVER_INLINE;
static void UpdateFAT12ClusterEntry(uint8_t* const FATTable,
const uint16_t Index,
const uint16_t ChainEntry) AUX_BOOT_SECTION;
static void UpdateFAT12ClusterChain(uint8_t* const FATTable,
const uint16_t StartIndex,
const uint8_t ChainLength) AUX_BOOT_SECTION;
static void ReadWriteFLASHFileBlock(const uint16_t BlockNumber,
uint8_t* BlockBuffer,
const bool Read) AUX_BOOT_SECTION;
static void ReadWriteEEPROMFileBlock(const uint16_t BlockNumber,
uint8_t* BlockBuffer,
const bool Read) AUX_BOOT_SECTION;
#endif
void VirtualFAT_WriteBlock(const uint16_t BlockNumber) AUX_BOOT_SECTION;
void VirtualFAT_ReadBlock(const uint16_t BlockNumber) AUX_BOOT_SECTION;
#endif

View File

@@ -0,0 +1,154 @@
<asf xmlversion="1.0">
<project caption="Mass Storage Bootloader - 128KB FLASH / 8KB Boot - AVR8 Architecture" id="lufa.bootloaders.mass_storage.avr8.128_8" force-caption="true" workspace-name="lufa_ms_128kb_8kb_">
<require idref="lufa.bootloaders.mass_storage"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="at90usb1287"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x1E000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1E000"/>
<build type="define" name="AUX_BOOT_SECTION_SIZE" value="0"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FFA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FFE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FFF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="Mass Storage Bootloader - 64KB FLASH / 8KB Boot - AVR8 Architecture" id="lufa.bootloaders.mass_storage.avr8.64_8" force-caption="true" workspace-name="lufa_ms_64kb_8kb_">
<require idref="lufa.bootloaders.mass_storage"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="at90usb647"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0xE000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0xE000"/>
<build type="define" name="AUX_BOOT_SECTION_SIZE" value="0"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0xFFA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0xFFE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0xFFF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="Mass Storage Bootloader - 32KB FLASH / 4KB Boot (2KB AUX) - AVR8 Architecture" id="lufa.bootloaders.mass_storage.avr8.32_4" force-caption="true" workspace-name="lufa_ms_32kb_4kb_">
<require idref="lufa.bootloaders.mass_storage"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega32u4"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x7000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x7000"/>
<build type="define" name="AUX_BOOT_SECTION_SIZE" value="2048"/>
<build type="linker-config" subtype="flags" value="--section-start=.boot_aux=0x6810"/>
<build type="linker-config" subtype="flags" value="--section-start=.boot_aux_trampoline=0x6800"/>
<build type="linker-config" subtype="flags" value="--undefined=Boot_AUX_Trampoline"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x7FA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x7FE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x7FF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="Mass Storage Bootloader - 16KB FLASH / 4KB Boot (2KB AUX) - AVR8 Architecture" id="lufa.bootloaders.mass_storage.avr8.16_4" force-caption="true" workspace-name="lufa_ms_16kb_4kb_">
<require idref="lufa.bootloaders.mass_storage"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega16u2"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x3000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x3000"/>
<build type="define" name="AUX_BOOT_SECTION_SIZE" value="2048"/>
<build type="linker-config" subtype="flags" value="--section-start=.boot_aux=0x2810"/>
<build type="linker-config" subtype="flags" value="--section-start=.boot_aux_trampoline=0x2800"/>
<build type="linker-config" subtype="flags" value="--undefined=Boot_AUX_Trampoline"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x3FA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x3FE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x3FF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<module type="application" id="lufa.bootloaders.mass_storage" caption="Mass Storage Bootloader">
<info type="description" value="summary">
Mass Storage Class Bootloader, capable of reprogramming a device via binary BIN files copied to the virtual FAT12 file-system it creates when plugged into a host.
</info>
<info type="gui-flag" value="move-to-root"/>
<info type="keyword" value="Technology">
<keyword value="Bootloaders"/>
<keyword value="USB Device"/>
</info>
<device-support-alias value="lufa_avr8"/>
<device-support-alias value="lufa_xmega"/>
<device-support-alias value="lufa_uc3"/>
<build type="include-path" value="."/>
<build type="c-source" value="BootloaderMassStorage.c"/>
<build type="header-file" value="BootloaderMassStorage.h"/>
<build type="c-source" value="Descriptors.c"/>
<build type="header-file" value="Descriptors.h"/>
<build type="c-source" value="BootloaderAPI.c"/>
<build type="header-file" value="BootloaderAPI.h"/>
<build type="asm-source" value="BootloaderAPITable.S"/>
<build type="module-config" subtype="path" value="Config"/>
<build type="header-file" value="Config/LUFAConfig.h"/>
<build type="include-path" value="Lib"/>
<build type="header-file" value="Lib/VirtualFAT.h"/>
<build type="c-source" value="Lib/VirtualFAT.c"/>
<build type="header-file" value="Lib/SCSI.h"/>
<build type="c-source" value="Lib/SCSI.c"/>
<build type="distribute" subtype="user-file" value="BootloaderMassStorage.txt"/>
<require idref="lufa.common"/>
<require idref="lufa.platform"/>
<require idref="lufa.drivers.usb"/>
<require idref="lufa.drivers.board"/>
<require idref="lufa.drivers.board.leds"/>
</module>
</asf>

View File

@@ -0,0 +1,68 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------
# Run "make help" for target help.
MCU = at90usb1287
ARCH = AVR8
BOARD = USBKEY
F_CPU = 8000000
F_USB = $(F_CPU)
OPTIMIZATION = s
TARGET = BootloaderMassStorage
SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S Lib/SCSI.c Lib/VirtualFAT.c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS)
LUFA_PATH = ../../LUFA
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DBOOT_START_ADDR=$(BOOT_START_OFFSET)
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAGS)
# Flash size and bootloader section sizes of the target, in KB. These must
# match the target's total FLASH size and the bootloader size set in the
# device's fuses.
FLASH_SIZE_KB = 128
BOOT_SECTION_SIZE_KB = 8
# Bootloader address calculation formulas
# Do not modify these macros, but rather modify the dependent values above.
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
# Bootloader linker section flags for relocating the API table sections to
# known FLASH addresses - these should not normally be user-edited.
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
# Check if the bootloader needs an AUX section, located before the real bootloader section to store some of the
# bootloader code. This is required for 32KB and smaller devices, where the actual bootloader is 6KB but the maximum
# bootloader section size is 4KB. The actual usable application space will be reduced by 6KB for these devices.
ifeq ($(BOOT_SECTION_SIZE_KB),8)
CC_FLAGS += -DAUX_BOOT_SECTION_SIZE=0
else
AUX_BOOT_SECTION_SIZE_KB = (6 - $(BOOT_SECTION_SIZE_KB))
CC_FLAGS += -DAUX_BOOT_SECTION_SIZE='($(AUX_BOOT_SECTION_SIZE_KB) * 1024)'
LD_FLAGS += -Wl,--section-start=.boot_aux=$(call BOOT_SEC_OFFSET, (($(BOOT_SECTION_SIZE_KB) + $(AUX_BOOT_SECTION_SIZE_KB)) * 1024 - 16))
LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .boot_aux_trampoline, Boot_AUX_Trampoline, ($(BOOT_SECTION_SIZE_KB) + $(AUX_BOOT_SECTION_SIZE_KB)) * 1024)
endif
# Default target
all:
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk
include $(LUFA_PATH)/Build/lufa_sources.mk
include $(LUFA_PATH)/Build/lufa_build.mk
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
include $(LUFA_PATH)/Build/lufa_doxygen.mk
include $(LUFA_PATH)/Build/lufa_avrdude.mk
include $(LUFA_PATH)/Build/lufa_atprogram.mk

View File

@@ -0,0 +1,75 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
*
* Bootloader user application API functions.
*/
#include "BootloaderAPI.h"
void BootloaderAPI_ErasePage(const uint32_t Address)
{
boot_page_erase_safe(Address);
boot_spm_busy_wait();
boot_rww_enable();
}
void BootloaderAPI_WritePage(const uint32_t Address)
{
boot_page_write_safe(Address);
boot_spm_busy_wait();
boot_rww_enable();
}
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
{
boot_page_fill_safe(Address, Word);
}
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
{
return boot_signature_byte_get(Address);
}
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
{
return boot_lock_fuse_bits_get(Address);
}
uint8_t BootloaderAPI_ReadLock(void)
{
return boot_lock_fuse_bits_get(GET_LOCK_BITS);
}
void BootloaderAPI_WriteLock(const uint8_t LockBits)
{
boot_lock_bits_set_safe(LockBits);
}

View File

@@ -0,0 +1,56 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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 BootloaderAPI.c.
*/
#ifndef _BOOTLOADER_API_H_
#define _BOOTLOADER_API_H_
/* Includes: */
#include <avr/io.h>
#include <avr/boot.h>
#include <stdbool.h>
#include <LUFA/Common/Common.h>
/* Function Prototypes: */
void BootloaderAPI_ErasePage(const uint32_t Address);
void BootloaderAPI_WritePage(const uint32_t Address);
void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
uint8_t BootloaderAPI_ReadLock(void);
void BootloaderAPI_WriteLock(const uint8_t LockBits);
#endif

View File

@@ -0,0 +1,91 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 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 disclaims 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.
*/
; Trampolines to actual API implementations if the target address is outside the
; range of a rjmp instruction (can happen with large bootloader sections)
.section .apitable_trampolines, "ax"
.global BootloaderAPI_Trampolines
BootloaderAPI_Trampolines:
BootloaderAPI_ErasePage_Trampoline:
jmp BootloaderAPI_ErasePage
BootloaderAPI_WritePage_Trampoline:
jmp BootloaderAPI_WritePage
BootloaderAPI_FillWord_Trampoline:
jmp BootloaderAPI_FillWord
BootloaderAPI_ReadSignature_Trampoline:
jmp BootloaderAPI_ReadSignature
BootloaderAPI_ReadFuse_Trampoline:
jmp BootloaderAPI_ReadFuse
BootloaderAPI_ReadLock_Trampoline:
jmp BootloaderAPI_ReadLock
BootloaderAPI_WriteLock_Trampoline:
jmp BootloaderAPI_WriteLock
BootloaderAPI_UNUSED1:
ret
BootloaderAPI_UNUSED2:
ret
BootloaderAPI_UNUSED3:
ret
BootloaderAPI_UNUSED4:
ret
BootloaderAPI_UNUSED5:
ret
; API function jump table
.section .apitable_jumptable, "ax"
.global BootloaderAPI_JumpTable
BootloaderAPI_JumpTable:
rjmp BootloaderAPI_ErasePage_Trampoline
rjmp BootloaderAPI_WritePage_Trampoline
rjmp BootloaderAPI_FillWord_Trampoline
rjmp BootloaderAPI_ReadSignature_Trampoline
rjmp BootloaderAPI_ReadFuse_Trampoline
rjmp BootloaderAPI_ReadLock_Trampoline
rjmp BootloaderAPI_WriteLock_Trampoline
rjmp BootloaderAPI_UNUSED1 ; UNUSED ENTRY 1
rjmp BootloaderAPI_UNUSED2 ; UNUSED ENTRY 2
rjmp BootloaderAPI_UNUSED3 ; UNUSED ENTRY 3
rjmp BootloaderAPI_UNUSED4 ; UNUSED ENTRY 4
rjmp BootloaderAPI_UNUSED5 ; UNUSED ENTRY 5
; Bootloader table signatures and information
.section .apitable_signatures, "ax"
.global BootloaderAPI_Signatures
BootloaderAPI_Signatures:
.long BOOT_START_ADDR ; Start address of the bootloader
.word 0xDF20 ; Signature for the Printer class bootloader
.word 0xDCFB ; Signature for a LUFA class bootloader

View File

@@ -0,0 +1,431 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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 Printer class bootloader. This file contains the complete bootloader logic.
*/
#include "BootloaderPrinter.h"
/** LUFA Printer Class driver interface configuration and state information. This structure is
* passed to all Printer Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
USB_ClassInfo_PRNT_Device_t TextOnly_Printer_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.DataINEndpoint =
{
.Address = PRINTER_IN_EPADDR,
.Size = PRINTER_IO_EPSIZE,
.Banks = 1,
},
.DataOUTEndpoint =
{
.Address = PRINTER_OUT_EPADDR,
.Size = PRINTER_IO_EPSIZE,
.Banks = 1,
},
.IEEE1284String =
"MFG:Generic;"
"MDL:Generic_/_Text_Only;"
"CMD:1284.4;"
"CLS:PRINTER",
},
};
/** Intel HEX parser state machine state information, to track the contents of
* a HEX file streamed in as a sequence of arbitrary bytes.
*/
struct
{
/** Current HEX parser state machine state. */
uint8_t ParserState;
/** Previously decoded numerical byte of data. */
uint8_t PrevData;
/** Currently decoded numerical byte of data. */
uint8_t Data;
/** Indicates if both bytes that correspond to a single decoded numerical
* byte of data (HEX encodes values in ASCII HEX, two characters per byte)
* have been read.
*/
bool ReadMSB;
/** Intel HEX record type of the current Intel HEX record. */
uint8_t RecordType;
/** Numerical bytes of data remaining to be read in the current record. */
uint8_t DataRem;
/** Checksum of the current record received so far. */
uint8_t Checksum;
/** Starting address of the last addressed FLASH page. */
uint32_t PageStartAddress;
/** Current 32-bit byte extended base address in FLASH being targeted. */
uint32_t CurrBaseAddress;
/** Current 32-bit byte address in FLASH being targeted. */
uint32_t CurrAddress;
} HEXParser;
/** Indicates if there is data waiting to be written to a physical page of
* memory in FLASH.
*/
static bool PageDirty = false;
/** 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
* started via a forced watchdog reset.
*/
static bool RunBootloader = true;
/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
* will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
* low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
* \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
*/
uint16_t MagicBootKey ATTR_NO_INIT;
/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
* start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
* this will force the user application to start via a software jump.
*/
void Application_Jump_Check(void)
{
/* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
{
MagicBootKey = 0;
// cppcheck-suppress constStatement
((void (*)(void))0x0000)();
}
}
/**
* Converts a given input byte of data from an ASCII encoded HEX value to an integer value.
*
* \note Input HEX bytes are expected to be in uppercase only.
*
* \param[in] Byte ASCII byte of data to convert
*
* \return Integer converted value of the input ASCII encoded HEX byte of data, or -1 if the
* input is not valid ASCII encoded HEX.
*/
static int8_t HexToDecimal(const char Byte)
{
if ((Byte >= 'A') && (Byte <= 'F'))
return (10 + (Byte - 'A'));
else if ((Byte >= '0') && (Byte <= '9'))
return (Byte - '0');
return -1;
}
/**
* Flushes a partially written page of data to physical FLASH, if a page
* boundary has been crossed.
*
* \note If a page flush occurs the global HEX parser state is updated.
*/
static void FlushPageIfRequired(void)
{
/* Abort if no data has been buffered for writing to the current page */
if (!PageDirty)
return;
/* Flush the FLASH page to physical memory if we are crossing a page boundary */
uint32_t NewPageStartAddress = (HEXParser.CurrAddress & ~(SPM_PAGESIZE - 1));
if (HEXParser.PageStartAddress != NewPageStartAddress)
{
boot_page_write(HEXParser.PageStartAddress);
boot_spm_busy_wait();
HEXParser.PageStartAddress = NewPageStartAddress;
PageDirty = false;
}
}
/**
* Parses an input Intel HEX formatted stream one character at a time, loading
* the data contents into the device's internal FLASH memory.
*
* \param[in] ReadCharacter Next input ASCII byte of data to parse
*/
static void ParseIntelHEXByte(const char ReadCharacter)
{
/* Reset the line parser while waiting for a new line to start */
if ((HEXParser.ParserState == HEX_PARSE_STATE_WAIT_LINE) || (ReadCharacter == ':'))
{
HEXParser.Checksum = 0;
HEXParser.CurrAddress = HEXParser.CurrBaseAddress;
HEXParser.ReadMSB = false;
/* ASCII ':' indicates the start of a new HEX record */
if (ReadCharacter == ':')
HEXParser.ParserState = HEX_PARSE_STATE_BYTE_COUNT;
return;
}
/* Only allow ASCII HEX encoded digits, ignore all other characters */
int8_t ReadCharacterDec = HexToDecimal(ReadCharacter);
if (ReadCharacterDec < 0)
return;
/* Read and convert the next nibble of data from the current character */
HEXParser.Data = (HEXParser.Data << 4) | ReadCharacterDec;
HEXParser.ReadMSB = !HEXParser.ReadMSB;
/* Only process further when a full byte (two nibbles) have been read */
if (HEXParser.ReadMSB)
return;
/* Intel HEX checksum is for all fields except starting character and the
* checksum itself
*/
if (HEXParser.ParserState != HEX_PARSE_STATE_CHECKSUM)
HEXParser.Checksum += HEXParser.Data;
switch (HEXParser.ParserState)
{
case HEX_PARSE_STATE_BYTE_COUNT:
HEXParser.DataRem = HEXParser.Data;
HEXParser.ParserState = HEX_PARSE_STATE_ADDRESS_HIGH;
break;
case HEX_PARSE_STATE_ADDRESS_HIGH:
HEXParser.CurrAddress += ((uint16_t)HEXParser.Data << 8);
HEXParser.ParserState = HEX_PARSE_STATE_ADDRESS_LOW;
break;
case HEX_PARSE_STATE_ADDRESS_LOW:
HEXParser.CurrAddress += HEXParser.Data;
HEXParser.ParserState = HEX_PARSE_STATE_RECORD_TYPE;
break;
case HEX_PARSE_STATE_RECORD_TYPE:
HEXParser.RecordType = HEXParser.Data;
HEXParser.ParserState = (HEXParser.DataRem ? HEX_PARSE_STATE_READ_DATA : HEX_PARSE_STATE_CHECKSUM);
break;
case HEX_PARSE_STATE_READ_DATA:
/* Track the number of read data bytes in the record */
HEXParser.DataRem--;
/* Protect the bootloader against being written to */
if (HEXParser.CurrAddress >= BOOT_START_ADDR)
{
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
PageDirty = false;
return;
}
/* Wait for a machine word (two bytes) of data to be read */
if (HEXParser.DataRem & 0x01)
{
HEXParser.PrevData = HEXParser.Data;
break;
}
/* Convert the last two received data bytes into a 16-bit word */
uint16_t NewDataWord = ((uint16_t)HEXParser.Data << 8) | HEXParser.PrevData;
switch (HEXParser.RecordType)
{
case HEX_RECORD_TYPE_Data:
/* If we are writing to a new page, we need to erase it first */
if (!(PageDirty))
{
boot_page_erase(HEXParser.PageStartAddress);
boot_spm_busy_wait();
PageDirty = true;
}
/* Fill the FLASH memory buffer with the new word of data */
boot_page_fill(HEXParser.CurrAddress, NewDataWord);
HEXParser.CurrAddress += 2;
/* Flush the FLASH page to physical memory if we are crossing a page boundary */
FlushPageIfRequired();
break;
case HEX_RECORD_TYPE_ExtendedSegmentAddress:
/* Extended address data - store the upper 12-bits of the new address */
HEXParser.CurrBaseAddress = ((uint32_t)NewDataWord << 4);
break;
case HEX_RECORD_TYPE_ExtendedLinearAddress:
/* Extended address data - store the upper 16-bits of the new address */
HEXParser.CurrBaseAddress = ((uint32_t)NewDataWord << 16);
break;
}
if (!HEXParser.DataRem)
HEXParser.ParserState = HEX_PARSE_STATE_CHECKSUM;
break;
case HEX_PARSE_STATE_CHECKSUM:
/* Verify checksum of the completed record */
if (HEXParser.Data != ((~HEXParser.Checksum + 1) & 0xFF))
break;
/* Flush the FLASH page to physical memory if we are crossing a page boundary */
FlushPageIfRequired();
/* If end of the HEX file reached, the bootloader should exit at next opportunity */
if (HEXParser.RecordType == HEX_RECORD_TYPE_EndOfFile)
RunBootloader = false;
break;
default:
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
break;
}
}
/** Main program entry point. This routine configures the hardware required by the application, then
* enters a loop to run the application tasks in sequence.
*/
int main(void)
{
SetupHardware();
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
GlobalInterruptEnable();
while (RunBootloader)
{
uint8_t BytesReceived = PRNT_Device_BytesReceived(&TextOnly_Printer_Interface);
if (BytesReceived)
{
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
while (BytesReceived--)
{
int16_t ReceivedByte = PRNT_Device_ReceiveByte(&TextOnly_Printer_Interface);
/* Feed the next byte of data to the HEX parser */
ParseIntelHEXByte(ReceivedByte);
}
LEDs_SetAllLEDs(LEDMASK_USB_READY);
}
PRNT_Device_USBTask(&TextOnly_Printer_Interface);
USB_USBTask();
}
/* Disconnect from the host - USB interface will be reset later along with the AVR */
USB_Detach();
/* Unlock the forced application start mode of the bootloader if it is restarted */
MagicBootKey = MAGIC_BOOT_KEY;
/* Enable the watchdog and force a timeout to reset the AVR */
wdt_enable(WDTO_250MS);
for (;;);
}
/** Configures the board hardware and chip peripherals for the demo's functionality. */
static 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);
/* Hardware Initialization */
LEDs_Init();
USB_Init();
/* Bootloader active LED toggle timer initialization */
TIMSK1 = (1 << TOIE1);
TCCR1B = ((1 << CS11) | (1 << CS10));
}
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
ISR(TIMER1_OVF_vect, ISR_BLOCK)
{
LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
}
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
void EVENT_USB_Device_Connect(void)
{
/* Indicate USB enumerating */
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
}
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
* the status LEDs and stops the Printer management task.
*/
void EVENT_USB_Device_Disconnect(void)
{
/* Indicate USB not ready */
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
}
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration
* of the USB device after enumeration - the device endpoints are configured and the Mass Storage management task started.
*/
void EVENT_USB_Device_ConfigurationChanged(void)
{
bool ConfigSuccess = true;
/* Setup Printer Data Endpoints */
ConfigSuccess &= PRNT_Device_ConfigureEndpoints(&TextOnly_Printer_Interface);
/* Reset the HEX parser upon successful connection to a host */
HEXParser.ParserState = HEX_PARSE_STATE_WAIT_LINE;
/* Indicate endpoint configuration success or failure */
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
}
/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
* the device from the USB host before passing along unhandled control requests to the library for processing
* internally.
*/
void EVENT_USB_Device_ControlRequest(void)
{
PRNT_Device_ProcessControlRequest(&TextOnly_Printer_Interface);
}

View File

@@ -0,0 +1,108 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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 BootloaderPrinter.c.
*/
#ifndef _BOOTLOADER_PRINTER_H_
#define _BOOTLOADER_PRINTER_H_
/* Includes: */
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include <avr/interrupt.h>
#include "Descriptors.h"
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Platform/Platform.h>
/* Preprocessor Checks: */
#if !defined(__OPTIMIZE_SIZE__)
#error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
#endif
/* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
#define LEDMASK_USB_BUSY LEDS_LED2
/** Magic bootloader key to unlock forced application start mode. */
#define MAGIC_BOOT_KEY 0xDC42
/* Enums: */
/** Intel HEX parser state machine states. */
enum HEX_Parser_States_t
{
HEX_PARSE_STATE_WAIT_LINE, /**< Parser is waiting for a HEX Start of Line character. */
HEX_PARSE_STATE_BYTE_COUNT, /**< Parser is waiting for a record byte count. */
HEX_PARSE_STATE_ADDRESS_HIGH, /**< Parser is waiting for the MSB of a record address. */
HEX_PARSE_STATE_ADDRESS_LOW, /**< Parser is waiting for the LSB of a record address. */
HEX_PARSE_STATE_RECORD_TYPE, /**< Parser is waiting for the record type. */
HEX_PARSE_STATE_READ_DATA, /**< Parser is waiting for more data in the current record. */
HEX_PARSE_STATE_CHECKSUM, /**< Parser is waiting for the checksum of the current record. */
};
/** Intel HEX record types, used to indicate the type of record contained in a line of a HEX file. */
enum HEX_Record_Types_t
{
HEX_RECORD_TYPE_Data = 0, /**< Record contains loadable data. */
HEX_RECORD_TYPE_EndOfFile = 1, /**< End of file record. */
HEX_RECORD_TYPE_ExtendedSegmentAddress = 2, /**< Extended segment start record. */
HEX_RECORD_TYPE_StartSegmentAddress = 3, /**< Normal segment start record. */
HEX_RECORD_TYPE_ExtendedLinearAddress = 4, /**< Extended linear address start record. */
HEX_RECORD_TYPE_StartLinearAddress = 5, /**< Linear address start record. */
};
/* Function Prototypes: */
static 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_ControlRequest(void);
#endif

View File

@@ -0,0 +1,184 @@
/** \file
*
* This file contains special DoxyGen information for the generation of the main page and other special
* documentation pages. It is not a project source file.
*/
/** \mainpage Printer Class USB AVR Bootloader
*
* \section Sec_Compat Demo Compatibility:
*
* The following list indicates what microcontrollers are compatible with this demo.
*
* \li Series 7 USB AVRs (AT90USBxxx7)
* \li Series 6 USB AVRs (AT90USBxxx6)
* \li Series 4 USB AVRs (ATMEGAxxU4)
* \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
*
* \section Sec_Info USB Information:
*
* The following table gives a rundown of the USB utilization of this demo.
*
* <table>
* <tr>
* <td><b>USB Mode:</b></td>
* <td>Device</td>
* </tr>
* <tr>
* <td><b>USB Class:</b></td>
* <td>Printer Class</td>
* </tr>
* <tr>
* <td><b>USB Subclass:</b></td>
* <td>Printer Subclass</td>
* </tr>
* <tr>
* <td><b>Relevant Standards:</b></td>
* <td>USBIF Printer Class Standard</td>
* </tr>
* <tr>
* <td><b>Supported USB Speeds:</b></td>
* <td>Full Speed Mode</td>
* </tr>
* </table>
*
* \section Sec_Description Project Description:
*
* This bootloader enumerates to the host as a Generic Text Only Printer device, capable of reading and parsing
* "printed" plain-text Intel HEX files to load firmware onto the AVR.
*
* Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit
* into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to
* edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile.
*
* When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the
* bootloader from the normal user application.
*
* \section Sec_Installation Driver Installation
*
* This bootloader uses the Generic Text-Only printer drivers inbuilt into all modern operating systems, thus no
* additional drivers need to be supplied for correct operation.
*
* \section Sec_HostApp Host Controller Application
*
* This bootloader is compatible with Notepad under Windows, and the command line \c lpr utility under Linux.
*
* \subsection SSec_Notepad Notepad (Windows)
*
* While most text applications under Windows will be compatible with the bootloader, the inbuilt Notepad utility
* is recommended as it will introduce minimal formatting changes to the output stream. To program with Notepad,
* open the target HEX file and print it to the Generic Text Only printer device the bootloader creates.
*
* \subsection SSec_LPR LPR (Linux)
*
* While the CUPS framework under Linux will enumerate the bootloader as a Generic Text-Only printer, many
* applications will refuse to print to the device due to the lack of rich formatting options available. As a result,
* under Linux HEX files must be printed via the low level \c lpr utility instead.
*
* \code
* cat Mouse.hex | lpr
* \endcode
*
* \section Sec_API User Application API
*
* Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader,
* allowing the user application to call into the bootloader at runtime to read and write FLASH data.
*
* By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the
* following layout:
*
* \code
* #define BOOTLOADER_API_TABLE_SIZE 32
* #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE)
* #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2)
*
* void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0);
* void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1);
* void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2);
* uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3);
* uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4);
* uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5);
* void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6);
*
* #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2))
* #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB
*
* #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4))
* #define BOOTLOADER_PRINTER_SIGNATURE 0xDF20
*
* #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8))
* #define BOOTLOADER_ADDRESS_LENGTH 4
* \endcode
*
* From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address
* \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader
* can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them
* to the value \c BOOTLOADER_PRINTER_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH
* memory starting from address \c BOOTLOADER_ADDRESS_START.
*
* \subsection SSec_API_MemLayout Device Memory Map
* The following illustration indicates the final memory map of the device when loaded with the bootloader.
*
* \verbatim
* +----------------------------+ 0x0000
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | User Application |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* +----------------------------+ FLASHEND - BOOT_SECTION_SIZE
* | |
* | Bootloader Application |
* | (Not User App. Accessible) |
* | |
* +----------------------------+ FLASHEND - 96
* | API Table Trampolines |
* | (Not User App. Accessible) |
* +----------------------------+ FLASHEND - 32
* | Bootloader API Table |
* | (User App. Accessible) |
* +----------------------------+ FLASHEND - 8
* | Bootloader ID Constants |
* | (User App. Accessible) |
* +----------------------------+ FLASHEND
* \endverbatim
*
*
* \section Sec_KnownIssues Known Issues:
*
* \par On Linux machines, new firmware fails to be sent to the device via CUPS.
* Only a limited subset of normal printer functionality is exposed via the
* bootloader, causing CUPS to reject print requests from applications that
* are unable to handle true plain-text printing. For best results, the low
* level \c lpr command should be used to print new firmware to the bootloader.
*
* \par After loading an application, it is not run automatically on startup.
* Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader
* to run automatically when the device is reset. In most cases, the BOOTRST
* fuse should be disabled and the HWBE fuse used instead to run the bootloader
* when needed.
*
* \section Sec_Options Project Options
*
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
*
* <table>
* <tr>
* <td>
* None
* </td>
* </tr>
* </table>
*/

View File

@@ -0,0 +1,93 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief LUFA Library Configuration Header File
*
* This header file is used to configure LUFA's compile time options,
* as an alternative to the compile time constants supplied through
* a makefile.
*
* For information on what each token does, refer to the LUFA
* manual section "Summary of Compile Tokens".
*/
#ifndef _LUFA_CONFIG_H_
#define _LUFA_CONFIG_H_
#if (ARCH == ARCH_AVR8)
/* Non-USB Related Configuration Tokens: */
// #define DISABLE_TERMINAL_CODES
/* USB Class Driver Related Tokens: */
// #define HID_HOST_BOOT_PROTOCOL_ONLY
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
// #define HID_MAX_COLLECTIONS {Insert Value Here}
// #define HID_MAX_REPORTITEMS {Insert Value Here}
// #define HID_MAX_REPORT_IDS {Insert Value Here}
// #define NO_CLASS_DRIVER_AUTOFLUSH
/* General USB Driver Related Tokens: */
#define ORDERED_EP_CONFIG
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
#define USB_DEVICE_ONLY
// #define USB_HOST_ONLY
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
// #define NO_LIMITED_CONTROLLER_CONNECT
#define NO_SOF_EVENTS
/* USB Device Mode Driver Related Tokens: */
#define USE_RAM_DESCRIPTORS
// #define USE_FLASH_DESCRIPTORS
// #define USE_EEPROM_DESCRIPTORS
#define NO_INTERNAL_SERIAL
#define FIXED_CONTROL_ENDPOINT_SIZE 8
#define DEVICE_STATE_AS_GPIOR 0
#define FIXED_NUM_CONFIGURATIONS 1
// #define CONTROL_ONLY_DEVICE
// #define INTERRUPT_CONTROL_ENDPOINT
#define NO_DEVICE_REMOTE_WAKEUP
#define NO_DEVICE_SELF_POWER
/* USB Host Mode Driver Related Tokens: */
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
// #define NO_AUTO_VBUS_MANAGEMENT
// #define INVERTED_VBUS_ENABLE_LINE
#else
#error Unsupported architecture for this LUFA configuration file.
#endif
#endif

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -37,39 +37,40 @@
#include "Descriptors.h"
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
/** Device descriptor structure. This descriptor, located in SRAM 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.
*/
const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
const USB_Descriptor_Device_t DeviceDescriptor =
{
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
.USBSpecification = VERSION_BCD(01.10),
.Class = USB_CSCP_VendorSpecificClass,
.Class = USB_CSCP_NoDeviceClass,
.SubClass = USB_CSCP_NoDeviceSubclass,
.Protocol = USB_CSCP_NoDeviceProtocol,
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
.VendorID = 0x03EB,
.ProductID = 0x2104,
.ReleaseNumber = VERSION_BCD(02.00),
.ProductID = 0x206B,
.ReleaseNumber = VERSION_BCD(00.01),
.ManufacturerStrIndex = 0x01,
.ProductStrIndex = 0x02,
.SerialNumStrIndex = 0x03,
.ManufacturerStrIndex = STRING_ID_Manufacturer,
.ProductStrIndex = STRING_ID_Product,
.SerialNumStrIndex = NO_DESCRIPTOR,
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
};
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
/** Configuration descriptor structure. This descriptor, located in SRAM 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.
*/
const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
const USB_Descriptor_Configuration_t ConfigurationDescriptor =
{
.Config =
{
@@ -81,12 +82,12 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.ConfigurationNumber = 1,
.ConfigurationStrIndex = NO_DESCRIPTOR,
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
.ConfigAttributes = USB_CONFIG_ATTR_RESERVED,
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
},
.AVRISP_Interface =
.Printer_Interface =
{
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
@@ -95,39 +96,39 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.TotalEndpoints = 2,
.Class = USB_CSCP_VendorSpecificClass,
.SubClass = 0x00,
.Protocol = 0x00,
.Class = PRNT_CSCP_PrinterClass,
.SubClass = PRNT_CSCP_PrinterSubclass,
.Protocol = PRNT_CSCP_BidirectionalProtocol,
.InterfaceStrIndex = NO_DESCRIPTOR
},
.AVRISP_DataInEndpoint =
.Printer_DataInEndpoint =
{
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
.EndpointAddress = (ENDPOINT_DIR_IN | AVRISP_DATA_IN_EPNUM),
.EndpointAddress = PRINTER_IN_EPADDR,
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = AVRISP_DATA_EPSIZE,
.PollingIntervalMS = 0x0A
.EndpointSize = PRINTER_IO_EPSIZE,
.PollingIntervalMS = 0x05
},
.AVRISP_DataOutEndpoint =
.Printer_DataOutEndpoint =
{
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
.EndpointAddress = (ENDPOINT_DIR_OUT | AVRISP_DATA_OUT_EPNUM),
.EndpointAddress = PRINTER_OUT_EPADDR,
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = AVRISP_DATA_EPSIZE,
.PollingIntervalMS = 0x0A
},
.EndpointSize = PRINTER_IO_EPSIZE,
.PollingIntervalMS = 0x05
}
};
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
/** Language descriptor structure. This descriptor, located in SRAM 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.
*/
const USB_Descriptor_String_t PROGMEM LanguageString =
const USB_Descriptor_String_t LanguageString =
{
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
@@ -138,7 +139,7 @@ const USB_Descriptor_String_t PROGMEM LanguageString =
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
* Descriptor.
*/
const USB_Descriptor_String_t PROGMEM ManufacturerString =
const USB_Descriptor_String_t ManufacturerString =
{
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
@@ -149,21 +150,11 @@ const USB_Descriptor_String_t PROGMEM ManufacturerString =
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
* Descriptor.
*/
const USB_Descriptor_String_t PROGMEM ProductString =
const USB_Descriptor_String_t ProductString =
{
.Header = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String},
.Header = {.Size = USB_STRING_LEN(23), .Type = DTYPE_String},
.UnicodeString = L"LUFA AVRISP MkII Clone"
};
/** Serial number string. This is a Unicode string containing the device's unique serial number, expressed as a
* series of uppercase hexadecimal digits.
*/
const USB_Descriptor_String_t PROGMEM SerialString =
{
.Header = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String},
.UnicodeString = L"0000A00128255"
.UnicodeString = L"LUFA Printer Bootloader"
};
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
@@ -195,21 +186,17 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
case DTYPE_String:
switch (DescriptorNumber)
{
case 0x00:
case STRING_ID_Language:
Address = &LanguageString;
Size = pgm_read_byte(&LanguageString.Header.Size);
Size = LanguageString.Header.Size;
break;
case 0x01:
case STRING_ID_Manufacturer:
Address = &ManufacturerString;
Size = pgm_read_byte(&ManufacturerString.Header.Size);
Size = ManufacturerString.Header.Size;
break;
case 0x02:
case STRING_ID_Product:
Address = &ProductString;
Size = pgm_read_byte(&ProductString.Header.Size);
break;
case 0x03:
Address = &SerialString;
Size = pgm_read_byte(&SerialString.Header.Size);
Size = ProductString.Header.Size;
break;
}

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -37,34 +37,19 @@
#define _DESCRIPTORS_H_
/* Includes: */
#include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h>
#include <avr/pgmspace.h>
/* Macros: */
/** Endpoint number of the CDC device-to-host notification IN endpoint. */
#define CDC_NOTIFICATION_EPNUM 5
/** Endpoint address of the Printer device-to-host data IN endpoint. */
#define PRINTER_IN_EPADDR (ENDPOINT_DIR_IN | 3)
/** Endpoint number of the CDC device-to-host data IN endpoint. */
#define CDC_TX_EPNUM 1
/** Endpoint address of the Printer host-to-device data OUT endpoint. */
#define PRINTER_OUT_EPADDR (ENDPOINT_DIR_OUT | 4)
/** Endpoint number of the CDC host-to-device data OUT endpoint. */
#define CDC_RX_EPNUM 2
/** 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 16
/** Endpoint number of the Mass Storage device-to-host data IN endpoint. */
#define MASS_STORAGE_IN_EPNUM 3
/** Endpoint number of the Mass Storage host-to-device data OUT endpoint. */
#define MASS_STORAGE_OUT_EPNUM 4
/** Size in bytes of the Mass Storage data endpoints. */
#define MASS_STORAGE_IO_EPSIZE 64
/** Size in bytes of the Printer data endpoints. */
#define PRINTER_IO_EPSIZE 64
/* Type Defines: */
/** Type define for the device configuration descriptor structure. This must be defined in the
@@ -73,14 +58,25 @@
*/
typedef struct
{
USB_Descriptor_Configuration_Header_t Config;
// Mass Storage Interface
USB_Descriptor_Interface_t MS_Interface;
USB_Descriptor_Endpoint_t MS_DataInEndpoint;
USB_Descriptor_Endpoint_t MS_DataOutEndpoint;
USB_Descriptor_Configuration_Header_t Config;
// Printer Interface
USB_Descriptor_Interface_t Printer_Interface;
USB_Descriptor_Endpoint_t Printer_DataInEndpoint;
USB_Descriptor_Endpoint_t Printer_DataOutEndpoint;
} USB_Descriptor_Configuration_t;
/** Enum for the device string descriptor IDs within the device. Each string descriptor should
* have a unique ID index associated with it, which can be used to refer to the string from
* other descriptors.
*/
enum StringDescriptors_t
{
STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
STRING_ID_Product = 2, /**< Product string ID */
};
/* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,

File diff suppressed because it is too large Load Diff

158
Bootloaders/Printer/asf.xml Normal file
View File

@@ -0,0 +1,158 @@
<asf xmlversion="1.0">
<project caption="Printer Bootloader - 128KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.printer.avr8.128_4" force-caption="true" workspace-name="lufa_printer_128kb_4kb_">
<require idref="lufa.bootloaders.printer"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="at90usb1287"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x1F000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1F000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FFA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FFE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FFF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="Printer Bootloader - 64KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.printer.avr8.64_4" force-caption="true" workspace-name="lufa_printer_64kb_4kb_">
<require idref="lufa.bootloaders.printer"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="at90usb647"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0xF000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0xF000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0xFFA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0xFFE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0xFFF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="Printer Bootloader - 32KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.printer.avr8.32_4" force-caption="true" workspace-name="lufa_printer_32kb_4kb_">
<require idref="lufa.bootloaders.printer"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega32u4"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x7000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x7000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x7FA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x7FE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x7FF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="Printer Bootloader - 16KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.printer.avr8.16_4" force-caption="true" workspace-name="lufa_printer_16kb_4kb_">
<require idref="lufa.bootloaders.printer"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega16u2"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x3000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x3000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x3FA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x3FE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x3FF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<project caption="Printer Bootloader - 8KB FLASH / 4KB Boot - AVR8 Architecture" id="lufa.bootloaders.printer.avr8.8_4" force-caption="true" workspace-name="lufa_printer_8kb_4kb_">
<require idref="lufa.bootloaders.printer"/>
<require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8"/>
<device-support value="atmega8u2"/>
<config name="lufa.drivers.board.name" value="none"/>
<config name="config.compiler.optimization.level" value="size"/>
<build type="define" name="F_CPU" value="16000000UL"/>
<build type="define" name="F_USB" value="16000000UL"/>
<build type="define" name="BOOT_START_ADDR" value="0x1000"/>
<build type="linker-config" subtype="flags" value="--section-start=.text=0x1000"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_trampolines=0x1FA0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Trampolines"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_jumptable=0x1FE0"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_JumpTable"/>
<build type="linker-config" subtype="flags" value="--section-start=.apitable_signatures=0x1FF8"/>
<build type="linker-config" subtype="flags" value="--undefined=BootloaderAPI_Signatures"/>
</project>
<module type="application" id="lufa.bootloaders.printer" caption="Printer Bootloader">
<info type="description" value="summary">
Printer Class Bootloader, capable of reprogramming a device by "printing" new HEX files to the virtual Plain-Text printer it creates when plugged into a host.
</info>
<info type="gui-flag" value="move-to-root"/>
<info type="keyword" value="Technology">
<keyword value="Bootloaders"/>
<keyword value="USB Device"/>
</info>
<device-support-alias value="lufa_avr8"/>
<device-support-alias value="lufa_xmega"/>
<device-support-alias value="lufa_uc3"/>
<build type="include-path" value="."/>
<build type="c-source" value="BootloaderPrinter.c"/>
<build type="header-file" value="BootloaderPrinter.h"/>
<build type="c-source" value="Descriptors.c"/>
<build type="header-file" value="Descriptors.h"/>
<build type="c-source" value="BootloaderAPI.c"/>
<build type="header-file" value="BootloaderAPI.h"/>
<build type="asm-source" value="BootloaderAPITable.S"/>
<build type="module-config" subtype="path" value="Config"/>
<build type="header-file" value="Config/LUFAConfig.h"/>
<build type="distribute" subtype="user-file" value="BootloaderPrinter.txt"/>
<require idref="lufa.common"/>
<require idref="lufa.platform"/>
<require idref="lufa.drivers.usb"/>
<require idref="lufa.drivers.board"/>
<require idref="lufa.drivers.board.leds"/>
</module>
</asf>

View File

@@ -0,0 +1,55 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------
# Run "make help" for target help.
MCU = at90usb1287
ARCH = AVR8
BOARD = USBKEY
F_CPU = 8000000
F_USB = $(F_CPU)
OPTIMIZATION = s
TARGET = BootloaderPrinter
SRC = $(TARGET).c Descriptors.c BootloaderAPI.c BootloaderAPITable.S $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS)
LUFA_PATH = ../../LUFA
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -DBOOT_START_ADDR=$(BOOT_START_OFFSET)
LD_FLAGS = -Wl,--section-start=.text=$(BOOT_START_OFFSET) $(BOOT_API_LD_FLAGS)
# Flash size and bootloader section sizes of the target, in KB. These must
# match the target's total FLASH size and the bootloader size set in the
# device's fuses.
FLASH_SIZE_KB = 128
BOOT_SECTION_SIZE_KB = 8
# Bootloader address calculation formulas
# Do not modify these macros, but rather modify the dependent values above.
CALC_ADDRESS_IN_HEX = $(shell printf "0x%X" $$(( $(1) )) )
BOOT_START_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) - $(BOOT_SECTION_SIZE_KB)) * 1024 )
BOOT_SEC_OFFSET = $(call CALC_ADDRESS_IN_HEX, ($(FLASH_SIZE_KB) * 1024) - ($(strip $(1))) )
# Bootloader linker section flags for relocating the API table sections to
# known FLASH addresses - these should not normally be user-edited.
BOOT_SECTION_LD_FLAG = -Wl,--section-start=$(strip $(1))=$(call BOOT_SEC_OFFSET, $(3)) -Wl,--undefined=$(strip $(2))
BOOT_API_LD_FLAGS = $(call BOOT_SECTION_LD_FLAG, .apitable_trampolines, BootloaderAPI_Trampolines, 96)
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_jumptable, BootloaderAPI_JumpTable, 32)
BOOT_API_LD_FLAGS += $(call BOOT_SECTION_LD_FLAG, .apitable_signatures, BootloaderAPI_Signatures, 8)
# Default target
all:
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk
include $(LUFA_PATH)/Build/lufa_sources.mk
include $(LUFA_PATH)/Build/lufa_build.mk
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
include $(LUFA_PATH)/Build/lufa_doxygen.mk
include $(LUFA_PATH)/Build/lufa_avrdude.mk
include $(LUFA_PATH)/Build/lufa_atprogram.mk

View File

@@ -1,6 +1,6 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2011.
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
@@ -13,18 +13,34 @@
# custom LUFA library build options are reflected in the compiled
# code.
all:
$(MAKE) -C CDC clean
$(MAKE) -C CDC all
PROJECT_DIRECTORIES := $(shell ls -d */)
$(MAKE) -C HID clean
$(MAKE) -C HID all
# This makefile is potentially infinitely recursive if something really bad
# happens when determining the set of project directories - hard-abort if
# more than 10 levels deep to avoid angry emails.
ifeq ($(MAKELEVEL), 10)
$(error EMERGENCY ABORT: INFINITE RECURSION DETECTED)
endif
$(MAKE) -C DFU clean
$(MAKE) -C DFU all
# Need to special-case building without a per-project object directory
ifeq ($(OBJDIR),)
# If no target specified, force "clean all" and disallow parallel build
ifeq ($(MAKECMDGOALS),)
MAKECMDGOALS := clean all
.NOTPARALLEL:
endif
%:
$(MAKE) -C CDC $@
$(MAKE) -C DFU $@
$(MAKE) -C HID $@
# If one of the targets is to build, force "clean" beforehand and disallow parallel build
ifneq ($(findstring all, $(MAKECMDGOALS)),)
MAKECMDGOALS := clean $(MAKECMDGOALS)
.NOTPARALLEL:
endif
endif
%: $(PROJECT_DIRECTORIES)
@echo . > /dev/null
$(PROJECT_DIRECTORIES):
@$(MAKE) -C $@ $(MAKECMDGOALS)
.PHONY: $(PROJECT_DIRECTORIES)

View File

@@ -0,0 +1,82 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief LUFA Custom Board Hardware Information Driver (Template)
*
* This is a stub driver header file, for implementing custom board
* layout hardware with compatible LUFA board specific drivers. If
* the library is configured to use the BOARD_USER board mode, this
* driver file should be completed and copied into the "/Board/" folder
* inside the application's folder.
*
* This stub is for the board-specific component of the LUFA Board Hardware
* information driver.
*/
#ifndef __BOARD_USER_H__
#define __BOARD_USER_H__
/* Includes: */
// TODO: Add any required includes here
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
#endif
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_BOARD_H)
#error Do not include this file directly. Include LUFA/Drivers/Board/Board.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Indicates the board has a hardware Buttons mounted if defined. */
// #define BOARD_HAS_BUTTONS
/** Indicates the board has a hardware Dataflash mounted if defined. */
// #define BOARD_HAS_DATAFLASH
/** Indicates the board has a hardware Joystick mounted if defined. */
// #define BOARD_HAS_JOYSTICK
/** Indicates the board has a hardware LEDs mounted if defined. */
// #define BOARD_HAS_LEDS
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
#endif
#endif
/** @} */

View File

@@ -0,0 +1,92 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief LUFA Custom Board Button Hardware Driver (Template)
*
* This is a stub driver header file, for implementing custom board
* layout hardware with compatible LUFA board specific drivers. If
* the library is configured to use the BOARD_USER board mode, this
* driver file should be completed and copied into the "/Board/" folder
* inside the application's folder.
*
* This stub is for the board-specific component of the LUFA Buttons driver,
* for the control of physical board-mounted GPIO pushbuttons.
*/
#ifndef __BUTTONS_USER_H__
#define __BUTTONS_USER_H__
/* Includes: */
// TODO: Add any required includes here
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
#endif
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_BUTTONS_H)
#error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
#endif
#define BOARD_DUMMY_BUTTONS_IMPLEMENTATION
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Button mask for the first button on the board. */
#define BUTTONS_BUTTON1 (1 << 0)
/* Inline Functions: */
#if !defined(__DOXYGEN__)
static inline void Buttons_Init(void)
{
}
static inline void Buttons_Disable(void)
{
}
static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Buttons_GetStatus(void)
{
return 0;
}
#endif
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,197 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief LUFA Custom Board Dataflash Hardware Driver (Template)
*
* This is a stub driver header file, for implementing custom board
* layout hardware with compatible LUFA board specific drivers. If
* the library is configured to use the BOARD_USER board mode, this
* driver file should be completed and copied into the "/Board/" folder
* inside the application's folder.
*
* This stub is for the board-specific component of the LUFA Dataflash
* driver.
*/
#ifndef __DATAFLASH_USER_H__
#define __DATAFLASH_USER_H__
/* Includes: */
// TODO: Add any required includes here
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_DATAFLASH_H)
#error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.
#endif
#define BOARD_DUMMY_DATAFLASH_IMPLEMENTATION
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define DATAFLASH_CHIPCS_MASK 0
#define DATAFLASH_CHIPCS_DDR 0
#define DATAFLASH_CHIPCS_PORT 0
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Constant indicating the total number of dataflash ICs mounted on the selected board. */
#define DATAFLASH_TOTALCHIPS 1
/** Mask for no dataflash chip selected. */
#define DATAFLASH_NO_CHIP 0
/** Mask for the first dataflash chip selected. */
#define DATAFLASH_CHIP1 0
/** Mask for the second dataflash chip selected. */
#define DATAFLASH_CHIP2 0
/** Internal main memory page size for the board's dataflash ICs. */
#define DATAFLASH_PAGE_SIZE 0
/** Total number of pages inside each of the board's dataflash ICs. */
#define DATAFLASH_PAGES 0
/* Inline Functions: */
/** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
* The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.
*/
static inline void Dataflash_Init(void)
{
}
/** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
*
* \param[in] Byte Byte of data to send to the dataflash
*
* \return Last response byte from the dataflash
*/
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)
{
return 0;
}
/** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.
*
* \param[in] Byte Byte of data to send to the dataflash
*/
static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline void Dataflash_SendByte(const uint8_t Byte)
{
}
/** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.
*
* \return Last response byte from the dataflash
*/
static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Dataflash_ReceiveByte(void)
{
return 0;
}
/** Determines the currently selected dataflash chip.
*
* \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected
* or a DATAFLASH_CHIPn mask (where n is the chip number).
*/
static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Dataflash_GetSelectedChip(void)
{
return 0;
}
/** Selects the given dataflash chip.
*
* \param[in] ChipMask Mask of the Dataflash IC to select, in the form of a \c DATAFLASH_CHIPn mask (where n is
* the chip number).
*/
static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;
static inline void Dataflash_SelectChip(const uint8_t ChipMask)
{
}
/** Deselects the current dataflash chip, so that no dataflash is selected. */
static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;
static inline void Dataflash_DeselectChip(void)
{
}
/** Selects a dataflash IC from the given page number, which should range from 0 to
* ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one
* dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside
* the total number of pages contained in the boards dataflash ICs, all dataflash ICs
* are deselected.
*
* \param[in] PageAddress Address of the page to manipulate, ranging from
* 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).
*/
static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)
{
}
/** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive
* a new command.
*/
static inline void Dataflash_ToggleSelectedChipCS(void)
{
}
/** Spin-loops while the currently selected dataflash is busy executing a command, such as a main
* memory page program or main memory to buffer transfer.
*/
static inline void Dataflash_WaitWhileBusy(void)
{
}
/** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with
* dataflash commands which require a complete 24-bit address.
*
* \param[in] PageAddress Page address within the selected dataflash IC
* \param[in] BufferByte Address within the dataflash's buffer
*/
static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, const uint16_t BufferByte)
{
}
#endif

View File

@@ -0,0 +1,104 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief LUFA Custom Board Joystick Hardware Driver (Template)
*
* This is a stub driver header file, for implementing custom board
* layout hardware with compatible LUFA board specific drivers. If
* the library is configured to use the BOARD_USER board mode, this
* driver file should be completed and copied into the "/Board/" folder
* inside the application's folder.
*
* This stub is for the board-specific component of the LUFA Joystick
* driver, for a digital four-way (plus button) joystick.
*/
#ifndef __JOYSTICK_USER_H__
#define __JOYSTICK_USER_H__
/* Includes: */
// TODO: Add any required includes here
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
#endif
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_JOYSTICK_H)
#error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.
#endif
#define BOARD_DUMMY_JOYSTICK_IMPLEMENTATION
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Mask for the joystick being pushed in the left direction. */
#define JOY_LEFT 0
/** Mask for the joystick being pushed in the right direction. */
#define JOY_RIGHT 0
/** Mask for the joystick being pushed in the upward direction. */
#define JOY_UP 0
/** Mask for the joystick being pushed in the downward direction. */
#define JOY_DOWN 0
/** Mask for the joystick being pushed inward. */
#define JOY_PRESS 0
/* Inline Functions: */
#if !defined(__DOXYGEN__)
static inline void Joystick_Init(void)
{
}
static inline void Joystick_Disable(void)
{
}
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Joystick_GetStatus(void)
{
return 0;
}
#endif
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,132 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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
* \brief LUFA Custom Board LED Hardware Driver (Template)
*
* This is a stub driver header file, for implementing custom board
* layout hardware with compatible LUFA board specific drivers. If
* the library is configured to use the BOARD_USER board mode, this
* driver file should be completed and copied into the "/Board/" folder
* inside the application's folder.
*
* This stub is for the board-specific component of the LUFA LEDs driver,
* for the LEDs (up to four) mounted on most development boards.
*/
#ifndef __LEDS_USER_H__
#define __LEDS_USER_H__
/* Includes: */
// TODO: Add any required includes here
/* 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
#define BOARD_DUMMY_LEDS_IMPLEMENTATION
/* Public Interface - May be used in end-application: */
/* Macros: */
/** LED mask for the first LED on the board. */
#define LEDS_LED1 (1 << 0)
/** LED mask for the second LED on the board. */
#define LEDS_LED2 (1 << 1)
/** LED mask for the third LED on the board. */
#define LEDS_LED3 (1 << 2)
/** LED mask for the fourth LED on the board. */
#define LEDS_LED4 (1 << 3)
/** LED mask for all the LEDs on the board. */
#define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)
/** LED mask for none of the board LEDs. */
#define LEDS_NO_LEDS 0
/* Inline Functions: */
#if !defined(__DOXYGEN__)
static inline void LEDs_Init(void)
{
}
static inline void LEDs_Disable(void)
{
}
static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
{
}
static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
{
}
static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
{
}
static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)
{
}
static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
{
}
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t LEDs_GetLEDs(void)
{
return 0;
}
#endif
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,85 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
#
# =============================================================================
# Board configuration map script, processed with the "BoardDriverTest"
# makefile. This script file maps the possible LUFA target BOARD makefile
# values in user projects to a specific architecture and device. This mapping is
# then used by the makefile to build all possible drivers for that board, to
# detect any missing or erroneous functions. To add a new board mapping, use
# the syntax:
#
# BOARD DEFINE = {ARCH} : {MCU} :
#
# And re-run the makefile. Note that each board may have only one target.
# =============================================================================
#
#
# ----------------- AVR8 Boards ------------------
BOARD_ADAFRUITU4 = AVR8 : atmega32u4 :
BOARD_ATAVRUSBRF01 = AVR8 : at90usb1287 :
BOARD_BENITO = AVR8 : at90usb162 :
BOARD_BIGMULTIO = AVR8 : atmega32u4 :
BOARD_BLACKCAT = AVR8 : at90usb162 :
BOARD_BUI = AVR8 : at90usb646 :
BOARD_BUMBLEB = AVR8 : at90usb162 :
BOARD_CULV3 = AVR8 : atmega32u4 :
BOARD_DUCE = AVR8 : atmega32u2 :
BOARD_EVK527 = AVR8 : atmega32u4 :
BOARD_JMDBU2 = AVR8 : atmega32u2 :
BOARD_LEONARDO = AVR8 : atmega32u4 :
BOARD_MAXIMUS = AVR8 : at90usb162 :
BOARD_MICROPENDOUS_32U2 = AVR8 : atmega32u2 :
BOARD_MICROPENDOUS_A = AVR8 : at90usb1287 :
BOARD_MICROPENDOUS_1 = AVR8 : at90usb162 :
BOARD_MICROPENDOUS_2 = AVR8 : atmega32u4 :
BOARD_MICROPENDOUS_3 = AVR8 : at90usb1287 :
BOARD_MICROPENDOUS_4 = AVR8 : at90usb1287 :
BOARD_MICROPENDOUS_DIP = AVR8 : at90usb1287 :
BOARD_MICROPENDOUS_REV1 = AVR8 : at90usb1287 :
BOARD_MICROPENDOUS_REV2 = AVR8 : at90usb1287 :
BOARD_MICROSIN162 = AVR8 : atmega162 :
BOARD_MINIMUS = AVR8 : atmega32u2 :
BOARD_MULTIO = AVR8 : at90usb162 :
BOARD_NONE = AVR8 : at90usb1287 :
BOARD_OLIMEX162 = AVR8 : at90usb162 :
BOARD_OLIMEX32U4 = AVR8 : atmega32u4 :
BOARD_OLIMEXT32U4 = AVR8 : atmega32u4 :
BOARD_OLIMEXISPMK2 = AVR8 : at90usb162 :
BOARD_RZUSBSTICK = AVR8 : at90usb1287 :
BOARD_SPARKFUN8U2 = AVR8 : atmega8u2 :
BOARD_STK525 = AVR8 : at90usb647 :
BOARD_STK526 = AVR8 : at90usb162 :
BOARD_TEENSY = AVR8 : at90usb162 :
BOARD_TEENSY2 = AVR8 : at90usb646 :
BOARD_TUL = AVR8 : atmega32u4 :
BOARD_UDIP = AVR8 : atmega32u2 :
BOARD_UNO = AVR8 : atmega8u2 :
BOARD_USB2AX = AVR8 : atmega32u2 :
BOARD_USB2AX_V3 = AVR8 : atmega32u2 :
BOARD_USB2AX_V31 = AVR8 : atmega32u2 :
BOARD_USBFOO = AVR8 : atmega162 :
BOARD_USBKEY = AVR8 : at90usb1287 :
BOARD_USBTINYMKII = AVR8 : at90usb162 :
BOARD_USER = AVR8 : at90usb1287 :
BOARD_XPLAIN = AVR8 : at90usb1287 :
BOARD_XPLAIN_REV1 = AVR8 : at90usb1287 :
BOARD_STANGE_ISP = AVR8 : at90usb162 :
BOARD_U2S = AVR8 : atmega32u2 :
#
# ----------------- XMEGA Boards -----------------
BOARD_A3BU_XPLAINED = XMEGA : atxmega256a3bu :
BOARD_B1_XPLAINED = XMEGA : atxmega128b1 :
BOARD_C3_XPLAINED = XMEGA : atxmega384c3 :
#
# ------------------ UC3 Boards ------------------
BOARD_EVK1100 = UC3 : uc3a0512 :
BOARD_EVK1101 = UC3 : uc3b0256 :
BOARD_EVK1104 = UC3 : uc3a3256 :
BOARD_UC3A3_XPLAINED = UC3 : uc3a3256 :
#

View File

@@ -0,0 +1,115 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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.
*/
#include <LUFA/Common/Common.h>
#include <LUFA/Drivers/Board/Board.h>
#include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/Board/Dataflash.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Joystick.h>
#if defined(BOARD_HAS_BUTTONS) == defined(BOARD_DUMMY_BUTTONS_IMPLEMENTATION)
#error Mismatch between BOARD_HAS_BUTTONS and implementation.
#endif
#if defined(BOARD_HAS_DATAFLASH) == defined(BOARD_DUMMY_DATAFLASH_IMPLEMENTATION)
#error Mismatch between BOARD_HAS_DATAFLASH and implementation.
#endif
#if defined(BOARD_HAS_LEDS) == defined(BOARD_DUMMY_LEDS_IMPLEMENTATION)
#error Mismatch between BOARD_HAS_LEDS and implementation.
#endif
#if defined(BOARD_HAS_JOYSTICK) == defined(BOARD_DUMMY_JOYSTICK_IMPLEMENTATION)
#error Mismatch between BOARD_HAS_JOYSTICK and implementation.
#endif
int main(void)
{
uint_reg_t Dummy;
/* =============================
* Buttons Compile Check
* ============================= */
// cppcheck-suppress redundantAssignment
Dummy = BUTTONS_BUTTON1;
Buttons_Init();
// cppcheck-suppress redundantAssignment
Dummy = Buttons_GetStatus();
Buttons_Disable();
/* =============================
* Dataflash Compile Check
* ============================= */
// cppcheck-suppress redundantAssignment
Dummy = DATAFLASH_TOTALCHIPS + DATAFLASH_NO_CHIP + DATAFLASH_CHIP1 + DATAFLASH_PAGE_SIZE + DATAFLASH_PAGES;
Dataflash_Init();
Dataflash_TransferByte(0);
Dataflash_SendByte(0);
// cppcheck-suppress redundantAssignment
Dummy = Dataflash_ReceiveByte();
// cppcheck-suppress redundantAssignment
Dummy = Dataflash_GetSelectedChip();
Dataflash_SelectChip(DATAFLASH_CHIP1);
Dataflash_DeselectChip();
Dataflash_SelectChipFromPage(0);
Dataflash_ToggleSelectedChipCS();
Dataflash_WaitWhileBusy();
Dataflash_SendAddressBytes(0, 0);
/* =============================
* LEDs Compile Check
* ============================= */
// cppcheck-suppress redundantAssignment
Dummy = LEDS_LED1 + LEDS_LED2 + LEDS_LED3 + LEDS_LED4;
LEDs_Init();
LEDs_TurnOnLEDs(LEDS_ALL_LEDS);
LEDs_TurnOffLEDs(LEDS_ALL_LEDS);
LEDs_SetAllLEDs(LEDS_ALL_LEDS);
LEDs_ChangeLEDs(LEDS_ALL_LEDS, LEDS_NO_LEDS);
LEDs_ToggleLEDs(LEDS_ALL_LEDS);
// cppcheck-suppress redundantAssignment
Dummy = LEDs_GetLEDs();
LEDs_Disable();
/* =============================
* Joystick Compile Check
* ============================= */
// cppcheck-suppress redundantAssignment
Dummy = JOY_LEFT + JOY_RIGHT + JOY_UP + JOY_DOWN + JOY_PRESS;
Joystick_Init();
// cppcheck-suppress redundantAssignment
Dummy = Joystick_GetStatus();
Joystick_Disable();
(void)Dummy;
}

View File

@@ -0,0 +1,68 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# Makefile for the board driver build test. This
# test attempts to build a dummy project with all
# possible board targets using their respective
# compiler.
# Path to the LUFA library core
LUFA_PATH := ../../LUFA/
# Build test cannot be run with multiple parallel jobs
.NOTPARALLEL:
all: begin makeboardlist testboards clean end
begin:
@echo Executing build test "BoardDriverTest".
@echo
end:
@echo Build test "BoardDriverTest" complete.
@echo
makeboardlist:
@grep "BOARD_" $(patsubst %/,%,$(LUFA_PATH))/Common/BoardTypes.h | cut -d'#' -f2 | cut -d' ' -f2 | grep "BOARD_" > BoardList.txt
testboards:
@echo "buildtest:" > BuildMakefile
@while read line; \
do \
build_cfg=`grep "$$line " BoardDeviceMap.cfg | grep -v "#" | cut -d'=' -f2- | sed 's/ //g'`; \
\
build_board=$$line; \
build_arch=`echo $$build_cfg | cut -d':' -f1`; \
build_mcu=`echo $$build_cfg | cut -d':' -f2`; \
\
if ( test -z "$$build_cfg" ); then \
echo "No matching information set for board $$build_board"; \
else \
echo "Found board configuration for $$build_board - $$build_arch, $$build_mcu"; \
\
printf "\t@echo Building dummy project for $$build_board...\n" >> BuildMakefile; \
printf "\t$(MAKE) -f makefile.test clean elf MCU=%s ARCH=%s BOARD=%s\n\n" $$build_mcu $$build_arch $$build_board >> BuildMakefile; \
fi; \
done < BoardList.txt
$(MAKE) -f BuildMakefile buildtest
clean:
rm -f BuildMakefile
rm -f BoardList.txt
$(MAKE) -f makefile.test clean BOARD=NONE ARCH=AVR8 MCU=at90usb1287
$(MAKE) -f makefile.test clean BOARD=NONE ARCH=XMEGA MCU=atxmega128a1u
$(MAKE) -f makefile.test clean BOARD=NONE ARCH=UC3 MCU=uc3a0256
%:
.PHONY: all begin end makeboardlist testboards clean
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk

View File

@@ -0,0 +1,27 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------
# Run "make help" for target help.
MCU =
ARCH =
BOARD =
F_CPU = $(F_USB)
F_USB = 8000000
OPTIMIZATION = 1
TARGET = Test
SRC = $(TARGET).c
LUFA_PATH = ../../LUFA
CC_FLAGS = -Werror
DEBUG_LEVEL = 0
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_build.mk

View File

@@ -0,0 +1,167 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
#
# =============================================================================
# Bootloader configuration map script, processed with the "BootloaderTest"
# makefile. This script file defines the targets for each LUFA bootloader,
# which are then built as part of the build test to ensure that there are no
# failures on all standard configurations. To add a new build target for a
# bootloader to this script, use the format:
#
# BOOTLOADER = {ARCH} : {MCU} : {BOARD} : {FLASH SIZE KB} : {BOOT SIZE KB} : {F_USB MHZ}
#
# And re-run the makefile.
# =============================================================================
#
#
# ------------ CDC Bootloader --------------------
CDC = AVR8 : at90usb1287 : XPLAIN : 128 : 8 : 8 :
CDC = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
CDC = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
CDC = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
CDC = AVR8 : at90usb1286 : NONE : 128 : 8 : 8 :
CDC = AVR8 : at90usb1286 : NONE : 128 : 4 : 8 :
CDC = AVR8 : at90usb646 : NONE : 64 : 4 : 8 :
CDC = AVR8 : atmega32u4 : NONE : 32 : 4 : 8 :
CDC = AVR8 : atmega16u4 : NONE : 16 : 4 : 8 :
CDC = AVR8 : atmega32u2 : NONE : 32 : 4 : 8 :
CDC = AVR8 : atmega16u2 : NONE : 16 : 4 : 8 :
CDC = AVR8 : atmega8u2 : NONE : 8 : 4 : 8 :
CDC = AVR8 : at90usb162 : NONE : 16 : 4 : 8 :
CDC = AVR8 : at90usb82 : NONE : 8 : 4 : 8 :
CDC = AVR8 : at90usb1287 : NONE : 128 : 8 : 16 :
CDC = AVR8 : at90usb1287 : NONE : 128 : 4 : 16 :
CDC = AVR8 : at90usb647 : NONE : 64 : 4 : 16 :
CDC = AVR8 : at90usb1286 : NONE : 128 : 8 : 16 :
CDC = AVR8 : at90usb1286 : NONE : 128 : 4 : 16 :
CDC = AVR8 : at90usb646 : NONE : 64 : 4 : 16 :
CDC = AVR8 : atmega32u4 : NONE : 32 : 4 : 16 :
CDC = AVR8 : atmega16u4 : NONE : 16 : 4 : 16 :
CDC = AVR8 : atmega32u2 : NONE : 32 : 4 : 16 :
CDC = AVR8 : atmega16u2 : NONE : 16 : 4 : 16 :
CDC = AVR8 : atmega8u2 : NONE : 8 : 4 : 16 :
CDC = AVR8 : at90usb162 : NONE : 16 : 4 : 16 :
CDC = AVR8 : at90usb82 : NONE : 8 : 4 : 16 :
#
# ------------ DFU Bootloader --------------------
DFU = AVR8 : at90usb1287 : XPLAIN : 128 : 8 : 8 :
DFU = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
DFU = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
DFU = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
DFU = AVR8 : at90usb1286 : NONE : 128 : 8 : 8 :
DFU = AVR8 : at90usb1286 : NONE : 128 : 4 : 8 :
DFU = AVR8 : at90usb646 : NONE : 64 : 4 : 8 :
DFU = AVR8 : atmega32u4 : NONE : 32 : 4 : 8 :
DFU = AVR8 : atmega16u4 : NONE : 16 : 4 : 8 :
DFU = AVR8 : atmega32u2 : NONE : 32 : 4 : 8 :
DFU = AVR8 : atmega16u2 : NONE : 16 : 4 : 8 :
DFU = AVR8 : atmega8u2 : NONE : 8 : 4 : 8 :
DFU = AVR8 : at90usb162 : NONE : 16 : 4 : 8 :
DFU = AVR8 : at90usb82 : NONE : 8 : 4 : 8 :
DFU = AVR8 : at90usb1287 : NONE : 128 : 8 : 16 :
DFU = AVR8 : at90usb1287 : NONE : 128 : 4 : 16 :
DFU = AVR8 : at90usb647 : NONE : 64 : 4 : 16 :
DFU = AVR8 : at90usb1286 : NONE : 128 : 8 : 16 :
DFU = AVR8 : at90usb1286 : NONE : 128 : 4 : 16 :
DFU = AVR8 : at90usb646 : NONE : 64 : 4 : 16 :
DFU = AVR8 : atmega32u4 : NONE : 32 : 4 : 16 :
DFU = AVR8 : atmega16u4 : NONE : 16 : 4 : 16 :
DFU = AVR8 : atmega32u2 : NONE : 32 : 4 : 16 :
DFU = AVR8 : atmega16u2 : NONE : 16 : 4 : 16 :
DFU = AVR8 : atmega8u2 : NONE : 8 : 4 : 16 :
DFU = AVR8 : at90usb162 : NONE : 16 : 4 : 16 :
DFU = AVR8 : at90usb82 : NONE : 8 : 4 : 16 :
#
# ------------ HID Bootloader --------------------
HID = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
HID = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
HID = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
HID = AVR8 : at90usb1286 : NONE : 128 : 8 : 8 :
HID = AVR8 : at90usb1286 : NONE : 128 : 4 : 8 :
HID = AVR8 : at90usb646 : NONE : 64 : 4 : 8 :
HID = AVR8 : atmega32u4 : NONE : 32 : 4 : 8 :
HID = AVR8 : atmega16u4 : NONE : 16 : 4 : 8 :
HID = AVR8 : atmega32u2 : NONE : 32 : 2 : 8 :
HID = AVR8 : atmega32u2 : NONE : 32 : 4 : 8 :
HID = AVR8 : atmega16u2 : NONE : 16 : 2 : 8 :
HID = AVR8 : atmega16u2 : NONE : 16 : 4 : 8 :
HID = AVR8 : atmega8u2 : NONE : 8 : 2 : 8 :
HID = AVR8 : atmega8u2 : NONE : 8 : 4 : 8 :
HID = AVR8 : at90usb162 : NONE : 16 : 2 : 8 :
HID = AVR8 : at90usb162 : NONE : 16 : 4 : 8 :
HID = AVR8 : at90usb162 : NONE : 16 : 2 : 8 :
HID = AVR8 : at90usb162 : NONE : 16 : 4 : 8 :
HID = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
HID = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
HID = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
HID = AVR8 : at90usb1286 : NONE : 128 : 8 : 16 :
HID = AVR8 : at90usb1286 : NONE : 128 : 4 : 16 :
HID = AVR8 : at90usb646 : NONE : 64 : 4 : 16 :
HID = AVR8 : atmega32u4 : NONE : 32 : 4 : 16 :
HID = AVR8 : atmega16u4 : NONE : 16 : 4 : 16 :
HID = AVR8 : atmega32u2 : NONE : 32 : 2 : 16 :
HID = AVR8 : atmega32u2 : NONE : 32 : 4 : 16 :
HID = AVR8 : atmega16u2 : NONE : 16 : 2 : 16 :
HID = AVR8 : atmega16u2 : NONE : 16 : 4 : 16 :
HID = AVR8 : atmega8u2 : NONE : 8 : 2 : 16 :
HID = AVR8 : atmega8u2 : NONE : 8 : 4 : 16 :
HID = AVR8 : at90usb162 : NONE : 16 : 2 : 16 :
HID = AVR8 : at90usb162 : NONE : 16 : 4 : 16 :
HID = AVR8 : at90usb162 : NONE : 16 : 2 : 16 :
HID = AVR8 : at90usb162 : NONE : 16 : 4 : 16 :
#
# ---------- Printer Bootloader ------------------
Printer = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
Printer = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
Printer = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
Printer = AVR8 : at90usb1286 : NONE : 128 : 8 : 8 :
Printer = AVR8 : at90usb1286 : NONE : 128 : 4 : 8 :
Printer = AVR8 : at90usb646 : NONE : 64 : 4 : 8 :
Printer = AVR8 : atmega32u4 : NONE : 32 : 4 : 8 :
Printer = AVR8 : atmega16u4 : NONE : 16 : 4 : 8 :
Printer = AVR8 : atmega32u2 : NONE : 32 : 4 : 8 :
Printer = AVR8 : atmega16u2 : NONE : 16 : 4 : 8 :
Printer = AVR8 : atmega8u2 : NONE : 8 : 4 : 8 :
Printer = AVR8 : at90usb162 : NONE : 16 : 4 : 8 :
Printer = AVR8 : at90usb82 : NONE : 8 : 4 : 8 :
Printer = AVR8 : at90usb1287 : NONE : 128 : 8 : 16 :
Printer = AVR8 : at90usb1287 : NONE : 128 : 4 : 16 :
Printer = AVR8 : at90usb647 : NONE : 64 : 4 : 16 :
Printer = AVR8 : at90usb1286 : NONE : 128 : 8 : 16 :
Printer = AVR8 : at90usb1286 : NONE : 128 : 4 : 16 :
Printer = AVR8 : at90usb646 : NONE : 64 : 4 : 16 :
Printer = AVR8 : atmega32u4 : NONE : 32 : 4 : 16 :
Printer = AVR8 : atmega16u4 : NONE : 16 : 4 : 16 :
Printer = AVR8 : atmega32u2 : NONE : 32 : 4 : 16 :
Printer = AVR8 : atmega16u2 : NONE : 16 : 4 : 16 :
Printer = AVR8 : atmega8u2 : NONE : 8 : 4 : 16 :
Printer = AVR8 : at90usb162 : NONE : 16 : 4 : 16 :
Printer = AVR8 : at90usb82 : NONE : 8 : 4 : 16 :
#
# ---------- Mass Storage Bootloader -----------------
MassStorage = AVR8 : at90usb1287 : XPLAIN : 128 : 8 : 8 :
MassStorage = AVR8 : at90usb1287 : NONE : 128 : 8 : 8 :
MassStorage = AVR8 : at90usb1287 : NONE : 128 : 4 : 8 :
MassStorage = AVR8 : at90usb647 : NONE : 64 : 4 : 8 :
MassStorage = AVR8 : at90usb1286 : NONE : 128 : 8 : 8 :
MassStorage = AVR8 : at90usb1286 : NONE : 128 : 4 : 8 :
MassStorage = AVR8 : at90usb646 : NONE : 64 : 4 : 8 :
MassStorage = AVR8 : atmega32u4 : LEONARDO : 32 : 4 : 16 :
MassStorage = AVR8 : atmega32u4 : NONE : 32 : 4 : 8 :
MassStorage = AVR8 : atmega16u4 : NONE : 16 : 4 : 8 :
MassStorage = AVR8 : atmega32u2 : NONE : 32 : 4 : 8 :
MassStorage = AVR8 : at90usb1287 : NONE : 128 : 8 : 16 :
MassStorage = AVR8 : at90usb1287 : NONE : 128 : 4 : 16 :
MassStorage = AVR8 : at90usb647 : NONE : 64 : 4 : 16 :
MassStorage = AVR8 : at90usb1286 : NONE : 128 : 8 : 16 :
MassStorage = AVR8 : at90usb1286 : NONE : 128 : 4 : 16 :
MassStorage = AVR8 : at90usb646 : NONE : 64 : 4 : 16 :
MassStorage = AVR8 : atmega32u4 : NONE : 32 : 4 : 16 :
MassStorage = AVR8 : atmega16u4 : NONE : 16 : 4 : 16 :
MassStorage = AVR8 : atmega32u2 : NONE : 32 : 4 : 16 :
#

View File

@@ -0,0 +1,64 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# Makefile for the bootloader build test. This
# test attempts to build all the bootloaders
# with all supported device configurations.
# Path to the LUFA library core
LUFA_PATH := ../../LUFA/
# Build test cannot be run with multiple parallel jobs
.NOTPARALLEL:
all: begin testbootloaders clean end
begin:
@echo Executing build test "BootloaderTest".
@echo
end:
@echo Build test "BootloaderTest" complete.
@echo
testbootloaders:
@echo "buildtest:" > BuildMakefile
@while read line; \
do \
build_cfg=`echo $$line | grep -v "#" | sed 's/ //g'`; \
\
if ( test -n "$$build_cfg" ); then \
build_bootloader=`echo $$build_cfg | cut -d'=' -f1`; \
build_cfg=`echo $$build_cfg | cut -d'=' -f2-`; \
\
build_arch=`echo $$build_cfg | cut -d':' -f1`; \
build_mcu=`echo $$build_cfg | cut -d':' -f2`; \
build_board=`echo $$build_cfg | cut -d':' -f3`; \
build_flashsize=`echo $$build_cfg | cut -d':' -f4`; \
build_bootsize=`echo $$build_cfg | cut -d':' -f5`; \
build_fusb=`echo $$build_cfg | cut -d':' -f6`; \
\
printf "Found '%s' bootloader configuration (FLASH: %3s KB | BOOT: %3s KB | MCU: %12s / %4s | BOARD: %s | F_USB: %sMHz)\n" $$build_bootloader $$build_flashsize $$build_bootsize $$build_mcu $$build_arch $$build_board $$build_fusb; \
\
printf "\t@echo Building bootloader %s - %s - FLASH: %s KB, BOOT: %s KB, BOARD: %s, F_USB: %sMHz\n" $$build_bootloader $$build_mcu $$build_flashsize $$build_bootsize $$build_board $$build_fusb >> BuildMakefile; \
printf "\t$(MAKE) -C $(patsubst %/,%,$(LUFA_PATH))/../Bootloaders/%s/ clean elf ARCH=%s MCU=%s BOARD=%s FLASH_SIZE_KB=%s BOOT_SECTION_SIZE_KB=%s F_USB=%s000000 DEBUG_LEVEL=0\n\n" $$build_bootloader $$build_arch $$build_mcu $$build_board $$build_flashsize $$build_bootsize $$build_fusb >> BuildMakefile; \
fi; \
done < BootloaderDeviceMap.cfg
$(MAKE) -f BuildMakefile buildtest
clean:
rm -f BuildMakefile
%:
.PHONY: all begin end testbootloaders clean
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -28,18 +28,14 @@
this software.
*/
#ifndef _PROGRAMMER_CONFIG_H_
#define _PROGRAMMER_CONFIG_H_
.section .text
/* Includes: */
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "../StandaloneProgrammer.h"
/* Function Prototypes: */
bool ProgrammerConfig_ProcessConfiguration(void);
#endif
# Mandatory entry point for successful compilation and link
.global main
main:
# Mandatory callback needed for base compile of the USB driver
.global CALLBACK_USB_GetDescriptor
CALLBACK_USB_GetDescriptor:

View File

@@ -0,0 +1,56 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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.
*/
#include <LUFA/Common/Common.h>
#include <LUFA/Platform/Platform.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Misc/RingBuffer.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#if (ARCH == ARCH_AVR8)
#if defined(TWCR)
#include <LUFA/Drivers/Peripheral/TWI.h>
#endif
#if defined(ADC)
#include <LUFA/Drivers/Peripheral/ADC.h>
#endif
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Peripheral/SPI.h>
#include <LUFA/Drivers/Peripheral/SerialSPI.h>
#elif (ARCH == ARCH_XMEGA)
#include <LUFA/Drivers/Peripheral/TWI.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Peripheral/SPI.h>
#include <LUFA/Drivers/Peripheral/SerialSPI.h>
#endif

View File

@@ -0,0 +1,31 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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.
*/
#include "Modules.h"

View File

@@ -0,0 +1,31 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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.
*/
#include "Modules.h"

View File

@@ -0,0 +1,66 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# Makefile for the module build test. This test
# attempts to build as many modules as possible
# under all supported architectures, and include
# all module headers in a simple C and C++
# application.
# Path to the LUFA library core
LUFA_PATH := ../../LUFA/
# Build test cannot be run with multiple parallel jobs
.NOTPARALLEL:
# List of device families per architecture, one device per architecture sub-family
AVR8_FAMILIES := at90usb1287 at90usb1286 atmega16u4 atmega16u2 at90usb162
XMEGA_FAMILIES := atxmega128a1u atxmega128a3u atxmega256a3bu atxmega128a4u atxmega128b1 atxmega128b3 atxmega128c3 atxmega32c4
UC3_FAMILIES := uc3a0256 uc3a1256 uc3a3256 uc3a4256 uc3b0256 uc3b1256
# List of all device families, with a family postfix
DEVICE_FAMILIES := $(AVR8_FAMILIES:%=%.avr8) $(XMEGA_FAMILIES:%=%.xmega) $(UC3_FAMILIES:%=%.uc3)
all: begin $(DEVICE_FAMILIES) clean end
arch_avr8: begin $(AVR8_FAMILIES:%=%.avr8) end
arch_xmega: begin $(XMEGA_FAMILIES:%=%.xmega) end
arch_uc3: begin $(UC3_FAMILIES:%=%.uc3) end
begin:
@echo Executing build test "ModuleTest".
@echo
end:
@echo Build test "ModuleTest" complete.
@echo
%.avr8:
@echo Building ModuleTest for ARCH=AVR8 MCU=$(@:%.avr8=%)...
$(MAKE) -f makefile.test clean elf ARCH=AVR8 MCU=$(@:%.avr8=%)
%.xmega:
@echo Building ModuleTest for ARCH=XMEGA MCU=$(@:%.xmega=%)...
$(MAKE) -f makefile.test clean elf ARCH=XMEGA MCU=$(@:%.xmega=%)
%.uc3:
@echo Building ModuleTest for ARCH=UC3 MCU=$(@:%.uc3=%)...
$(MAKE) -f makefile.test clean elf ARCH=UC3 MCU=$(@:%.uc3=%)
clean:
$(MAKE) -f makefile.test clean ARCH=AVR8 MCU=$(firstword $(AVR8_FAMILIES))
$(MAKE) -f makefile.test clean ARCH=XMEGA MCU=$(firstword $(XMEGA_FAMILIES))
$(MAKE) -f makefile.test clean ARCH=UC3 MCU=$(firstword $(UC3_FAMILIES))
%:
.PHONY: all arch_avr8 arch_xmega arch_uc3 begin end
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk

View File

@@ -0,0 +1,88 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------
# Run "make help" for target help.
MCU =
ARCH =
BOARD = NONE
F_CPU = $(F_USB)
OPTIMIZATION = 1
TARGET = Test
SRC = $(TARGET)_C.c $(TARGET)_CPP.cpp Dummy.S $(LUFA_SRC_USB)
LUFA_PATH = ../../LUFA
DEBUG_LEVEL = 0
ifeq ($(ARCH), AVR8)
F_USB = 8000000
else ifeq ($(ARCH), XMEGA)
F_USB = 48000000
else ifeq ($(ARCH), UC3)
F_USB = 48000000
endif
# Generic C/C++ compiler flags
CC_FLAGS = -Wextra
CC_FLAGS += -Werror
CC_FLAGS += -Wformat=2
CC_FLAGS += -Winit-self
CC_FLAGS += -Wswitch-enum
CC_FLAGS += -Wunused
CC_FLAGS += -Wundef
CC_FLAGS += -Wpointer-arith
CC_FLAGS += -Wcast-align
CC_FLAGS += -Wwrite-strings
CC_FLAGS += -Wlogical-op
CC_FLAGS += -Wmissing-declarations
CC_FLAGS += -Wmissing-field-initializers
CC_FLAGS += -Wmissing-format-attribute
CC_FLAGS += -Woverlength-strings
CC_FLAGS += -Wswitch-default
CC_FLAGS += -Wfloat-equal
CC_FLAGS += -Waggregate-return
CC_FLAGS += -Wmissing-include-dirs
# Disable warnings not supported by the version of GCC used for UC3 targets (FIXME)
ifneq ($(ARCH), UC3)
CC_FLAGS += -Wdouble-promotion
endif
# Only enable redundant declaration warnings for AVR8 target (FIXME)
ifeq ($(ARCH), AVR8)
CC_FLAGS += -Wredundant-decls
endif
# C compiler only flags
C_FLAGS += -Wmissing-parameter-type
C_FLAGS += -Wmissing-prototypes
C_FLAGS += -Wnested-externs
C_FLAGS += -Wbad-function-cast
C_FLAGS += -Wstrict-prototypes
C_FLAGS += -Wold-style-definition
# Disable warnings not supported by the version of GCC used for UC3 targets (FIXME)
ifneq ($(ARCH), UC3)
C_FLAGS += -Wunsuffixed-float-constants
C_FLAGS += -Wjump-misses-init
endif
# Only check C++ compatibility on the build files, to ensure headers are C++ compatible
Test_C.c Test_CPP.c: CC_FLAGS += -Wc++-compat
# Potential additional warnings to enable in the future (FIXME)
#CC_FLAGS += -Wcast-qual
#CC_FLAGS += -Wconversion
#CC_FLAGS += -Wsign-conversion
#CC_FLAGS += -pedantic
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_sources.mk
include $(LUFA_PATH)/Build/lufa_build.mk

View File

@@ -0,0 +1,42 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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.
*/
.section .text
# Mandatory entry point for successful compilation and link
.global main
main:
# Force code generation of the base USB stack
call USB_Init
# Mandatory callback needed for base compile of the USB driver
.global CALLBACK_USB_GetDescriptor
CALLBACK_USB_GetDescriptor:

View File

@@ -0,0 +1,32 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2013 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 disclaims 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.
*/
#include <LUFA/Common/Common.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@@ -0,0 +1,56 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# Makefile for the single USB mode build test.
# This test attempts to build the USB module
# under fixed device and fixed host modes under
# all supported architectures
# Path to the LUFA library core
LUFA_PATH := ../../LUFA/
# Build test cannot be run with multiple parallel jobs
.NOTPARALLEL:
all: begin compile clean end
begin:
@echo Executing build test "SingleUSBModeTest".
@echo
end:
@echo Build test "SingleUSBModeTest" complete.
@echo
compile:
@echo Building SingleUSBModeTest for ARCH=AVR8 in device only mode...
$(MAKE) -f makefile.test clean elf ARCH=AVR8 MCU=at90usb1287 CC_FLAGS='-D USB_DEVICE_ONLY'
@echo Building SingleUSBModeTest for ARCH=AVR8 in host only mode...
$(MAKE) -f makefile.test clean elf ARCH=AVR8 MCU=at90usb1287 CC_FLAGS='-D USB_HOST_ONLY'
@echo Building SingleUSBModeTest for ARCH=XMEGA in device only mode...
$(MAKE) -f makefile.test clean elf ARCH=XMEGA MCU=atxmega128a1u CC_FLAGS='-D USB_DEVICE_ONLY'
@echo Building SingleUSBModeTest for ARCH=UC3 in device only mode...
$(MAKE) -f makefile.test clean elf ARCH=UC3 MCU=uc3a0256 CC_FLAGS='-D USB_DEVICE_ONLY'
@echo Building SingleUSBModeTest for ARCH=UC3 in host only mode...
$(MAKE) -f makefile.test clean elf ARCH=UC3 MCU=uc3a0256 CC_FLAGS='-D USB_HOST_ONLY'
clean:
$(MAKE) -f makefile.test clean ARCH=AVR8 MCU=at90usb1287
$(MAKE) -f makefile.test clean ARCH=XMEGA MCU=atxmega128a1u
$(MAKE) -f makefile.test clean ARCH=UC3 MCU=uc3a0256
%:
.PHONY: begin end compile clean
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk

View File

@@ -0,0 +1,69 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------
# Run "make help" for target help.
MCU =
ARCH =
BOARD = NONE
F_CPU = $(F_USB)
DEBUG_LEVEL = 0
ifeq ($(ARCH), AVR8)
F_USB = 8000000
else ifeq ($(ARCH), XMEGA)
F_USB = 48000000
else ifeq ($(ARCH), UC3)
F_USB = 48000000
endif
OPTIMIZATION = 1
TARGET = Test
SRC = Test.c Dummy.S $(LUFA_SRC_USB)
LUFA_PATH = ../../LUFA
# Generic C/C++ compiler flags
CC_FLAGS = -Wextra
CC_FLAGS += -Werror
CC_FLAGS += -Wformat=2
CC_FLAGS += -Winit-self
CC_FLAGS += -Wswitch-enum
CC_FLAGS += -Wunused
CC_FLAGS += -Wundef
CC_FLAGS += -Wpointer-arith
CC_FLAGS += -Wcast-align
CC_FLAGS += -Wwrite-strings
CC_FLAGS += -Wlogical-op
CC_FLAGS += -Wmissing-declarations
CC_FLAGS += -Wmissing-field-initializers
CC_FLAGS += -Wmissing-format-attribute
CC_FLAGS += -Woverlength-strings
# Only enable rendundant declaration warnings for AVR8 target (FIXME)
ifeq ($(ARCH), AVR8)
CC_FLAGS += -Wredundant-decls
endif
# C compiler only flags
C_FLAGS += -Wmissing-parameter-type
C_FLAGS += -Wnested-externs
# Potential additional warnings to enable in the future (FIXME)
#CC_FLAGS += -Wswitch-default
#CC_FLAGS += -Wc++-compat
#CC_FLAGS += -Wcast-qual
#CC_FLAGS += -Wconversion
#CC_FLAGS += -Wjump-misses-init
#CC_FLAGS += -pedantic
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_sources.mk
include $(LUFA_PATH)/Build/lufa_build.mk

View File

@@ -0,0 +1,47 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# Static anlysis of the entire LUFA source tree, using the free cross-platform "cppcheck" tool.
# Path to the LUFA library core
LUFA_PATH := ../../LUFA/
CPPCHECK_EXCLUDES := FATFs/ \
PetiteFATFs/ \
uip/
CPPCHECK_INCLUDES := $(patsubst %/,%,$(LUFA_PATH))/CodeTemplates/ \
$(patsubst %/,%,$(LUFA_PATH))/../Projects/AVRISP-MKII/
CPPCHECK_FLAGS := -U TEMPLATE_FUNC_NAME -U __GNUC__ -U __DOXYGEN__
CPPCHECK_SUPPRESS := variableScope missingInclude unusedFunction
SRC := $(patsubst %/,%,$(LUFA_PATH))/..
# Build test cannot be run with multiple parallel jobs
.NOTPARALLEL:
all: begin cppcheck end
begin:
@echo Executing build test "StaticAnalysisTest".
@echo
end:
@echo Build test "StaticAnalysisTest" complete.
@echo
%:
.PHONY: all begin end
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk
include $(LUFA_PATH)/Build/lufa_cppcheck.mk

24
BuildTests/makefile Normal file
View File

@@ -0,0 +1,24 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2013.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# Makefile to build all the LUFA Build Tests. Build Tests are
# used to verify the correctness of the LUFA library, and are
# not intended to be modified or compiled by non-developers.
all:
%:
@echo Executing \"make $@\" on all LUFA build tests.
@echo
$(MAKE) -C BoardDriverTest $@
$(MAKE) -C BootloaderTest $@
$(MAKE) -C ModuleTest $@
$(MAKE) -C SingleUSBModeTest $@
$(MAKE) -C StaticAnalysisTest $@
@echo
@echo LUFA build test \"make $@\" operation complete.

View File

@@ -1 +0,0 @@
<AVRStudio><MANAGEMENT><ProjectName>AudioInput</ProjectName><Created>13-Jul-2010 15:22:28</Created><LastEdit>13-Jul-2010 15:22:44</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:22:28</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\AudioInput\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>AudioInput.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>AudioInput.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>AudioInput.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -44,10 +44,14 @@ USB_ClassInfo_Audio_Device_t Microphone_Audio_Interface =
{
.Config =
{
.ControlInterfaceNumber = 0,
.StreamingInterfaceNumber = 1,
.DataINEndpointNumber = AUDIO_STREAM_EPNUM,
.DataINEndpointSize = AUDIO_STREAM_EPSIZE,
.DataINEndpoint =
{
.Address = AUDIO_STREAM_EPADDR,
.Size = AUDIO_STREAM_EPSIZE,
.Banks = 2,
},
},
};
@@ -63,7 +67,7 @@ int main(void)
SetupHardware();
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
sei();
GlobalInterruptEnable();
for (;;)
{
@@ -75,12 +79,14 @@ int main(void)
/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
#if (ARCH == ARCH_AVR8)
/* Disable watchdog if enabled by bootloader/fuses */
MCUSR &= ~(1 << WDRF);
wdt_disable();
/* Disable clock division */
clock_prescale_set(clock_div_1);
#endif
/* Hardware Initialization */
LEDs_Init();
@@ -90,7 +96,7 @@ void SetupHardware(void)
USB_Init();
/* Start the ADC conversion in free running mode */
ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | MIC_IN_ADC_MUX_MASK);
ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_GET_CHANNEL_MASK(MIC_IN_ADC_CHANNEL));
}
/** ISR to handle the reloading of the data endpoint with the next sample. */
@@ -106,11 +112,11 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
#if defined(USE_TEST_TONE)
static uint8_t SquareWaveSampleCount;
static int16_t CurrentWaveValue;
/* In test tone mode, generate a square wave at 1/256 of the sample rate */
if (SquareWaveSampleCount++ == 0xFF)
CurrentWaveValue ^= 0x8000;
/* Only generate audio if the board button is being pressed */
AudioSample = (Buttons_GetStatus() & BUTTONS_BUTTON1) ? CurrentWaveValue : 0;
#else
@@ -122,7 +128,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
AudioSample -= (SAMPLE_MAX_RANGE / 2);
#endif
#endif
Audio_Device_WriteSample16(&Microphone_Audio_Interface, AudioSample);
}
@@ -171,7 +177,7 @@ void EVENT_USB_Device_ControlRequest(void)
*
* When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for
* the given endpoint index, and should return as fast as possible. When non-NULL, this value may be altered for GET operations
* to indicate the size of the retreived data.
* to indicate the size of the retrieved data.
*
* \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value
* of the \c DataLength parameter.
@@ -186,7 +192,7 @@ void EVENT_USB_Device_ControlRequest(void)
* \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where
* the retrieved data is to be stored for GET operations.
*
* \return Boolean true if the property get/set was successful, false otherwise
* \return Boolean \c true if the property get/set was successful, \c false otherwise
*/
bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
const uint8_t EndpointProperty,
@@ -196,7 +202,7 @@ bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t*
uint8_t* Data)
{
/* Check the requested endpoint to see if a supported endpoint is being manipulated */
if (EndpointAddress == (ENDPOINT_DIR_IN | Microphone_Audio_Interface.Config.DataINEndpointNumber))
if (EndpointAddress == Microphone_Audio_Interface.Config.DataINEndpoint.Address)
{
/* Check the requested control to see if a supported control is being manipulated */
if (EndpointControl == AUDIO_EPCONTROL_SamplingFreq)
@@ -211,10 +217,10 @@ bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t*
CurrentAudioSampleFrequency = (((uint32_t)Data[2] << 16) | ((uint32_t)Data[1] << 8) | (uint32_t)Data[0]);
/* Adjust sample reload timer to the new frequency */
OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);
OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);
}
return true;
return true;
case AUDIO_REQ_GetCurrent:
/* Check if we are just testing for a valid property, or actually reading it */
if (DataLength != NULL)
@@ -223,13 +229,46 @@ bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t*
Data[2] = (CurrentAudioSampleFrequency >> 16);
Data[1] = (CurrentAudioSampleFrequency >> 8);
Data[0] = (CurrentAudioSampleFrequency & 0xFF);
Data[0] = (CurrentAudioSampleFrequency & 0xFF);
}
return true;
}
}
}
return false;
}
/** Audio class driver callback for the setting and retrieval of streaming interface properties. This callback must be implemented
* in the user application to handle property manipulations on streaming audio interfaces.
*
* When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for
* the given entity and should return as fast as possible. When non-NULL, this value may be altered for GET operations
* to indicate the size of the retrieved data.
*
* \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value
* of the \c DataLength parameter.
*
* \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
* \param[in] Property Property of the interface to get or set, a value from Audio_ClassRequests_t.
* \param[in] EntityAddress Address of the audio entity whose property is being referenced.
* \param[in] Parameter Parameter of the entity to get or set, specific to each type of entity (see USB Audio specification).
* \param[in,out] DataLength For SET operations, the length of the parameter data to set. For GET operations, the maximum
* length of the retrieved data. When NULL, the function should return whether the given property
* and parameter is valid for the requested endpoint without reading or modifying the Data buffer.
* \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where
* the retrieved data is to be stored for GET operations.
*
* \return Boolean \c true if the property GET/SET was successful, \c false otherwise
*/
bool CALLBACK_Audio_Device_GetSetInterfaceProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
const uint8_t Property,
const uint8_t EntityAddress,
const uint16_t Parameter,
uint16_t* const DataLength,
uint8_t* Data)
{
/* No audio interface entities in the device descriptor, thus no properties to get or set. */
return false;
}

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -42,21 +42,16 @@
#include <avr/power.h>
#include <avr/interrupt.h>
#include <LUFA/Version.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/Peripheral/ADC.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Platform/Platform.h>
#include "Descriptors.h"
#include "Config/AppConfig.h"
/* Macros: */
/** ADC channel number for the microphone input. */
#define MIC_IN_ADC_CHANNEL 2
/** ADC channel MUX mask for the microphone input. */
#define MIC_IN_ADC_MUX_MASK ADC_CHANNEL2
/** Maximum audio sample value for the microphone input. */
#define SAMPLE_MAX_RANGE 0xFFFF
@@ -83,5 +78,17 @@
void EVENT_USB_Device_ConfigurationChanged(void);
void EVENT_USB_Device_ControlRequest(void);
bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
const uint8_t EndpointProperty,
const uint8_t EndpointAddress,
const uint8_t EndpointControl,
uint16_t* const DataLength,
uint8_t* Data) ATTR_NON_NULL_PTR_ARG(1);
bool CALLBACK_Audio_Device_GetSetInterfaceProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
const uint8_t Property,
const uint8_t EntityAddress,
const uint16_t Parameter,
uint16_t* const DataLength,
uint8_t* Data);
#endif

View File

@@ -10,9 +10,9 @@
*
* The following list indicates what microcontrollers are compatible with this demo.
*
* - Series 7 USB AVRs (AT90USBxxx7)
* - Series 6 USB AVRs (AT90USBxxx6)
* - Series 4 USB AVRs (ATMEGAxxU4)
* \li Series 7 USB AVRs (AT90USBxxx7)
* \li Series 6 USB AVRs (AT90USBxxx6)
* \li Series 4 USB AVRs (ATMEGAxxU4)
*
* \section Sec_Info USB Information:
*
@@ -38,7 +38,7 @@
* USBIF Audio 1.0 Data Formats Specification</td>
* </tr>
* <tr>
* <td><b>Usable Speeds:</b></td>
* <td><b>Supported USB Speeds:</b></td>
* <td>Full Speed Mode</td>
* </tr>
* </table>
@@ -50,7 +50,7 @@
* basic USB Audio 1.0 drivers in all modern OSes (i.e. no special drivers
* required).
*
* On start-up the system will automatically enumerate and function as a
* On start-up the system will automatically enumerate and function as a
* USB microphone. By default, the demo will produce a square wave test tone
* when the board button is pressed. If USE_TEST_TONE is not defined in the
* project makefile, incoming audio from the ADC channel 1 will be sampled
@@ -67,19 +67,24 @@
*
* <table>
* <tr>
* <td><b>Define Name:</b></td>
* <td><b>Location:</b></td>
* <td><b>Description:</b></td>
* <th><b>Define Name:</b></th>
* <th><b>Location:</b></th>
* <th><b>Description:</b></th>
* </tr>
* <tr>
* <td>MIC_IN_ADC_CHANNEL</td>
* <td>AppConfig.h</td>
* <td>Sets the ADC channel used by the demo for the input audio samples from an attached microphone.</td>
* </tr>
* <tr>
* <td>USE_TEST_TONE</td>
* <td>Makefile LUFA_OPTS</td>
* <td>AppConfig.h</td>
* <td>When defined, this alters the demo to produce a square wave test tone when the first board button is pressed
* instead of sampling the board microphone.</td>
* </tr>
* <tr>
* <td>MICROPHONE_BIASED_TO_HALF_RAIL</td>
* <td>Makefile LUFA_OPTS</td>
* <td>AppConfig.h</td>
* <td>When defined, this alters the demo so that the half VCC bias of the microphone input is subtracted.</td>
* </tr>
* </table>

View File

@@ -1,13 +1,13 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
Copyright (C) Dean Camera, 2013.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Copyright 2013 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
@@ -18,7 +18,7 @@
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
The author disclaims 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
@@ -28,33 +28,24 @@
this software.
*/
#include "SideshowApplications.h"
/** \file
* \brief Application Configuration Header File
*
* This is a header file which is be used to configure some of
* the application's compile time options, as an alternative to
* specifying the compile time constants supplied through a
* makefile or build system.
*
* For information on what each token does, refer to the
* \ref Sec_Options section of the application documentation.
*/
SideShow_Application_t InstalledApplications[MAX_APPLICATIONS];
#ifndef _APP_CONFIG_H_
#define _APP_CONFIG_H_
#define MIC_IN_ADC_CHANNEL 2
SideShow_Application_t* SideShow_GetFreeApplication(void)
{
for (uint8_t App = 0; App < ARRAY_ELEMENTS(InstalledApplications); App++)
{
if (!(InstalledApplications[App].InUse))
return &InstalledApplications[App];
}
return NULL;
}
SideShow_Application_t* SideShow_GetApplicationFromGUID(GUID_t* const GUID)
{
for (uint8_t App = 0; App < ARRAY_ELEMENTS(InstalledApplications); App++)
{
if (InstalledApplications[App].InUse)
{
if (GUID_COMPARE(&InstalledApplications[App].ApplicationID, GUID))
return &InstalledApplications[App];
}
}
return NULL;
}
#define MICROPHONE_BIASED_TO_HALF_RAIL
#define USE_TEST_TONE
#endif

Some files were not shown because too many files have changed in this diff Show More