§2023-09-16
-
機器: h2Jammy.yushei.net:///home/alexlai/build/rpi-4B/odroi-hc4
¶1. make the kernel
$ ls
linux-6.3.tar.gz
$ tar xvf linux-6.3.tar.gz
$ mv linux-6.3 linux-6.3-manjaro
$ cd linux-6.3-manjaro/
$ ls arch/arm64/configs/
defconfig virt.config
$ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make distclean
$ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/menu.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTLD scripts/kconfig/conf
*** Default configuration is based on 'defconfig'
#
# configuration written to .config
#
$ time ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j4 Image modules dtbs
real 52m19.437s
user 184m59.731s
sys 22m27.560s
$ ls -l arch/arm64/boot/
total 38564
drwxrwxr-x 35 alexlai alexlai 4096 四 24 03:02 dts
-rw-rw-r-- 1 alexlai alexlai 39475712 九 16 19:04 Image
-rwxrwxr-x 1 alexlai alexlai 962 四 24 03:02 install.sh
-rw-rw-r-- 1 alexlai alexlai 1198 四 24 03:02 Makefile
$ ls arch/arm64/boot/dts/
actions amazon apm bitmain exynos intel marvell nuvoton realtek socionext tesla xilinx
allwinner amd apple broadcom freescale lg mediatek nvidia renesas sprd ti
altera amlogic arm cavium hisilicon Makefile microchip qcom rockchip synaptics toshiba
¶2. Prepare hardisk
the hd was installed with manjaro-arm-installer, and keep first partion and redo partions on 2nd or 3rd
$ sudo mkfs.vfat -F32 /dev/sdb1
$ sudo mkswap /dev/sdb2
$ sudo mkfs.ext4 /dev/sdb3
$ sudo mount /dev/sdb3 /mnt/gentoo/
$ sudo mkdir /mnt/gentoo/boot
$ sudo mount /dev/sdb1 /mnt/gentoo/boot/
¶ 3. Copy stage3-arm64-desktop-systemd
$ sudo tar xvfp stage3-arm64-desktop-systemd-20230917T224644Z.tar.xz -C /mnt/gentoo/
¶ 4. modules-install,
$ cd linux-6.3-manjaro/
$ sudo ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make modules_install INSTALL_MOD_PATH=/mnt/gentoo
¶5. Copy manjaro boot
$ cd ..
$ ls
boot linux-6.3-manjaro linux-6.3.tar.gz
$ sudo cp -rv boot/* /mnt/gentoo/boot/
$ ls /mnt/gentoo/boot/
boot.ini dtbs Image Image.gz initramfs-linux.img initramfs-linux.uimg sd_fusing.sh u-boot.bin
¶6. copy kerel
$ sudo cp -v linux-6.3-manjaro/arch/arm64/boot/Image /mnt/gentoo/boot/Image-6.3
'linux-6.3-manjaro/arch/arm64/boot/Image' -> '/mnt/gentoo/boot/Image-63'
Image Name: Initramfs
Created: Sat Sep 23 13:54:58 2023
Image Type: ARM Linux RAMDisk Image (uncompressed)
Data Size: 39475712 Bytes = 38550.50 KiB = 37.65 MiB
Load Address: 00000000
Entry Point: 00000000
root@h2Jammy:/mnt/gentoo
¶7. modify /mnt/gentoo/boot/boot.ini
ODROIDC4-UBOOT-CONFIG
# Default Console Device Setting
setenv condev "console=ttyAML0,115200n8" # on both
# setenv bootlabel
setenv bootlabel "2023-09-22 from Manjaro to Gentoo"
# Boot Args
# setenv bootargs "root=PARTUUID=e9f2e6ef-02 rootwait rw ${condev} ${amlogic} no_console_suspend fsck.repair=yes net.ifnames=0 clk_ignore_unused quiet splash plymouth.ignore-serial-consoles"
setenv bootargs "root=PARTUUID=0269efda-03 rootwait rw ${condev} ${amlogic} no_console_suspend fsck.repair=yes net.ifnames=0 clk_ignore_unused"
# 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}
# /dev/sdb1: UUID="0BB9-765B" BLOCK_SIZE="512" TYPE="vfat"
# /dev/sdb2: UUID="474567e2-2b7f-4698-a79c-c9bd304ed46e" TYPE="swap" PARTUUID="0269efda-02"
# /dev/sdb3: UUID="ee4b8088-bc31-423e-a0a6-725c643f25cc" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="0269efda-03"
# /dev/sdb4: PTTYPE="dos" PARTUUID="0269efda-04"
# /etc/fstab: static file system information.
#
# See the manpage fstab(5) for more information.
#
# NOTE: The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# NOTE: Even though we list ext4 as the type here, it will work with ext2/ext3
# filesystems. This just tells the kernel to use the ext4 driver.
#
# NOTE: You can use full paths to devices like /dev/sda3, but it is often
# more reliable to use filesystem labels or UUIDs. See your filesystem
# documentation for details on setting a label. To obtain the UUID, use
# the blkid(8) command.
# <fs> <mountpoint> <type> <opts> <dump> <pass>
#LABEL=boot /boot ext4 defaults 1 2
UUID=0BB9-765B /boot vfat defaults 1 2
#UUID=58e72203-57d1-4497-81ad-97655bd56494 / xfs defaults 0 1
UUID=ee4b8088-bc31-423e-a0a6-725c643f25cc / ext4 defaults 0 1
#LABEL=swap none swap sw 0 0
#/dev/cdrom /mnt/cdrom auto noauto,ro 0 0
# /dev/sdb1: UUID="0BB9-765B" BLOCK_SIZE="512" TYPE="vfat"
# /dev/sdb2: UUID="474567e2-2b7f-4698-a79c-c9bd304ed46e" TYPE="swap" PARTUUID="0269efda-02"
# /dev/sdb3: UUID="ee4b8088-bc31-423e-a0a6-725c643f25cc" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="0269efda-03"
# /dev/sdb4: PTTYPE="dos" PARTUUID="0269efda-04"
¶8. mkimage
root@h2Jammy:/mnt/gentoo/boot# ls
boot.ini dtbs Image Image.gz initramfs-linux.img initramfs-linux.uimg sd_fusing.sh u-boot.bin
root@h2Jammy:/mnt/gentoo/boot# rm uImage
root@h2Jammy:/mnt/gentoo/boot# mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 -n "Linux Kernel" -d Image initramfs-linux.img
Image Name: Linux Kernel
Created: Mon Sep 18 05:50:54 2023
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 39475712 Bytes = 38550.50 KiB = 37.65 MiB
Load Address: 80008000
Entry Point: 80008000
root@h2Jammy:/mnt/gentoo/boot# mkimage -A arm -T ramdisk -C none -n "Initramfs" -d initramfs-linux.img initramfs-linux.uimg
Image Name: Initramfs
Created: Mon Sep 18 05:53:22 2023
Image Type: ARM Linux RAMDisk Image (uncompressed)
Data Size: 39475776 Bytes = 38550.56 KiB = 37.65 MiB
Load Address: 00000000
Entry Point: 00000000
root@h2Jammy:/mnt/gentoo/boot# ls -l initramfs-linux.*
-rwxr-xr-x 1 root root 39475776 九 18 05:50 initramfs-linux.img
-rwxr-xr-x 1 root root 39475840 九 18 05:53 initramfs-linux.uimg
root@h2Jammy:/mnt/gentoo/boot# ls -l Image
-rwxr-xr-x 1 root root 39475712 九 18 05:46 Image
¶ 8. boot.ini
ODROIDC4-UBOOT-CONFIG
# setenv bootlabel
setenv bootlabel "2023-09-18 From Manjato to Gentoo"
# Default Console Device Setting
setenv condev "console=ttyAML0,115200n8" # on both
# Boot Args
setenv bootargs "root=PARTUUID=cf565ff2-03 rootwait rw ${condev} ${amlogic} no_console_suspend fsck.repair=yes net.ifnames=0 clk_ignore_unused quiet spl>
# 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}
#
# /dev/sdb2: UUID="4a125258-ee1a-49a7-a3cc-d3f5b02aa88b" TYPE="swap" PARTUUID="cf565ff2-02"
# /dev/sdb3: UUID="7ae00610-ef04-4466-a353-ab7b5d279985" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="cf565ff2-03"
# /dev/sdb1: UUID="EAC0-592C" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="cf565ff2-01"
#
¶9. /etc/fstab
# <fs> <mountpoint> <type> <opts> <dump> <pass>
#LABEL=boot /boot ext4 defaults 1 2
UUID=EAC0-592C /boot vfat defaults 1 2
#UUID / xfs defaults 0 1
UUID=7ae00610-ef04-4466-a353-ab7b5d279985 / ext4 defaults 0 1
#LABEL=swap none swap sw 0 0
#/dev/cdrom /mnt/cdrom auto noauto,ro 0 0
#
# /dev/sdb2: UUID="4a125258-ee1a-49a7-a3cc-d3f5b02aa88b" TYPE="swap" PARTUUID="cf565ff2-02"
# /dev/sdb3: UUID="7ae00610-ef04-4466-a353-ab7b5d279985" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="cf565ff2-03"
# /dev/sdb1: UUID="EAC0-592C" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="cf565ff2-01"
#
Here's what each option and argument means:
mkimage: This is the command itself, which is used to create U-Boot bootable images.
-A arm: This option specifies the architecture of the target platform, which is "arm" in this case. It indicates that the kernel is intended to run on ARM architecture.
-O linux: This option specifies the operating system type, which is "linux" here. It tells mkimage that the kernel image is intended for Linux.
-T kernel: This option specifies the type of data being processed as a "kernel." It informs mkimage that the input file is a kernel image.
-C none: This option specifies that no compression should be applied to the input data. In this case, "none" means the kernel image is not compressed. This is important because some kernel images might be compressed, but in this command, it's specified as uncompressed.
-a 0x80008000: This option sets the load address for the kernel image. The address 0x80008000 is where the kernel will be loaded in memory.
-e 0x80008000: This option sets the entry point address for the kernel image. The entry point is where execution should begin after the kernel is loaded. It's also set to 0x80008000 in this case, which means the kernel will start executing from this address.
-n "Linux Kernel": This option sets the image name to "Linux Kernel." This is a human-readable identifier for the image.
-d arch/arm/boot/zImage: This specifies the input file, which is the kernel image you want to package into a U-Boot bootable image. The path provided is the location of the kernel image file on your system. Make sure this path is correct and that the file exists.
uImage: This is the output file name. It's the name of the U-Boot bootable image that mkimage will create.
In summary, this mkimage command is used to create a U-Boot bootable image for an ARM-based Linux kernel. It specifies various parameters such as architecture, operating system type, load address, entry point, image name, and the input kernel image file. The resulting output file will be named "uImage" and will be suitable for loading and executing the Linux kernel using U-Boot on an ARM platform. User for odroid machines -a 0x0 -e 0x0