Skip to content

Commit 461ae69

Browse files
committed
feat: support Turing RK1 board
Signed-off-by: Tom Plant <21111317+pl4nty@users.noreply.github.com>
1 parent d8a435f commit 461ae69

File tree

6 files changed

+112
-3
lines changed

6 files changed

+112
-3
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ FROM ${PKG_KERNEL} AS pkg-kernel
8282
FROM --platform=amd64 ${PKG_KERNEL} AS pkg-kernel-amd64
8383
FROM --platform=arm64 ${PKG_KERNEL} AS pkg-kernel-arm64
8484

85-
FROM --platform=arm64 ghcr.io/siderolabs/u-boot:${PKGS} AS pkg-u-boot-arm64
85+
FROM --platform=arm64 ghcr.io/pl4nty/u-boot:d3cadf7 AS pkg-u-boot-arm64
8686
FROM --platform=arm64 ghcr.io/siderolabs/raspberrypi-firmware:${PKGS} AS pkg-raspberrypi-firmware-arm64
8787

8888
# Resolve package images using ${EXTRAS} to be used later in COPY --from=.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,11 @@ images-essential: image-aws image-gcp image-metal secureboot-installer ## Builds
317317

318318
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).
319319

320-
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)
320+
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)
321321
@docker pull $(REGISTRY_AND_USERNAME)/imager:$(IMAGE_TAG)
322322
@docker run --rm -t -v /dev:/dev -v $(PWD)/$(ARTIFACTS):/out --network=host --privileged $(REGISTRY_AND_USERNAME)/imager:$(IMAGE_TAG) $* --arch arm64 $(IMAGER_ARGS)
323323

324-
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).
324+
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, Nano Pi R4S and Turing RK1).
325325

326326
.PHONY: iso
327327
iso: image-iso ## Builds the ISO and outputs it to the artifact directory.

internal/app/machined/pkg/runtime/v1alpha1/board/board.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
rockpi4 "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/rockpi4"
2323
rockpi4c "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/rockpi4c"
2424
rpigeneric "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/rpi_generic"
25+
turingrk1 "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/turing_rk1"
2526
"github.com/siderolabs/talos/pkg/machinery/constants"
2627
)
2728

@@ -70,6 +71,8 @@ func newBoard(board string) (b runtime.Board, err error) {
7071
b = &jetsonnano.JetsonNano{}
7172
case constants.BoardNanoPiR4S:
7273
b = &nanopir4s.NanoPiR4S{}
74+
case constants.BoardTuringRK1:
75+
b = &turingrk1.TuringRK1{}
7376
default:
7477
return nil, fmt.Errorf("unsupported board: %q", board)
7578
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
// Package turingrk1 provides the Turing RK1 board implementation.
6+
package turingrk1
7+
8+
import (
9+
"os"
10+
"path/filepath"
11+
12+
"github.com/siderolabs/go-procfs/procfs"
13+
"golang.org/x/sys/unix"
14+
15+
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
16+
"github.com/siderolabs/talos/pkg/copy"
17+
"github.com/siderolabs/talos/pkg/machinery/constants"
18+
)
19+
20+
var (
21+
bin = constants.BoardTuringRK1 + "/u-boot-rockchip.bin"
22+
off int64 = 512 * 64
23+
dtb = "rockchip/rk3588-turing-rk1.dtb"
24+
)
25+
26+
// TuringRK1 represents the Turing RK1 board.
27+
//
28+
// Reference: https://turingpi.com/product/turing-rk1/
29+
type TuringRK1 struct{}
30+
31+
// Name implements the runtime.Board.
32+
func (b *TuringRK1) Name() string {
33+
return constants.BoardTuringRK1
34+
}
35+
36+
// Install implements the runtime.Board.
37+
func (b *TuringRK1) Install(options runtime.BoardInstallOptions) (err error) {
38+
file, err := os.OpenFile(options.InstallDisk, os.O_RDWR|unix.O_CLOEXEC, 0o666)
39+
if err != nil {
40+
return err
41+
}
42+
43+
defer file.Close() //nolint:errcheck
44+
45+
uboot, err := os.ReadFile(filepath.Join(options.UBootPath, bin))
46+
if err != nil {
47+
return err
48+
}
49+
50+
options.Printf("writing %s at offset %d", bin, off)
51+
52+
amount, err := file.WriteAt(uboot, off)
53+
if err != nil {
54+
return err
55+
}
56+
57+
options.Printf("wrote %d bytes", amount)
58+
59+
// NB: In the case that the block device is a loopback device, we sync here
60+
// to esure that the file is written before the loopback device is
61+
// unmounted.
62+
if err := file.Sync(); err != nil {
63+
return err
64+
}
65+
66+
src := filepath.Join(options.DTBPath, dtb)
67+
dst := filepath.Join("/boot/EFI/dtb", dtb)
68+
69+
if err := os.MkdirAll(filepath.Dir(dst), 0o600); err != nil {
70+
return err
71+
}
72+
73+
return copy.File(src, dst)
74+
}
75+
76+
// KernelArgs implements the runtime.Board.
77+
func (n *TuringRK1) KernelArgs() procfs.Parameters {
78+
return []*procfs.Parameter{
79+
procfs.NewParameter("console").Append("tty0").Append("ttyS0,115200"),
80+
procfs.NewParameter("sysctl.kernel.kexec_load_disabled").Append("1"),
81+
procfs.NewParameter(constants.KernelParamDashboardDisabled).Append("1"),
82+
procfs.NewParameter("irqchip.gicv3_pseudo_nmi").Append("0"),
83+
}
84+
}
85+
86+
// PartitionOptions implements the runtime.Board.
87+
func (n *TuringRK1) PartitionOptions() *runtime.PartitionOptions {
88+
return &runtime.PartitionOptions{PartitionsOffset: 2048 * 10}
89+
}

pkg/imager/profile/default.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,18 @@ var Default = map[string]Profile{
367367
},
368368
},
369369
},
370+
constants.BoardTuringRK1: {
371+
Arch: "arm64",
372+
Platform: constants.PlatformMetal,
373+
Board: constants.BoardTuringRK1,
374+
SecureBoot: pointer.To(false),
375+
Output: Output{
376+
Kind: OutKindImage,
377+
OutFormat: OutFormatXZ,
378+
ImageOptions: &ImageOptions{
379+
DiskSize: MinRAWDiskSize,
380+
DiskFormat: DiskFormatRaw,
381+
},
382+
},
383+
},
370384
}

pkg/machinery/constants/constants.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ const (
112112
// BoardNanoPiR4S is the name of the Friendlyelec Nano Pi R4S.
113113
BoardNanoPiR4S = "nanopi_r4s"
114114

115+
// BoardTuringRK1 is the name of the Turing RK1.
116+
BoardTuringRK1 = "turing_rk1"
117+
115118
// KernelParamHostname is the kernel parameter name for specifying the
116119
// hostname.
117120
KernelParamHostname = "talos.hostname"

0 commit comments

Comments
 (0)