Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Enable Rockchip arch in kernel #2556

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ccfe3ea
kernel: upgrade from 6.6 to 6.10
ader1990 Sep 9, 2024
4563b0e
kernel: add corect checksums
ader1990 Sep 9, 2024
3edf8fe
linux: add coreos-modules for 6.10.9
ader1990 Sep 10, 2024
b01e779
linux: pahole flags moved to scripts/Makefile.btf
ader1990 Sep 10, 2024
8c91f0d
linux: remove CONFIG_AMD_IOMMU_V2
ader1990 Sep 10, 2024
1d972a9
linux: remove CONFIG_MD_LINEAR
ader1990 Sep 10, 2024
1632cd1
linux: remove CONFIG_NET_ACT_IPT
ader1990 Sep 10, 2024
103ce4d
pahole: added a revamped patch to remove the parallel implementation
ader1990 Sep 11, 2024
912e96d
zfs: unmask 2.2.6 version compatible with linux kernel 6.10
ader1990 Sep 11, 2024
388b190
linux: remove CONFIG_FB_ARMCLCD
ader1990 Sep 11, 2024
a429bc2
To be fixed: build_image: do not fail on cpio end of file
ader1990 Sep 11, 2024
068aabf
build: force max load
ader1990 Sep 11, 2024
162bf91
kernel: remove rebased files
ader1990 Sep 17, 2024
317604d
hv_daemons: update the hv_fcopy to hv_fcopy_uio
ader1990 Sep 17, 2024
b2f98bf
kernel: use pahole 1.27 feature of reproducible builds
ader1990 Sep 17, 2024
9225cb0
Add the required patches
ader1990 Sep 18, 2024
9c0114e
kernel: update patch for secureboot
ader1990 Sep 18, 2024
2be94c2
cpio: show all the rootfs found
ader1990 Sep 18, 2024
47b9495
kernel: fix hv tools build for arm64
ader1990 Sep 19, 2024
ca8a7da
app-emulation/hv-daemons: add hv_fcopy_uio_daemon
ader1990 Sep 19, 2024
218f211
kernel: upgrade from 6.10 to 6.11
ader1990 Oct 29, 2024
b1578e9
kernel: use kernel 6.12
ader1990 Nov 19, 2024
354489d
kernel: use new patches for secure boot
ader1990 Nov 19, 2024
c9f9794
kernel: add required CONFIG_MODULE_COMPRESS=y
ader1990 Nov 19, 2024
582883a
sys-fs/zfs: add and enable 2.2.7 which is compatible with kernel 6.12
ader1990 Dec 19, 2024
87bc1d5
kernel: set CONFIG_ARCH_ROCKCHIP
sambonbonne Jan 26, 2025
3d0e057
Merge branch 'main' into feature/enable-rockchip-in-kernel
ader1990 Feb 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build_library/build_image_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,8 @@ EOF
write_contents_with_technical_details "${root_fs_dir}" "${BUILD_DIR}/${image_contents_wtd}"

if [[ -n "${image_initrd_contents}" ]] || [[ -n "${image_initrd_contents_wtd}" ]]; then
"${BUILD_LIBRARY_DIR}/extract-initramfs-from-vmlinuz.sh" "${root_fs_dir}/boot/flatcar/vmlinuz-a" "${BUILD_DIR}/tmp_initrd_contents"
echo ">>>>DEBUG<<<${root_fs_dir}/boot/flatcar/vmlinuz-a"
"${BUILD_LIBRARY_DIR}/extract-initramfs-from-vmlinuz.sh" "${root_fs_dir}/boot/flatcar/vmlinuz-a" "${BUILD_DIR}/tmp_initrd_contents" || true
if [[ -n "${image_initrd_contents}" ]]; then
write_contents "${BUILD_DIR}/tmp_initrd_contents" "${BUILD_DIR}/${image_initrd_contents}"
fi
Expand Down
8 changes: 3 additions & 5 deletions build_library/extract-initramfs-from-vmlinuz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ perform_round() {
for rnd in "${round_prefix}"*; do
if [[ $(file --brief "${rnd}") =~ 'cpio archive' ]]; then
mkdir -p "${out}/rootfs-${ROOTFS_IDX}"
while cpio --quiet --extract --make-directories --directory="${out}/rootfs-${ROOTFS_IDX}" --nonmatching 'dev/*'; do
ROOTFS_IDX=$(( ROOTFS_IDX + 1 ))
mkdir -p "${out}/rootfs-${ROOTFS_IDX}"
done <${rnd}
rmdir "${out}/rootfs-${ROOTFS_IDX}"
# On Linux 6.10, the first rootfs is an extra ghost rootfs of 336K, that has a corrupted CPIO
cpio --quiet --extract --make-directories --directory="${out}/rootfs-${ROOTFS_IDX}" --nonmatching 'dev/*' < $rnd || true
ROOTFS_IDX=$(( ROOTFS_IDX + 1 ))
fi
done
}
Expand Down
2 changes: 1 addition & 1 deletion common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [[ -z ${NUM_JOBS} ]] || [[ ${NUM_JOBS} -eq 0 ]]; then
NUM_JOBS=$(grep -c "^processor" /proc/cpuinfo)
fi
# Ensure that any sub scripts we invoke get the max proc count.
export NUM_JOBS
export NUM_JOBS=350

