summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/rk27utils/rk27load/main.c6
-rw-r--r--utils/rk27utils/rkusbtool/rkusbtool.c48
2 files changed, 49 insertions, 5 deletions
diff --git a/utils/rk27utils/rk27load/main.c b/utils/rk27utils/rk27load/main.c
index d183ae2df1..e34d7667e3 100644
--- a/utils/rk27utils/rk27load/main.c
+++ b/utils/rk27utils/rk27load/main.c
@@ -91,6 +91,12 @@ int main(int argc, char **argv)
91 } 91 }
92 } 92 }
93 93
94 if(filenames[0] == NULL || filenames[1] == NULL || filenames[2] == NULL)
95 {
96 usage(argv[0]);
97 return -5;
98 }
99
94 100
95 fprintf(stderr,"rk27load " VERSION "\n"); 101 fprintf(stderr,"rk27load " VERSION "\n");
96 fprintf(stderr,"(C) Marcin Bukat 2011\n"); 102 fprintf(stderr,"(C) Marcin Bukat 2011\n");
diff --git a/utils/rk27utils/rkusbtool/rkusbtool.c b/utils/rk27utils/rkusbtool/rkusbtool.c
index 06fb7e860c..afe6171e64 100644
--- a/utils/rk27utils/rkusbtool/rkusbtool.c
+++ b/utils/rk27utils/rkusbtool/rkusbtool.c
@@ -3,6 +3,7 @@
3#include <stdint.h> 3#include <stdint.h>
4#include <stdio.h> 4#include <stdio.h>
5#include <string.h> 5#include <string.h>
6#include <stdlib.h>
6 7
7#define VERSION "v0.1" 8#define VERSION "v0.1"
8 9
@@ -190,7 +191,7 @@ static int get_sense(libusb_device_handle *hdev)
190{ 191{
191 struct CBWCB_t cbwcb; 192 struct CBWCB_t cbwcb;
192 unsigned char sense[0x12]; 193 unsigned char sense[0x12];
193 int size, ret; 194 int size;
194 uint32_t reftag; 195 uint32_t reftag;
195 196
196 memset(&cbwcb, 0, sizeof(cbwcb)); 197 memset(&cbwcb, 0, sizeof(cbwcb));
@@ -199,7 +200,7 @@ static int get_sense(libusb_device_handle *hdev)
199 cbwcb.LBA = 0; 200 cbwcb.LBA = 0;
200 cbwcb.cbLen = 0x12; 201 cbwcb.cbLen = 0x12;
201 202
202 ret = send_msc_cmd(hdev, &cbwcb, 0x12, &reftag); 203 send_msc_cmd(hdev, &cbwcb, 0x12, &reftag);
203 libusb_bulk_transfer(hdev, IN_EP, (unsigned char*)&sense, 0x12, &size, USB_TIMEOUT); 204 libusb_bulk_transfer(hdev, IN_EP, (unsigned char*)&sense, 0x12, &size, USB_TIMEOUT);
204 205
205 return get_msc_csw(hdev, reftag); 206 return get_msc_csw(hdev, reftag);
@@ -213,14 +214,17 @@ static void usage(void)
213 printf("-d|--dfu Put device into DFU mode\n"); 214 printf("-d|--dfu Put device into DFU mode\n");
214 printf("-s|--sysdisk Open system disk\n"); 215 printf("-s|--sysdisk Open system disk\n");
215 printf("-c|--checkusb Check if dev is in System or Loader USB mode\n"); 216 printf("-c|--checkusb Check if dev is in System or Loader USB mode\n");
217 printf("-u|--usb <p>:<v> Override device PID and PIVD\n");
216} 218}
217 219
218int main (int argc, char **argv) 220int main (int argc, char **argv)
219{ 221{
220 libusb_device_handle *hdev; 222 libusb_device_handle *hdev;
221 int ret; 223 int ret;
222 int i = 0, action = NONE; 224 int i = 1, action = NONE;
223 uint32_t ver[3]; 225 uint32_t ver[3];
226 uint16_t pid = PRODUCTID;
227 uint16_t vid = VENDORID;
224 228
225 if (argc < 2) 229 if (argc < 2)
226 { 230 {
@@ -253,11 +257,45 @@ int main (int argc, char **argv)
253 { 257 {
254 action |= CHECKUSB; 258 action |= CHECKUSB;
255 } 259 }
256 else if ((strcmp(argv[i],"-h")==0) || (strcmp(argv[i],"--help")==0)) 260 else if ((strcmp(argv[i],"-u")==0) || (strcmp(argv[i],"--usb")==0))
261 {
262 if (i + 1 == argc)
263 {
264 fprintf(stderr,"Missing argument for USB IDs\n");
265 return -1;
266 }
267 char *svid = argv[i + 1];
268 char *spid = strchr(svid, ':');
269 if(svid == NULL)
270 {
271 fprintf(stderr,"Invalid argument for USB IDs (missing ':')\n");
272 return -2;
273 }
274 char *end;
275 vid = strtoul(svid, &end, 0);
276 if(*end != ':')
277 {
278 fprintf(stderr,"Invalid argument for USB VID\n");
279 return -3;
280 }
281 pid = strtoul(spid + 1, &end, 0);
282 if(*end)
283 {
284 fprintf(stderr,"Invalid argument for USB PID\n");
285 return -4;
286 }
287 i++;
288 }
289 else if((strcmp(argv[i],"-h")==0) || (strcmp(argv[i],"--help")==0))
257 { 290 {
258 usage(); 291 usage();
259 return 0; 292 return 0;
260 } 293 }
294 else
295 {
296 fprintf(stderr,"Unknown argument '%s'\n", argv[i]);
297 return -5;
298 }
261 i++; 299 i++;
262 } 300 }
263 301
@@ -265,7 +303,7 @@ int main (int argc, char **argv)
265 libusb_init(NULL); 303 libusb_init(NULL);
266 /* usb_set_debug(2); */ 304 /* usb_set_debug(2); */
267 305
268 hdev = libusb_open_device_with_vid_pid(NULL, VENDORID, PRODUCTID); 306 hdev = libusb_open_device_with_vid_pid(NULL, vid, pid);
269 if (hdev == NULL) 307 if (hdev == NULL)
270 { 308 {
271 printf("error: can't open device\n"); 309 printf("error: can't open device\n");