§2023-09-08

&psra; 1. flash u-boot.bin, in arch-chroot

(chroot) SurfacePro /usr/src/u-boot-odroid-hc4 # dd if=u-boot.bin of=/dev/sdc conv=fsync,notrunc bs=512 seek=1
1710+1 records in
1710+1 records out
875888 bytes (876 kB, 855 KiB) copied, 2.47447 s, 354 kB/s

¶2. partion a microSD, out of arch-chroot

デバイス   起動 開始位置 終了位置   セクタ サイズ Id タイプ
/dev/sdc1           2048  1050623  1048576   512M  c W95 FAT32 (LBA)
/dev/sdc2        1050624 31422463 30371840  14.5G 83 Linux

$ sudo mkfs.vfat -F 32 /dev/sdc1
$ sudo mkfs.ext4 /dev/sdc2
# put stage3 arm64 onto /dev/sdc2
$ sudo mount /dev/sdc2 /mn
$ sudo tar xvpf stage3-arm64-systemd-20230903T203159Z.tar.xz -C /mnt

get into arch-chroot

¶ 3. ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make modules_install

(chroot) SurfacePro /usr/src # ln -sf linux-6.1.46-gentoo/ linux

(chroot) SurfacePro /usr/src/linux # pwd
/usr/src/linux
(chroot) SurfacePro /usr/src/linux # ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make modules_install

¶ 4. genkernel

(chroot) SurfacePro /usr/src # mount /dev/sdc1 /boot
(chroot) SurfacePro /usr/src/linux # genkernel --install initramfs 
* Gentoo Linux Genkernel; Version 4.3.6
* Using genkernel configuration from '/etc/genkernel.conf' ...
* Running with options: --install initramfs

* Working with Linux kernel 6.1.46-gentoo for x86_64
* Using kernel config file '/usr/share/genkernel/arch/x86_64/generated-config' ...

* Current kernel's LOCALVERSION is set to ''; Will ignore set --kernel-localversion value '-x86_64' because kernel was not built ...

* initramfs: >> Initializing ...
*         >> Appending devices cpio data ...
*         >> Appending base_layout cpio data ...
*         >> Appending util-linux cpio data ...
*         >> Appending eudev cpio data ...
*         >> Appending auxiliary cpio data ...
*         >> Appending busybox cpio data ...
*         >> Appending modprobed cpio data ...
*         >> Appending modules cpio data ...
*         >> Deduping cpio ...
*         >> Pre-generating initramfs' /etc/ld.so.cache ...
*         >> Compressing cpio data (.xz) ...
xz: Reduced the number of threads from 4 to 1 to not exceed the memory usage limit of 1964 MiB
* 
* You will find the initramfs in '/boot/initramfs-6.1.46-gentoo.img'.

* WARNING... WARNING... WARNING...
* Additional kernel parameters that *may* be required to boot properly:

* Do NOT report kernel bugs as genkernel bugs unless your bug
* is about the default genkernel configuration...
* 
* Make sure you have the latest ~arch genkernel before reporting bugs.
* Failed to determine session leader; Will not try to stop child processes
(chroot) SurfacePro /usr/src/linux # ls -l /boot
合計 7388
-rwxr-xr-x 1 root root 7564920 Sep  8 20:23 initramfs-6.1.46-gentoo.img

Current kernel's LOCALVERSION is set to ''; Will ignore set --kernel-localversion value '-x86_64' because kernel was not built ...

(chroot) SurfacePro /usr/src/linux # ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make menuconfig

In the make menuconfig interface for configuring the Linux kernel, you can set the LOCALVERSION by following these steps:


¶ 5. make modules intall into stage3 binary on /dev/sdc2

(chroot) SurfacePro / # mount /dev/sdd2 /mnt
# ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make modules_install INSTALL_MOD_PATH=/mnt/
(chroot) SurfacePro /usr/src/linux # ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make modules_install INSTALL_MOD_PATH=/mnt

¶6. /mnt/etc/fstab

(chroot) SurfacePro /usr/src/linux # blkid /dev/sdd**
/dev/sdd: PTUUID="d3ab319c" PTTYPE="dos"
/dev/sdd1: UUID="7575-5140" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="d3ab319c-01"
/dev/sdd2: UUID="66df2bfb-52ba-49bd-8b03-5da75b14ee7a" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="d3ab319c-02"

#
# LABEL=boot
UUID=7575-5140                                          /boot           vfat            defaults                1 2

# LABEL=/
UUID=66df2bfb-52ba-49bd-8b03-5da75b14ee7a               /               ext4            defaulta                0 1

¶6. setup mkimage

(chroot) SurfacePro /usr/src/linux # ls /boot
initramfs-6.1.46-gentoo.img
(chroot) SurfacePro /boot # mkimage -A arm64 -O linux -T ramdisk -C none -a 0 -e 0  -d initramfs-6.1.46-gentoo.img initramfs-6.1.46-gentoo.uimg
Image Name:   
Created:      Fri Sep  8 20:38:14 2023
Image Type:   AArch64 Linux RAMDisk Image (uncompressed)
Data Size:    7564920 Bytes = 7387.62 KiB = 7.21 MiB
Load Address: 00000000
Entry Point:  00000000
(chroot) SurfacePro /boot # ls -l
合計 14776
-rwxr-xr-x 1 root root 7564920 Sep  8 20:23 initramfs-6.1.46-gentoo.img
-rwxr-xr-x 1 root root 7564984 Sep  8 20:38 initramfs-6.1.46-gentoo.uimg

¶7. Image

(chroot) SurfacePro /boot # cp /usr/src/linux/arch/arm64/boot/Image ./
(chroot) SurfacePro /boot # ls -l
合計 38332
-rwxr-xr-x 1 root root 24119808 Sep  8 20:39 Image
-rwxr-xr-x 1 root root  7564920 Sep  8 20:23 initramfs-6.1.46-gentoo.img
-rwxr-xr-x 1 root root  7564984 Sep  8 20:38 initramfs-6.1.46-gentoo.uimg

(chroot) SurfacePro /boot # mkdir -p dts/amlogic
(chroot) SurfacePro /boot # cp -v /usr/src/linux/arch/arm64/boot/dts/amlogic/* ./dts/amlogic/

¶ /boot/boot.ini

ODROIDHC4-UBOOT-CONFIG

# Default Console Device Setting
setenv condev "console=ttyAML0,115200n8"   # on both

# setenv bootlabel
setenv bootlabel "2023-09-08 Gentoo"

# Boot Args
setenv bootargs "root=UUID=66df2bfb-52ba-49bd-8b03-5da75b14ee7a 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-6.1.46-gentoo.uimg
#fdt addr ${dtb_loadaddr}

# boot
booti ${loadaddr} ${initrd_loadaddr} ${dtb_loadaddr}