Discussion:
[U-Boot-Users] mkimage multi file use?
Tom Guilliams
2003-08-18 17:55:09 UTC
Permalink
I know this has been addressed before but I no longer have access to my
U-Boot list archive on my PC and finding on the SourceForge list has
proved troublesome such as it keeps telling me it's not accessible right
now on the SoureForge page! Is there any place I can dowload the archives?

I haven't been successful referencing the include/image.h file on how to
use "mkimage -T multi". Any examples out there? Basically I just want
to create an U-Boot image of a gzipped kernel and ramdisk.

Also, I received some pointers on how to extract the U-Boot header from
an image (thanks Wolfgang and Marc Singer!). Now I'm going to want to
see if I can extract the kernel from a multi-file image. I think this
will be similar to the header extract but any pointers are greatly
appreciated. Fightin the clock on this one!

Tom
Wolfgang Denk
2003-08-18 18:19:26 UTC
Permalink
Dear Tom,
Post by Tom Guilliams
now on the SoureForge page! Is there any place I can dowload the archives?
Sorry, I have no idea. If really needed, I can arrange to
(temporarily) put a copy of the U-Boot archive on our FTP server (the
bzip2ed tarball for U-Boot-Users is 22 MB, and 40 MB for PPCBoot).
Post by Tom Guilliams
I haven't been successful referencing the include/image.h file on how to
use "mkimage -T multi". Any examples out there? Basically I just want
to create an U-Boot image of a gzipped kernel and ramdisk.
"mkimage" will print a help message when called without arguments:

bash$ mkimage
Usage: mkimage -l image
-l ==> list image header information
mkimage -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image
-A ==> set architecture to 'arch'
-O ==> set operating system to 'os'
-T ==> set image type to 'type'
-C ==> set compression type 'comp'
-a ==> set load address to 'addr' (hex)
-e ==> set entry point to 'ep' (hex)
-n ==> set image name to 'name'
-d ==> use image data from 'datafile'


So try:

bash$ mkimage -T multi -C gzip -a 0 -e 0 -n 'test multifile' \
-d /path/to/kernel_image:/path/to/ramdisk_image uMulti
Post by Tom Guilliams
Also, I received some pointers on how to extract the U-Boot header from
an image (thanks Wolfgang and Marc Singer!). Now I'm going to want to
see if I can extract the kernel from a multi-file image. I think this
will be similar to the header extract but any pointers are greatly
appreciated. Fightin the clock on this one!
See the README (section "More About U-Boot Image Types") for the file
format. This explains that with a mutlifile image with a kernel and a
ramdisk you will have to skip a total of 76 bytes of header
information (64 for U-Boot header + 4 for kernel size + 4 for ramdisk
size + 4 for terminating null).

So I recommend a three step approach:

bash$ mkimage -l uMulti
Image Name: Linux-2.4.4-2003-04-05 Multiboot
Created: Sun Apr 6 12:44:18 2003
Image Type: PowerPC Linux Multi-File Image (gzip compressed)
Data Size: 2610664 Bytes = 2549.48 kB = 2.49 MB
Load Address: 0x00000000
Entry Point: 0x00000000
Contents:
Image 0: 715859 Bytes = 699 kB = 0 MB
Image 1: 1894792 Bytes = 1850 kB = 1 MB

bash$ dd if=uMulti bs=76 skip=1 of=foo
34350+1 records in
34350+1 records out
bash$ dd if=foo of=kernel.gz bs=715859 count=1
1+0 records in
1+0 records out
bash$ gzip -vt kernel.gz
kernel.gz: OK

The "bs=715859" uses the kernel data size as printed by the "mkimage
-l" command.

Hope this helps.

Best regards,

Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de
White dwarf seeks red giant for binary relationship.
Tom Guilliams
2003-08-18 18:24:44 UTC
Permalink
Post by Wolfgang Denk
Sorry, I have no idea. If really needed, I can arrange to
(temporarily) put a copy of the U-Boot archive on our FTP server (the
bzip2ed tarball for U-Boot-Users is 22 MB, and 40 MB for PPCBoot).
OK, well I may take you up on that but I'll get back to you. I hate
having to ask questions I know have been answered already.
Post by Wolfgang Denk
bash$ mkimage -T multi -C gzip -a 0 -e 0 -n 'test multifile' \
-d /path/to/kernel_image:/path/to/ramdisk_image uMulti
Hmmm... include/image.h talks about having byte counts in there as
well. Maybe I'm just confused. I'll recheck it.
Post by Wolfgang Denk
See the README (section "More About U-Boot Image Types") for the file
format. This explains that with a mutlifile image with a kernel and a
ramdisk you will have to skip a total of 76 bytes of header
information (64 for U-Boot header + 4 for kernel size + 4 for ramdisk
size + 4 for terminating null).
Thank you. Very helpful. Can't believe I missed the README reference!
Ugh!
Post by Wolfgang Denk
bash$ mkimage -l uMulti
Image Name: Linux-2.4.4-2003-04-05 Multiboot
Created: Sun Apr 6 12:44:18 2003
Image Type: PowerPC Linux Multi-File Image (gzip compressed)
Data Size: 2610664 Bytes = 2549.48 kB = 2.49 MB
Load Address: 0x00000000
Entry Point: 0x00000000
Image 0: 715859 Bytes = 699 kB = 0 MB
Image 1: 1894792 Bytes = 1850 kB = 1 MB
bash$ dd if=uMulti bs=76 skip=1 of=foo
34350+1 records in
34350+1 records out
bash$ dd if=foo of=kernel.gz bs=715859 count=1
1+0 records in
1+0 records out
bash$ gzip -vt kernel.gz
kernel.gz: OK
The "bs=715859" uses the kernel data size as printed by the "mkimage
-l" command.
Very much appreciated. Thanks again!

Tom
Wolfgang Denk
2003-08-18 19:05:04 UTC
Permalink
Dear Tom,
Post by Tom Guilliams
OK, well I may take you up on that but I'll get back to you. I hate
having to ask questions I know have been answered already.
I am dissatisfied with the availability and efficiency of the search
options at SF, too.
Post by Tom Guilliams
Post by Wolfgang Denk
bash$ mkimage -T multi -C gzip -a 0 -e 0 -n 'test multifile' \
-d /path/to/kernel_image:/path/to/ramdisk_image uMulti
Hmmm... include/image.h talks about having byte counts in there as
well. Maybe I'm just confused. I'll recheck it.
The byte counts are generated and inserted by the mkimage tool.
Post by Tom Guilliams
Thank you. Very helpful. Can't believe I missed the README reference!
Ugh!
That text was added less than 6 months ago, so you might have missed
it when you read an older version of the README.
Post by Tom Guilliams
Very much appreciated. Thanks again!
You are welcome.

Best regards,

Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de
Fascinating is a word I use for the unexpected.
-- Spock, "The Squire of Gothos", stardate 2124.5
Loading...