diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/jz4740_tools/HXFmerge.c | 24 | ||||
-rw-r--r-- | utils/jz4740_tools/HXFreplace.c | 8 | ||||
-rw-r--r-- | utils/jz4740_tools/HXFsplit.c | 46 | ||||
-rw-r--r-- | utils/jz4740_tools/IHFSsplit.c | 195 | ||||
-rw-r--r-- | utils/jz4740_tools/Makefile | 28 | ||||
-rw-r--r-- | utils/jz4740_tools/jz4740_usbtool.c | 12 |
6 files changed, 257 insertions, 56 deletions
diff --git a/utils/jz4740_tools/HXFmerge.c b/utils/jz4740_tools/HXFmerge.c index fb5a0bf2f3..6b6c62505e 100644 --- a/utils/jz4740_tools/HXFmerge.c +++ b/utils/jz4740_tools/HXFmerge.c | |||
@@ -143,12 +143,12 @@ static void merge_hxf(const char* indir, FILE* outfile, const char* add) | |||
143 | unsigned int filesize; | 143 | unsigned int filesize; |
144 | strcpy(file, dir); | 144 | strcpy(file, dir); |
145 | strcat(file, dirs->d_name); | 145 | strcat(file, dirs->d_name); |
146 | if((filehandle = fopen(file, "rb")) == NULL) | 146 | if((filehandle = fopen(file, "rb")) == NULL) |
147 | { | 147 | { |
148 | fprintf(stderr, "[ERR] Cannot open %s\n", file); | 148 | fprintf(stderr, "[ERR] Cannot open %s\n", file); |
149 | closedir(indir_handle); | 149 | closedir(indir_handle); |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | filesize = _filesize(filehandle); | 152 | filesize = _filesize(filehandle); |
153 | if(filesize > 0) | 153 | if(filesize > 0) |
154 | { | 154 | { |
@@ -179,7 +179,7 @@ static void merge_hxf(const char* indir, FILE* outfile, const char* add) | |||
179 | WRITE(int2le(strlen(dirs->d_name)+strlen(add)), 4); | 179 | WRITE(int2le(strlen(dirs->d_name)+strlen(add)), 4); |
180 | #endif | 180 | #endif |
181 | #ifndef _WIN32 | 181 | #ifndef _WIN32 |
182 | WRITE(replace(&add), strlen(add)-1); | 182 | WRITE(replace((char*)add), strlen(add)-1); |
183 | #else | 183 | #else |
184 | WRITE(add, strlen(add)-1); | 184 | WRITE(add, strlen(add)-1); |
185 | #endif | 185 | #endif |
@@ -276,20 +276,20 @@ int main(int argc, char *argv[]) | |||
276 | #ifdef _WIN32 | 276 | #ifdef _WIN32 |
277 | if(strcmp((char*)(argv[1]+strlen(argv[1])-1), "\\") != 0) | 277 | if(strcmp((char*)(argv[1]+strlen(argv[1])-1), "\\") != 0) |
278 | { | 278 | { |
279 | fprintf(stderr, "[ERR] Input path must end with a \\\n"); | 279 | fprintf(stderr, "[ERR] Input path must end with a \\\n"); |
280 | #else | 280 | #else |
281 | if(strcmp((char*)(argv[1]+strlen(argv[1])-1), "/") != 0) | 281 | if(strcmp((char*)(argv[1]+strlen(argv[1])-1), "/") != 0) |
282 | { | 282 | { |
283 | fprintf(stderr, "[ERR] Input path must end with a /\n"); | 283 | fprintf(stderr, "[ERR] Input path must end with a /\n"); |
284 | #endif | 284 | #endif |
285 | return 2; | 285 | return 2; |
286 | } | 286 | } |
287 | 287 | ||
288 | if((outfile = fopen(argv[2], "wb+")) == NULL) | 288 | if((outfile = fopen(argv[2], "wb+")) == NULL) |
289 | { | 289 | { |
290 | fprintf(stderr, "[ERR] Cannot open %s\n", argv[2]); | 290 | fprintf(stderr, "[ERR] Cannot open %s\n", argv[2]); |
291 | return 3; | 291 | return 3; |
292 | } | 292 | } |
293 | 293 | ||
294 | fseek(outfile, 0x40, SEEK_SET); | 294 | fseek(outfile, 0x40, SEEK_SET); |
295 | 295 | ||
diff --git a/utils/jz4740_tools/HXFreplace.c b/utils/jz4740_tools/HXFreplace.c index 154bc13071..989a59dd61 100644 --- a/utils/jz4740_tools/HXFreplace.c +++ b/utils/jz4740_tools/HXFreplace.c | |||
@@ -119,11 +119,11 @@ int main(int argc, char *argv[]) | |||
119 | return 1; | 119 | return 1; |
120 | } | 120 | } |
121 | 121 | ||
122 | if((infile = fopen(argv[1], "rb")) == NULL) | 122 | if((infile = fopen(argv[1], "rb")) == NULL) |
123 | { | 123 | { |
124 | fprintf(stderr, "[ERR] Cannot open %s\n", argv[1]); | 124 | fprintf(stderr, "[ERR] Cannot open %s\n", argv[1]); |
125 | return 2; | 125 | return 2; |
126 | } | 126 | } |
127 | 127 | ||
128 | if(fseek(infile, 0x40, SEEK_SET) != 0) | 128 | if(fseek(infile, 0x40, SEEK_SET) != 0) |
129 | { | 129 | { |
diff --git a/utils/jz4740_tools/HXFsplit.c b/utils/jz4740_tools/HXFsplit.c index d5e578625b..6e945b067a 100644 --- a/utils/jz4740_tools/HXFsplit.c +++ b/utils/jz4740_tools/HXFsplit.c | |||
@@ -31,11 +31,11 @@ | |||
31 | #define VERSION "0.2" | 31 | #define VERSION "0.2" |
32 | 32 | ||
33 | struct header{ | 33 | struct header{ |
34 | char main_header[20]; | 34 | char main_header[20]; |
35 | unsigned int size; | 35 | unsigned int size; |
36 | unsigned int checksum; | 36 | unsigned int checksum; |
37 | unsigned int unknown; | 37 | unsigned int unknown; |
38 | char other_header[32]; | 38 | char other_header[32]; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | static char* basepath(char* path) | 41 | static char* basepath(char* path) |
@@ -197,7 +197,7 @@ static int split_hxf(const unsigned char* infile, unsigned int size, const char* | |||
197 | if(!file_exists(filename)) | 197 | if(!file_exists(filename)) |
198 | { | 198 | { |
199 | printf("[INFO] %s: %d bytes\n", filename, filesize); | 199 | printf("[INFO] %s: %d bytes\n", filename, filesize); |
200 | if((outfile = fopen(filename, "wb")) == NULL) | 200 | if((outfile = fopen(filename, "wb")) == NULL) |
201 | { | 201 | { |
202 | fprintf(stderr, "[ERR] Error opening file %s\n", filename); | 202 | fprintf(stderr, "[ERR] Error opening file %s\n", filename); |
203 | return -1; | 203 | return -1; |
@@ -251,20 +251,20 @@ int main(int argc, char *argv[]) | |||
251 | #ifdef _WIN32 | 251 | #ifdef _WIN32 |
252 | if(strcmp((char*)(argv[2]+strlen(argv[2])-1), "\\") != 0) | 252 | if(strcmp((char*)(argv[2]+strlen(argv[2])-1), "\\") != 0) |
253 | { | 253 | { |
254 | fprintf(stderr, "[ERR] Output path must end with a \\\n"); | 254 | fprintf(stderr, "[ERR] Output path must end with a \\\n"); |
255 | #else | 255 | #else |
256 | if(strcmp((char*)(argv[2]+strlen(argv[2])-1), "/") != 0) | 256 | if(strcmp((char*)(argv[2]+strlen(argv[2])-1), "/") != 0) |
257 | { | 257 | { |
258 | fprintf(stderr, "[ERR] Output path must end with a /\n"); | 258 | fprintf(stderr, "[ERR] Output path must end with a /\n"); |
259 | #endif | 259 | #endif |
260 | return 2; | 260 | return 2; |
261 | } | 261 | } |
262 | 262 | ||
263 | if((infile = fopen(argv[1], "rb")) == NULL) | 263 | if((infile = fopen(argv[1], "rb")) == NULL) |
264 | { | 264 | { |
265 | fprintf(stderr, "[ERR] Cannot open %s\n", argv[1]); | 265 | fprintf(stderr, "[ERR] Cannot open %s\n", argv[1]); |
266 | return 3; | 266 | return 3; |
267 | } | 267 | } |
268 | 268 | ||
269 | if((inbuffer = (unsigned char*)malloc(sizeof(struct header))) == NULL) | 269 | if((inbuffer = (unsigned char*)malloc(sizeof(struct header))) == NULL) |
270 | { | 270 | { |
@@ -273,12 +273,12 @@ int main(int argc, char *argv[]) | |||
273 | return 4; | 273 | return 4; |
274 | } | 274 | } |
275 | 275 | ||
276 | if(fread(inbuffer, sizeof(struct header), 1, infile) != 1) | 276 | if(fread(inbuffer, sizeof(struct header), 1, infile) != 1) |
277 | { | 277 | { |
278 | fclose(infile); | 278 | fclose(infile); |
279 | fprintf(stderr, "Cannot read header of %s\n", argv[1]); | 279 | fprintf(stderr, "Cannot read header of %s\n", argv[1]); |
280 | return 5; | 280 | return 5; |
281 | } | 281 | } |
282 | 282 | ||
283 | memcpy(hdr.main_header, inbuffer, 20); | 283 | memcpy(hdr.main_header, inbuffer, 20); |
284 | hdr.size = le2int(&inbuffer[20]); | 284 | hdr.size = le2int(&inbuffer[20]); |
@@ -290,8 +290,8 @@ int main(int argc, char *argv[]) | |||
290 | if(strcmp(hdr.other_header, "Chinachip PMP firmware V1.0") != 0) | 290 | if(strcmp(hdr.other_header, "Chinachip PMP firmware V1.0") != 0) |
291 | { | 291 | { |
292 | fclose(infile); | 292 | fclose(infile); |
293 | fprintf(stderr, "[ERR] Header doesn't match\n"); | 293 | fprintf(stderr, "[ERR] Header doesn't match\n"); |
294 | return 6; | 294 | return 6; |
295 | } | 295 | } |
296 | 296 | ||
297 | if((inbuffer = (unsigned char*)malloc(hdr.size)) == NULL) | 297 | if((inbuffer = (unsigned char*)malloc(hdr.size)) == NULL) |
@@ -303,13 +303,13 @@ int main(int argc, char *argv[]) | |||
303 | 303 | ||
304 | fseek(infile, sizeof(struct header), SEEK_SET); | 304 | fseek(infile, sizeof(struct header), SEEK_SET); |
305 | 305 | ||
306 | if(fread(inbuffer, hdr.size-sizeof(struct header), 1, infile) != 1) | 306 | if(fread(inbuffer, hdr.size-sizeof(struct header), 1, infile) != 1) |
307 | { | 307 | { |
308 | fclose(infile); | 308 | fclose(infile); |
309 | free(inbuffer); | 309 | free(inbuffer); |
310 | fprintf(stderr, "[ERR] Cannot read file in buffer\n"); | 310 | fprintf(stderr, "[ERR] Cannot read file in buffer\n"); |
311 | return 8; | 311 | return 8; |
312 | } | 312 | } |
313 | 313 | ||
314 | fclose(infile); | 314 | fclose(infile); |
315 | 315 | ||
diff --git a/utils/jz4740_tools/IHFSsplit.c b/utils/jz4740_tools/IHFSsplit.c new file mode 100644 index 0000000000..1f90a50007 --- /dev/null +++ b/utils/jz4740_tools/IHFSsplit.c | |||
@@ -0,0 +1,195 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by William Poetra Yoga Hadisoeseno | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdio.h> | ||
23 | #include <string.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <stdint.h> | ||
26 | #include <libgen.h> | ||
27 | #include <sys/types.h> | ||
28 | #include <sys/stat.h> | ||
29 | #include <unistd.h> | ||
30 | #include <fcntl.h> | ||
31 | |||
32 | void usage() | ||
33 | { | ||
34 | fprintf(stderr, "usage: IHFSsplit <ihfs_img> <output_dir>\n"); | ||
35 | exit(1); | ||
36 | } | ||
37 | |||
38 | typedef struct { | ||
39 | uint32_t signature; | ||
40 | uint32_t fslen; | ||
41 | uint32_t unknown1; | ||
42 | uint32_t unknown2; | ||
43 | char timestamp[12]; | ||
44 | uint32_t numfiles; | ||
45 | char zeros[476]; | ||
46 | uint32_t marker; | ||
47 | } ihfs_header_t; | ||
48 | |||
49 | #define MAX_FILES 2048 | ||
50 | #define MAX_IHFS_PATH 56 | ||
51 | |||
52 | typedef struct { | ||
53 | struct { | ||
54 | char fullpath[MAX_IHFS_PATH]; | ||
55 | uint32_t sector; | ||
56 | uint32_t length; | ||
57 | } files[MAX_FILES]; | ||
58 | } ihfs_file_table_t; | ||
59 | |||
60 | #define SECTOR_SIZE 512 | ||
61 | |||
62 | int ihfs_sanity(const int ihfs_img) | ||
63 | { | ||
64 | struct stat statbuf; | ||
65 | ihfs_header_t ihfs_hdr; | ||
66 | |||
67 | printf("starting sanity check for IHFS image...\n"); | ||
68 | |||
69 | lseek(ihfs_img, 0, SEEK_SET); | ||
70 | read(ihfs_img, &ihfs_hdr, sizeof (ihfs_hdr)); | ||
71 | |||
72 | printf(" checking for IHFS signature...\n"); | ||
73 | if (ihfs_hdr.signature != 0x49484653) | ||
74 | return 1; | ||
75 | |||
76 | printf(" checking for FS length...\n"); | ||
77 | fstat(ihfs_img, &statbuf); | ||
78 | if (ihfs_hdr.fslen * SECTOR_SIZE != statbuf.st_size) | ||
79 | return 1; | ||
80 | |||
81 | printf(" checking for unknown value 1...\n"); | ||
82 | if (ihfs_hdr.unknown1 != 0x00000004) | ||
83 | return 1; | ||
84 | |||
85 | printf(" checking for unknown value 2...\n"); | ||
86 | if (ihfs_hdr.unknown2 != 0xfffff000) | ||
87 | return 1; | ||
88 | |||
89 | printf(" checking for number of files...\n"); | ||
90 | if (ihfs_hdr.numfiles > MAX_FILES) | ||
91 | return 1; | ||
92 | |||
93 | printf(" checking for marker...\n"); | ||
94 | if (ihfs_hdr.marker != 0x55aa55aa) | ||
95 | return 1; | ||
96 | |||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | void mkdir_p(const char *path) | ||
101 | { | ||
102 | char *dir; | ||
103 | |||
104 | dir = dirname(strdup(path)); | ||
105 | if (strchr(dir, '/')) | ||
106 | mkdir_p(dir); | ||
107 | |||
108 | mkdir(dir, 0755); | ||
109 | } | ||
110 | |||
111 | #define BUF_SIZE 4096 | ||
112 | |||
113 | void outputfile(const char *outpath, const int ihfs_img, const int offset, const int length) | ||
114 | { | ||
115 | int outfd; | ||
116 | int i, rem; | ||
117 | char buf[BUF_SIZE]; | ||
118 | |||
119 | lseek(ihfs_img, offset, SEEK_SET); | ||
120 | |||
121 | outfd = creat(outpath, 0644); | ||
122 | |||
123 | for (i = 0; i < length / BUF_SIZE; ++i) { | ||
124 | read(ihfs_img, buf, BUF_SIZE); | ||
125 | write(outfd, buf, BUF_SIZE); | ||
126 | } | ||
127 | rem = length - i * BUF_SIZE; | ||
128 | if (rem > 0) { | ||
129 | read(ihfs_img, buf, rem); | ||
130 | write(outfd, buf, rem); | ||
131 | } | ||
132 | |||
133 | close(outfd); | ||
134 | } | ||
135 | |||
136 | int main(int argc, char **argv) | ||
137 | { | ||
138 | struct stat statbuf; | ||
139 | int ihfs_img; | ||
140 | ihfs_header_t ihfs_hdr; | ||
141 | ihfs_file_table_t ihfs_ftbl; | ||
142 | int i, j; | ||
143 | char *outpath, *base_path, ihfs_path[MAX_IHFS_PATH+1]; | ||
144 | |||
145 | /* check the arguments */ | ||
146 | |||
147 | if (argc != 3) | ||
148 | usage(); | ||
149 | |||
150 | stat(argv[1], &statbuf); | ||
151 | if (!S_ISREG(statbuf.st_mode)) | ||
152 | usage(); | ||
153 | |||
154 | stat(argv[2], &statbuf); | ||
155 | if (!S_ISDIR(statbuf.st_mode)) | ||
156 | usage(); | ||
157 | |||
158 | /* check the file, then split */ | ||
159 | |||
160 | ihfs_img = open(argv[1], O_RDONLY); | ||
161 | |||
162 | if (ihfs_sanity(ihfs_img)) { | ||
163 | printf("Non-IHFS format!\n"); | ||
164 | return 1; | ||
165 | } else | ||
166 | printf("sanity check OK\n"); | ||
167 | |||
168 | lseek(ihfs_img, 0, SEEK_SET); | ||
169 | read(ihfs_img, &ihfs_hdr, sizeof (ihfs_hdr)); | ||
170 | lseek(ihfs_img, 4 * SECTOR_SIZE, SEEK_SET); | ||
171 | read(ihfs_img, &ihfs_ftbl, sizeof (ihfs_ftbl)); | ||
172 | |||
173 | base_path = strdup(argv[2]); | ||
174 | outpath = malloc(strlen(base_path) + 1 + MAX_IHFS_PATH + 1); | ||
175 | for (i = 0; i < ihfs_hdr.numfiles; ++i) { | ||
176 | printf("\n"); | ||
177 | printf("pathname: %s\n", ihfs_ftbl.files[i].fullpath); | ||
178 | printf("starts at sector %d, length is %d bytes\n", ihfs_ftbl.files[i].sector, ihfs_ftbl.files[i].length); | ||
179 | |||
180 | strncpy(ihfs_path, ihfs_ftbl.files[i].fullpath, MAX_IHFS_PATH); | ||
181 | ihfs_path[MAX_IHFS_PATH] = '\0'; | ||
182 | for (j = 0; j < strlen(ihfs_path); ++j) | ||
183 | if (ihfs_path[j] == '\\') | ||
184 | ihfs_path[j] = '/'; | ||
185 | |||
186 | sprintf(outpath, "%s/%s", base_path, ihfs_path); | ||
187 | mkdir_p(outpath); | ||
188 | outputfile(outpath, ihfs_img, ihfs_ftbl.files[i].sector * SECTOR_SIZE, ihfs_ftbl.files[i].length); | ||
189 | } | ||
190 | free(outpath); | ||
191 | |||
192 | close(ihfs_img); | ||
193 | |||
194 | return 0; | ||
195 | } \ No newline at end of file | ||
diff --git a/utils/jz4740_tools/Makefile b/utils/jz4740_tools/Makefile index 6ebf0c8fb3..7ed79eb22c 100644 --- a/utils/jz4740_tools/Makefile +++ b/utils/jz4740_tools/Makefile | |||
@@ -1,28 +1,34 @@ | |||
1 | WIN_DRIVERS_LIBUSB_DIR = C:\Program Files\LibUSB-Win32 | 1 | WIN_DRIVERS_LIBUSB_DIR = C:\Program Files\LibUSB-Win32 |
2 | WIN_LIBUSB_INCLUDE_DIR = "$(WIN_DRIVERS_LIBUSB_DIR)\include" | 2 | WIN_LIBUSB_INCLUDE_DIR = "$(WIN_DRIVERS_LIBUSB_DIR)\include" |
3 | WIN_LIBUSB_LIB_DIR = "$(WIN_DRIVERS_LIBUSB_DIR)\lib\gcc" | 3 | WIN_LIBUSB_LIB_DIR = "$(WIN_DRIVERS_LIBUSB_DIR)\lib\$(CC)" |
4 | 4 | ||
5 | linux: usbtool HXFmerge HXFreplace HXFsplit | 5 | CFLAGS=-Wall |
6 | win: usbtool_win HXFmerge_win HXFsplit_win HXFreplace_win | 6 | |
7 | linux: usbtool HXFmerge HXFreplace HXFsplit IHFSsplit | ||
8 | win: usbtool_win HXFmerge_win HXFsplit_win HXFreplace_win IHFSsplit_win | ||
7 | 9 | ||
8 | usbtool: | 10 | usbtool: |
9 | gcc -Wall -o usbtool jz4740_usbtool.c -lusb | 11 | $(CC) $(CFLAGS) -o usbtool jz4740_usbtool.c -lusb |
10 | usbtool_win: | 12 | usbtool_win: |
11 | gcc -Wall -o usbtool.exe jz4740_usbtool.c -lusb -I $(WIN_LIBUSB_INCLUDE_DIR) -L $(WIN_LIBUSB_LIB_DIR) | 13 | $(CC) $(CFLAGS) -o usbtool.exe jz4740_usbtool.c -lusb -I $(WIN_LIBUSB_INCLUDE_DIR) -L $(WIN_LIBUSB_LIB_DIR) |
12 | 14 | ||
13 | HXFmerge: | 15 | HXFmerge: |
14 | gcc -Wall -o HXFmerge HXFmerge.c | 16 | $(CC) $(CFLAGS) -o HXFmerge HXFmerge.c |
15 | HXFreplace: | 17 | HXFreplace: |
16 | gcc -Wall -o HXFreplace HXFreplace.c | 18 | $(CC) $(CFLAGS) -o HXFreplace HXFreplace.c |
17 | HXFsplit: | 19 | HXFsplit: |
18 | gcc -Wall -o HXFsplit HXFsplit.c | 20 | $(CC) $(CFLAGS) -o HXFsplit HXFsplit.c |
21 | IHFSsplit: | ||
22 | $(CC) $(CFLAGS) -o IHFSsplit IHFSsplit.c | ||
19 | 23 | ||
20 | HXFmerge_win: | 24 | HXFmerge_win: |
21 | gcc -Wall -o HXFmerge.exe HXFmerge.c | 25 | $(CC) $(CFLAGS) -o HXFmerge.exe HXFmerge.c |
22 | HXFreplace_win: | 26 | HXFreplace_win: |
23 | gcc -Wall -o HXFreplace.exe HXFreplace.c | 27 | $(CC) $(CFLAGS) -o HXFreplace.exe HXFreplace.c |
24 | HXFsplit_win: | 28 | HXFsplit_win: |
25 | gcc -Wall -o HXFsplit.exe HXFsplit.c | 29 | $(CC) $(CFLAGS) -o HXFsplit.exe HXFsplit.c |
30 | IHFSsplit_win: | ||
31 | $(CC) $(CFLAGS) -o IHFSsplit.exe IHFSsplit.c | ||
26 | 32 | ||
27 | clean-linux: | 33 | clean-linux: |
28 | rm HXFmerge HXFreplace HXFsplit usbtool | 34 | rm HXFmerge HXFreplace HXFsplit usbtool |
diff --git a/utils/jz4740_tools/jz4740_usbtool.c b/utils/jz4740_tools/jz4740_usbtool.c index fe8771ae12..bc26804bdd 100644 --- a/utils/jz4740_tools/jz4740_usbtool.c +++ b/utils/jz4740_tools/jz4740_usbtool.c | |||
@@ -127,30 +127,30 @@ int filesize(FILE* fd) | |||
127 | return tmp; | 127 | return tmp; |
128 | } | 128 | } |
129 | 129 | ||
130 | #define SEND_COMMAND(cmd, arg) err = usb_control_msg(dh, USB_ENDPOINT_OUT | USB_TYPE_VENDOR, cmd, arg>>16, arg&0xFFFF, NULL, 0, TOUT);\ | 130 | #define SEND_COMMAND(cmd, arg) err = usb_control_msg(dh, USB_ENDPOINT_OUT | USB_TYPE_VENDOR, (cmd), (arg)>>16, (arg)&0xFFFF, NULL, 0, TOUT);\ |
131 | if (err < 0) \ | 131 | if (err < 0) \ |
132 | { \ | 132 | { \ |
133 | fprintf(stderr,"\n[ERR] Error sending control message (%d, %s)\n", err, usb_strerror()); \ | 133 | fprintf(stderr,"\n[ERR] Error sending control message (%d, %s)\n", err, usb_strerror()); \ |
134 | return -1; \ | 134 | return -1; \ |
135 | } | 135 | } |
136 | 136 | ||
137 | #define GET_CPU_INFO(s) err = usb_control_msg(dh, USB_ENDPOINT_IN | USB_TYPE_VENDOR, VR_GET_CPU_INFO, 0, 0, s, 8, TOUT); \ | 137 | #define GET_CPU_INFO(s) err = usb_control_msg(dh, USB_ENDPOINT_IN | USB_TYPE_VENDOR, VR_GET_CPU_INFO, 0, 0, (s), 8, TOUT); \ |
138 | if (err < 0) \ | 138 | if (err < 0) \ |
139 | { \ | 139 | { \ |
140 | fprintf(stderr,"\n[ERR] Error sending control message (%d, %s)\n", err, usb_strerror()); \ | 140 | fprintf(stderr,"\n[ERR] Error sending control message (%d, %s)\n", err, usb_strerror()); \ |
141 | return -1; \ | 141 | return -1; \ |
142 | } | 142 | } |
143 | 143 | ||
144 | #define SEND_DATA(ptr, size) err = usb_bulk_write(dh, USB_ENDPOINT_OUT | EP_BULK_TO, ptr, size, TOUT); \ | 144 | #define SEND_DATA(ptr, size) err = usb_bulk_write(dh, USB_ENDPOINT_OUT | EP_BULK_TO, ((char*)(ptr)), (size), TOUT); \ |
145 | if (err != size) \ | 145 | if (err != (size)) \ |
146 | { \ | 146 | { \ |
147 | fprintf(stderr,"\n[ERR] Error writing data\n"); \ | 147 | fprintf(stderr,"\n[ERR] Error writing data\n"); \ |
148 | fprintf(stderr,"[ERR] Bulk write error (%d, %s)\n", err, strerror(-err)); \ | 148 | fprintf(stderr,"[ERR] Bulk write error (%d, %s)\n", err, strerror(-err)); \ |
149 | return -1; \ | 149 | return -1; \ |
150 | } | 150 | } |
151 | 151 | ||
152 | #define GET_DATA(ptr, size) err = usb_bulk_read(dh, USB_ENDPOINT_IN | EP_BULK_TO, ptr, size, TOUT); \ | 152 | #define GET_DATA(ptr, size) err = usb_bulk_read(dh, USB_ENDPOINT_IN | EP_BULK_TO, ((char*)(ptr)), (size), TOUT); \ |
153 | if (err != size) \ | 153 | if (err != (size)) \ |
154 | { \ | 154 | { \ |
155 | fprintf(stderr,"\n[ERR] Error writing data\n"); \ | 155 | fprintf(stderr,"\n[ERR] Error writing data\n"); \ |
156 | fprintf(stderr,"[ERR] Bulk write error (%d, %s)\n", err, strerror(-err)); \ | 156 | fprintf(stderr,"[ERR] Bulk write error (%d, %s)\n", err, strerror(-err)); \ |