projects
/
pub
/
USBasp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix "grep: Version.h: No such file or directory" error when including the core LUFA...
[pub/USBasp.git]
/
Bootloaders
/
HID
/
HostLoaderApp
/
hid_bootloader_cli.c
diff --git
a/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c
b/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c
index
9cb81b5
..
058ccc6
100644
(file)
--- a/
Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c
+++ b/
Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c
@@
-49,7
+49,7
@@
void usage(void)
fprintf(stderr, "\n<MCU> = atmegaXXuY or at90usbXXXY");
fprintf(stderr, "\nFor support and 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-l
u
b.org\n");
+ fprintf(stderr, "http://www.lufa-l
i
b.org\n");
fprintf(stderr, "\nBased on the TeensyHID command line programmer software:\n");
fprintf(stderr, "http://www.pjrc.com/teensy/loader_cli.html\n");
fprintf(stderr, "\nBased on the TeensyHID command line programmer software:\n");
fprintf(stderr, "http://www.pjrc.com/teensy/loader_cli.html\n");
@@
-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;
struct usb_bus *bus;
struct usb_device *dev;
usb_dev_handle *h;
+ #ifdef LIBUSB_HAS_GET_DRIVER_NP
char buf[128];
char buf[128];
+ #endif
int r;
usb_init();
int r;
usb_init();
@@
-249,9
+251,8
@@
int teensy_open(void)
teensy_close();
libusb_teensy_handle = open_usb_device(0x16C0, 0x0478);
teensy_close();
libusb_teensy_handle = open_usb_device(0x16C0, 0x0478);
- if (!libusb_teensy_handle)
{
+ if (!libusb_teensy_handle)
libusb_teensy_handle = open_usb_device(0x03eb, 0x2067);
libusb_teensy_handle = open_usb_device(0x03eb, 0x2067);
- }
if (!libusb_teensy_handle) return 0;
return 1;
if (!libusb_teensy_handle) return 0;
return 1;
@@
-283,9
+284,8
@@
int hard_reboot(void)
rebootor = open_usb_device(0x16C0, 0x0477);
rebootor = open_usb_device(0x16C0, 0x0477);
- if (!rebootor)
{
+ if (!rebootor)
rebootor = open_usb_device(0x03eb, 0x2067);
rebootor = open_usb_device(0x03eb, 0x2067);
- }
if (!rebootor) return 0;
r = usb_control_msg(rebootor, 0x21, 9, 0x0200, 0, "reboot", 6, 100);
if (!rebootor) return 0;
r = usb_control_msg(rebootor, 0x21, 9, 0x0200, 0, "reboot", 6, 100);
@@
-392,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 (r != WAIT_OBJECT_0) return 0;
}
if (!GetOverlappedResult(h, &ov, &n, FALSE)) return 0;
- if (n <= 0) return 0;
return 1;
}
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)
static HANDLE win32_teensy_handle = NULL;
int teensy_open(void)
@@
-414,12
+402,11
@@
int teensy_open(void)
teensy_close();
win32_teensy_handle = open_usb_device(0x16C0, 0x0478);
teensy_close();
win32_teensy_handle = open_usb_device(0x16C0, 0x0478);
- if (
win32_teensy_handle) {
+ if (
!win32_teensy_handle)
win32_teensy_handle = open_usb_device(0x03eb, 0x2067);
win32_teensy_handle = open_usb_device(0x03eb, 0x2067);
- }
- if (
win32_teensy_handle) return 1
;
- return
0
;
+ if (
!win32_teensy_handle) return 0
;
+ return
1
;
}
int teensy_write(void *buf, int len, double timeout)
}
int teensy_write(void *buf, int len, double timeout)
@@
-444,9
+431,8
@@
int hard_reboot(void)
rebootor = open_usb_device(0x16C0, 0x0477);
rebootor = open_usb_device(0x16C0, 0x0477);
- if (!rebootor)
{
+ if (!rebootor)
rebootor = open_usb_device(0x03eb, 0x2067);
rebootor = open_usb_device(0x03eb, 0x2067);
- }
if (!rebootor) return 0;
r = write_usb_device(rebootor, "reboot", 6, 100);
if (!rebootor) return 0;
r = write_usb_device(rebootor, "reboot", 6, 100);
@@
-601,12
+587,11
@@
int teensy_open(void)
teensy_close();
iokit_teensy_reference = open_usb_device(0x16C0, 0x0478);
teensy_close();
iokit_teensy_reference = open_usb_device(0x16C0, 0x0478);
- if (!iokit_teensy_reference)
{
+ if (!iokit_teensy_reference)
iokit_teensy_reference = open_usb_device(0x03eb, 0x2067);
iokit_teensy_reference = open_usb_device(0x03eb, 0x2067);
- }
- if (
iokit_teensy_reference) return 1
;
- return
0
;
+ if (
!iokit_teensy_reference) return 0
;
+ return
1
;
}
int teensy_write(void *buf, int len, double timeout)
}
int teensy_write(void *buf, int len, double timeout)
@@
-638,9
+623,8
@@
int hard_reboot(void)
rebootor = open_usb_device(0x16C0, 0x0477);
rebootor = open_usb_device(0x16C0, 0x0477);
- if (!rebootor)
{
+ if (!rebootor)
rebootor = open_usb_device(0x03eb, 0x2067);
rebootor = open_usb_device(0x03eb, 0x2067);
- }
if (!rebootor) return 0;
ret = IOHIDDeviceSetReport(rebootor,
if (!rebootor) return 0;
ret = IOHIDDeviceSetReport(rebootor,
@@
-673,6
+657,11
@@
int hard_reboot(void)
#include <dev/usb/usb_ioctl.h>
#endif
#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;
int open_usb_device(int vid, int pid)
{
int r, fd;
@@
-716,6
+705,10
@@
int teensy_open(void)
{
teensy_close();
uhid_teensy_fd = open_usb_device(0x16C0, 0x0478);
{
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;
}
if (uhid_teensy_fd < 0) return 0;
return 1;
}
@@
-724,7
+717,7
@@
int teensy_write(void *buf, int len, double timeout)
{
int r;
{
int r;
- // TODO: im
e
plement timeout... how??
+ // TODO: implement timeout... how??
r = write(uhid_teensy_fd, buf, len);
if (r == len) return 1;
return 0;
r = write(uhid_teensy_fd, buf, len);
if (r == len) return 1;
return 0;
@@
-744,9
+737,8
@@
int hard_reboot(void)
rebootor_fd = open_usb_device(0x16C0, 0x0477);
rebootor_fd = open_usb_device(0x16C0, 0x0477);
- if (rebootor_fd < 0)
{
+ if (rebootor_fd < 0)
rebootor_fd = open_usb_device(0x03eb, 0x2067);
rebootor_fd = open_usb_device(0x03eb, 0x2067);
- }
if (rebootor_fd < 0) return 0;
r = write(rebootor_fd, "reboot", 6);
if (rebootor_fd < 0) return 0;
r = write(rebootor_fd, "reboot", 6);
@@
-804,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);
if (*buf) {
if (parse_hex_line(buf) == 0) {
//printf("Warning, parse error line %d\n", lineno);
+ fclose(fp);
return -2;
}
}
return -2;
}
}
@@
-819,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 */
/* 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 occur
r
ed. The variable */
/* num gets the number of bytes that were stored into bytes[] */
/* num gets the number of bytes that were stored into bytes[] */
@@
-829,7
+822,7
@@
parse_hex_line(char *line)
int addr, code, num;
int sum, len, cksum, i;
char *ptr;
int addr, code, num;
int sum, len, cksum, i;
char *ptr;
-
+
num = 0;
if (line[0] != ':') return 0;
if (strlen(line) < 11) return 0;
num = 0;
if (line[0] != ':') return 0;
if (strlen(line) < 11) return 0;
@@
-982,13
+975,9
@@
void parse_options(int argc, char **argv)
} else if (strncmp(arg, "-mmcu=", 6) == 0) {
arg += 6;
} else if (strncmp(arg, "-mmcu=", 6) == 0) {
arg += 6;
- uint8_t valid_prefix = 0;
-
if (strncmp(arg, "at90usb", 7) == 0) {
if (strncmp(arg, "at90usb", 7) == 0) {
- valid_prefix = 1;
arg += 7;
} else if (strncmp(arg, "atmega", 6) == 0) {
arg += 7;
} else if (strncmp(arg, "atmega", 6) == 0) {
- valid_prefix = 1;
arg += 6;
} else {
die("Unknown MCU type\n");
arg += 6;
} else {
die("Unknown MCU type\n");