# Make sure we have the location and name of the calling script, using
# the current value if it is already set.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Hyper-V FCOPY UIO daemon
ConditionPathExists=/sys/bus/vmbus/devices/eb765408-105f-49b6-b4aa-c123b64d17d4/uio

[Service]
ExecStart=/usr/bin/hv_fcopy_uio_daemon --no-daemon

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ if [[ "${PV}" == 9999 ]]; then
fi

src_compile() {
# Build hv_vss_daemon, hv_kvp_daemon, hv_fcopy_daemon
# Build hv_vss_daemon, hv_kvp_daemon, hv_fcopy_daemon
kmake tools/hv
}

src_install() {
dobin "${S}/build/tools/hv/hv_fcopy_daemon"
dobin "${S}/build/tools/hv/hv_kvp_daemon"
dobin "${S}/build/tools/hv/hv_vss_daemon"

systemd_dounit "${FILESDIR}/hv_fcopy_daemon.service"
systemd_dounit "${FILESDIR}/hv_kvp_daemon.service"
systemd_dounit "${FILESDIR}/hv_vss_daemon.service"

systemd_enable_service "multi-user.target" "hv_fcopy_daemon.service"
systemd_enable_service "multi-user.target" "hv_kvp_daemon.service"
systemd_enable_service "multi-user.target" "hv_vss_daemon.service"
HV_DAEMONS=(hv_vss_daemon hv_kvp_daemon hv_fcopy_daemon hv_fcopy_uio_daemon)
for HV_DAEMON in "$HV_DAEMONS[@]"
do
if [ -f "${S}/build/tools/hv/${HV_DAEMON}" ]; then
dobin "${S}/build/tools/hv/${HV_DAEMON}"
systemd_dounit "${FILESDIR}/${HV_DAEMON}.service"
systemd_enable_service "multi-user.target" "${HV_DAEMON}.service"
fi
done
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Copyright 2014-2016 CoreOS, Inc.
# Distributed under the terms of the GNU General Public License v2

EAPI=7
COREOS_SOURCE_REVISION=""
inherit coreos-kernel

DESCRIPTION="CoreOS Linux kernel"
KEYWORDS="amd64 arm64"

RDEPEND="=sys-kernel/coreos-modules-${PVR}"
DEPEND="${RDEPEND}
app-arch/gzip
app-arch/zstd
app-crypt/clevis
app-shells/bash
coreos-base/coreos-init:=
sys-apps/coreutils
sys-apps/findutils
sys-apps/grep
sys-apps/ignition:=
sys-apps/less
sys-apps/nvme-cli
sys-apps/sed
sys-apps/shadow
sys-apps/systemd[cryptsetup]
sys-apps/seismograph
sys-apps/util-linux
sys-fs/btrfs-progs
sys-fs/e2fsprogs
sys-fs/mdadm
sys-fs/xfsprogs
>=sys-kernel/coreos-firmware-20180103-r1:=
>=sys-kernel/bootengine-0.0.4:=
sys-kernel/dracut
virtual/udev
amd64? ( sys-firmware/intel-microcode:= )"

# We are bad, we want to get around the sandbox. So do the creation of the
# cpio image in pkg_setup() where we are free to mount filesystems, chroot,
# and other fun stuff.
pkg_setup() {
coreos-kernel_pkg_setup

[[ "${MERGE_TYPE}" == binary ]] && return

# Fail early if we didn't detect the build installed by coreos-modules
[[ -n "${KV_OUT_DIR}" ]] || die "Failed to detect modules build tree"

if [[ "${ROOT:-/}" != / ]]; then
# TMPDIR needs to be corrected for chroot
TMPDIR=${TMPDIR#${ROOT}} ${ROOT}/usr/sbin/update-bootengine -m -c ${ROOT} -k "${KV_FULL}" || die
else
update-bootengine -k "${KV_FULL}" || die
fi
}

src_prepare() {
default
# KV_OUT_DIR points to the minimal build tree installed by coreos-modules
# Pull in the config and public module signing key
KV_OUT_DIR="${SYSROOT%/}/lib/modules/${COREOS_SOURCE_NAME#linux-}/build"
cp -v "${KV_OUT_DIR}/.config" build/ || die
local sig_key="$(getconfig MODULE_SIG_KEY)"
mkdir -p "build/${sig_key%/*}" || die
cp -v "${KV_OUT_DIR}/${sig_key}" "build/${sig_key}" || die

# Symlink to bootengine.cpio so we can stick with relative paths in .config
ln -sv "${SYSROOT%/}"/usr/share/bootengine/bootengine.cpio build/ || die
config_update 'CONFIG_INITRAMFS_SOURCE="bootengine.cpio"'

# include all intel and amd microcode files, avoiding the signatures
local fw_dir="${SYSROOT%/}/lib/firmware"
use amd64 && config_update "CONFIG_EXTRA_FIRMWARE=\"$(find ${fw_dir} -type f \
\( -path ${fw_dir}'/intel-ucode/*' -o -path ${fw_dir}'/amd-ucode/*' \) -printf '%P ')\""
use amd64 && config_update "CONFIG_EXTRA_FIRMWARE_DIR=\"${fw_dir}\""
}

src_compile() {
kmake "$(kernel_target)"

# sanity check :)
[[ -e build/certs/signing_key.pem ]] && die "created a new key!"
}

src_install() {
# coreos-postinst expects to find the kernel in /usr/boot
insinto "/usr/boot"
newins "$(kernel_path)" "vmlinuz-${KV_FULL}"
dosym "vmlinuz-${KV_FULL}" "/usr/boot/vmlinuz"

insinto "/usr/lib/modules/${KV_FULL}/build"
doins build/System.map

insinto "/usr/lib/debug/usr/boot"
newins build/vmlinux "vmlinux-${KV_FULL}"
dosym "../../../boot/vmlinux-${KV_FULL}" "/usr/lib/debug/usr/lib/modules/${KV_FULL}/vmlinux"

# For easy access to vdso debug symbols in gdb:
# set debug-file-directory /usr/lib/debug/usr/lib/modules/${KV_FULL}/vdso/
kmake INSTALL_MOD_PATH="${D}/usr/lib/debug/usr" vdso_install
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright 2014-2016 CoreOS, Inc.
# Distributed under the terms of the GNU General Public License v2

EAPI=7
COREOS_SOURCE_REVISION=""
inherit coreos-kernel savedconfig

DESCRIPTION="CoreOS Linux kernel modules"
KEYWORDS="amd64 arm64"
RDEPEND="!<sys-kernel/coreos-kernel-4.6.3-r1"

src_prepare() {
default
restore_config build/.config
if [[ ! -f build/.config ]]; then
local archconfig="$(find_archconfig)"
local commonconfig="$(find_commonconfig)"
elog "Building using config ${archconfig} and ${commonconfig}"
cat "${archconfig}" "${commonconfig}" >> build/.config || die
fi
cpio -ov </dev/null >build/bootengine.cpio

# Check that an old pre-ebuild-split config didn't leak in.
grep -q "^CONFIG_INITRAMFS_SOURCE=" build/.config && \
die "CONFIG_INITRAMFS_SOURCE must be removed from kernel config"
config_update 'CONFIG_INITRAMFS_SOURCE="bootengine.cpio"'
}

src_compile() {
# Generate module signing key
setup_keys

# Build both vmlinux and modules (moddep checks symbols in vmlinux)
kmake vmlinux modules
}

src_install() {
# Install modules to /usr.
# Install firmware to a temporary (bogus) location.
# The linux-firmware package will be used instead.
# Stripping must be done here, not portage, to preserve sigs.
kmake INSTALL_MOD_PATH="${D}/usr" \
INSTALL_MOD_STRIP="--strip-debug" \
INSTALL_FW_PATH="${T}/fw" \
modules_install

# Install to /usr/lib/debug with debug symbols intact
kmake INSTALL_MOD_PATH="${D}/usr/lib/debug/usr" \
INSTALL_FW_PATH="${T}/fw" \
modules_install
rm "${D}/usr/lib/debug/usr/lib/modules/${KV_FULL}/"modules.* || die
rm "${D}/usr/lib/debug/usr/lib/modules/${KV_FULL}/build" || die

# Clean up the build tree
shred_keys
kmake clean
find "build/" -type d -empty -delete || die
rm "build/.config.old" || die

# Install /lib/modules/${KV_FULL}/{build,source}
install_build_source

# Not strictly required but this is where we used to install the config.
dodir "/usr/boot"
local build="lib/modules/${KV_FULL}/build"
dosym "../${build}/.config" "/usr/boot/config-${KV_FULL}"
dosym "../${build}/.config" "/usr/boot/config"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ CONFIG_ACPI_IPMI=m
CONFIG_ACPI_PCI_SLOT=y
CONFIG_ACPI_PROCESSOR_AGGREGATOR=y
CONFIG_AMD_IOMMU=y
CONFIG_AMD_IOMMU_V2=m
CONFIG_AQTION=m
CONFIG_ARCH_MEMORY_PROBE=y
CONFIG_AUTOFS_FS=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CONFIG_ARCH_BCM2835=y
CONFIG_ARCH_BCM_IPROC=y
# CONFIG_ARCH_MEDIATEK is not set
# CONFIG_ARCH_QCOM is not set
CONFIG_ARCH_ROCKCHIP=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONFIG_ARCH_MULTI_V7 might be required too

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RK3566 is ARMv8-A (it has only 4 Cortex A-55, which are ARMv8.2-A) and CONFIG_ARCH_MULTI_V7 is for ARMv7 (if I understand correctly). So at first sight, it should not be required but if my real test fails, I'll try to add it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is weird because it says it's for Rockchip Cortex-A9 so I'll try without it and if it doesn't work, I'll try to add it.

If I add it, I'll try to use the SDK container to build locally and make the change if it helps.

CONFIG_ARCH_SEATTLE=y
CONFIG_ARCH_SPRD=y
CONFIG_ARCH_TEGRA=y
Expand Down Expand Up @@ -32,7 +33,6 @@ CONFIG_CRYPTO_SHA1_ARM64_CE=y
CONFIG_CRYPTO_SHA2_ARM64_CE=y
# CONFIG_DEBUG_PREEMPT is not set
CONFIG_DM_DEBUG=y
CONFIG_FB_ARMCLCD=y
CONFIG_GPIO_PL061=y
CONFIG_GPIO_XGENE=y
CONFIG_GPIO_XGENE_SB=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ CONFIG_MAGIC_SYSRQ=y
CONFIG_MARVELL_PHY=m
CONFIG_MAX_RAW_DEVS=8192
CONFIG_MD=y
CONFIG_MD_LINEAR=m
CONFIG_MD_RAID0=m
CONFIG_MEGARAID_MAILBOX=m
CONFIG_MEGARAID_MM=m
Expand All @@ -457,6 +456,7 @@ CONFIG_MMC_BLOCK_MINORS=16
CONFIG_MMC_SDHCI=m
CONFIG_MMC_SDHCI_PCI=m
CONFIG_MODULES=y
CONFIG_MODULE_COMPRESS=y
CONFIG_MODULE_COMPRESS_XZ=y
CONFIG_MODULE_SIG=y
CONFIG_MODULE_SIG_KEY="certs/modules.pem"
Expand Down Expand Up @@ -555,7 +555,6 @@ CONFIG_NET_9P_RDMA=m
CONFIG_NET_9P_VIRTIO=m
CONFIG_NET_ACT_CSUM=m
CONFIG_NET_ACT_GACT=m
CONFIG_NET_ACT_IPT=m
CONFIG_NET_ACT_MIRRED=m
CONFIG_NET_ACT_NAT=m
CONFIG_NET_ACT_PEDIT=m
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
DIST linux-6.6.tar.xz 140064536 BLAKE2B 5f02fd8696d42f7ec8c5fbadec8e7270bdcfcb1f9844a6c4db3e1fd461c93ce1ccda650ca72dceb4890ebcbbf768ba8fba0bce91efc49fbd2c307b04e95665f2 SHA512 458b2c34d46206f9b4ccbac54cc57aeca1eaecaf831bc441e59701bac6eadffc17f6ce24af6eadd0454964e843186539ac0d63295ad2cc32d112b60360c39a35
DIST patch-6.6.75.xz 3746436 BLAKE2B 341eef5843e45bde810560b3a6e9c0460decc553aba28b5a1fa65c90130703fd2299aeaf2cc850948301e8869774920cbb05eeebc6bfb3098f4601b07da4a583 SHA512 f2a2faf11ec041b21fa9ea1033046c631d6e7e49d75842cad1d6ec282bf4e57107035c38e165a3ba91c1e6b0fe494cc1e1117be60be1943fd2e039c3e6faa305
DIST linux-6.12.tar.xz 147906904 BLAKE2B b2ec2fc69218cacabbbe49f78384a5d259ca581b717617c12b000b16f4a4c59ee348ea886b37147f5f70fb9a7a01c1e2c8f19021078f6b23f5bc62d1c48d5e5e SHA512 a37b1823df7b4f72542f689b65882634740ba0401a42fdcf6601d9efd2e132e5a7650e70450ba76f6cd1f13ca31180f2ccee9d54fe4df89bc0000ade4380a548
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2014 CoreOS, Inc.
# Distributed under the terms of the GNU General Public License v2

EAPI=7
ETYPE="sources"

# -rc releases should be versioned L.M_rcN
# Final releases should be versioned L.M.N, even for N == 0

# Only needed for RCs
K_BASE_VER="5.15"

inherit kernel-2
EXTRAVERSION="-flatcar"
detect_version

DESCRIPTION="Full sources for the CoreOS Linux kernel"
HOMEPAGE="http://www.kernel.org"
if [[ "${PV%%_rc*}" != "${PV}" ]]; then
SRC_URI="https://git.kernel.org/torvalds/p/v${KV%-coreos}/v${OKV} -> patch-${KV%-coreos}.patch ${KERNEL_BASE_URI}/linux-${OKV}.tar.xz"
PATCH_DIR="${FILESDIR}/${KV_MAJOR}.${KV_PATCH}"
else
SRC_URI="${KERNEL_URI}"
PATCH_DIR="${FILESDIR}/${KV_MAJOR}.${KV_MINOR}"
fi

# make modules_prepare depends on pahole
RDEPEND="dev-util/pahole"

KEYWORDS="amd64 arm64"
IUSE=""

# XXX: Note we must prefix the patch filenames with "z" to ensure they are
# applied _after_ a potential patch-${KV}.patch file, present when building a
# patchlevel revision. We mustn't apply our patches first, it fails when the
# local patches overlap with the upstream patch.
UNIPATCH_LIST="
${PATCH_DIR}/z0001-kbuild-derive-relative-path-for-srctree-from-CURDIR.patch \
${PATCH_DIR}/z0002-pahole-support-reproducible-builds.patch \
${PATCH_DIR}/z0003-Revert-x86-boot-Remove-the-bugger-off-message.patch \
${PATCH_DIR}/z0004-efi-add-an-efi_secure_boot-flag-to-indicate-secure-b.patch \
${PATCH_DIR}/z0005-efi-lock-down-the-kernel-if-booted-in-secure-boot-mo.patch \
${PATCH_DIR}/z0006-mtd-disable-slram-and-phram-when-locked-down.patch \
${PATCH_DIR}/z0007-arm64-add-kernel-config-option-to-lock-down-when.patch \
${PATCH_DIR}/z0008-tools-hv-fix-cross-compilation-for-ARM64.patch \
"
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 9faff3734e6456e7927c0914829a4764ec9f1b44 Mon Sep 17 00:00:00 2001
From: Adrian Vladu <avladu@cloudbasesolutions.com>
Date: Tue, 17 Sep 2024 13:44:14 +0000
Subject: [PATCH] pahole: support reproducible builds

---
scripts/Makefile.btf | 3 +++
1 file changed, 3 insertions(+)

diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf
index 2d6e5ed9081e..b2f88b0fcf37 100644
--- a/scripts/Makefile.btf
+++ b/scripts/Makefile.btf
@@ -23,6 +23,9 @@ else
# Switch to using --btf_features for v1.26 and later.
pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func

+# Support reproducible builds.
+pahole-flags-$(call test-ge, $(pahole-ver), 127) = -j --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,reproducible_build
+
endif

pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE) += --lang_exclude=rust
--
2.34.1

Loading
Loading