* Fix usb initialization link with n900 * minor syntax fixup
This commit is contained in:
1 parent
e2aaa2cb40
commit
20eed53d8c
2 files changed
+79
-70
No files matched your search
@@ -103,6 +103,7 @@ int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_devic
|
|||||||
|
|
||||||
if ((dev_index = is_valid_device(udd))) {
|
if ((dev_index = is_valid_device(udd))) {
|
||||||
device = dev;
|
device = dev;
|
||||||
|
printf("%s found!\n", dev->filename);
|
||||||
*it_device = supported_devices[dev_index];
|
*it_device = supported_devices[dev_index];
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+78
-70
@@ -116,7 +116,7 @@ int unpack_callback(struct header_t *header)
|
|||||||
if (strchr(header->name, ',') != NULL) {
|
if (strchr(header->name, ',') != NULL) {
|
||||||
if (!strstr(header->name, subverstr)) {
|
if (!strstr(header->name, subverstr)) {
|
||||||
printf("Skipping '%s' does not matches -S subversion\n",
|
printf("Skipping '%s' does not matches -S subversion\n",
|
||||||
header->name);
|
header->name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,10 +165,10 @@ int fiasco_flash(const char *file)
|
|||||||
char *p;
|
char *p;
|
||||||
char version[64];
|
char version[64];
|
||||||
|
|
||||||
if (connect_via_usb()) {
|
if (connect_via_usb()) {
|
||||||
fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
|
fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (info)
|
// if (info)
|
||||||
cmd_info("");
|
cmd_info("");
|
||||||
@@ -202,67 +202,75 @@ int fiasco_flash(const char *file)
|
|||||||
int connect_via_usb()
|
int connect_via_usb()
|
||||||
{
|
{
|
||||||
static char pbc[]={'/','-','\\', '|'};
|
static char pbc[]={'/','-','\\', '|'};
|
||||||
struct usb_device_descriptor udd;
|
struct usb_device_descriptor udd;
|
||||||
struct devices it_device;
|
struct devices it_device;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
// usb_set_debug(5);
|
// usb_set_debug(5);
|
||||||
usb_init();
|
usb_init();
|
||||||
|
|
||||||
/* Tries to get access to the Internet Tablet and retries
|
/* Tries to get access to the Internet Tablet and retries
|
||||||
* if any of the neccessary steps fail.
|
* if any of the neccessary steps fail.
|
||||||
*
|
*
|
||||||
* Note: While a proper device may be found on the bus it may
|
* Note: While a proper device may be found on the bus it may
|
||||||
* not be in the right state to be accessed (e.g. the Nokia is
|
* not be in the right state to be accessed (e.g. the Nokia is
|
||||||
* not in the boot stage any more).
|
* not in the boot stage any more).
|
||||||
*/
|
*/
|
||||||
while(!dev) {
|
while(!dev) {
|
||||||
usleep(0xc350); // 0.5s
|
usleep(0xc350); // 0.5s
|
||||||
|
|
||||||
if(!usb_device_found(&udd, &it_device)) {
|
if(!usb_device_found(&udd, &it_device)) {
|
||||||
printf("\rWaiting for device... %c", pbc[++c%4]);
|
printf("\rWaiting for device... %c", pbc[++c%4]);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* open device */
|
/* open device */
|
||||||
if(!(dev = usb_open(device))) {
|
if(!(dev = usb_open(device))) {
|
||||||
perror("usb_open");
|
perror("usb_open");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( usb_claim_interface(dev, 2) < 0) {
|
#if 1
|
||||||
//device->config->interface->altsetting->bInterfaceNumber) < 0) { // 2 or 0
|
{
|
||||||
D perror("usb_claim_interface");
|
char name[32];
|
||||||
|
name[0] = '\0';
|
||||||
|
usb_get_driver_np(dev, 2, name, sizeof(name));
|
||||||
|
printf ("Driver: %s\n", name);
|
||||||
|
usb_detach_kernel_driver_np(dev, 2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (usb_claim_interface(dev, 2) < 0) {
|
||||||
|
//device->config->interface->altsetting->bInterfaceNumber) < 0) { // 2 or 0
|
||||||
|
perror("usb_claim_interface");
|
||||||
|
|
||||||
// Something is broken if closing fails.
|
// Something is broken if closing fails.
|
||||||
if(usb_close(dev)) {
|
if(usb_close(dev)) {
|
||||||
perror("usb_close");
|
perror("usb_close");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
dev = NULL;
|
||||||
|
// Try again later.?
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
dev = NULL;
|
if (usb_set_altinterface(dev, 1) <0) { //device->config->interface->altsetting->bAlternateSetting) < 0) {
|
||||||
|
perror("usb_set_altinterface");
|
||||||
|
|
||||||
// Try again later.
|
// Something is broken if closing fails.
|
||||||
continue;
|
if(usb_close(dev)) {
|
||||||
}
|
perror("usb_close");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (usb_set_altinterface(dev, 1) <0) { //device->config->interface->altsetting->bAlternateSetting) < 0) {
|
dev = NULL;
|
||||||
D perror("usb_set_altinterface");
|
// Try again later.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Something is broken if closing fails.
|
printf("found %s (%04x:%04x)\n", it_device.name,
|
||||||
if(usb_close(dev)) {
|
|
||||||
perror("usb_close");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev = NULL;
|
|
||||||
// Try again later.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("found %s (%04x:%04x)\n", it_device.name,
|
|
||||||
it_device.vendor_id, it_device.product_id);
|
it_device.vendor_id, it_device.product_id);
|
||||||
|
|
||||||
/* go go go! */
|
/* go go go! */
|
||||||
@@ -305,8 +313,8 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
sscanf(optarg, "%04hx:%04hx",
|
sscanf(optarg, "%04hx:%04hx",
|
||||||
&supported_devices[SUPPORTED_DEVICES-2].vendor_id,
|
&supported_devices[SUPPORTED_DEVICES-2].vendor_id,
|
||||||
&supported_devices[SUPPORTED_DEVICES-2].product_id);
|
&supported_devices[SUPPORTED_DEVICES-2].product_id);
|
||||||
supported_devices[SUPPORTED_DEVICES-2].name = strdup("user");
|
supported_devices[SUPPORTED_DEVICES-2].name = strdup("user");
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
@@ -314,14 +322,14 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
if (!strcmp(optarg,"help")) {
|
if (!strcmp(optarg,"help")) {
|
||||||
printf("* Flags are composed of:\n");
|
printf("* Flags are composed of:\n");
|
||||||
printf(" 0x02 - disable OMAP watchdog (possibly)\n");
|
printf(" 0x02 - disable OMAP watchdog (possibly)\n");
|
||||||
printf(" 0x04 - disable RETU watchdog (possibly)\n");
|
printf(" 0x04 - disable RETU watchdog (possibly)\n");
|
||||||
printf(" 0x08 - disable lifeguard reset\n");
|
printf(" 0x08 - disable lifeguard reset\n");
|
||||||
printf(" 0x10 - enable serial console\n");
|
printf(" 0x10 - enable serial console\n");
|
||||||
printf(" 0x20 - disable USB timeout\n");
|
printf(" 0x20 - disable USB timeout\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
rd_flags = (unsigned short) strtoul(optarg, NULL, 16);
|
rd_flags = (unsigned short) strtoul(optarg, NULL, 16);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
@@ -382,7 +390,7 @@ int main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// flags ok?
|
// flags ok?
|
||||||
if ( (fiasco_image == NULL)
|
if ( (fiasco_image == NULL)
|
||||||
&& (boot_cmdline == NULL)
|
&& (boot_cmdline == NULL)
|
||||||
&& (reverseto == NULL)
|
&& (reverseto == NULL)
|
||||||
&& (pcs_n == 0)
|
&& (pcs_n == 0)
|
||||||
@@ -395,9 +403,9 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
|
|
||||||
printf("# The Free Fiasco Firmware Flasher v"VERSION"\n"
|
printf("# The Free Fiasco Firmware Flasher v"VERSION"\n"
|
||||||
"0xFFFF [-chinlQRvVx] [-C mtd-dev] [-d vid:pid] [-D 0|1|2] [-e path] [-f flags]\n"
|
"0xFFFF [-chinlQRvVx] [-C mtd-dev] [-d vid:pid] [-D 0|1|2] [-e path] [-f flags]\n"
|
||||||
" [-F fiasco] [-H hash-file] [-I piece] [-p [piece%%]file]] [-r 0|1] [-S subver]\n"
|
" [-F fiasco] [-H hash-file] [-I piece] [-p [piece%%]file]] [-r 0|1] [-S subver]\n"
|
||||||
" [-s serial-dev] [-u fiasco-image] [-U 0|1] | [-P new-fiasco] [piece1] [2] ..\n");
|
" [-s serial-dev] [-u fiasco-image] [-U 0|1] | [-P new-fiasco] [piece1] [2] ..\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,14 +422,14 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_USB
|
#if HAVE_USB
|
||||||
if (connect_via_usb()) {
|
if (connect_via_usb()) {
|
||||||
fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
|
fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (info)
|
// if (info)
|
||||||
cmd_info("");
|
cmd_info("");
|
||||||
|
|
||||||
if (pcs_n) {
|
if (pcs_n) {
|
||||||
char version[64];
|
char version[64];
|
||||||
check_nolo_order();
|
check_nolo_order();
|
||||||
@@ -444,10 +452,10 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rd_mode != -1)
|
if (rd_mode != -1)
|
||||||
set_rd_mode(rd_mode);
|
set_rd_mode(rd_mode);
|
||||||
|
|
||||||
if (rd_flags != -1)
|
if (rd_flags != -1)
|
||||||
set_rd_flags(rd_flags);
|
set_rd_flags(rd_flags);
|
||||||
|
|
||||||
if (root_device != -1)
|
if (root_device != -1)
|
||||||
set_root_device(root_device);
|
set_root_device(root_device);
|
||||||
|
|||||||
Reference in new issue
Block a user