Skip to contentSkip to conversation

Howto known uncompressed length when uncompress_fd_to_buf

DISCUSSION 张忠山 2 participants 6 messages Nov 30, 2012 – Dec 4, 2012

lore
Share & tools
lore

张忠山

author
#0 lore raw

the function uncompress_fd_to_buf has no parameter to return the uncompressed length, How to get the uncompressed content length?

Signature · 9 lines
Best Regards,
zzs



_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 3 lines · 张忠山

the function uncompress_fd_to_buf has no parameter to return the uncompressed length, How to get the uncompressed content length?

AFAIK the uncompressed size is not contained in the compressed data You would have to uncompress to a file and use this afterwards. If I understand correctly you want to load a FPGA firmware which you have in compressed form. What I would do is:

- uncompress the firmware in a script rather than uncompress it from C code.
- write a command to flash the firmware.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
author
#2 lore raw
Quoted 5 lines · In message <[email protected]> Sascha Hauer wrote:
Quoted 3 lines · 张忠山

the function uncompress_fd_to_buf has no parameter to return the uncompressed length, How to get the uncompressed content length?

Quoted 9 lines

AFAIK the uncompressed size is not contained in the compressed data You would have to uncompress to a file and use this afterwards. If I understand correctly you want to load a FPGA firmware which you have in compressed form. What I would do is:

- uncompress the firmware in a script rather than uncompress it from C code.
- write a command to flash the firmware.

But if uncompress it to a device file, like /dev/tmpmem. the file size is the device size, not the uncompressed size.

So now I uncompressed it to a file in C code using uncompress_fd_to_fd, then use lseek to get the current position of target file. That is the uncompressed size.

Signature · 9 lines
Best Regards,
zzs



_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw
Quoted 15 lines · 张忠山
Quoted 5 lines · In message <[email protected]> Sascha Hauer wrote:
Quoted 3 lines · 张忠山

the function uncompress_fd_to_buf has no parameter to return the uncompressed length, How to get the uncompressed content length?

Quoted 9 lines

AFAIK the uncompressed size is not contained in the compressed data You would have to uncompress to a file and use this afterwards. If I understand correctly you want to load a FPGA firmware which you have in compressed form. What I would do is:

- uncompress the firmware in a script rather than uncompress it from C code.
- write a command to flash the firmware.

Quoted 6 lines

But if uncompress it to a device file, like /dev/tmpmem. the file size is the device size, not the uncompressed size.

So now I uncompressed it to a file in C code using uncompress_fd_to_fd, then use lseek to get the current position of target file. That is the uncompressed size.

Why don't you uncompress to a regular file (i.e. /tmp/foo) rather than to the device file?

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
author
#4 lore raw
Quoted 3 lines

Why don't you uncompress to a regular file (i.e. /tmp/foo) rather than to the device file?

My fireware will be a huge file: about 12M bytes. I don't known How much a regular file's size.

Signature · 9 lines
Best Regards,
zzs



_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw
Quoted 5 lines · 张忠山
Quoted 3 lines

Why don't you uncompress to a regular file (i.e. /tmp/foo) rather than to the device file?

My fireware will be a huge file: about 12M bytes. I don't known How much a regular file's size.

barebox will handle these file sizes just fine given that your malloc area size is configured big enough. The only thing that could happen is that the performance of the memory allocator will decrease with that many allocations. You can work around this by increasing CHUNK_SIZE in fs/ramfs.c.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox