From 7d823d926f9cac7b3c540cb0e864d7cec0af1826 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 9 Feb 2011 22:35:48 +0000 Subject: [PATCH] Update HID bootloader loader application to support the VID/PID used by the bootloader. --- Bootloaders/CDC/makefile | 1 + Bootloaders/DFU/makefile | 1 + Bootloaders/HID/HostLoaderApp/Makefile | 20 ++-- Bootloaders/HID/HostLoaderApp/Makefile.bsd | 6 +- ...ensy_loader_cli.c => hid_bootloader_cli.c} | 97 +++++++++++++++---- Bootloaders/HID/makefile | 7 +- LUFA.pnproj | 2 +- LUFA/ManPages/LibraryApps.txt | 3 +- 8 files changed, 98 insertions(+), 39 deletions(-) rename Bootloaders/HID/HostLoaderApp/{teensy_loader_cli.c => hid_bootloader_cli.c} (93%) diff --git a/Bootloaders/CDC/makefile b/Bootloaders/CDC/makefile index 3b2e2db0bd..8fa7cb2298 100644 --- a/Bootloaders/CDC/makefile +++ b/Bootloaders/CDC/makefile @@ -199,6 +199,7 @@ 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_CLOCK=$(F_CLOCK)UL diff --git a/Bootloaders/DFU/makefile b/Bootloaders/DFU/makefile index bcb908b1b5..ce97b58d12 100644 --- a/Bootloaders/DFU/makefile +++ b/Bootloaders/DFU/makefile @@ -194,6 +194,7 @@ 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_CLOCK=$(F_CLOCK)UL diff --git a/Bootloaders/HID/HostLoaderApp/Makefile b/Bootloaders/HID/HostLoaderApp/Makefile index 8c041bd8bc..ab450d2546 100644 --- a/Bootloaders/HID/HostLoaderApp/Makefile +++ b/Bootloaders/HID/HostLoaderApp/Makefile @@ -6,34 +6,34 @@ OS ?= LINUX ifeq ($(OS), LINUX) # also works on FreeBSD CC ?= gcc CFLAGS ?= -O2 -Wall -teensy_loader_cli: teensy_loader_cli.c - $(CC) $(CFLAGS) -s -DUSE_LIBUSB -o teensy_loader_cli teensy_loader_cli.c -lusb +hid_bootloader_cli: hid_bootloader_cli.c + $(CC) $(CFLAGS) -s -DUSE_LIBUSB -o hid_bootloader_cli hid_bootloader_cli.c -lusb else ifeq ($(OS), WINDOWS) CC = i586-mingw32msvc-gcc CFLAGS ?= -O2 -Wall -teensy_loader_cli.exe: teensy_loader_cli.c - $(CC) $(CFLAGS) -s -DUSE_WIN32 -o teensy_loader_cli.exe teensy_loader_cli.c -lhid -lsetupapi +hid_bootloader_cli.exe: hid_bootloader_cli.c + $(CC) $(CFLAGS) -s -DUSE_WIN32 -o thid_bootloader_cli.exe hid_bootloader_cli.c -lhid -lsetupapi else ifeq ($(OS), MACOSX) CC ?= gcc SDK ?= /Developer/SDKs/MacOSX10.5.sdk CFLAGS ?= -O2 -Wall -teensy_loader_cli: teensy_loader_cli.c - $(CC) $(CFLAGS) -DUSE_APPLE_IOKIT -isysroot $(SDK) -o teensy_loader_cli teensy_loader_cli.c -Wl,-syslibroot,$(SDK) -framework IOKit -framework CoreFoundation +hid_bootloader_cli: hid_bootloader_cli.c + $(CC) $(CFLAGS) -DUSE_APPLE_IOKIT -isysroot $(SDK) -o hid_bootloader_cli hid_bootloader_cli.c -Wl,-syslibroot,$(SDK) -framework IOKit -framework CoreFoundation else ifeq ($(OS), BSD) # works on NetBSD and OpenBSD -CC ?= gcc +CC ?= gcct CFLAGS ?= -O2 -Wall -teensy_loader_cli: teensy_loader_cli.c - $(CC) $(CFLAGS) -s -DUSE_UHID -o teensy_loader_cli teensy_loader_cli.c +hid_bootloader_cli: hid_bootloader_cli.c + $(CC) $(CFLAGS) -s -DUSE_UHID -o teensy_loader_cli hid_bootloader_cli.c endif clean: - rm -f teensy_loader_cli teensy_loader_cli.exe + rm -f thid_bootloader_cli hid_bootloader_cli.exe diff --git a/Bootloaders/HID/HostLoaderApp/Makefile.bsd b/Bootloaders/HID/HostLoaderApp/Makefile.bsd index 2aea86d05f..a15a664053 100644 --- a/Bootloaders/HID/HostLoaderApp/Makefile.bsd +++ b/Bootloaders/HID/HostLoaderApp/Makefile.bsd @@ -14,8 +14,8 @@ LIBS = .endif -teensy_loader_cli: teensy_loader_cli.c - $(CC) $(CFLAGS) -s -o teensy_loader_cli teensy_loader_cli.c $(LIBS) +hid_bootloader_cli: hid_bootloader_cli.c + $(CC) $(CFLAGS) -s -o hid_bootloader_cli hid_bootloader_cli.c $(LIBS) clean: - rm -f teensy_loader_cli + rm -f hid_bootloader_cli diff --git a/Bootloaders/HID/HostLoaderApp/teensy_loader_cli.c b/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c similarity index 93% rename from Bootloaders/HID/HostLoaderApp/teensy_loader_cli.c rename to Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c index 3d9dbca984..9cb81b50c1 100644 --- a/Bootloaders/HID/HostLoaderApp/teensy_loader_cli.c +++ b/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c @@ -1,8 +1,15 @@ +/* Modified for the LUFA HID Bootloader by Dean Camera + * http://www.lufa-lib.org + * + * THIS MODIFIED VERSION IS UNSUPPORTED BY PJRC. + */ + /* Teensy Loader, Command Line Interface * Program and Reboot Teensy Board with HalfKay Bootloader * http://www.pjrc.com/teensy/loader_cli.html * Copyright 2008-2010, PJRC.COM, LLC * + * * You may redistribute this program and/or modify it under the terms * of the GNU General Public License as published by the Free Software * Foundation, version 3 of the License. @@ -25,7 +32,6 @@ * http://www.pjrc.com/teensy/49-teensy.rules */ - #include #include #include @@ -35,13 +41,17 @@ void usage(void) { - fprintf(stderr, "Usage: teensy_loader_cli -mmcu= [-w] [-h] [-n] [-v] \n"); + fprintf(stderr, "Usage: hid_bootloader_cli -mmcu= [-w] [-h] [-n] [-v] \n"); fprintf(stderr, "\t-w : Wait for device to appear\n"); fprintf(stderr, "\t-r : Use hard reboot if device not online\n"); fprintf(stderr, "\t-n : No reboot after programming\n"); fprintf(stderr, "\t-v : Verbose output\n"); - fprintf(stderr, "\n = atmega32u4 | at90usb162 | at90usb646 | at90usb1286\n"); - fprintf(stderr, "\nFor more information, please visit:\n"); + fprintf(stderr, "\n = atmegaXXuY or at90usbXXXY"); + + fprintf(stderr, "\nFor support and more information, please visit:\n"); + fprintf(stderr, "http://www.lufa-lub.org\n"); + + fprintf(stderr, "\nBased on the TeensyHID command line programmer software:\n"); fprintf(stderr, "http://www.pjrc.com/teensy/loader_cli.html\n"); exit(1); } @@ -238,8 +248,13 @@ int teensy_open(void) { teensy_close(); libusb_teensy_handle = open_usb_device(0x16C0, 0x0478); - if (libusb_teensy_handle) return 1; - return 0; + + if (!libusb_teensy_handle) { + libusb_teensy_handle = open_usb_device(0x03eb, 0x2067); + } + + if (!libusb_teensy_handle) return 0; + return 1; } int teensy_write(void *buf, int len, double timeout) @@ -267,6 +282,11 @@ int hard_reboot(void) int r; rebootor = open_usb_device(0x16C0, 0x0477); + + if (!rebootor) { + rebootor = open_usb_device(0x03eb, 0x2067); + } + if (!rebootor) return 0; r = usb_control_msg(rebootor, 0x21, 9, 0x0200, 0, "reboot", 6, 100); usb_release_interface(rebootor, 0); @@ -393,6 +413,11 @@ int teensy_open(void) { teensy_close(); win32_teensy_handle = open_usb_device(0x16C0, 0x0478); + + if (win32_teensy_handle) { + win32_teensy_handle = open_usb_device(0x03eb, 0x2067); + } + if (win32_teensy_handle) return 1; return 0; } @@ -402,7 +427,6 @@ int teensy_write(void *buf, int len, double timeout) int r; if (!win32_teensy_handle) return 0; r = write_usb_device(win32_teensy_handle, buf, len, (int)(timeout * 1000.0)); - //if (!r) print_win32_err(); return r; } @@ -419,6 +443,11 @@ int hard_reboot(void) int r; rebootor = open_usb_device(0x16C0, 0x0477); + + if (!rebootor) { + rebootor = open_usb_device(0x03eb, 0x2067); + } + if (!rebootor) return 0; r = write_usb_device(rebootor, "reboot", 6, 100); CloseHandle(rebootor); @@ -571,6 +600,11 @@ int teensy_open(void) { teensy_close(); iokit_teensy_reference = open_usb_device(0x16C0, 0x0478); + + if (!iokit_teensy_reference) { + iokit_teensy_reference = open_usb_device(0x03eb, 0x2067); + } + if (iokit_teensy_reference) return 1; return 0; } @@ -603,6 +637,11 @@ int hard_reboot(void) IOReturn ret; rebootor = open_usb_device(0x16C0, 0x0477); + + if (!rebootor) { + rebootor = open_usb_device(0x03eb, 0x2067); + } + if (!rebootor) return 0; ret = IOHIDDeviceSetReport(rebootor, kIOHIDReportTypeOutput, 0, (uint8_t *)("reboot"), 6); @@ -704,6 +743,11 @@ int hard_reboot(void) int r, rebootor_fd; rebootor_fd = open_usb_device(0x16C0, 0x0477); + + if (rebootor_fd < 0) { + rebootor_fd = open_usb_device(0x03eb, 0x2067); + } + if (rebootor_fd < 0) return 0; r = write(rebootor_fd, "reboot", 6); delay(0.1); @@ -925,7 +969,7 @@ void parse_options(int argc, char **argv) for (i=1; i \ No newline at end of file + \ No newline at end of file diff --git a/LUFA/ManPages/LibraryApps.txt b/LUFA/ManPages/LibraryApps.txt index 9964bb0499..ce1fc80e86 100644 --- a/LUFA/ManPages/LibraryApps.txt +++ b/LUFA/ManPages/LibraryApps.txt @@ -96,8 +96,9 @@ * - ClassDriver * - MouseHostDevice - Dual role Mouse Host and Mouse Device demo, using the library USB CDC Class driver framework * - Bootloaders - * - DFU - DFU Class USB bootloader, compatible with Atmel's FLIP and the open source dfu-programmer software * - CDC - CDC Class USB bootloader, compatible with any AVR910 protocol programming software such as AVRDude + * - DFU - DFU Class USB bootloader, compatible with Atmel's FLIP and the open source dfu-programmer software + * - HID - HID Class USB bootloader, compatible with a modified PJRC TeensyHID protocol loader application software * - Projects * - AVRISP-MKII - AVRISP-MKII Programmer Clone project * - Benito - Benito Board Arduino Programmer project