Bootimage / uInitd Rootfilesystem für PowerPC erzeugen

Der Bootloader u-boot für PowerPC Systeme verlangt bootimages mit einem speziellen Header, der unter anderem eine Prüfsumme beinhaltet. Daher muss ein "normales" X86 Ramdisk Image noch weiter verarbeitet werden.

Liegt ein mit gzip komprimiertes ext2 filesystem image for, so erzeugt man hieraus eine uInitrd mit
user@host$ mkimage -T ramdisk \
        -C gzip \
        -n "Beschreibung" \
        -d $ROOTFS_IMAGE \
        uInitrd

Man erhält mit uInitd das image.

Die Informationen einer existierenden uInitrd die informationen
user@host$ mkimage -l uInitrd
Image Name:   handel asl720.acc.gsi.de
Created:      Tue Jan 12 17:02:30 2010
Image Type:   PowerPC Linux RAMDisk Image (gzip compressed)
Data Size:    1582818 Bytes = 1545.72 kB = 1.51 MB
Load Address: 0x00000000
Entry Point:  0x00000000

Kombiniertes Bootimage

Es kann auch Kernel und Ramdisk zu einem Bootimage zusammengepackt werden. Dies hat den Vorteil, dass nur eine Datei per TFTP übertragen werden muss und der Name dieser Datei im DHCP hinterlegt werden kann.

Compilieren eines Kernels
# compile a kernel
user@host$ make vmlinux     
# strip it raw
user@host$ ${CROSS_COMPILE}objcopy -O binary -R .note -R .comment -S vmlinux linux.bin 
user@host$ gzip -9 linux.bin  # compress it

Dieses Image würde man nun mit mkimage zu einem bootfähigen PowerPC Kernel Image verwandeln mit
user@host$ mkimage -A ppc -O linux -T kernel -C gzip -n 'test raw' -d linux.bin.gz uImage

Um aus einem Vorhandenen uImage den Kernel herauszuholen
dd if=uImage of=zImage bs=64 skip=1

Um das mit gzip komprimierte Rootfilesystem und den komprimierte Kernel zusammen in ein PowerPC Image zu verwandeln
user@host$ mkimage -A ppc -O linux -T multi -C gzip \
   -n 'combined' \
   -d linux.bin.gz:rootfs.gz \
   uMulti

Wichtig erst Kernel, dann Rootfilesystem

Wie man ein Image bootet beschreibt EmbeddedBootUBoot

unpack exisiting image

a combined image contains a header, byte length per image, terminating zeros, the first image byte aligned to 4, the next image and so on.

Check what is inside the image
[handel@asl732]$ mkimage -l cu824-zks 
Image Name:   combined
Created:      Tue Apr  7 14:26:42 2015
Image Type:   PowerPC Linux Multi-File Image (gzip compressed)
Data Size:    4495161 Bytes = 4389.81 kB = 4.29 MB
Load Address: 00000000
Entry Point:  00000000
Contents:
   Image 0: 1372677 Bytes = 1340.50 kB = 1.31 MB
   Image 1: 3122469 Bytes = 3049.29 kB = 2.98 MB

so, two images. we need to skip the default header of 64 bytes, an image size for image 0 (4 bytes), an image size for image 1 (4 bytes), zero padding (4 bytes). In total 76 bytes.

dd if=cu824-zks of=noheader bs=76 skip=1

the first image is easy,
dd if=noheader of=kernel.gz bs=1372677 count=1

for the next image we need to round up to the byte alignment
1372677 / 4 = 343169.25
round it up
343170 * 4 = 1372680

extract second image
dd if=noheader of=ramdisk.gz bs=1372680 skip=1

hint gzip has a magic header, the first two bytes should be 0x1f 0x8b
Topic revision: r3 - 26 Apr 2016, ChristophHandel
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback