User:Jens3/Installing Gentoo on a Raspberry Pi 400
Installing Gentoo on a Raspberry Pi 400
This are my notes about installing Gentoo on a Raspberry Pi 400. The 1.-3. try weren't successful, the 4. works and is still in use. The fifth installation is on a 4B, 4GB Ram.
The 4B and the 400 have nearly the same hardware with slight differences in some firmware files. The 4B needs brcmfmac43455*, the Pi 400 needs brcmfmac43456*.
5. (First try on a Pi 4B, 4GB RAM)
As base I use https://cmpct.info/~sam/gentoo/arm64/PiGentoo64.html and my #4. try.
- 128GB microSD card with sdb1 1GB vfat /boot vfat type c, sdb2 8GB swap and all other sdb3 as /
- mkfs.vfat -n gentooboot /dev/sdb1
- mkswap -L swap /dev/sdb2
- mkfs.ext4 -m 2 -L gentooroot /dev/sdb3
- mkdir /mnt/gentoo
- mount /dev/sdb3 /mnt/gentoo
- copied several files from the host dir /etc/portage, esp. make.conf, to the chroot. Because of a change in [i]threads a perl-cleaner --all is necessary
4.
After running in https://bugs.gentoo.org/727188 I started using -O2 instead of -Os.
- VIDEO_CARDS="v3d vc4" is needed
- https://cmpct.info/~sam/gentoo/arm64/PiGentoo64.html
- mkfs.ext4 /dev/sda2
- mount /dev/sda2 /mnt/gentoo/
- wget,
tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
- make.conf: I prefer COMMON_FLAGS="-Os -pipe -march=native" and MAKEOPTS="-j3", since my Raspi400 has just 4GB Ram. For big packages I may have to add -j1 on a per-package base.
- 10. and 11. are the same
- 12.1 is the same. Instead of 12.2:
- echo sys-kernel/raspberrypi-sources ~arm64 >> /etc/portage/package.accept_keywords ; emerge -va raspberrypi-sources
- ln -s /usr/src/linux-5.10.11_p20210201-raspberrypi/ /usr/src/linux
- 12.3 same
- make menuconfig # I changed:
- Compiler optimization level to -Os
- Default CPUfreq governor to ondemand
- added some crypto algos as modules that are (maybe) supported by the cpu
- 12.4 same
- 12.5 time nice ionice -c3 make -j4 Image modules dtbs
- real 75m18.147s
- user 261m19.520s
- sys 32m35.646s
- 12.6 mount /boot inside chroot
- 12.7 the same
- 12.8. a) same b) make install
- added ACCEPT_LICENSE="* -@EULA" to make.conf
- 13, 14 same
- some steps are missing here
- I had problems with modprobe giving me an "exec format error". I am using the kernel from the package raspberrypi-sources and used make install modules_install dtbs_install . The kernel resides then in /boot/vmlinuz-5.* . After copying vmlinuz-5.x to kernel-8-p4.img it worked.
- emerge rpi-eeprom
- perl-cleaner --all # after reinstalling perl
- After booting into gentoo without having X up and runnig I like to use dvtm. To get the time into the status line I copy the script from /usr/share/doc/dvtm-*/README.md.bz2 subheader ### Statusbar to a shell script and start dvtm with this script. Screenshots are available at https://screenshots.debian.net/package/dvtm
Third try
- https://cmpct.info/~sam/gentoo/arm64/PiGentoo64.html
- formatting the gentoo root partition with mkfs.btrfs gives me "SSD detected: no" which leads to "Metadata: DUP;System: DUP"
- from man mkfs.btrfs (8): "The detection is based on the value of /sys/block/DEV/queue/rotational". rotational was 1, therefore I zeroed it: echo 0>rotational .
- mkfs.btrfs -fL gentooroot /dev/sdaX
- for f2fs there is no label command, but you can enter the label at the mkfs command, too
- mount -o nodatacow,noatime,lazytime /dev/sdaX /mnt/gentoo # nodatacow disables the feature copy on write. Small changes get faster and I hope there will be fewer data written to the SSD
- cd /mnt/gentoo;wget "stage3"
tar xpvf stage3-*.tar.bz2 --xattrs-include='*.*' --numeric-owner
- make.conf: I prefer COMMON_FLAGS="...-Os..." and MAKEOPTS="-j3", since my Raspi400 has just 4GB Ram. For big packages I may have to add -j1 on a per-package base.
- 10. and 11. are the same
- The PiGentoo64.html links to an old stage3.
- 12.1 is the same. Instead of 12.2:
- echo sys-kernel/raspberrypi-sources ~arm64 >> /etc/portage/package.accept_keywords ; emerge -va raspberrypi-sources
- ln -s /usr/src/linux-5.10.11_p20210201-raspberrypi/ /usr/src/linux
- 12.3. same.
- make menuconfig # I changed:
- Compiler optimization level to -Os
- Default CPUfreq governor to ondemand
- added some crypto algos as modules that are (maybe) supported by the cpu
- btrfs should be included, if it is used as root
- make menuconfig # I changed:
- 12.4 same
- 12.5.: time nice ionice -c3 make -j3 Image modules dtbs
- real 85m43.988s
- user 233m17.883s
- sys 30m17.258s
- 12.6 mount /boot inside chroot
- 12.7 the same
- 12.8. a) same b) make install
- added ACCEPT_LICENSE="* -@EULA" to make.conf
Second try
- Downloaded [gentoo-on-rpi-64bit 1.6.0 full](https://github.com/sakaki-/gentoo-on-rpi-64bit/releases/download/v1.6.0/genpi64.img.xz) [asc](https://github.com/sakaki-/gentoo-on-rpi-64bit/releases/download/v1.6.0/genpi64.img.xz.asc)
# xzcat genpi64.img.xz > /dev/sdX && sync
The Rpi 400 doesn't boot the image but shuts down immediately. I copied bcm2711-rpi-400.dtb to the boot dir, but it didn't change anything. I copied from a /boot First try below /boot/start* /boot/fixup* to the /boot and gentoo started, but got stuck at "switching off virutalization kvm". After rebooting the system started.
I copied the dir /lib/firmware/brcm and rebooted.
emerge --sync ; emerge -uvaDN @world gives several problems.
I tried to upgrade the packages one by one, until I realized, with help from #gentoo-arm, that the /etc/portage/repos.conf/gentoo.conf uses isshoni.org as source, which doesn't get any updates any more.
I tried again to upgrade one by one but realized how many programs are installed, how many couldn't be upgraded one by one and thought, it would not be a clean system after all. I gave up.
Gentoo doesn't seem to get my stable desktop system now, but it is still a nice distro for fun. I guess, I go back to run gentoo in a virtual machine and get more knowledge.
First try
Somewhere at installing X I got stuck and this will not be finished!
- Hardware: Raspberry Pi 400 with a 64GB microSD card with A1 standard
- From Handbook:Main_Page "Note: The arm and arm64 architectures are supported by the Gentoo project but do not yet have Handbooks at their disposal. Please refer to the ARM project and #534376 for more information.
- since there is no handbook for installing Gentoo on Arm 64, I took the AMD64 handbook
- base system: Raspberry Pi OS 64bit beta works so far (WiP), optional mirrorselect is missing; gentoo root is in a 20 GB loopback mounted file
- make.conf: COMMON_FLAGS="-Os -pipe -mcpu=native"
- profile-config set 2 (default/linux/arm64/17.0/desktop (stable)) brings a loop dependency with harfbuzz. The loop dependecy is documented in use.local.desc: "media-libs/freetype:harfbuzz - Use media-libs/harfbuzz for auto-hinting OpenType fonts. WARNING: may trigger circular dependencies!". I then used profile 1.
- /etc/portage/make.conf: MAKEOPTS="-j1" because otherwise compiling gcc leaves the computer unuseable for two hours
- gcc didn't get compiled, error was: "{standard input}: Assembler messages: \n {standard input}:2669550: Warning: end of file not at end of a line; newline inserted \n xg++: fatal error: Killed signal terminated program cc1plus" in the irc I got the information, that is was an OOM
- Retrying with 16G of swap and stopping firefox and thunderbird. Raspberry Pi OS has just a 100MB swap file as default. Compiling worked.
- echo sys-kernel/raspberrypi-sources ~arm64 >> /etc/portage/packages.accept_keywords ; emerge -va raspberrypi-sources
- emerge -va raspberrypi-firmware raspberrypi-image
- emerge -va rpi-eeprom
- cd /usr/src/linux; make bcm2711_defconfig
- make menuconfig # I changed:
- Compiler optimization level to -Os
- Default CPUfreq governor to ondemand
- added some crypto algos as modules that are (maybe) supported by the cpu
- make all
- added CPU_FLAGS_ARM="edsp neon thumb vfp vfpv3 vfpv4 vfp-d32 crc32 v4 v5 v6 v7 v8 thumb2" to /etc/portage/make.conf . They were reported by cpuid2cpuflags, seeCPU FLAGS X86#Using cpuid2cpuflags for details.
- emerge -va wpa_supplicant # < steev> broadcom-sta is the "wl" driver for (older?) broadcom chips.
- Partitioning the 1TB SSD (Raspberry Pi 3 64 bit Install#Partitioning)
- Partition size id Type mount
- sda1 256M c W95 FAT32 (LBA) /boot
- sda2 other 5 extended -
- sda5 8G 82 swap swap
- sda6 100G 83 Linux /
- sda7 823G 83 Linux /data
/boot/cmdline.txt
This file will not exist until its created. Create it with the following content.
root=/dev/mmcblk0p3 rootfstype=ext4 rootwait
- emerge xorg-x11
qemu
As of qemu 6.1.50 (checked on 2021-09-06) Rpi 4b and 400 are not supported as targets. see https://qemu-project.gitlab.io/qemu/system/arm/raspi.html for details- "Qemu 2.0 includes arm64 support, and Debian 8 (and above) fully supports it." https://wiki.debian.org/Arm64Qemu . I hope, it works in RaspberryPi OS
Links
- Raspberry Pi/Quick Install Guide
- Raspberry_Pi_VC4
- https://github.com/sakaki-/gentoo-on-rpi-64bit
- User:Maffblaster/Projects/GenPi64
- https://cmpct.info/~sam/gentoo/arm64/PiGentoo64.html
- https://www.raspberrypi.org/documentation/computers/linux_kernel.html#cross-compiling-the-kernel At the end of the section is a list of files to copy