§2023-09-11
¶1. Installation requirements
- cross compile on x86_64
- Get the aarch64-unknown-linux-gnu cross toolchain.
- a fat32 partition to boot from
¶2. build the kernel
- we will use
SurfacePro:~/build/gentoo/src/gentoo-32G-systemd-rpi-2023-09-06.img
- gentoo-32G-systemd-rpi-2023-09-06.img has cros-dev setup
$ 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 /
- 以下、in chroot ENV
# 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
- partition as
デバイス 起動 開始位置 最後から セクタ サイズ Id タイプ
/dev/sdc1 2048 526335 524288 256M c W95 FAT32 (LBA)
/dev/sdc2 526336 62333951 61807616 29.5G 83 Linux
- put arm64 stage3 onto /dev/sdc2
$ 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
- IMPORTANT: 10 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.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:
-
sys-boot/raspberrypi-firmware-9999::gentoo (masked by: raspberrypi-videocore-bin license(s), missing keyword) A copy of the 'raspberrypi-videocore-bin' license is located at '/var/db/repos/gentoo/licenses/raspberrypi-videocore-bin'.
-
sys-boot/raspberrypi-firmware-1.20230106::gentoo (masked by: raspberrypi-videocore-bin license(s), missing keyword)
-
sys-boot/raspberrypi-firmware-1.20221104::gentoo (masked by: raspberrypi-videocore-bin license(s), missing keyword)
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
-
Manifest timestamp: 2023-09-10 21:09:51 UTC
-
Valid OpenPGP signature found:
-
- primary key: DCD05B71EAB94199527F44ACDB6B8C1F96D8BF6D
-
- subkey: E1D6ABB63BFCFB4BA02FDF1CEC590EEAC9189250
-
- timestamp: 2023-09-10 21:09:51 UTC
-
Verifying /var/db/repos/gentoo/.tmp-unverified-download-quarantine ...!!! Manifest verification failed: Manifest mismatch for metadata/Manifest.gz size: expected: 6986, have: 6996
-
IMPORTANT: 10 news items need reading for repository 'gentoo'.
-
Use eselect news read to view new items.
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"