Not really. For the format you're talking about (single-file uImage),
you can extract the data like so:
data = open("foobar.uImage","rb").read()[64:]
Then just uncompress 'data' as desired.
If you want to look at individual fields in the heaer, here's the
structure:
#define IH_MAGIC 0x27051956 /* Image Magic Number */
#define IH_NMLEN 32 /* Image Name Length */
typedef struct image_header
{
uint32_t ih_magic; /* Image Header Magic Number */
uint32_t ih_hcrc; /* Image Header CRC Checksum */
uint32_t ih_time; /* Image Creation Timestamp */
uint32_t ih_size; /* Image Data Size */
uint32_t ih_load; /* Data Load Address */
uint32_t ih_ep; /* Entry Point Address */
uint32_t ih_dcrc; /* Image Data CRC Checksum */
uint8_t ih_os; /* Operating System */
uint8_t ih_arch; /* CPU architecture */
uint8_t ih_type; /* Image Type */
uint8_t ih_comp; /* Compression Type */
uint8_t ih_name[IH_NMLEN]; /* Image Name */
} image_header_t;
Header fields are all in network byte order (bit-endian).
However, there's also a "multi-file" uImage format that I suspect is
what the OP is referring to (since he says he needs to extract "files"
from a uImage file).
http://www.isysop.com/unpacking-and-repacking-u-boot-uimage-files/
In that case, the "Image Type" field will be set to 4, and the 'data'
field starts with a list of 32-bit image size values (network byte
order, terminated by 0x00000000). That list is then followed by the
image data.
Here's a Python 2.7 program that reads the uImage header, prints some
stuff and then reads the data for the image(s). What to _do_ with the
data for the image(s) is left as an exercise for the gentle reader.
-------------------------------------8<-------------------------------------
#!/usr/bin/python
import sys,struct
f = open(sys.argv[1],"rb")
(ih_magic, ih_hcrc, ih_time, ih_size, ih_load, ih_ep, ih_dcrc,
ih_os, ih_arch, ih_type, ih_comp, ih_name) \
= struct.unpack("!IIIIIIIBBBB32s",f.read(64))
print "magic=%08x type=%d size=%d name='%s'" % (ih_magic, ih_type, ih_size, ih_name)
if ih_type == 4:
# multi-file: read image lengths from data
imagesizes = []
while 1:
size, = struct.unpack("!I",f.read(4))
if size == 0:
break
imagesizes.append(size)
else:
# single-file
imagesizes = [ih_size]
print imagesizes
images = [f.read(size) for size in imagesizes]
print [len(image) for image in images]
extradata = f.read()
if extradata:
print "%d bytes of extra data" % len(extradata)
-------------------------------------8<-------------------------------------
--
Grant Edwards grant.b.edwards Yow! The Korean War must
at have been fun.
gmail.com