§2023-09-06

¶Step 1. emerge --ask dev-vcs/git

¶Step 2. Fetch the Raspberry Pi firmware

# cd /usr/src
# mkdir raspberrypi && cd $_
# git clone -b stable --depth=1 https://github.com/raspberrypi/firmware

The /boot directory will be needed out of the master branch. The --depth option is used so that not all the history will be fetched (it is unnecessary). This will save a lot of space, bandwidth, and time.

¶Step 3. Fetch the Raspberry Pi kernel

latest version 6.1.y

 # pwd
/usr/src/raspberrypi
# git clone --depth=1 https://github.com/raspberrypi/linux -b rpi-6.1.y

¶Step 3. configure kernel

# ls
firmware  linux
# cd linux/
# ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make bcmrpi3_defconfig
..
#
# configuration written to .config
#

Either use menuconfig to change the default CPU governor, add something to the kernel command line, or change it after booting.

raspberry-kernel-config.png

but in 6.1.y it seems has been set

¶Step 4. Cross compiling the kernel

The build is conventional, other than telling the build system to build for arm64 and use the cross compiler.

# time ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- make -j4

- h2Jammy.yushei.net
real    56m43.940s
user    200m4.779s
sys     23m59.168s

- surfacePro.yushei.net
real	48m0.140s
user	172m5.842s
sys	     6m41.232s