§2023-08-26
¶ mkimage
The mkimage command is used to create images for use with the U-Boot boot loader. Thes eimages can contain the linux kernel, device tree blob, root file system image, firmware images etc., either separate or combined.
¶1. emerge -av u-boot-tools
(chroot) hc4Gentoo /boot # emerge -av u-boot-tools
* IMPORTANT: 11 news items need reading for repository 'gentoo'.
* Use eselect news read to view new items.
These are the packages that would be merged, in order:
Calculating dependencies... done!
Dependency resolution took 5.96 s.
[ebuild N ] dev-lang/swig-4.1.1-r1::gentoo USE="pcre -ccache -doc -test" 8400 KiB
[ebuild N ] dev-embedded/u-boot-tools-2023.01::gentoo USE="-envtools" 18126 KiB
Total: 2 packages (2 new), Size of downloads: 26525 KiB
Would you like to merge these packages? [Yes/No] yes
>>> Verifying ebuild manifests
>>> Emerging (1 of 2) dev-lang/swig-4.1.1-r1::gentoo
* Fetching files in the background.
* To view fetch progress, run in another terminal:
* tail -f /var/log/emerge-fetch.log
....
--- /usr/bin/
>>> /usr/bin/fw_printenv
>>> /usr/bin/dumpimage
>>> /usr/bin/img2srec
>>> /usr/bin/bmp_logo
>>> /usr/bin/gen_eth_addr
>>> /usr/bin/mkenvimage
>>> /usr/bin/fw_setenv -> fw_printenv
>>> /usr/bin/fdtgrep
>>> /usr/bin/mkimage
¶ 2. `mkimage1
(chroot) hc4Gentoo /boot # pwd
/boot
(chroot) hc4Gentoo /boot # mkimage -A arm64 -O linux -T ramdisk -C none -a 0 -e 0 "Initramfs Image" -d initramfs-6.1.46-gentoo.img initramfs-6.1.46-gentoo.uimg
Image Name:
Created: Sun Aug 27 11:34:52 2023
Image Type: AArch64 Linux RAMDisk Image (uncompressed)
Data Size: 5770132 Bytes = 5634.89 KiB = 5.50 MiB
Load Address: 00000000
Entry Point: 00000000
(chroot) hc4Gentoo /boot # ls
'Initramfs Image' initramfs-6.1.46-gentoo.img
¶Description
The mkimage command is used to create images for use with the U-Boot boot loader. Thes eimages can contain the linux kernel, device tree blob, root file system image, firmware images etc., either separate or combined.
mkimage supports two different formats:
- The old, legacy image format concatenates the individual parts (for example, kernel image, device tree blob and ramdisk image) and adds a 64 bytes header containing information about target architecture, operating system, image type, compression method, entry points, time stamp, checksums, etc.
- The new, FIT (Flattened Image Tree) format allows for more flexibility in handling images of various and also enhances integrity protection of images with stronger checksums.
For Example:
mkimage -A arm64 -O linux -T ramdisk -C none -a 0x4080000 -e 0x1080000 -n "Initramfs Image" -d initramfs.img initramfs.img.uimg
-a 0, -e 0 for odroid
Options List image information:
-l [uimage file name] mkimage lists the information contained in the header of an existing U-Boot image. Create old legacy image:
-A [architecture]
Set architecture. Pass -A -h
as the architecture to see the list of supported architectures.
-O [os]
Set operating system. bootm command of u-boot changes boot method by os type. Pass -h as the OS to see the list of supported OS.
-T [image type]
Set image type. Pass -T -h
as the image to see the list of supported image type.
-C [compression type]
Set compression type. Pass -h as the compression to see the list of supported compression type.
-a [load addess]
Set load address with a hex number.
-e [entry point]
Set entry point with a hex number.
-n [image name]
Set image name to 'image name'.
-d [image data file]
Use image data from 'image data file'.
-x
Set XIP (execute in place) flag.
Create FIT image:
-D dtcoption" Provide special options to the device tree compiler that is used to create the image. -f fit-image.its" Image tree source fine that descbres the structure and contents of the FIT image.
- in my boot.ini
ODROIDC4-UBOOT-CONFIG
# Default Console Device Setting
setenv condev "console=ttyAML0,115200n8" # on both
# setenv bootlabel
setenv bootlabel "2023-08-26 From Manjaro-arm-installer To Gentoo"
# Boot Args
setenv bootargs "root=PARTUUID=69ed71c7-03 rootwait rw ${condev} ${amlogic} no_console_suspend fsck.repair=yes net.ifnames=0 clk_ignore_unused quiet splash plymouth.ignore-serial-consoles"
# Set load addresses
setenv dtb_loadaddr "0x20000000"
setenv loadaddr "0x1080000"
setenv initrd_loadaddr "0x4080000"
# Load kernel, dtb and initrd
load mmc ${devno}:1 ${loadaddr} /Image
load mmc ${devno}:1 ${dtb_loadaddr} /dtbs/amlogic/meson-sm1-odroid-hc4.dtb
load mmc ${devno}:1 ${initrd_loadaddr} /initramfs-linux.uimg
#fdt addr ${dtb_loadaddr}
# boot
booti ${loadaddr} ${initrd_loadaddr} ${dtb_loadaddr}
And my /boot/Image is my image file, what will be my initramfs.img.uimg
for U-boot using mkimage?