§2023-09-11

¶1. Installation requirements

¶2. build the kernel

$ sudo losetup /dev/loop27 gentoo-32G-systemd-rpi-2023-09-06.img
$ sudo mount /dev/loop27p2 root
$ sudo arch-chroot root /bin/bash
SurfacePro / # source /etc/profile
(chroot) SurfacePro / 
 # pwd
/usr/src/raspberrypi/linux   --> git clone --depth=1 https://github.com/raspberrypi/linux -b rpi-6.1.y
# ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make  clean              --->  clean old make
# ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make  mrproper           --->  clean old menuconfig
# ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make  bcm2711_defconfig   ---> menuconfig
# time ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make  -j4            ---> compile
real    38m51.990s
user    139m25.728s
sys     13m6.511s
# ls -l arch/arm64/boot/
合計 30564
-rw-r--r--  1 root root 22962688 Sep 11 11:16 Image
-rw-r--r--  1 root root  8472340 Sep 11 11:16 Image.gz
-rw-r--r--  1 root root     1198 Sep  6 15:49 Makefile
drwxr-xr-x 35 root root     4096 Sep  6 15:49 dts
-rwxr-xr-x  1 root root      962 Sep  6 15:49 install.sh

¶3. Prepare MicroSD

Not in chroot mode

デバイス   起動 開始位置 最後から   セクタ サイズ Id タイプ
/dev/sdc1           2048   526335   524288   256M  c W95 FAT32 (LBA)
/dev/sdc2         526336 62333951 61807616  29.5G 83 Linux
$ sudo mount /dev/sdc2 /mnt/gentoo/

$ sudo tar xpvf stage3-arm64-systemd-20230903T203159Z.tar.xz --xattrs-include='.' --numeric-owner -C /mnt/gentoo

- Install a Gentoo repository snapshot

$ sudo mkdir /mnt/gentoo/var/db/repos/gentoo $ sudo tar xvpf portage-latest.tar.bz2 --strip-components=1 -C /mnt/gentoo/var/db/repos/gentoo

>--strip-components=1: This option tells tar to remove the first component (directory)

¶4. get into chroot again

- first create

mkdir /mnt/{root,boot} ---> watch out /mnt/{root, boot} no space between root and boot

ls /mnt

boot root

- mount /dev/sd??

mount /dev/sdc1 /mnt/boot

mount /dev/sdc2 /mnt/root

lsblk /dev/sdc*

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sdc 8:32 1 29.7G 0 disk ├─sdc1 8:33 1 256M 0 part /mnt/boot └─sdc2 8:34 1 29.5G 0 part /mnt/root sdc1 8:33 1 256M 0 part /mnt/boot sdc2 8:34 1 29.5G 0 part /mnt/root


- install kernel

pwd

/usr/src/raspberrypi/linux

cp -v arch/arm64/boot/Image /mnt/boot/kernel8.img

- install kernel modules

pwd

/usr/src/raspberrypi/linux

ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make modules_install INSTALL_MOD_PATH=/mnt/root

... XZ /mnt/root/lib/modules/6.1.51-v8+/kernel/sound/usb/misc/snd-ua101.ko.xz INSTALL /mnt/root/lib/modules/6.1.51-v8+/kernel/sound/usb/snd-usb-audio.ko XZ /mnt/root/lib/modules/6.1.51-v8+/kernel/sound/usb/snd-usb-audio.ko.xz INSTALL /mnt/root/lib/modules/6.1.51-v8+/kernel/sound/usb/snd-usbmidi-lib.ko XZ /mnt/root/lib/modules/6.1.51-v8+/kernel/sound/usb/snd-usbmidi-lib.ko.xz DEPMOD /mnt/root/lib/modules/6.1.51-v8+

- Build and install the device tree and overlays by running make dtbs, then copy the resulting device tree and overlay files to /boot

pwd

/usr/src/raspberrypi/linux

ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make dtbs

mkdir -p /mnt/boot/overlays

cp -vR arch/arm64/boot/dts/overlays/*.dtbo /mnt/boot/overlays

cp -v arch/arm64/boot/dts/broadcom/bcm2711-rpi-4-b.dtb /mnt/boot/

ls -l /mnt/boot/

合計 22502 -rwxr-xr-x 1 root root 54388 Sep 11 12:58 bcm2711-rpi-4-b.dtb -rwxr-xr-x 1 root root 22962688 Sep 11 12:47 kernel8.img drwxr-xr-x 2 root root 24064 Sep 11 12:58 overlays

- In order to install the kernel on a Pi 400, install the relative device tree

pwd

/usr/src/raspberrypi/linux

cp -v arch/arm64/boot/dts/broadcom/bcm2711-rpi-400.dtb /mnt/boot/

ls -l /mnt/boot/

合計 22555 -rwxr-xr-x 1 root root 54388 Sep 11 12:58 bcm2711-rpi-4-b.dtb -rwxr-xr-x 1 root root 54477 Sep 11 13:00 bcm2711-rpi-400.dtb -rwxr-xr-x 1 root root 22962688 Sep 11 12:47 kernel8.img drwxr-xr-x 2 root root 24064 Sep 11 12:58 overlays


¶5. Install the firmware

All the firmware needed to boot the Pi is found in the sys-boot/raspberrypi-firmware package:

emerge --ask sys-boot/raspberrypi-firmware

These are the packages that would be merged, in order:

Calculating dependencies... done! Dependency resolution took 5.59 s.

!!! All ebuilds that could satisfy "sys-boot/raspberrypi-firmware" have been masked. !!! One of the following masked packages is required to complete your request:

For more information, see the MASKED PACKAGES section in the emerge man page or refer to the Gentoo Handbook.

- to solve

emerge --sync

... sent 80.56K bytes received 19.10M bytes 4.53K bytes/sec total size is 195.78M speedup is 10.21

Action: sync for repo: gentoo, returned code = 1

- `# nano  /etc/portage/package.accept_keywords/raspberrypi-firmware` as

sys-boot/raspberrypi-firmware-1.20230106 **

# emerge --ask sys-kernel/genkernel
ACCEPT_LICENSE="linux-fw-redistributable"