DENX . DULG . HowCanICreateAnUImageFromAELFFile

14.2.19. How can I create an uImage from a ELF file

I would like to run a standard distribution kernel on my target, but I can find only ELF kernel images or even RPM files. How can I use these?

If you have just the kernel ELF file, this may be difficult, as you will usually also need a bunch of kernel modules that the distribution of your choice probably bundles with this kernel file. Try to locate and install these first.

If you have a kernel RPM, this usually includes both the kernel ELF file and the required modules. Install these in the ELDK root file system so you can use this for example mounted over NFS. The following example uses a Fedora kernel RPM on a 4xxFP target:
$ cd /tmp/
$ wget
After downloading the RPM we install it (manually using "rpm2cpio" and "cpio" in the root of the ELDK file system, "/opt/eldk/ppc_4xxFP/" :
$ cd /opt/eldk/ppc_4xxFP/
$ rpm2cpio /tmp/kernel- | sudo cpio -vidum
This installs a lot of kernel modules in "./lib/modules/" and a kernel ELF file in "./boot" :
$ ls -l boot
total 8792
-rw-r--r-- 1 root root 1226119 Oct 17 17:31
-rw-r--r-- 1 root root   96224 Oct 17 17:31 config-
-rwxr-xr-x 1 root root 7673768 Oct 17 18:20 vmlinuz-
Now convert the ELF kernel image into an uImage file:
$ ppc_4xxFP-objcopy -O binary boot/vmlinuz- /tmp/vmlinux.bin
$ gzip -v9 /tmp/vmlinux.bin
/tmp/vmlinux.bin:        58.1% -- replaced with /tmp/vmlinux.bin.gz
$ mkimage -A ppc -O linux -T kernel -C gzip \
> -a 0x00000000 -e 0x00000000 \
> -n Linux- \
> -d /tmp/vmlinux.bin.gz /tftpboot/uImage-
Image Name:   Linux-
Created:      Sun Nov  1 17:00:37 2009
Image Type:   PowerPC Linux Kernel Image (gzip compressed)
Data Size:    3187431 Bytes = 3112.73 kB = 3.04 MB
Load Address: 0x00000000
Entry Point:  0x00000000
There you go.
ALERT! Note: you still need the Device Tree Blob for your specific target board. This usually does not come with any of the standard distributions. Also, you may find that you need a ramdisk image to get some modules loaded that might be needed to mount your root file system.

----- Revision r1.2 - 02 Nov 2009 - 13:36 - DetlevZundel
Copyright © 2002-2021 by DENX Software Engineering