summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpancake <none@none>2010-04-26 18:29:19 +0200
committerpancake <none@none>2010-04-26 18:29:19 +0200
commit20eed53d8c8794fe752f66b4e0d5a14d2cee657a (patch)
treee484ecef4baab7bed9d41bd2f1ef099b9feab35c
parente2aaa2cb402db09bf510bb877a4f3bfe941514e9 (diff)
download0xFFFF-20eed53d8c8794fe752f66b4e0d5a14d2cee657a.tar.bz2
* Fix usb initialization link with n900 * minor syntax fixup
-rw-r--r--src/devices.c1
-rw-r--r--src/main.c148
2 files changed, 79 insertions, 70 deletions
diff --git a/src/devices.c b/src/devices.c
index 2ffdfde..0f15d47 100644
--- a/src/devices.c
+++ b/src/devices.c
@@ -103,6 +103,7 @@ int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_devic
if ((dev_index = is_valid_device(udd))) {
device = dev;
+ printf("%s found!\n", dev->filename);
*it_device = supported_devices[dev_index];
return 1;
}
diff --git a/src/main.c b/src/main.c
index 5a1ef64..4217c92 100644
--- a/src/main.c
+++ b/src/main.c
@@ -116,7 +116,7 @@ int unpack_callback(struct header_t *header)
if (strchr(header->name, ',') != NULL) {
if (!strstr(header->name, subverstr)) {
printf("Skipping '%s' does not matches -S subversion\n",
- header->name);
+ header->name);
return 1;
}
}
@@ -165,10 +165,10 @@ int fiasco_flash(const char *file)
char *p;
char version[64];
- if (connect_via_usb()) {
- fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
- return 0;
- }
+ if (connect_via_usb()) {
+ fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
+ return 0;
+ }
// if (info)
cmd_info("");
@@ -202,67 +202,75 @@ int fiasco_flash(const char *file)
int connect_via_usb()
{
static char pbc[]={'/','-','\\', '|'};
- struct usb_device_descriptor udd;
- struct devices it_device;
+ struct usb_device_descriptor udd;
+ struct devices it_device;
int c = 0;
// usb_set_debug(5);
usb_init();
- /* Tries to get access to the Internet Tablet and retries
- * if any of the neccessary steps fail.
- *
- * 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 in the boot stage any more).
- */
+ /* Tries to get access to the Internet Tablet and retries
+ * if any of the neccessary steps fail.
+ *
+ * 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 in the boot stage any more).
+ */
while(!dev) {
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]);
fflush(stdout);
continue;
}
- /* open device */
- if(!(dev = usb_open(device))) {
- perror("usb_open");
- return 1;
- }
-
- if ( usb_claim_interface(dev, 2) < 0) {
- //device->config->interface->altsetting->bInterfaceNumber) < 0) { // 2 or 0
- D perror("usb_claim_interface");
-
- // Something is broken if closing fails.
- if(usb_close(dev)) {
- perror("usb_close");
- return 1;
- }
+ /* open device */
+ if(!(dev = usb_open(device))) {
+ perror("usb_open");
+ return 1;
+ }
- dev = NULL;
+#if 1
+{
+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");
- // Try again later.
- continue;
- }
+ // Something is broken if closing fails.
+ if(usb_close(dev)) {
+ perror("usb_close");
+ return 1;
+ }
+ dev = NULL;
+ // Try again later.?
+ exit(1);
+ }
- if (usb_set_altinterface(dev, 1) <0) { //device->config->interface->altsetting->bAlternateSetting) < 0) {
- D perror("usb_set_altinterface");
+ if (usb_set_altinterface(dev, 1) <0) { //device->config->interface->altsetting->bAlternateSetting) < 0) {
+ perror("usb_set_altinterface");
- // Something is broken if closing fails.
- if(usb_close(dev)) {
- perror("usb_close");
- return 1;
- }
+ // Something is broken if closing fails.
+ if(usb_close(dev)) {
+ perror("usb_close");
+ return 1;
+ }
- dev = NULL;
- // Try again later.
- continue;
- }
- }
+ dev = NULL;
+ // Try again later.
+ continue;
+ }
+ break;
+ }
- printf("found %s (%04x:%04x)\n", it_device.name,
+ printf("found %s (%04x:%04x)\n", it_device.name,
it_device.vendor_id, it_device.product_id);
/* go go go! */
@@ -305,8 +313,8 @@ int main(int argc, char **argv)
break;
case 'd':
sscanf(optarg, "%04hx:%04hx",
- &supported_devices[SUPPORTED_DEVICES-2].vendor_id,
- &supported_devices[SUPPORTED_DEVICES-2].product_id);
+ &supported_devices[SUPPORTED_DEVICES-2].vendor_id,
+ &supported_devices[SUPPORTED_DEVICES-2].product_id);
supported_devices[SUPPORTED_DEVICES-2].name = strdup("user");
break;
case 'D':
@@ -314,14 +322,14 @@ int main(int argc, char **argv)
break;
case 'f':
if (!strcmp(optarg,"help")) {
- printf("* Flags are composed of:\n");
- printf(" 0x02 - disable OMAP watchdog (possibly)\n");
- printf(" 0x04 - disable RETU watchdog (possibly)\n");
- printf(" 0x08 - disable lifeguard reset\n");
- printf(" 0x10 - enable serial console\n");
- printf(" 0x20 - disable USB timeout\n");
- exit(1);
- }
+ printf("* Flags are composed of:\n");
+ printf(" 0x02 - disable OMAP watchdog (possibly)\n");
+ printf(" 0x04 - disable RETU watchdog (possibly)\n");
+ printf(" 0x08 - disable lifeguard reset\n");
+ printf(" 0x10 - enable serial console\n");
+ printf(" 0x20 - disable USB timeout\n");
+ exit(1);
+ }
rd_flags = (unsigned short) strtoul(optarg, NULL, 16);
break;
case 'r':
@@ -382,7 +390,7 @@ int main(int argc, char **argv)
return 0;
// flags ok?
- if ( (fiasco_image == NULL)
+ if ( (fiasco_image == NULL)
&& (boot_cmdline == NULL)
&& (reverseto == NULL)
&& (pcs_n == 0)
@@ -395,9 +403,9 @@ int main(int argc, char **argv)
{
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"
- " [-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");
+ "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"
+ " [-s serial-dev] [-u fiasco-image] [-U 0|1] | [-P new-fiasco] [piece1] [2] ..\n");
return 1;
}
@@ -414,14 +422,14 @@ int main(int argc, char **argv)
}
#if HAVE_USB
- if (connect_via_usb()) {
- fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
- return 0;
- }
+ if (connect_via_usb()) {
+ fprintf(stderr, "Cannot connect to device. It is possibly not in boot stage.\n");
+ return 0;
+ }
// if (info)
cmd_info("");
-
+
if (pcs_n) {
char version[64];
check_nolo_order();
@@ -444,10 +452,10 @@ int main(int argc, char **argv)
}
if (rd_mode != -1)
- set_rd_mode(rd_mode);
-
+ set_rd_mode(rd_mode);
+
if (rd_flags != -1)
- set_rd_flags(rd_flags);
+ set_rd_flags(rd_flags);
if (root_device != -1)
set_root_device(root_device);