Skip to content

Commit 327266f

Browse files
joshdmoorefrezbo
authored andcommitted
feat: add ROCK 5A support
Add Rock 5A support. Signed-off-by: Noel Georgi <[email protected]>
1 parent 0f72371 commit 327266f

File tree

14 files changed

+215
-1
lines changed

14 files changed

+215
-1
lines changed

MAINTAINERS.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ This document contains a list of maintainers in this repo. For now, you become a
1818
| rockpi4c | Rock Pi 4C | [#1](https://github.com/siderolabs/sbc-rockchip/pull/1) | RK3399 | TBD (Initial PR moved from pkgs) | TBD |
1919
| rock4cplus | Radxa ROCK 4C+ | [#5](https://github.com/siderolabs/sbc-rockchip/pull/5) | RK3399 | Damià Poquet Femenia | [DamiaPoquet](https://github.com/DamiaPoquet) |
2020
| rock4se | Radxa ROCK 4SE | [#18](https://github.com/siderolabs/sbc-rockchip/pull/18) | RK3399 | Boran Car | [borancar](https://github.com/borancar) |
21+
| rock5a | Radxa ROCK 5A | [#51](https://github.com/siderolabs/sbc-rockchip/pull/51) | RK3588 | Josh Moore | [joshdmoore](https://github.com/joshdmoore) |
2122
| rock5b | Radxa ROCK 5B | [#45](https://github.com/siderolabs/sbc-rockchip/pull/45) | RK3588 | Christoph Hoopmann | [choopm](https://github.com/choopm) |
2223
| helios64 | Kobol Helios64 | [#23](https://github.com/siderolabs/sbc-rockchip/pull/23) | RK3399 | Hemanth Bollamreddi | [blmhemu](https://github.com/blmhemu) |

Pkgfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ vars:
1818
uboot_sha512: 678f44e2b9132140f0bf05c637e57e638c73c278611037a41824b3ebff2131af4dec0163da4664bb2e5c4fd8034ba8c95b93b57f7aa9f4c045da322d87c3b5e9
1919

2020
# renovate: datasource=github-tags extractVersion=^v(?<version>.*)$ depName=u-boot/u-boot
21-
uboot_rk1_version: 2024.10
21+
uboot_rk1_version: 2025.01
2222
uboot_rk1_sha256: b28daf4ac17e43156363078bf510297584137f6df50fced9b12df34f61a92fb0
2323
uboot_rk1_sha512: ef817c9b5ae8dc6cd9e3f57811e90acc6a4d4394f0356aa5923e3e3c8559168f977bd5bf82824cd3650aa8e5e3c3d1b00e20818d21368151748682f1fc51152c
2424

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ This repo provides the overlay for RockChip based Talos image.
1616
| rockpi4c | Rock Pi 4C | RK3399 | Overlay for Rock Pi 4C |
1717
| rock4se | Rock 4 SE | RK3399 | Overlay for Rock 4 SE |
1818
| rock4cplus | Radxa ROCK 4C+ | RK3399 | Overlay for Radxa ROCK 4C+ |
19+
| rock5a | Radxa ROCK 5A | RK3588s | Overlay for Radxa ROCK 5A |
1920
| rock5b | Radxa ROCK 5B | RK3588 | Overlay for Radxa ROCK 5B |
2021
| turingrk1 | Turing Machines RK1 | RK3588 | Overlay for Turing Machines RK1 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
2+
index a4cb3bfde5..0ecd088f4a 100644
3+
--- a/include/linux/byteorder/little_endian.h
4+
+++ b/include/linux/byteorder/little_endian.h
5+
@@ -7,7 +7,10 @@
6+
#ifndef __LITTLE_ENDIAN_BITFIELD
7+
#define __LITTLE_ENDIAN_BITFIELD
8+
#endif
9+
+
10+
+#ifndef __BYTE_ORDER
11+
#define __BYTE_ORDER __LITTLE_ENDIAN
12+
+#endif
13+
14+
#include <linux/compiler.h>
15+
#include <linux/types.h>

artifacts/rock5a/u-boot/pkg.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# References:
2+
# U-Boot:
3+
# - https://u-boot.readthedocs.io/en/latest
4+
name: u-boot-rock5a
5+
variant: scratch
6+
shell: /toolchain/bin/bash
7+
dependencies:
8+
- stage: base
9+
- stage: arm-trusted-firmware-rk3588
10+
- stage: rkbin-rk3588
11+
platform: linux/amd64
12+
steps:
13+
- sources:
14+
- url: https://ftp.denx.de/pub/u-boot/u-boot-{{ .uboot_rk1_version }}.tar.bz2
15+
destination: u-boot.tar.bz2
16+
sha256: "{{ .uboot_rk1_sha256 }}"
17+
sha512: "{{ .uboot_rk1_sha512 }}"
18+
env:
19+
SOURCE_DATE_EPOCH: {{ .BUILD_ARG_SOURCE_DATE_EPOCH }}
20+
prepare:
21+
# rock-5a-rk3588s
22+
- |
23+
mkdir -p /usr/bin \
24+
&& ln -sf /toolchain/bin/env /usr/bin/env \
25+
&& ln -sf /toolchain/bin/python3 /toolchain/bin/python
26+
27+
pip3 install pyelftools setuptools \
28+
&& ln -sf /toolchain/bin/python3 /toolchain/bin/python
29+
30+
tar xf u-boot.tar.bz2 --strip-components=1
31+
32+
patch -p1 < /pkg/patches/uboot-byteorder.patch
33+
- |
34+
make rock5a-rk3588s_defconfig
35+
build:
36+
- |
37+
make -j $(nproc) HOSTLDLIBS_mkimage="-lssl -lcrypto" BL31=/libs/arm-trusted-firmware/rk3588/bl31.elf ROCKCHIP_TPL=/libs/rkbin/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.18.bin
38+
install:
39+
- |
40+
mkdir -p /rootfs/artifacts/arm64/u-boot/rock5a
41+
cp u-boot-rockchip.bin /rootfs/artifacts/arm64/u-boot/rock5a
42+
finalize:
43+
- from: /rootfs
44+
to: /rootfs

artifacts/rock5a/vars.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# renovate: datasource=docker versioning=docker depName=cgr.dev/chainguard/wolfi-base
2+
WOLFI_BASE_REF: sha256:8dd9ceace8b1574e550374e9c07c2baafa60cc96223c1314fac61bd2edb48c70

go.work

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use (
1111
./installers/rockpi4c/src
1212
./installers/rock4cplus/src
1313
./installers/rock4se/src
14+
./installers/rock5a/src
1415
./installers/rock5b/src
1516
./installers/turingrk1/src
1617
)

installers/pkg.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies:
1212
- stage: rockpi4c
1313
- stage: rock4cplus
1414
- stage: rock4se
15+
- stage: rock5a
1516
- stage: rock5b
1617
- stage: turingrk1
1718
- stage: profiles
@@ -35,6 +36,8 @@ dependencies:
3536
platform: linux/arm64
3637
- stage: u-boot-rock4se
3738
platform: linux/arm64
39+
- stage: u-boot-rock5a
40+
platform: linux/arm64
3841
- stage: u-boot-rock5b
3942
platform: linux/arm64
4043
- stage: u-boot-turingrk1
@@ -79,6 +82,10 @@ dependencies:
7982
platform: linux/arm64
8083
from: /dtb/rockchip/rk3399-rock-4se.dtb
8184
to: /rootfs/artifacts/arm64/dtb/rockchip/rk3399-rock-4se.dtb
85+
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}"
86+
platform: linux/arm64
87+
from: /dtb/rockchip/rk3588s-rock-5a.dtb
88+
to: /rootfs/artifacts/arm64/dtb/rockchip/rk3588s-rock-5a.dtb
8289
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}"
8390
platform: linux/arm64
8491
from: /dtb/rockchip/rk3588-rock-5b.dtb

installers/rock5a/pkg.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: rock5a
2+
variant: scratch
3+
shell: /toolchain/bin/bash
4+
dependencies:
5+
- stage: base
6+
steps:
7+
- env:
8+
GOPATH: /go
9+
cachePaths:
10+
- /.cache/go-build
11+
- /go/pkg
12+
build:
13+
- |
14+
export PATH=${PATH}:${TOOLCHAIN}/go/bin
15+
16+
cd /pkg/src
17+
CGO_ENABLED=0 go build -o ./rock5a .
18+
install:
19+
- |
20+
mkdir -p /rootfs/installers/
21+
22+
cp /pkg/src/rock5a /rootfs/installers/rock5a
23+
finalize:
24+
- from: /rootfs
25+
to: /rootfs

installers/rock5a/src/go.mod

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module rock5a
2+
3+
go 1.23.0
4+
5+
require (
6+
github.com/siderolabs/go-copy v0.1.0
7+
github.com/siderolabs/talos/pkg/machinery v1.8.3
8+
golang.org/x/sys v0.27.0
9+
)
10+
11+
require gopkg.in/yaml.v3 v3.0.1 // indirect

installers/rock5a/src/go.sum

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/siderolabs/go-copy v0.1.0 h1:OIWCtSg+rhOtnIZTpT31Gfpn17rv5kwJqQHG+QUEgC8=
2+
github.com/siderolabs/go-copy v0.1.0/go.mod h1:4bF2rZOZAR/ags/U4AVSpjFE5RPGdEeSkOq6yR9YOkU=
3+
github.com/siderolabs/talos/pkg/machinery v1.8.3 h1:raK1oLzSMpwpy/AqkeFyBYkJS+QuOnlRMznVl/rZ25k=
4+
github.com/siderolabs/talos/pkg/machinery v1.8.3/go.mod h1:cNR2TELu2T9AzYOHAoNr/7ZS3ZVDLzM/KnuOr4XW4s4=
5+
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
6+
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
7+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
8+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
10+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

installers/rock5a/src/main.go

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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 main
6+
7+
import (
8+
_ "embed"
9+
"fmt"
10+
"os"
11+
"path/filepath"
12+
13+
"github.com/siderolabs/go-copy/copy"
14+
"github.com/siderolabs/talos/pkg/machinery/overlay"
15+
"github.com/siderolabs/talos/pkg/machinery/overlay/adapter"
16+
"golang.org/x/sys/unix"
17+
)
18+
19+
const (
20+
off int64 = 512 * 64
21+
board = "rock5a"
22+
dtb = "rockchip/rk3588s-rock-5a.dtb"
23+
)
24+
25+
func main() {
26+
adapter.Execute(&rock5a{})
27+
}
28+
29+
type rock5a struct{}
30+
31+
type rock5aExtraOptions struct{}
32+
33+
func (i *rock5a) GetOptions(extra rock5aExtraOptions) (overlay.Options, error) {
34+
return overlay.Options{
35+
Name: board,
36+
KernelArgs: []string{
37+
"cma=128MB",
38+
"console=tty0",
39+
"console=ttyS9,115200",
40+
"console=ttyS2,115200",
41+
"sysctl.kernel.kexec_load_disabled=1",
42+
"talos.dashboard.disabled=1",
43+
},
44+
PartitionOptions: overlay.PartitionOptions{
45+
Offset: 2048 * 10,
46+
},
47+
}, nil
48+
}
49+
50+
func (i *rock5a) Install(options overlay.InstallOptions[rock5aExtraOptions]) error {
51+
var f *os.File
52+
53+
f, err := os.OpenFile(options.InstallDisk, os.O_RDWR|unix.O_CLOEXEC, 0o666)
54+
if err != nil {
55+
return fmt.Errorf("failed to open %s: %w", options.InstallDisk, err)
56+
}
57+
58+
defer f.Close() //nolint:errcheck
59+
60+
uboot, err := os.ReadFile(filepath.Join(options.ArtifactsPath, "arm64/u-boot", board, "u-boot-rockchip.bin"))
61+
if err != nil {
62+
return err
63+
}
64+
65+
if _, err = f.WriteAt(uboot, off); err != nil {
66+
return err
67+
}
68+
69+
// NB: In the case that the block device is a loopback device, we sync here
70+
// to ensure that the file is written before the loopback device is
71+
// unmounted.
72+
err = f.Sync()
73+
if err != nil {
74+
return err
75+
}
76+
77+
src := filepath.Join(options.ArtifactsPath, "arm64/dtb", dtb)
78+
dst := filepath.Join(options.MountPrefix, "/boot/EFI/dtb", dtb)
79+
80+
err = os.MkdirAll(filepath.Dir(dst), 0o600)
81+
if err != nil {
82+
return err
83+
}
84+
85+
return copy.File(src, dst)
86+
}

profiles/pkg.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ finalize:
2121
to: /rootfs/profiles
2222
- from: /pkg/rock4se
2323
to: /rootfs/profiles
24+
- from: /pkg/rock5a
25+
to: /rootfs/profiles
2426
- from: /pkg/rock5b
2527
to: /rootfs/profiles
2628
- from: /pkg/turingrk1

profiles/rock5a/rock5a.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
arch: arm64
2+
platform: metal
3+
secureboot: false
4+
output:
5+
kind: image
6+
outFormat: .xz
7+
imageOptions:
8+
diskSize: 1306525696
9+
diskFormat: raw

0 commit comments

Comments
 (0)