diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2011-02-09 22:35:48 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2011-02-09 22:35:48 +0000 |
commit | 7d823d926f9cac7b3c540cb0e864d7cec0af1826 (patch) | |
tree | ecb0ec4d485a9cb5f169a6719fb6a1aff1b8fe0e /Bootloaders/HID/HostLoaderApp | |
parent | cae0fa73d70f82820bd8d71c4d60b6aff8ccf3cb (diff) | |
download | lufa-7d823d926f9cac7b3c540cb0e864d7cec0af1826.tar.gz lufa-7d823d926f9cac7b3c540cb0e864d7cec0af1826.tar.bz2 lufa-7d823d926f9cac7b3c540cb0e864d7cec0af1826.zip |
Update HID bootloader loader application to support the VID/PID used by the bootloader.
Diffstat (limited to 'Bootloaders/HID/HostLoaderApp')
-rw-r--r-- | Bootloaders/HID/HostLoaderApp/Makefile | 20 | ||||
-rw-r--r-- | Bootloaders/HID/HostLoaderApp/Makefile.bsd | 6 | ||||
-rw-r--r-- | Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c (renamed from Bootloaders/HID/HostLoaderApp/teensy_loader_cli.c) | 97 |
3 files changed, 92 insertions, 31 deletions
diff --git a/Bootloaders/HID/HostLoaderApp/Makefile b/Bootloaders/HID/HostLoaderApp/Makefile index 8c041bd8b..ab450d254 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 2aea86d05..a15a66405 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 index 3d9dbca98..9cb81b50c 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 <stdio.h> #include <stdlib.h> #include <stdint.h> @@ -35,13 +41,17 @@ void usage(void) { - fprintf(stderr, "Usage: teensy_loader_cli -mmcu=<MCU> [-w] [-h] [-n] [-v] <file.hex>\n"); + fprintf(stderr, "Usage: hid_bootloader_cli -mmcu=<MCU> [-w] [-h] [-n] [-v] <file.hex>\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<MCU> = atmega32u4 | at90usb162 | at90usb646 | at90usb1286\n"); - fprintf(stderr, "\nFor more information, please visit:\n"); + fprintf(stderr, "\n<MCU> = 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<argc; i++) { arg = argv[i]; - //printf("arg: %s\n", arg); + if (*arg == '-') { if (strcmp(arg, "-w") == 0) { wait_for_device_to_appear = 1; @@ -936,18 +980,35 @@ void parse_options(int argc, char **argv) } else if (strcmp(arg, "-v") == 0) { verbose = 1; } else if (strncmp(arg, "-mmcu=", 6) == 0) { - if (strcasecmp(arg+6, "at90usb162") == 0) { - code_size = 15872; - block_size = 128; - } else if (strcasecmp(arg+6, "atmega32u4") == 0) { - code_size = 32256; - block_size = 128; - } else if (strcasecmp(arg+6, "at90usb646") == 0) { - code_size = 64512; + 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"); + } + + if (strncmp(arg, "128", 3) == 0) { + code_size = 128 * 1024; block_size = 256; - } else if (strcasecmp(arg+6, "at90usb1286") == 0) { - code_size = 130048; + } else if (strncmp(arg, "64", 2) == 0) { + code_size = 64 * 1024; block_size = 256; + } else if (strncmp(arg, "32", 2) == 0) { + code_size = 32 * 1024; + block_size = 128; + } else if (strncmp(arg, "16", 2) == 0) { + code_size = 16 * 1024; + block_size = 128; + } else if (strncmp(arg, "8", 1) == 0) { + code_size = 8 * 1024; + block_size = 128; } else { die("Unknown MCU type\n"); } |