From cd0f56e122cb15a95f6b34ad239b5144094c9060 Mon Sep 17 00:00:00 2001 From: Nico Berlee Date: Sat, 18 Nov 2023 16:15:18 +0100 Subject: [PATCH] feat: adds board Turing RK1 Adds board Turing RK1 (rk3588) board support Add kernel module check for 6.6 Temporary alternative u-boot & kernel image Signed-off-by: Nico Berlee --- Dockerfile | 2 +- Makefile | 6 +- hack/modules-amd64.txt | 50 +++++++++- hack/modules-arm64.txt | 50 ++++++++++ .../pkg/runtime/v1alpha1/board/board.go | 3 + .../v1alpha1/board/turing_rk1/turing_rk1.go | 94 +++++++++++++++++++ pkg/imager/profile/default.go | 14 +++ pkg/machinery/constants/constants.go | 5 +- 8 files changed, 217 insertions(+), 7 deletions(-) create mode 100644 internal/app/machined/pkg/runtime/v1alpha1/board/turing_rk1/turing_rk1.go diff --git a/Dockerfile b/Dockerfile index 23fa0263e2c..f7618a00c16 100644 --- a/Dockerfile +++ b/Dockerfile @@ -82,7 +82,7 @@ FROM ${PKG_KERNEL} AS pkg-kernel FROM --platform=amd64 ${PKG_KERNEL} AS pkg-kernel-amd64 FROM --platform=arm64 ${PKG_KERNEL} AS pkg-kernel-arm64 -FROM --platform=arm64 ghcr.io/siderolabs/u-boot:${PKGS} AS pkg-u-boot-arm64 +FROM --platform=arm64 ghcr.io/nberlee/u-boot:v1.6.0-3-gcb3e668-dirty AS pkg-u-boot-arm64 FROM --platform=arm64 ghcr.io/siderolabs/raspberrypi-firmware:${PKGS} AS pkg-raspberrypi-firmware-arm64 # Resolve package images using ${EXTRAS} to be used later in COPY --from=. diff --git a/Makefile b/Makefile index 735179e2147..800dead4e40 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,8 @@ CLOUD_IMAGES_EXTRA_ARGS ?= "" ARTIFACTS := _out TOOLS ?= ghcr.io/siderolabs/tools:v1.6.0-1-g336d248 PKGS ?= v1.6.0-3-g617d342 -PKG_KERNEL ?= ghcr.io/siderolabs/kernel:$(PKGS) EXTRAS ?= v1.6.0-1-g113887a +PKG_KERNEL ?= ghcr.io/nberlee/kernel:v1.6.0-3-gcb3e668 # renovate: datasource=github-tags depName=golang/go GO_VERSION ?= 1.21 # renovate: datasource=go depName=golang.org/x/tools @@ -317,11 +317,11 @@ images-essential: image-aws image-gcp image-metal secureboot-installer ## Builds images: image-aws image-azure image-digital-ocean image-exoscale image-gcp image-hcloud image-iso image-metal image-nocloud image-openstack image-oracle image-scaleway image-upcloud image-vmware image-vultr ## Builds all known images (AWS, Azure, DigitalOcean, Exoscale, GCP, HCloud, Metal, NoCloud, Openstack, Oracle, Scaleway, UpCloud, Vultr and VMware). -sbc-%: ## Builds the specified SBC image. Valid options are rpi_generic, rock64, bananapi_m64, libretech_all_h3_cc_h5, rockpi_4, rockpi_4c, pine64, jetson_nano and nanopi_r4s (e.g. sbc-rpi_generic) +sbc-%: ## Builds the specified SBC image. Valid options are rpi_generic, rock64, bananapi_m64, libretech_all_h3_cc_h5, rockpi_4, rockpi_4c, pine64, jetson_nano, nanopi_r4s and turing_rk1 (e.g. sbc-rpi_generic) @docker pull $(REGISTRY_AND_USERNAME)/imager:$(IMAGE_TAG) @docker run --rm -t -v /dev:/dev -v $(PWD)/$(ARTIFACTS):/out --network=host --privileged $(REGISTRY_AND_USERNAME)/imager:$(IMAGE_TAG) $* --arch arm64 $(IMAGER_ARGS) -sbcs: sbc-rpi_generic sbc-rock64 sbc-bananapi_m64 sbc-libretech_all_h3_cc_h5 sbc-rockpi_4 sbc-rockpi_4c sbc-pine64 sbc-jetson_nano sbc-nanopi_r4s ## Builds all known SBC images (Raspberry Pi 4, Rock64, Banana Pi M64, Radxa ROCK Pi 4, Radxa ROCK Pi 4c, Pine64, Libre Computer Board ALL-H3-CC, Jetson Nano and Nano Pi R4S). +sbcs: sbc-rpi_generic sbc-rock64 sbc-bananapi_m64 sbc-libretech_all_h3_cc_h5 sbc-rockpi_4 sbc-rockpi_4c sbc-pine64 sbc-jetson_nano sbc-nanopi_r4s sbc-turing_rk1 ## Builds all known SBC images (Raspberry Pi 4, Rock64, Banana Pi M64, Radxa ROCK Pi 4, Radxa ROCK Pi 4c, Pine64, Libre Computer Board ALL-H3-CC, Jetson Nano and Nano Pi R4S). .PHONY: iso iso: image-iso ## Builds the ISO and outputs it to the artifact directory. diff --git a/hack/modules-amd64.txt b/hack/modules-amd64.txt index a343f5b4c6e..22ad2b6e701 100644 --- a/hack/modules-amd64.txt +++ b/hack/modules-amd64.txt @@ -6,7 +6,10 @@ kernel/crypto/async_tx/async_pq.ko kernel/crypto/async_tx/async_raid6_recov.ko kernel/crypto/async_tx/async_tx.ko kernel/crypto/async_tx/async_xor.ko +kernel/crypto/blake2b_generic.ko kernel/crypto/xor.ko +kernel/crypto/xxhash_generic.ko +kernel/crypto/zstd.ko kernel/drivers/hwmon/fam15h_power.ko kernel/drivers/hwmon/i5500_temp.ko kernel/drivers/hwmon/i5k_amb.ko @@ -25,6 +28,11 @@ kernel/drivers/net/ethernet/atheros/alx/alx.ko kernel/drivers/net/ethernet/broadcom/bnx2.ko kernel/drivers/net/ethernet/broadcom/bnx2x/bnx2x.ko kernel/drivers/net/ethernet/broadcom/bnxt/bnxt_en.ko +kernel/drivers/net/ethernet/chelsio/cxgb/cxgb.ko +kernel/drivers/net/ethernet/chelsio/cxgb3/cxgb3.ko +kernel/drivers/net/ethernet/chelsio/cxgb4/cxgb4.ko +kernel/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf.ko +kernel/drivers/net/ethernet/chelsio/inline_crypto/ch_ipsec/ch_ipsec.ko kernel/drivers/net/ethernet/cisco/enic/enic.ko kernel/drivers/net/ethernet/emulex/benet/be2net.ko kernel/drivers/net/ethernet/google/gve/gve.ko @@ -37,7 +45,6 @@ kernel/drivers/net/ethernet/intel/ice/ice.ko kernel/drivers/net/ethernet/intel/igb/igb.ko kernel/drivers/net/ethernet/intel/igbvf/igbvf.ko kernel/drivers/net/ethernet/intel/igc/igc.ko -kernel/drivers/net/ethernet/intel/ixgb/ixgb.ko kernel/drivers/net/ethernet/intel/ixgbe/ixgbe.ko kernel/drivers/net/ethernet/intel/ixgbevf/ixgbevf.ko kernel/drivers/net/ethernet/marvell/sky2.ko @@ -57,6 +64,38 @@ kernel/drivers/net/ethernet/realtek/8139too.ko kernel/drivers/net/ethernet/realtek/r8169.ko kernel/drivers/net/ethernet/sfc/siena/sfc-siena.ko kernel/drivers/net/mdio.ko +kernel/drivers/net/phy/ax88796b.ko +kernel/drivers/net/phy/smsc.ko +kernel/drivers/net/thunderbolt/thunderbolt_net.ko +kernel/drivers/net/usb/aqc111.ko +kernel/drivers/net/usb/asix.ko +kernel/drivers/net/usb/ax88179_178a.ko +kernel/drivers/net/usb/cdc-phonet.ko +kernel/drivers/net/usb/cdc_eem.ko +kernel/drivers/net/usb/cdc_ether.ko +kernel/drivers/net/usb/cdc_mbim.ko +kernel/drivers/net/usb/cdc_ncm.ko +kernel/drivers/net/usb/cdc_subset.ko +kernel/drivers/net/usb/cx82310_eth.ko +kernel/drivers/net/usb/dm9601.ko +kernel/drivers/net/usb/gl620a.ko +kernel/drivers/net/usb/huawei_cdc_ncm.ko +kernel/drivers/net/usb/int51x1.ko +kernel/drivers/net/usb/kalmia.ko +kernel/drivers/net/usb/lg-vl600.ko +kernel/drivers/net/usb/mcs7830.ko +kernel/drivers/net/usb/net1080.ko +kernel/drivers/net/usb/plusb.ko +kernel/drivers/net/usb/qmi_wwan.ko +kernel/drivers/net/usb/r8153_ecm.ko +kernel/drivers/net/usb/rndis_host.ko +kernel/drivers/net/usb/sierra_net.ko +kernel/drivers/net/usb/smsc75xx.ko +kernel/drivers/net/usb/smsc95xx.ko +kernel/drivers/net/usb/sr9700.ko +kernel/drivers/net/usb/sr9800.ko +kernel/drivers/net/usb/usbnet.ko +kernel/drivers/net/usb/zaurus.ko kernel/drivers/net/vmxnet3/vmxnet3.ko kernel/drivers/scsi/aacraid/aacraid.ko kernel/drivers/scsi/hpsa.ko @@ -64,14 +103,21 @@ kernel/drivers/scsi/megaraid/megaraid_sas.ko kernel/drivers/scsi/mpt3sas/mpt3sas.ko kernel/drivers/scsi/smartpqi/smartpqi.ko kernel/drivers/scsi/vmw_pvscsi.ko +kernel/drivers/thunderbolt/thunderbolt.ko +kernel/drivers/usb/class/cdc-wdm.ko +kernel/drivers/usb/serial/option.ko +kernel/drivers/usb/serial/usb_wwan.ko kernel/drivers/virtio/virtio_balloon.ko kernel/drivers/virtio/virtio_input.ko kernel/drivers/virtio/virtio_mmio.ko +kernel/drivers/virtio/virtio_pci.ko kernel/drivers/virtio/virtio_pci_legacy_dev.ko kernel/drivers/virtio/virtio_pci_modern_dev.ko -kernel/drivers/virtio/virtio_pci.ko +kernel/fs/binfmt_misc.ko +kernel/fs/btrfs/btrfs.ko kernel/lib/objagg.ko kernel/lib/parman.ko kernel/lib/raid6/raid6_pq.ko +kernel/lib/zstd/zstd_compress.ko kernel/net/ipv4/ip_gre.ko kernel/net/openvswitch/vport-gre.ko diff --git a/hack/modules-arm64.txt b/hack/modules-arm64.txt index 2061b9e62d9..ac3e8e357e8 100644 --- a/hack/modules-arm64.txt +++ b/hack/modules-arm64.txt @@ -1,12 +1,17 @@ modules.order modules.builtin modules.builtin.modinfo +kernel/arch/arm64/lib/xor-neon.ko kernel/crypto/async_tx/async_memcpy.ko kernel/crypto/async_tx/async_pq.ko kernel/crypto/async_tx/async_raid6_recov.ko kernel/crypto/async_tx/async_tx.ko kernel/crypto/async_tx/async_xor.ko +kernel/crypto/blake2b_generic.ko kernel/crypto/xor.ko +kernel/crypto/xxhash_generic.ko +kernel/crypto/zstd.ko +kernel/drivers/dma/bcm-sba-raid.ko kernel/drivers/hwmon/i5k_amb.ko kernel/drivers/infiniband/sw/rxe/rdma_rxe.ko kernel/drivers/irqchip/irq-imx-mu-msi.ko @@ -19,6 +24,11 @@ kernel/drivers/md/dm-thin-pool.ko kernel/drivers/md/persistent-data/dm-persistent-data.ko kernel/drivers/md/raid456.ko kernel/drivers/net/ethernet/atheros/alx/alx.ko +kernel/drivers/net/ethernet/chelsio/cxgb/cxgb.ko +kernel/drivers/net/ethernet/chelsio/cxgb3/cxgb3.ko +kernel/drivers/net/ethernet/chelsio/cxgb4/cxgb4.ko +kernel/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf.ko +kernel/drivers/net/ethernet/chelsio/inline_crypto/ch_ipsec/ch_ipsec.ko kernel/drivers/net/ethernet/google/gve/gve.ko kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_core.ko kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko @@ -30,8 +40,48 @@ kernel/drivers/net/ethernet/mellanox/mlxsw/mlxsw_minimal.ko kernel/drivers/net/ethernet/mellanox/mlxsw/mlxsw_pci.ko kernel/drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko kernel/drivers/net/ethernet/sfc/siena/sfc-siena.ko +kernel/drivers/net/mdio/mdio-mux-meson-gxl.ko +kernel/drivers/net/phy/ax88796b.ko +kernel/drivers/net/thunderbolt/thunderbolt_net.ko +kernel/drivers/net/usb/aqc111.ko +kernel/drivers/net/usb/asix.ko +kernel/drivers/net/usb/ax88179_178a.ko +kernel/drivers/net/usb/cdc-phonet.ko +kernel/drivers/net/usb/cdc_eem.ko +kernel/drivers/net/usb/cdc_ether.ko +kernel/drivers/net/usb/cdc_mbim.ko +kernel/drivers/net/usb/cdc_ncm.ko +kernel/drivers/net/usb/cdc_subset.ko +kernel/drivers/net/usb/ch9200.ko +kernel/drivers/net/usb/cx82310_eth.ko +kernel/drivers/net/usb/dm9601.ko +kernel/drivers/net/usb/gl620a.ko +kernel/drivers/net/usb/huawei_cdc_ncm.ko +kernel/drivers/net/usb/int51x1.ko +kernel/drivers/net/usb/kalmia.ko +kernel/drivers/net/usb/lg-vl600.ko +kernel/drivers/net/usb/mcs7830.ko +kernel/drivers/net/usb/net1080.ko +kernel/drivers/net/usb/plusb.ko +kernel/drivers/net/usb/qmi_wwan.ko +kernel/drivers/net/usb/r8153_ecm.ko +kernel/drivers/net/usb/rndis_host.ko +kernel/drivers/net/usb/sierra_net.ko +kernel/drivers/net/usb/smsc75xx.ko +kernel/drivers/net/usb/smsc95xx.ko +kernel/drivers/net/usb/sr9700.ko +kernel/drivers/net/usb/sr9800.ko +kernel/drivers/net/usb/usbnet.ko +kernel/drivers/net/usb/zaurus.ko +kernel/drivers/thunderbolt/thunderbolt.ko +kernel/drivers/usb/class/cdc-wdm.ko +kernel/drivers/usb/serial/option.ko +kernel/drivers/usb/serial/usb_wwan.ko +kernel/fs/binfmt_misc.ko +kernel/fs/btrfs/btrfs.ko kernel/lib/objagg.ko kernel/lib/parman.ko kernel/lib/raid6/raid6_pq.ko +kernel/lib/zstd/zstd_compress.ko kernel/net/ipv4/ip_gre.ko kernel/net/openvswitch/vport-gre.ko diff --git a/internal/app/machined/pkg/runtime/v1alpha1/board/board.go b/internal/app/machined/pkg/runtime/v1alpha1/board/board.go index 743655caa7d..3fd3fe07883 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/board/board.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/board/board.go @@ -22,6 +22,7 @@ import ( rockpi4 "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/rockpi4" rockpi4c "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/rockpi4c" rpigeneric "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/rpi_generic" + turingrk1 "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/turing_rk1" "github.com/siderolabs/talos/pkg/machinery/constants" ) @@ -70,6 +71,8 @@ func newBoard(board string) (b runtime.Board, err error) { b = &jetsonnano.JetsonNano{} case constants.BoardNanoPiR4S: b = &nanopir4s.NanoPiR4S{} + case constants.BoardTuringRK1: + b = &turingrk1.TuringRK1{} default: return nil, fmt.Errorf("unsupported board: %q", board) } diff --git a/internal/app/machined/pkg/runtime/v1alpha1/board/turing_rk1/turing_rk1.go b/internal/app/machined/pkg/runtime/v1alpha1/board/turing_rk1/turing_rk1.go new file mode 100644 index 00000000000..4cee4e99f02 --- /dev/null +++ b/internal/app/machined/pkg/runtime/v1alpha1/board/turing_rk1/turing_rk1.go @@ -0,0 +1,94 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Package TuringRK1 provides the Turing RK1 implementation. +package TuringRK1 + +import ( + "os" + "path/filepath" + + "github.com/siderolabs/go-procfs/procfs" + "golang.org/x/sys/unix" + + "github.com/siderolabs/talos/internal/app/machined/pkg/runtime" + "github.com/siderolabs/talos/pkg/copy" + "github.com/siderolabs/talos/pkg/machinery/constants" +) + +var ( + bin = constants.BoardTuringRK1 + "/u-boot-rockchip.bin" + off int64 = 512 * 64 + dtb = "rockchip/rk3588-turing-rk1.dtb" +) + +// TuringRK1 represents the Turing RK1 board. +// +// Reference: https://rockpi.org/ +type TuringRK1 struct{} + +// Name implements the runtime.Board. +func (r *TuringRK1) Name() string { + return constants.BoardTuringRK1 +} + +// Install implements the runtime.Board. +func (r *TuringRK1) Install(options runtime.BoardInstallOptions) (err error) { + var f *os.File + + if f, err = os.OpenFile(options.InstallDisk, os.O_RDWR|unix.O_CLOEXEC, 0o666); err != nil { + return err + } + + defer f.Close() //nolint:errcheck + + uboot, err := os.ReadFile(filepath.Join(options.UBootPath, bin)) + if err != nil { + return err + } + + options.Printf("writing %s at offset %d", bin, off) + + var n int + + n, err = f.WriteAt(uboot, off) + if err != nil { + return err + } + + options.Printf("wrote %d bytes", n) + + // NB: In the case that the block device is a loopback device, we sync here + // to esure that the file is written before the loopback device is + // unmounted. + err = f.Sync() + if err != nil { + return err + } + + src := filepath.Join(options.DTBPath, dtb) + dst := filepath.Join("/boot/EFI/dtb", dtb) + + err = os.MkdirAll(filepath.Dir(dst), 0o600) + if err != nil { + return err + } + + return copy.File(src, dst) +} + +// KernelArgs implements the runtime.Board. +func (r *TuringRK1) KernelArgs() procfs.Parameters { + return []*procfs.Parameter{ + procfs.NewParameter("console").Append("tty0").Append("ttyS0,115200").Append("ttyS2,115200"), + procfs.NewParameter("sysctl.kernel.kexec_load_disabled").Append("1"), + procfs.NewParameter(constants.KernelParamDashboardDisabled).Append("1"), + procfs.NewParameter("irqchip.gicv3_pseudo_nmi").Append("0"), + } +} + +// PartitionOptions implements the runtime.Board. +func (r *TuringRK1) PartitionOptions() *runtime.PartitionOptions { + return &runtime.PartitionOptions{PartitionsOffset: 2048 * 10} +} diff --git a/pkg/imager/profile/default.go b/pkg/imager/profile/default.go index a08401291cc..1137064e2e6 100644 --- a/pkg/imager/profile/default.go +++ b/pkg/imager/profile/default.go @@ -367,4 +367,18 @@ var Default = map[string]Profile{ }, }, }, + constants.BoardTuringRK1: { + Arch: "arm64", + Platform: constants.PlatformMetal, + Board: constants.BoardTuringRK1, + SecureBoot: pointer.To(false), + Output: Output{ + Kind: OutKindImage, + OutFormat: OutFormatXZ, + ImageOptions: &ImageOptions{ + DiskSize: MinRAWDiskSize, + DiskFormat: DiskFormatRaw, + }, + }, + }, } diff --git a/pkg/machinery/constants/constants.go b/pkg/machinery/constants/constants.go index ba3b74a3d86..078da2022d1 100644 --- a/pkg/machinery/constants/constants.go +++ b/pkg/machinery/constants/constants.go @@ -16,7 +16,7 @@ import ( const ( // DefaultKernelVersion is the default Linux kernel version. - DefaultKernelVersion = "6.1.65-talos" + DefaultKernelVersion = "6.6.5-talos" // KernelModulesPath is the default path to the kernel modules without the kernel version. KernelModulesPath = "/lib/modules" @@ -112,6 +112,9 @@ const ( // BoardNanoPiR4S is the name of the Friendlyelec Nano Pi R4S. BoardNanoPiR4S = "nanopi_r4s" + // BoardTuringRK1 is the name of the Turing Pi RK1 board. + BoardTuringRK1 = "turing_rk1" + // KernelParamHostname is the kernel parameter name for specifying the // hostname. KernelParamHostname = "talos.hostname"