Hi,
I have another patch for 0xFFFF. It does:

1) name the simple functions get_foo and set_foo (and make them more
consistent e.g. set_rd_mode and get_rd_mode).

2) moved remaining simple queries from main.c into query.c

3) created separate query.h header and included it in main.c

4) implemented get_usb_mode (they do not have this in the proprietary
flasher) and added this function to a normal run (-> you will see the
current USB mode when running with -i)

I plan to add the remaining features of the proprietary flasher tool soon.

Regards
Robert
Binärdateien /home/rob/devel/nokia/0xFFFF-0.1-orig/src/0xFFFF and 0xFFFF/src/0xFFFF sind verschieden.
Binärdateien /home/rob/devel/nokia/0xFFFF-0.1-orig/src/dump.o and 0xFFFF/src/dump.o sind verschieden.
Binärdateien /home/rob/devel/nokia/0xFFFF-0.1-orig/src/fiasco.o and 0xFFFF/src/fiasco.o sind verschieden.
Binärdateien /home/rob/devel/nokia/0xFFFF-0.1-orig/src/flash.o and 0xFFFF/src/flash.o sind verschieden.
Binärdateien /home/rob/devel/nokia/0xFFFF-0.1-orig/src/fpid.o and 0xFFFF/src/fpid.o sind verschieden.
Binärdateien /home/rob/devel/nokia/0xFFFF-0.1-orig/src/hash.o and 0xFFFF/src/hash.o sind verschieden.
Binärdateien /home/rob/devel/nokia/0xFFFF-0.1-orig/src/hexdump.o and 0xFFFF/src/hexdump.o sind verschieden.
diff -urN /home/rob/devel/nokia/0xFFFF-0.1-orig/src/main.c 0xFFFF/src/main.c
--- /home/rob/devel/nokia/0xFFFF-0.1-orig/src/main.c	2007-04-23 12:21:55.000000000 +0200
+++ 0xFFFF/src/main.c	2007-04-23 13:11:13.000000000 +0200
@@ -19,6 +19,8 @@
  */
 
 #include "main.h"
+#include "query.h"
+
 #include <usb.h>
 #include <stdio.h>
 #include <string.h>
@@ -176,26 +178,6 @@
 	// TODO
 }
 
