ยง2023-10-01

Note: No custom kernel configuration and initramfs has baic stuffs only.

  1. Install emerge --ask sys-kernel/genkernel
emerge sys-kernel/genkernel --autounmask --autounmask-write
dispatch-off
at /mnt/gentoo/etc/portage/package.license 
# required by sys-kernel/genkernel-4.3.6::gentoo[firmware]
# required by sys-kernel/genkernel (argument)
=sys-kernel/linux-firmware-20230919 linux-fw-redistributable
  1. get kernel source
(chroot) orgpi5Gentoo / # emerge --ask sys-kernel/gentoo-sources
setlocale: unsupported locale setting
setlocale: unsupported locale setting

 * IMPORTANT: 12 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!q
Dependency resolution took 1.23 s.

[ebuild  N     ] sys-kernel/gentoo-sources-6.1.53-r1  USE="-build -experimental -symlink" 

Would you like to merge these packages? [Yes/No] 
(chroot) orgpi5Gentoo / # cd /usr/src/
(chroot) orgpi5Gentoo /usr/src # ls -l
total 4
drwxr-xr-x 27 root root 4096 10ๆœˆ  1 05:06 linux-6.1.53-gentoo-r1
(chroot) orgpi5Gentoo /usr/src # ln -sf linux-6.1.53-gentoo-r1/ linux
(chroot) orgpi5Gentoo /usr/src # ls -l
total 4
lrwxrwxrwx  1 root root   23 10ๆœˆ  1 05:34 linux -> linux-6.1.53-gentoo-r1/
drwxr-xr-x 27 root root 4096 10ๆœˆ  1 05:06 linux-6.1.53-gentoo-r1
    • menuconfig and make
(chroot) orgpi5Gentoo /usr/src/linux # zcat /proc/config.gz > orgpi5+_defconfig
(chroot) orgpi5Gentoo /usr/src/linux # cp -v orgpi5+_defconfig arch/arm64/configs/
'orgpi5+_defconfig' -> 'arch/arm64/configs/orgpi5+_defconfig'
(chroot) orgpi5Gentoo /usr/src/linux # make orgpi5+_defconfig 
  HOSTCC  scripts/kconfig/conf.o
  HOSTLD  scripts/kconfig/conf
arch/arm64/configs/orgpi5+_defconfig:8056:warning: symbol value 'm' invalid for CRYPTO_LIB_BLAKE2S_GENERIC
#
# configuration written to .config
#

# time make -j8
real     30m55.592s
user    191m25.193s
sys      26m43.623s
(chroot) orgpi5Gentoo /usr/src/linux # ls arch/arm64/boot/
dts  Image  Image.gz  install.sh  Makefile
  1. make mddule_install
(chroot) orgpi5Gentoo /usr/src/linux # make modules_install
....
INSTALL /lib/modules/6.1.53-gentoo-r1/kernel/sound/drivers/mpu401/snd-mpu401.ko
  INSTALL /lib/modules/6.1.53-gentoo-r1/kernel/sound/drivers/snd-aloop.ko
  INSTALL /lib/modules/6.1.53-gentoo-r1/kernel/sound/drivers/snd-dummy.ko
  INSTALL /lib/modules/6.1.53-gentoo-r1/kernel/sound/drivers/snd-mtpav.ko
  INSTALL /lib/modules/6.1.53-gentoo-r1/kernel/sound/drivers/snd-serial-u16550.ko
  INSTALL /lib/modules/6.1.53-gentoo-r1/kernel/sound/drivers/snd-virmidi.ko
  DEPMOD  /lib/modules/6.1.53-gentoo-r1
    • prepare /boot
(chroot) orgpi5Gentoo /usr/src/linux # mount /dev/sdc1 /boot
(chroot) orgpi5Gentoo /usr/src/linux # ls /boot/   <-- this is from orgpi5 download source
boot.bmp  boot.cmd  boot.scr  config-5.10.110-rockchip-rk3588  dtb  dtb-5.10.110-rockchip-rk3588  Image  initrd.img-5.10.110-rockchip-rk3588  logo.bmp  orangepiEnv.txt  orangepi_first_run.txt.template  System.map-5.10.110-rockchip-rk3588  uInitrd  vmlinuz-5.10.110-rockchip-rk3588

