Add 16KB PAGESIZE kernel for BCM2712 (Pi 5)

While here, install kernel & initramfs OSTree to the canonical location
([/usr]/lib/$kver) [1].

[1] https://bootc.dev/bootc/bootc-install.html#installing-bootc-compatible-images
This commit is contained in:
Koichiro Iwao 2026-07-29 17:32:24 +09:00
parent fd686c1d95
commit cad995dde8

View File

@ -11,7 +11,7 @@ ExclusiveArch: aarch64
%define local_version v8
%define bcmmodel 2711
%define extra_version 1
%define extra_version 2
# This originally implies Kernel 4.x for RPi 2 and is not appropriate now.
# Be careful to change this not to disturb the seamless package update.
@ -35,6 +35,8 @@ ExclusiveArch: aarch64
%define with_firmware %{?_without_firmware: 0} %{?!_without_firmware: 1}
# kernel-headers
%define with_headers %{?_without_headers: 0} %{?!_without_headers: 1}
# kernel-16k (aarch64 kernel with 16K page_size; RPi 5 only)
%define with_arm64_16k %{?_without_arm64_16k: 0} %{?!_without_arm64_16k: 1}
Name: raspberrypi%{rpisuffix}
Version: %{kversion}.%{patchlevel}
@ -157,6 +159,39 @@ This package provides pseudo dependency for the packages that depends on regular
kernel-modules-extra-matched packages.
%endif
%if %{with_arm64_16k}
%package kernel%{?ksuffix}-16k
Group: System Environment/Kernel
Summary: The Linux kernel
Provides: kernel = %{version}-%{release}
Provides: kernel-core = %{version}-%{release}
Provides: installonlypkg(kernel)
Requires: %{name}-kernel%{?ksuffix} = %{version}-%{release}
Requires: coreutils
Requires: dracut
%description kernel%{?ksuffix}-16k
The kernel package contains the Linux kernel (vmlinuz), the core of any
Linux operating system. The kernel handles the basic functions
of the operating system: memory allocation, process allocation, device
input and output, etc.
%package kernel%{?ksuffix}-16k-devel
Group: System Environment/Kernel
Summary: Development package for building kernel modules to match the kernel
Provides: kernel-devel = %{version}-%{release}
Provides: kernel-devel-uname-r = %{version}-%{release}
Provides: %{name}-kernel%{?ksuffix-devel} = %{version}-%{release}
Provides: installonlypkg(kernel)
Provides: installonlypkg(kernel)
Autoreq: no
Requires(pre): findutils
Requires: findutils
Requires: perl-interpreter
%description kernel%{?ksuffix}-16k-devel
This package provides kernel headers and makefiles sufficient to build modules
against the kernel package.
%endif
%if %{with_tools}
%package kernel%{?ksuffix}-tools
Summary: Assortment of tools for the Linux kernel
@ -227,10 +262,11 @@ glibc package.
%endif
%prep
%setup -q -n linux-stable_%{version_tag}
%setup -q -c -n linux-stable_%{version_tag}
pushd linux-stable_%{version_tag}
%patch -P 100 -p1
%patch -P 101 -p1
perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}/" Makefile
perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}.%{_arch}/" Makefile
perl -p -i -e "s/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=/" arch/%{Arch}/configs/bcm2711_defconfig
perl -p -i -e "s/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=/" arch/%{Arch}/configs/bcm2712_defconfig
@ -245,18 +281,38 @@ perl -p -i -e "s/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=/" arch/%{Arch}/con
scripts/jobserver-exec scripts/dtc/dt-extract-compatibles
%{pathfix} -pni "%{__python3} %{py3_shbang_opts}" tools/ tools/kvm/kvm_stat/kvm_stat
%endif
popd
cp -r linux-stable_%{version_tag} 2711
%if %{with_arm64_16k}
cp -r linux-stable_%{version_tag} 2712
perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}.%{_arch}+16k/" 2712/Makefile
%endif
%build
# 16K page-size kernel optimized (bcmmodel=2712) for RPi 5 is not built at the moment
# to support both RPi 4 and 5.
export KERNEL=kernel%{armtarget}
make bcm%{bcmmodel}_defconfig
pushd 2711
make bcm2711_defconfig
popd
# 4K page-size kernel
%if %{with_up}
pushd 2711
make %{?_smp_mflags} HOSTCFLAGS="%{?build_cflags}" HOSTLDFLAGS="%{?build_ldflags}" %{build_image} modules dtbs
popd
%endif
# 16K page-size kernel for RPi 5
%if %{with_arm64_16k}
pushd 2712
make bcm2712_defconfig
make %{?_smp_mflags} HOSTCFLAGS="%{?build_cflags}" HOSTLDFLAGS="%{?build_ldflags}" %{build_image} modules dtbs
popd
%endif
# kernel-tools
%if %{with_tools}
pushd 2711
make %{?_smp_mflags} -C tools/power/cpupower CPUFREQ_BENCH=false DEBUG=false
pushd tools/thermal/tmon/
make %{?_smp_mflags} HOSTCFLAGS="%{?build_cflags}" HOSTLDFLAGS="%{?build_ldflags}"
@ -270,67 +326,104 @@ popd
pushd tools/mm/
make %{?_smp_mflags} HOSTCFLAGS="%{?build_cflags}" HOSTLDFLAGS="%{?build_ldflags}" slabinfo page_owner_sort
popd
popd # 2711
%endif
%install
%if %{with_up}
# kernel
mkdir -p %{buildroot}/boot/overlays/
mkdir -p %{buildroot}/usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}/boot/overlays
cp -p -v COPYING %{buildroot}/boot/COPYING.linux-%{kversion}
cp -p -v arch/%{Arch}/boot/dts/overlays/README %{buildroot}/usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}/boot/overlays
%ifarch aarch64
cp -p -v arch/%{Arch}/boot/dts/broadcom/*.dtb %{buildroot}/usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}/boot
%else
cp -p -v arch/%{Arch}/boot/dts/*.dtb %{buildroot}/usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}/boot
%endif
cp -p -v arch/%{Arch}/boot/dts/overlays/*.dtb* %{buildroot}/usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}/boot/overlays
cp -p -v arch/%{Arch}/boot/%{build_image} %{buildroot}/boot/kernel-%{version}-%{release}.img
make INSTALL_MOD_PATH=%{buildroot} modules_install
cat > %{buildroot}/boot/config-kernel-%{version}-%{release}.inc <<__EOF__
%ifarch aarch64
InstallKernel() {
BcmModel=$1
case "${BcmModel}" in
2711)
Variant=""
;;
2712)
Variant="+16k"
;;
*)
exit 1
;;
esac
KernelVer=%{version}-%{release}.%{_arch}${Variant}
InstallDir=%{buildroot}/usr/share/%{name}-kernel%{?ksuffix}/${KernelVer}
ModulesDir=%{buildroot}/lib/modules/${KernelVer}
DevelDir=/usr/src/kernels/${KernelVer}
pushd ${BcmModel}
# kernel
mkdir -p %{buildroot}/boot/overlays
mkdir -p ${InstallDir}/boot/overlays
cp -p -v COPYING ${InstallDir}/boot/COPYING.linux-${KernelVer}
cp -p -v arch/%{Arch}/boot/dts/overlays/README ${InstallDir}/boot/overlays
cp -p -v arch/%{Arch}/boot/dts/broadcom/*.dtb ${InstallDir}/boot
cp -p -v arch/%{Arch}/boot/dts/overlays/*.dtb* ${InstallDir}/boot/overlays
cp -p -v arch/%{Arch}/boot/%{build_image} ${InstallDir}/boot/kernel-${KernelVer}.img
cp .config ${InstallDir}/boot/config-${KernelVer}
make INSTALL_MOD_PATH=%{buildroot} KERNELRELEASE="${KernelVer}" modules_install
cat > ${InstallDir}/boot/config-kernel-${KernelVer}.inc <<__EOF__
arm_64bit=1
%endif
kernel kernel-%{version}-%{release}.img
initramfs initramfs-%{version}-%{release}.img followkernel
kernel kernel-${KernelVer}.img
initramfs initramfs-${KernelVer}.img followkernel
__EOF__
cp .config %{buildroot}/boot/config-%{version}-%{release}
# /boot for normal boot
cp -p -v ${InstallDir}/boot/COPYING.linux-${KernelVer} %{buildroot}/boot/COPYING.linux-${KernelVer}
cp ${InstallDir}/boot/config-kernel-${KernelVer}.inc %{buildroot}/boot/config-kernel-${KernelVer}.inc
cp ${InstallDir}/boot/config-${KernelVer} %{buildroot}/boot/config-${KernelVer}
cp ${InstallDir}/boot/kernel-${KernelVer}.img %{buildroot}/boot/kernel-${KernelVer}.img
[ x"${BcmModel}" = x"2712" ] && cp ${InstallDir}/boot/kernel-${KernelVer}.img %{buildroot}/boot/kernel_${BcmModel}.img
# /lib/modules for ostree boot
cp ${InstallDir}/boot/kernel-${KernelVer}.img ${ModulesDir}/vmlinuz
cp -p -v System.map ${ModulesDir}
# kernel-devel
DevelDir=/usr/src/kernels/%{version}-%{release}
mkdir -p %{buildroot}$DevelDir
# first copy everything
cp -p -v Module.symvers System.map %{buildroot}$DevelDir
cp --parents `find -type f -name "Makefile*" -o -name "Kconfig*"` %{buildroot}$DevelDir
# then drop all but the needed Makefiles/Kconfig files
rm -rf %{buildroot}$DevelDir/Documentation
rm -rf %{buildroot}$DevelDir/scripts
rm -rf %{buildroot}$DevelDir/include
cp .config %{buildroot}$DevelDir
cp -a scripts %{buildroot}$DevelDir
cp -a include %{buildroot}$DevelDir
# kernel-devel
mkdir -p %{buildroot}${DevelDir}
# first copy everything
cp -p -v Module.symvers System.map %{buildroot}${DevelDir}
cp --parents `find -type f -name "Makefile*" -o -name "Kconfig*"` %{buildroot}${DevelDir}
if [ -d arch/%{Arch}/scripts ]; then
cp -a arch/%{Arch}/scripts %{buildroot}$DevelDir/arch/%{_arch} || :
fi
if [ -f arch/%{Arch}/*lds ]; then
cp -a arch/%{Arch}/*lds %{buildroot}$DevelDir/arch/%{_arch}/ || :
fi
if [ -f arch/%{Arch}/kernel/module.lds ]; then
cp -a --parents arch/%{Arch}/kernel/module.lds %{buildroot}$DevelDir/
fi
rm -f %{buildroot}$DevelDir/scripts/*.o
rm -f %{buildroot}$DevelDir/scripts/*/*.o
cp -a --parents arch/%{Arch}/include %{buildroot}$DevelDir
# include the machine specific headers for ARM variants, if available.
if [ -d arch/%{Arch}/mach-bcm%{bcmmodel}/include ]; then
cp -a --parents arch/%{Arch}/mach-bcm%{bcmmodel}/include %{buildroot}$DevelDir
fi
cp include/generated/uapi/linux/version.h %{buildroot}$DevelDir/include/linux
touch -r %{buildroot}$DevelDir/Makefile %{buildroot}$DevelDir/include/linux/version.h
ln -T -s $DevelDir %{buildroot}/lib/modules/%{version}-%{release}/build --force
ln -T -s build %{buildroot}/lib/modules/%{version}-%{release}/source --force
# then drop all but the needed Makefiles/Kconfig files
rm -rf %{buildroot}${DevelDir}/Documentation
rm -rf %{buildroot}${DevelDir}/scripts
rm -rf %{buildroot}${DevelDir}/include
cp .config %{buildroot}${DevelDir}
cp -a scripts %{buildroot}${DevelDir}
cp -a include %{buildroot}${DevelDir}
rm -rf %{buildroot}${DevelDir}/scripts/kconfig/conf
# cleanup kernel-devel and
find %{buildroot}${DevelDir} -name ".*.cmd" -delete
find %{buildroot}${DevelDir} -name "*.o" -delete
find %{buildroot}${DevelDir} -name ".gitignore" -delete
if [ -d arch/%{Arch}/scripts ]; then
cp -a arch/%{Arch}/scripts ${DevelDir}/arch/%{_arch} || :
fi
if [ -f arch/%{Arch}/*lds ]; then
cp -a arch/%{Arch}/*lds ${DevelDir}/arch/%{_arch}/ || :
fi
if [ -f arch/%{Arch}/kernel/module.lds ]; then
cp -a --parents arch/%{Arch}/kernel/module.lds %{buildroot}${DevelDir}/
fi
rm -f %{buildroot}${DevelDir}/scripts/*.o
rm -f %{buildroot}${DevelDir}/scripts/*/*.o
cp -a --parents arch/%{Arch}/include %{buildroot}${DevelDir}
# include the machine specific headers for ARM variants, if available.
if [ -d arch/%{Arch}/mach-bcm%{bcmmodel}/include ]; then
cp -a --parents arch/%{Arch}/mach-bcm%{bcmmodel}/include %{buildroot}${DevelDir}
fi
cp include/generated/uapi/linux/version.h %{buildroot}${DevelDir}/include/linux
touch -r %{buildroot}${DevelDir}/Makefile %{buildroot}${DevelDir}/include/linux/version.h
ln -T -s ${DevelDir} ${ModulesDir}/build --force
ln -T -s build ${ModulesDir}/source --force
popd
}
%if %{with_up}
InstallKernel 2711
%endif
%if %{with_arm64_16k}
InstallKernel 2712
%endif
%if %{with_firmware}
@ -348,6 +441,7 @@ popd
%endif
%if %{with_tools}
pushd 2711
# kernel-tools
make -C tools/power/cpupower DESTDIR=$RPM_BUILD_ROOT libdir=%{_libdir} mandir=%{_mandir} CPUFREQ_BENCH=false install
rm -f %{buildroot}%{_libdir}/*.{a,la}
@ -374,14 +468,17 @@ pushd tools/mm/
install -m755 slabinfo %{buildroot}%{_bindir}/slabinfo
install -m755 page_owner_sort %{buildroot}%{_bindir}/page_owner_sort
popd
popd #2711
%endif
%if %{with_headers}
pushd 2711
%{__make} ARCH=%{Arch} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
find %{buildroot}/usr/include \
\( -name .install -o -name .check -o \
-name ..install.cmd -o -name ..check.cmd \) -delete
popd
%endif
%if %{with_tools}
@ -404,46 +501,32 @@ find %{buildroot}/usr/include \
%if %{with_up}
%files kernel%{?ksuffix}
%defattr(-,root,root,-)
/lib/modules/%{version}-%{release}
/usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}
/usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}/boot
/usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}/boot/*.dtb
/boot/config-%{version}-%{release}
/lib/modules/%{version}-%{release}.%{_arch}
%ghost /lib/modules/%{version}-%{release}.%{_arch}/initramfs
/usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}.%{_arch}
/boot/config-%{version}-%{release}.%{_arch}
/boot/config-kernel-%{version}-%{release}.%{_arch}.inc
/boot/overlays/
/usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}/boot/overlays/*
%attr(0755,root,root) /boot/kernel-%{version}-%{release}.img
%ghost /boot/initramfs-%{version}-%{release}.img
/boot/config-kernel-%{version}-%{release}.inc
%doc /boot/COPYING.linux-%{kversion}
%attr(0755,root,root) /boot/kernel-%{version}-%{release}.%{_arch}.img
%ghost /boot/initramfs-%{version}-%{release}.%{_arch}.img
%doc /boot/COPYING.linux-%{version}-%{release}.%{_arch}
%posttrans kernel%{?ksuffix}
if [ -d /usr/lib/ostree-boot ]; then
mkdir -p /usr/lib/modules/%{version}-%{release}
pushd /usr/lib/ostree-boot
[ -e config-%{version}-%{release} ] && \
mv config-%{version}-%{release} /usr/lib/modules/%{version}-%{release}/
[ -e config-kernel-%{version}-%{release}.inc ] && \
mv config-kernel-%{version}-%{release}.inc /usr/lib/modules/%{version}-%{release}/
[ -e initramfs-%{version}-%{release}.img ] && \
mv initramfs-%{version}-%{release}.img /usr/lib/modules/%{version}-%{release}/initramfs
[ -e kernel-%{version}-%{release}.img ] && \
mv kernel-%{version}-%{release}.img /usr/lib/modules/%{version}-%{release}/vmlinuz
popd
fi
if [ -d /boot ]; then
if [ -f /boot/kernel%{armtarget}.img ] || [ ! -f /boot/config-kernel.inc ];then
# if nothing exists, fall back to generating the file, but don't create it
# if we have moved to initramfs
cp /boot/kernel-%{version}-%{release}.img /boot/kernel%{armtarget}.img
cp /boot/kernel-%{version}-%{release}.%{_arch}.img /boot/kernel%{armtarget}.img
fi
cp /usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}/boot/*.dtb /boot/
cp /usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}/boot/overlays/*.dtb* /boot/overlays/
cp /usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}/boot/overlays/README /boot/overlays/
cp /boot/config-kernel-%{version}-%{release}.inc /boot/config-kernel.inc
cp /usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}.%{_arch}/boot/*.dtb /boot/
cp /usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}.%{_arch}/boot/overlays/*.dtb* /boot/overlays/
cp /usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}.%{_arch}/boot/overlays/README /boot/overlays/
cp /boot/config-kernel-%{version}-%{release}.%{_arch}.inc /boot/config-kernel.inc
/usr/bin/dracut --no-hostonly /boot/initramfs-%{version}-%{release}.img %{version}-%{release}
cp /boot/initramfs-%{version}-%{release}.img /boot/initramfs%{armtarget}
/usr/bin/dracut --no-hostonly \
/lib/modules/%{version}-%{release}.%{_arch}/initramfs.img %{version}-%{release}.%{_arch}
cp /lib/modules/%{version}-%{release}.%{_arch}/initramfs.img /boot/initramfs-%{version}-%{release}.%{_arch}.img
cp /boot/initramfs-%{version}-%{release}.%{_arch}.img /boot/initramfs%{armtarget}
fi
%postun kernel%{?ksuffix}
@ -459,10 +542,9 @@ cp $(ls -1d /usr/share/%{name}-kernel%{?ksuffix}/*-*/|sort -V|tail -1)/boot/over
cp $(ls -1d /usr/share/%{name}-kernel%{?ksuffix}/*-*/|sort -V|tail -1)/boot/overlays/README /boot/overlays/
cp $(ls -1 /boot/config-kernel-*-*|sort -V|tail -1) /boot/config-kernel.inc
%files kernel%{?ksuffix}-devel
%defattr(-,root,root)
/usr/src/kernels/%{version}-%{release}
/usr/src/kernels/%{version}-%{release}.%{_arch}
%if 0%{?rhel} >= 10
%files kernel%{?ksuffix}-modules
@ -483,8 +565,30 @@ cp $(ls -1 /boot/config-kernel-*-*|sort -V|tail -1) /boot/config-kernel.inc
%endif
%endif
%if %{with_arm64_16k}
%files kernel%{?ksuffix}-16k
%defattr(-,root,root,-)
/lib/modules/%{version}-%{release}.%{_arch}+16k
%ghost /lib/modules/%{version}-%{release}.%{_arch}+16k/initramfs.img
/usr/share/%{name}-kernel%{?ksuffix}/%{version}-%{release}.%{_arch}+16k
/boot/config-%{version}-%{release}.%{_arch}+16k
/boot/config-kernel-%{version}-%{release}.%{_arch}+16k.inc
/boot/kernel-%{version}-%{release}.%{_arch}+16k.img
/boot/kernel_2712.img
%doc /boot/COPYING.linux-%{version}-%{release}.%{_arch}+16k
%posttrans kernel%{?ksuffix}-16k
/usr/bin/dracut --no-hostonly \
/lib/modules/%{version}-%{release}.%{_arch}+16k/initramfs.img %{version}-%{release}.%{_arch}+16k
cp /lib/modules/%{version}-%{release}.%{_arch}+16k/initramfs.img /boot/initramfs-%{version}-%{release}.%{_arch}+16k.img
%files kernel%{?ksuffix}-16k-devel
%defattr(-,root,root)
/usr/src/kernels/%{version}-%{release}.%{_arch}+16k
%endif
%if %{with_tools}
%files kernel%{?ksuffix}-tools -f cpupower.lang
%files kernel%{?ksuffix}-tools -f 2711/cpupower.lang
%{_bindir}/cpupower
%{_datadir}/bash-completion/completions/cpupower
%{_unitdir}/cpupower.service
@ -531,11 +635,16 @@ cp $(ls -1 /boot/config-kernel-*-*|sort -V|tail -1) /boot/config-kernel.inc
%files kernel%{?ksuffix}-headers
/usr/include/*
%exclude %{_includedir}/cpufreq.h
%exclude %{_includedir}/internal/
%exclude %{_includedir}/perf/
%exclude %{_includedir}/cpuidle.h
%exclude %{_includedir}/powercap.h
%endif
%changelog
* Wed Jul 29 2026 Koichiro Iwao <meta@almalinux.org> - 6.18.34-20260609.v8.2
- Add 16KB PAGESIZE kernel for BCM2712 (Pi 5)
- Install kernel & initramfs OSTree to the canonical location ([/usr]/lib/$kver)
https://bootc.dev/bootc/bootc-install.html#installing-bootc-compatible-images
* Thu Jul 09 2026 Koichiro Iwao <meta@almalinux.org> - 6.18.34-20260609.v8.1
- Update kernel to v6.18.34 stable_20260609