Skip to main content.

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

Question:
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?

Answer:
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 kenrel 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 http://download.fedora.redhat.com/pub/fedora/linux/updates/11/ppc/kernel-2.6.30.9-90.fc11.ppc.rpm
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-2.6.30.9-90.fc11.ppc.rpm | 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 System.map-2.6.30.9-90.fc11.ppc
-rw-r--r-- 1 root root   96224 Oct 17 17:31 config-2.6.30.9-90.fc11.ppc
-rwxr-xr-x 1 root root 7673768 Oct 17 18:20 vmlinuz-2.6.30.9-90.fc11.ppc
Now convert the ELF kernel image into an uImage file:
$ ppc_4xxFP-objcopy -O binary boot/vmlinuz-2.6.30.9-90.fc11.ppc /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-2.6.30.9-90.fc11.ppc \
> -d /tmp/vmlinux.bin.gz /tftpboot/uImage-2.6.30.9-90.fc11.ppc
Image Name:   Linux-2.6.30.9-90.fc11.ppc
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.
14.2.18. How can I load and uncompress a compressed image 1. Abstract 14.2.20. My standalone program does not work
Prev Home Next