Add the following aa the end of `/etc/genkernel.conf

# custom
KERNEL_DIR=/usr/src/linux
KERNEL_CONFIG=/usr/src/linux/arch/arm64/configs/orgpi5+_defconfig
# CONFIG_LOCALVERSION="arm64"
# KERNEL_LOCALVERSION="arm64" 
(chroot) orgpi5Gentoo / # 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.53-gentoo-r1 for arm64
* Using kernel config file '/usr/share/genkernel/arch/arm64/generated-config' ...

* Current kernel's LOCALVERSION is set to ''; Will ignore set --kernel-localversion value '-arm64' 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 8 to 3 to not exceed the memory usage limit of 3930 MiB
* 
* You will find the initramfs in '/boot/initramfs-6.1.53-gentoo-r1.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) orgpi5Gentoo / # ls /boot/
boot.bmp  boot.scr                         dtb                           Image            initramfs-6.1.53-gentoo-r1.img       logo.bmp         orangepi_first_run.txt.template      uInitrd
boot.cmd  config-5.10.110-rockchip-rk3588  dtb-5.10.110-rockchip-rk3588  Image-6.1.53-r1  initrd.img-5.10.110-rockchip-rk3588  orangepiEnv.txt  System.map-5.10.110-rockchip-rk3588  vmlinuz-5.10.110-rockchip-rk3588
(chroot) orgpi5Gentoo /usr/src/linux/arch/arm64/boot # cp -v Image /boot/Image-6.1.53-r1
'Image' -> '/boot/Image-6.1.53-r1'

  1. emerge dev-embedded/u-boot-tools
# emerge dev-embedded/u-boot-tools
  1. mkimage
# cd /boot
(chroot) orgpi5Gentoo /boot # ls
boot.bmp  boot.scr                         dtb                           Image            initramfs-6.1.53-gentoo-r1.img       logo.bmp         orangepi_first_run.txt.template      uInitrd
boot.cmd  config-5.10.110-rockchip-rk3588  dtb-5.10.110-rockchip-rk3588  Image-6.1.53-r1  initrd.img-5.10.110-rockchip-rk3588  orangepiEnv.txt  System.map-5.10.110-rockchip-rk3588  vmlinuz-5.10.110-rockchip-rk3588

(chroot) orgpi5Gentoo /boot # mkimage -A arm -T ramdisk -C none -n uInitrd-6.1.53 -d /boot/initramfs-6.1.53-gentoo-r1.img /boot/uInitrd-6.1.53-r1
Image Name:   uInitrd-6.1.53
Created:      Sun Oct  1 08:04:26 2023
Image Type:   ARM Linux RAMDisk Image (uncompressed)
Data Size:    5892308 Bytes = 5754.21 KiB = 5.62 MiB
Load Address: 00000000
Entry Point:  00000000
(chroot) orgpi5Gentoo /boot # ls
boot.bmp  boot.scr                         dtb                           Image            initramfs-6.1.53-gentoo-r1.img       logo.bmp         orangepi_first_run.txt.template      uInitrd         uInitrd-6.1.53-r1
boot.cmd  config-5.10.110-rockchip-rk3588  dtb-5.10.110-rockchip-rk3588  Image-6.1.53-r1  initrd.img-5.10.110-rockchip-rk3588  orangepiEnv.txt  System.map-5.10.110-rockchip-rk3588  uInitrd-6.1.53  vmlinuz-5.10.110-rockchip-rk3588
(chroot) orgpi5Gentoo /boot #
  1. fstab
(chroot) orgpi5Gentoo /boot # blkid /dev/sdc*
/dev/sdc: PTUUID="738115be-8654-0442-a5c6-b0b37ecc8c8f" PTTYPE="gpt"
/dev/sdc1: LABEL_FATBOOT="opi_boot" LABEL="opi_boot" UUID="EE66-DCBA" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="bootfs" PARTUUID="d10b7fec-0bcf-af4d-a274-67504d80a2de"
/dev/sdc2: LABEL="opi_root" UUID="4ba4cf3f-3f6d-4fc0-9200-9e92d6d2f5fb" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="f5417459-931f-5848-bec1-e8cf44578ab1"
(chroot) orgpi5Gentoo /boot # cp -v /opt/orangepi5+-backup/fstab  /etc
'/opt/orangepi5+-backup/fstab' -> '/etc/fstab'
(chroot) orgpi5Gentoo /boot # cat /etc/fstab
UUID=4ba4cf3f-3f6d-4fc0-9200-9e92d6d2f5fb / ext4 defaults,noatime,commit=600,errors=remount-ro 0 1
UUID=EE66-DCBA /boot vfat defaults 0 2
tmpfs /tmp tmpfs defaults,nosuid 0 0
  1. nano /boot/boot.scr
load ${devtype} ${devnum} ${ramdisk_addr_r} ${prefix}uInitrd-6.1.53-r1
load ${devtype} ${devnum} ${kernel_addr_r} ${prefix}Image-6.1.53-r1