gunzip error when uncompress to buf

张忠山 zzs213 at 126.com
Fri Nov 30 06:00:29 EST 2012


On host use the flowwing cmd build a gziped file

----------------
$ gzip -c9 zbarebox.bin > xxx

$ ls zbarebox.bin xxx -l
-rw-rw-r-- 1 zzs zzs 127605 2012-11-30 17:46 xxx
-rwxrwxr-x 1 zzs zzs 136769 2012-11-30 18:44 zbarebox.bin*
----------------

Then on barebox write it to /dev/nor0.kernel

----------------
[barebox at SSR600]:/
# tftp xxx /dev/nor0.kernel
----------------


And add a barebox cmd to uncompress it:

----------------
char ptr[SZ_512K];
static int do_tx(int argc, char *argv[])
{
	int ret = 0, size = 0, fd, fd1;

	fd = open("/dev/tempmem", O_RDWR);
	if(fd < 0)
		printf("error open tempmem\n");
	fd1 = open("/dev/nor0.kernel", O_RDONLY);
	if(fd1 < 0)
		printf("error open kernel\n");
	ret = uncompress_fd_to_fd (fd1, fd, uncompress_err_stdout);
	printf("ret is %d\n", ret);

	close(fd1);
	fd1 = open("/dev/nor0.kernel", O_RDONLY);
	if(fd1 < 0)
		printf("error open kernel\n");
	ret = uncompress_fd_to_buf(fd1, ptr, uncompress_err_stdout);
	printf("ret is %d\n", ret);

	return 0;
}

BAREBOX_CMD_START(tx)
	.cmd		= do_tx,
BAREBOX_CMD_END
----------------

Compile barebox, download to board and run this command

----------------
[barebox at SSR600]:/
# tx
ret is 0
uncompression error
ret is -1
----------------

The result is:

uncompress_fd_to_fd is OK
uncompress_fd_to_buf fail and lib/decompress_inflate.c:gunzip()
output a message "uncompression error"

Anybody help me!

-- 
Best Regards,
zzs





More information about the barebox mailing list