-int query_sw_version()
-{
-	int ret;
-	char bytes[1024];
-
-	strcpy(bytes, "version:sw-release");
-	ret = usb_control_msg(dev, CMD_WRITE, 18, 0, 0, (char *)&bytes, 18, 2000);
-	if (ret<0) {
-		fprintf(stderr, "error: cannot write query 18\n");
-		return 0;
-	}
-	ret = usb_control_msg(dev, CMD_QUERY, 20, 0, 0, (char *)&bytes, 512, 2000);
-	if (ret<0) {
-		fprintf(stderr, "error: b0rken swversion read!\n");
-		return 0;
-	}
-	printf("SWVERSION GOT: %s\n", bytes); //???+strlen(bytes)+1));
-	return 1;
-}
-
 int main(int argc, char **argv)
 {
 	struct usb_device_descriptor udd;
@@ -320,16 +302,18 @@
 
 	// if (info)
 	sleep(1); // take breath
-	query_root_device(); // only for flashing
-	query_rdmode_device();
-	query_hw_revision(); // get hardware revision:
+	get_root_device(); // only for flashing
+	get_rd_mode();
+	get_usb_mode();
+	
+	get_hw_revision(); // get hardware revision:
 
 	if (pcs_n) {
 		int c;
 
 		check_nolo_order();
-		query_sw_version();
-		query_nolo_version();
+		get_sw_version();
+		get_nolo_version();
 
 		for(c=0;c<pcs_n;c++) {
 			printf("Flashing %s (%s)\n", pcs[c].type, pcs[c].name);
@@ -341,7 +325,7 @@
 		set_root_device(root_device);
 
 	if (usb_mode!=-1)
-		set_usb_host_mode(usb_mode);
+		set_usb_mode(usb_mode);
 
 	if (boot_cmdline)
 		boot_board(boot_cmdline);
diff -urN /home/rob/devel/nokia/0xFFFF-0.1-orig/src/main.h 0xFFFF/src/main.h
--- /home/rob/devel/nokia/0xFFFF-0.1-orig/src/main.h	2007-04-23 12:21:55.000000000 +0200
+++ 0xFFFF/src/main.h	2007-04-23 12:32:04.000000000 +0200
@@ -1,3 +1,4 @@
+
 #ifndef _INCLUDE_MAIN_H_
 #define _INCLUDE_MAIN_H_
 
@@ -11,21 +12,7 @@
 extern struct usb_dev_handle *dev;
 unsigned long get_file_size(char *file);
 void progressbar(unsigned long long part, unsigned long long total);
-int get_status();
-int get_peripheral_host_mode(int foo);
-int boot_board(char *cmdline);
-int boot_board(char *cmdline);
-int reboot_board();
 char *fpid_file(char *filename);
-int set_rd_mode(unsigned short mode);
-int set_usb_host_mode(unsigned short mode);
-int query_hw_revision();
-int query_rdmode_device();
-
-int query_root_device();
-int set_root_device(unsigned short);
-
-int query_nolo_version();
 int add_piece(char *piece);
 
 #define D if (verbose)
Binärdateien /home/rob/devel/nokia/0xFFFF-0.1-orig/src/main.o and 0xFFFF/src/main.o sind verschieden.
Binärdateien /home/rob/devel/nokia/0xFFFF-0.1-orig/src/pieces.o and 0xFFFF/src/pieces.o sind verschieden.
diff -urN /home/rob/devel/nokia/0xFFFF-0.1-orig/src/query.c 0xFFFF/src/query.c
--- /home/rob/devel/nokia/0xFFFF-0.1-orig/src/query.c	2007-04-23 12:21:55.000000000 +0200
+++ 0xFFFF/src/query.c	2007-04-23 13:24:11.000000000 +0200
@@ -36,26 +36,48 @@
 	return ret;
 }
 
-int get_peripheral_host_mode(int foo)
+/**
+ * request type: CMD_WRITE
+ * request     : 16
+ * value       : 0|1 (=> client|host)
+ * index       : 2
+ */
+int set_usb_mode(unsigned int mode)
+{
+	if (usb_control_msg(dev, CMD_WRITE, 16, mode, 2, 0, 0, 2000) == -1) {
+		fprintf(stderr, "Cannot set USB mode.\n");
+		return -1;
+	}
+
+	printf("Set USB mode to: '%s'.\n", (mode) ? "host" : "client");
+
+	return 0;
+}
+
+/**
+ * request type: CMD_QUERY
+ * request     : 17
+ * index       : 2
+ * 
+ * return value: 0|1 (=> client|host)
+ */
+int get_usb_mode()
 {
-	//unsigned short mode = 0;
+	unsigned short mode = 0;
 
-	// XXX BROKEN
-#if 0
-	if (usb_control_msg(dev, 64, 16, 2, 0, 2, 0, 0, 2000)) {
+	if (usb_control_msg(dev, CMD_QUERY, 17, 0, 2, &mode, sizeof(mode), 2000) == -1) {
 		fprintf(stderr, "Cannot query device.\n");
 		return -1;
 	}
 
-	printf("Device is in \"%s\" mode (%hd)\n", (mode)?"host":"peripheral", mode);
-#endif
+	printf("Device's USB mode is '%s'\n", (mode) ? "host" : "client");
 
 	return 0;
 }
+
 /*
- * boot the omap mobo
+ * Boots the Kernel with the given command-line.
  */
-
 int boot_board(char *cmdline)
 {
 	if (usb_control_msg(dev, CMD_WRITE, 130, 0, 0, cmdline, strlen(cmdline), 2000) == -1) {
@@ -70,7 +92,7 @@
 }
 
 /*
- * reboot the omap mobo
+ * Reboots the omap mobo.
  */
 int reboot_board()
 {
@@ -100,23 +122,10 @@
 	return 0;
 }
 
-// mode = 1 || 0
-int set_usb_host_mode(unsigned short mode)
-{
-	if (usb_control_msg(dev, CMD_WRITE, 16, mode, 2, 0, 0, 2000) == -1) {
-		fprintf(stderr, "Cannot change the usb-host mode.\n");
-		return -1;
-	}
-
-	printf("USB host mode is %s.\n", mode?"enabled":"disabled");
-
-	return 0;
-}
-
 /*
  * query root device
  */
-int query_hw_revision()
+int get_hw_revision()
 {
 	unsigned char string[512];
 	int i = 0;
@@ -140,7 +149,7 @@
 	return 0;
 }
 
-int query_rdmode_device()
+int get_rd_mode()
 {
 	char isrd = 1;
 
@@ -153,7 +162,7 @@
 	return isrd;
 }
 
-int query_root_device()
+int get_root_device()
 {
 	unsigned char opcode;
 
@@ -194,7 +203,7 @@
 	return 0;
 }
 
-int query_nolo_version()
+int get_nolo_version()
 {
 	unsigned int version; // ensure uint is at least 32 bits
 
@@ -214,3 +223,24 @@
 
 	return 0;
 }
+
+int get_sw_version()
+{
+	int ret;
+	char bytes[1024];
+
+	strcpy(bytes, "version:sw-release");
+	ret = usb_control_msg(dev, CMD_WRITE, 18, 0, 0, (char *)&bytes, 18, 2000);
+	if (ret<0) {
+		fprintf(stderr, "error: cannot write query 18\n");
+		return 0;
+	}
+	ret = usb_control_msg(dev, CMD_QUERY, 20, 0, 0, (char *)&bytes, 512, 2000);
+	if (ret<0) {
+		fprintf(stderr, "error: b0rken swversion read!\n");
+		return 0;
+	}
+	printf("SWVERSION GOT: %s\n", bytes); //???+strlen(bytes)+1));
+	return 1;
+}
+
diff -urN /home/rob/devel/nokia/0xFFFF-0.1-orig/src/query.h 0xFFFF/src/query.h
--- /home/rob/devel/nokia/0xFFFF-0.1-orig/src/query.h	1970-01-01 01:00:00.000000000 +0100
+++ 0xFFFF/src/query.h	2007-04-23 13:09:35.000000000 +0200
@@ -0,0 +1,28 @@
+#ifndef QUERY_H_
+#define QUERY_H_
+
+int boot_board(char *cmdline);
+
+int reboot_board();
+
+int get_status();
+
+int get_usb_mode();
+int set_usb_mode(unsigned int);
+
+int set_rd_mode(unsigned short mode);
+
+int get_rd_mode();
+
+int set_usb_host_mode(unsigned short mode);
+
+int get_hw_revision();
+
+int get_root_device();
+int set_root_device(unsigned short);
+
+int get_nolo_version();
+
+int get_sw_version();
+
+#endif /*QUERY_H_*/
Binärdateien /home/rob/devel/nokia/0xFFFF-0.1-orig/src/query.o and 0xFFFF/src/query.o sind verschieden.
Binärdateien /home/rob/devel/nokia/0xFFFF-0.1-orig/src/utils.o and 0xFFFF/src/utils.o sind verschieden.

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
0xffff mailing list
0xffff@lists.nopcode.org
https://lists.nopcode.org/mailman/listinfo/0xffff

Reply via email to