diff options
author | Dean Camera <[email protected]> | 2011-02-09 22:35:48 +0000 |
---|---|---|
committer | Dean Camera <[email protected]> | 2011-02-09 22:35:48 +0000 |
commit | 7d823d926f9cac7b3c540cb0e864d7cec0af1826 (patch) | |
tree | ecb0ec4d485a9cb5f169a6719fb6a1aff1b8fe0e /Bootloaders | |
parent | cae0fa73d70f82820bd8d71c4d60b6aff8ccf3cb (diff) | |
download | qmk_firmware-7d823d926f9cac7b3c540cb0e864d7cec0af1826.tar.gz qmk_firmware-7d823d926f9cac7b3c540cb0e864d7cec0af1826.zip |
Update HID bootloader loader application to support the VID/PID used by the bootloader.
Diffstat (limited to 'Bootloaders')
-rw-r--r-- | Bootloaders/CDC/makefile | 1 | ||||
-rw-r--r-- | Bootloaders/DFU/makefile | 1 | ||||
-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 | ||||
-rw-r--r-- | Bootloaders/HID/makefile | 7 |
6 files changed, 95 insertions, 37 deletions
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 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 <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"); } diff --git a/Bootloaders/HID/makefile b/Bootloaders/HID/makefile index 555c727abf..81561c3712 100644 --- a/Bootloaders/HID/makefile +++ b/Bootloaders/HID/makefile @@ -124,12 +124,6 @@ LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENAB 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
@@ -199,6 +193,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
|