Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Erik Strand
lufa
Commits
77cd3a42
Commit
77cd3a42
authored
Dec 20, 2009
by
Dean Camera
Browse files
Fixed TeensyHID bootloader not enumerating to the host correctly.
parent
b408a5fe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Bootloaders/TeensyHID/TeensyHID.c
View file @
77cd3a42
...
...
@@ -52,12 +52,12 @@ int main(void)
while
(
RunBootloader
)
USB_USBTask
();
/*
Turn off the USB interface, disconnect from
the
host
*/
USB_
ShutDown
();
/*
Disconnect from the host - USB interface will be reset later along with
the
AVR
*/
USB_
Detach
();
/* Enable the watchdog and force a timeout to reset the AVR */
wdt_enable
(
WDTO_250MS
);
for
(;;);
}
...
...
@@ -100,53 +100,50 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
switch
(
USB_ControlRequest
.
bRequest
)
{
case
REQ_SetReport
:
if
(
USB_ControlRequest
.
bmRequestType
==
(
REQDIR_HOSTTODEVICE
|
REQTYPE_CLASS
|
REQREC_INTERFACE
))
{
Endpoint_ClearSETUP
();
/* Wait until the command has been sent by the host */
while
(
!
(
Endpoint_IsOUTReceived
()));
Endpoint_ClearSETUP
();
/* Read in the write destination address */
uint16_t
PageAddress
=
Endpoint_Read_Word_LE
();
/* Wait until the command has been sent by the host */
while
(
!
(
Endpoint_IsOUTReceived
()));
/* Read in the write destination address */
uint16_t
PageAddress
=
Endpoint_Read_Word_LE
();
/* Check if the command is a program page command, or a start application command */
if
(
PageAddress
==
TEENSY_STARTAPPLICATION
)
{
RunBootloader
=
false
;
}
else
{
/* Erase the given FLASH page, ready to be programmed */
boot_page_erase
(
PageAddress
);
boot_spm_busy_wait
();
/* Check if the command is a program page command, or a start application command */
if
(
PageAddress
==
TEENSY_STARTAPPLICATION
)
{
RunBootloader
=
false
;
}
else
/* Write each of the FLASH page's bytes in sequence */
for
(
uint8_t
PageByte
=
0
;
PageByte
<
SPM_PAGESIZE
;
PageByte
+=
2
)
{
/* 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
PageByte
=
0
;
PageByte
<
SPM_PAGESIZE
;
PageByte
+=
2
)
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if
(
!
(
Endpoint_BytesInEndpoint
()))
{
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if
(
!
(
Endpoint_BytesInEndpoint
()))
{
Endpoint_ClearOUT
();
while
(
!
(
Endpoint_IsOUTReceived
()));
}
/* Write the next data word to the FLASH page */
boot_page_fill
(
PageAddress
+
PageByte
,
Endpoint_Read_Word_LE
());
Endpoint_ClearOUT
();
while
(
!
(
Endpoint_IsOUTReceived
()));
}
/* Write the filled FLASH page to memory */
boot_page_write
(
PageAddress
);
boot_spm_busy_wait
();
/* Re-enable RWW section */
boot_rww_enable
();
/* Write the next data word to the FLASH page */
boot_page_fill
(
PageAddress
+
PageByte
,
Endpoint_Read_Word_LE
());
}
Endpoint_ClearOUT
();
/* Write the filled FLASH page to memory */
boot_page_write
(
PageAddress
);
boot_spm_busy_wait
();
Endpoint_ClearStatusStage
();
/* Re-enable RWW section */
boot_rww_enable
();
}
Endpoint_ClearOUT
();
Endpoint_ClearStatusStage
();
break
;
}
...
...
Bootloaders/TeensyHID/TeensyHID.h
View file @
77cd3a42
...
...
@@ -49,11 +49,6 @@
#include <LUFA/Drivers/USB/USB.h>
/* Preprocessor Checks: */
#if !defined(__AVR_AT90USB162__) && !defined(__AVR_AT90USB646__)
#error This bootloader is not compatible with the selected AVR model.
#endif
/* Macros: */
/** HID Class specific request to send the next HID report to the device. */
#define REQ_SetReport 0x09
...
...
Bootloaders/TeensyHID/TeensyHID.txt
View file @
77cd3a42
...
...
@@ -10,8 +10,10 @@
*
* The following list indicates what microcontrollers are compatible with this demo.
*
* - AT90USB646
* - AT90USB162
* - ATMEGA32U4
* - AT90USB646
* - AT90USB1286
*
* \section SSec_Info USB Information:
*
...
...
@@ -47,7 +49,9 @@
* This bootloader enumerates to the host as a HID Class device, allowing for Teensy compatible programming
* software to load firmware onto the AVR, such as the official software at <a>http://www.pjrc.com/teensy/</a>.
*
* Out of the box this bootloader builds for the AT90USB162, and will fit into 4KB of bootloader space.
* Out of the box this bootloader builds for the ATMEGA32U4, and will fit into 4KB of bootloader space. For other
* devices, the makefile will need to be updated to reflect the altered MCU model and bootloader start address. When
* calculating the bootloader start address, use (TARGET_FLASH_SIZE_BYTES - 4096).
*
* This spoofs (with permission) the official Teensy bootloader's VID and PID, so that the software remains
* compatible with no changes.
...
...
Bootloaders/TeensyHID/makefile
View file @
77cd3a42
...
...
@@ -60,7 +60,7 @@
# MCU name
MCU
=
at
90usb162
MCU
=
at
mega32u4
# Target board (see library "Board Types" documentation, USER or blank for projects not requiring
...
...
@@ -98,7 +98,7 @@ F_CLOCK = $(F_CPU)
# Starting byte address of the bootloader
BOOT_START
=
0x
C
000
BOOT_START
=
0x
7
000
# Output format. (can be srec, ihex, binary)
...
...
@@ -121,7 +121,6 @@ LUFA_PATH = ../..
# LUFA library compile-time options
LUFA_OPTS
=
-D
USB_DEVICE_ONLY
LUFA_OPTS
+=
-D
CONTROL_ONLY_DEVICE
LUFA_OPTS
+=
-D
DEVICE_STATE_AS_GPIOR
=
0
LUFA_OPTS
+=
-D
FIXED_CONTROL_ENDPOINT_SIZE
=
8
LUFA_OPTS
+=
-D
FIXED_NUM_CONFIGURATIONS
=
1
...
...
LUFA/ManPages/ChangeLog.txt
View file @
77cd3a42
...
...
@@ -66,6 +66,7 @@
* - Fixed Still Image Host Class driver truncating the PIMA response code (thanks to Daniel Seibert)
* - Fixed USB_CurrentMode not being reset to USB_MODE_NONE when the USB interface is shut down and both Host and Device modes can be
* used (thanks to Daniel Levy)
* - Fixed TeensyHID bootloader not enumerating to the host correctly
*
* \section Sec_ChangeLog091122 Version 091122
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment