Skip to content

Commit

Permalink
feat: add ROCK 5A support
Browse files Browse the repository at this point in the history
Add Rock 5A support.

Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
joshdmoore authored and frezbo committed Jan 29, 2025
1 parent 0f72371 commit 327266f
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 1 deletion.
1 change: 1 addition & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ This document contains a list of maintainers in this repo. For now, you become a
| rockpi4c | Rock Pi 4C | [#1](https://github.com/siderolabs/sbc-rockchip/pull/1) | RK3399 | TBD (Initial PR moved from pkgs) | TBD |
| rock4cplus | Radxa ROCK 4C+ | [#5](https://github.com/siderolabs/sbc-rockchip/pull/5) | RK3399 | Damià Poquet Femenia | [DamiaPoquet](https://github.com/DamiaPoquet) |
| rock4se | Radxa ROCK 4SE | [#18](https://github.com/siderolabs/sbc-rockchip/pull/18) | RK3399 | Boran Car | [borancar](https://github.com/borancar) |
| rock5a | Radxa ROCK 5A | [#51](https://github.com/siderolabs/sbc-rockchip/pull/51) | RK3588 | Josh Moore | [joshdmoore](https://github.com/joshdmoore) |
| rock5b | Radxa ROCK 5B | [#45](https://github.com/siderolabs/sbc-rockchip/pull/45) | RK3588 | Christoph Hoopmann | [choopm](https://github.com/choopm) |
| helios64 | Kobol Helios64 | [#23](https://github.com/siderolabs/sbc-rockchip/pull/23) | RK3399 | Hemanth Bollamreddi | [blmhemu](https://github.com/blmhemu) |
2 changes: 1 addition & 1 deletion Pkgfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ vars:
uboot_sha512: 678f44e2b9132140f0bf05c637e57e638c73c278611037a41824b3ebff2131af4dec0163da4664bb2e5c4fd8034ba8c95b93b57f7aa9f4c045da322d87c3b5e9

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

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ This repo provides the overlay for RockChip based Talos image.
| rockpi4c | Rock Pi 4C | RK3399 | Overlay for Rock Pi 4C |
| rock4se | Rock 4 SE | RK3399 | Overlay for Rock 4 SE |
| rock4cplus | Radxa ROCK 4C+ | RK3399 | Overlay for Radxa ROCK 4C+ |
| rock5a | Radxa ROCK 5A | RK3588s | Overlay for Radxa ROCK 5A |
| rock5b | Radxa ROCK 5B | RK3588 | Overlay for Radxa ROCK 5B |
| turingrk1 | Turing Machines RK1 | RK3588 | Overlay for Turing Machines RK1 |
15 changes: 15 additions & 0 deletions artifacts/rock5a/u-boot/patches/uboot-byteorder.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
index a4cb3bfde5..0ecd088f4a 100644
--- a/include/linux/byteorder/little_endian.h
+++ b/include/linux/byteorder/little_endian.h
@@ -7,7 +7,10 @@
#ifndef __LITTLE_ENDIAN_BITFIELD
#define __LITTLE_ENDIAN_BITFIELD
#endif
+
+#ifndef __BYTE_ORDER
#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif

#include <linux/compiler.h>
#include <linux/types.h>
44 changes: 44 additions & 0 deletions artifacts/rock5a/u-boot/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# References:
# U-Boot:
# - https://u-boot.readthedocs.io/en/latest
name: u-boot-rock5a
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: base
- stage: arm-trusted-firmware-rk3588
- stage: rkbin-rk3588
platform: linux/amd64
steps:
- sources:
- url: https://ftp.denx.de/pub/u-boot/u-boot-{{ .uboot_rk1_version }}.tar.bz2
destination: u-boot.tar.bz2
sha256: "{{ .uboot_rk1_sha256 }}"
sha512: "{{ .uboot_rk1_sha512 }}"
env:
SOURCE_DATE_EPOCH: {{ .BUILD_ARG_SOURCE_DATE_EPOCH }}
prepare:
# rock-5a-rk3588s
- |
mkdir -p /usr/bin \
&& ln -sf /toolchain/bin/env /usr/bin/env \
&& ln -sf /toolchain/bin/python3 /toolchain/bin/python
pip3 install pyelftools setuptools \
&& ln -sf /toolchain/bin/python3 /toolchain/bin/python
tar xf u-boot.tar.bz2 --strip-components=1
patch -p1 < /pkg/patches/uboot-byteorder.patch
- |
make rock5a-rk3588s_defconfig
build:
- |
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
install:
- |
mkdir -p /rootfs/artifacts/arm64/u-boot/rock5a
cp u-boot-rockchip.bin /rootfs/artifacts/arm64/u-boot/rock5a
finalize:
- from: /rootfs
to: /rootfs
2 changes: 2 additions & 0 deletions artifacts/rock5a/vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# renovate: datasource=docker versioning=docker depName=cgr.dev/chainguard/wolfi-base
WOLFI_BASE_REF: sha256:8dd9ceace8b1574e550374e9c07c2baafa60cc96223c1314fac61bd2edb48c70
1 change: 1 addition & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use (
./installers/rockpi4c/src
./installers/rock4cplus/src
./installers/rock4se/src
./installers/rock5a/src
./installers/rock5b/src
./installers/turingrk1/src
)
7 changes: 7 additions & 0 deletions installers/pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
- stage: rockpi4c
- stage: rock4cplus
- stage: rock4se
- stage: rock5a
- stage: rock5b
- stage: turingrk1
- stage: profiles
Expand All @@ -35,6 +36,8 @@ dependencies:
platform: linux/arm64
- stage: u-boot-rock4se
platform: linux/arm64
- stage: u-boot-rock5a
platform: linux/arm64
- stage: u-boot-rock5b
platform: linux/arm64
- stage: u-boot-turingrk1
Expand Down Expand Up @@ -79,6 +82,10 @@ dependencies:
platform: linux/arm64
from: /dtb/rockchip/rk3399-rock-4se.dtb
to: /rootfs/artifacts/arm64/dtb/rockchip/rk3399-rock-4se.dtb
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}"
platform: linux/arm64
from: /dtb/rockchip/rk3588s-rock-5a.dtb
to: /rootfs/artifacts/arm64/dtb/rockchip/rk3588s-rock-5a.dtb
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}"
platform: linux/arm64
from: /dtb/rockchip/rk3588-rock-5b.dtb
Expand Down
25 changes: 25 additions & 0 deletions installers/rock5a/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: rock5a
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: base
steps:
- env:
GOPATH: /go
cachePaths:
- /.cache/go-build
- /go/pkg
build:
- |
export PATH=${PATH}:${TOOLCHAIN}/go/bin
cd /pkg/src
CGO_ENABLED=0 go build -o ./rock5a .
install:
- |
mkdir -p /rootfs/installers/
cp /pkg/src/rock5a /rootfs/installers/rock5a
finalize:
- from: /rootfs
to: /rootfs
11 changes: 11 additions & 0 deletions installers/rock5a/src/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module rock5a

go 1.23.0

require (
github.com/siderolabs/go-copy v0.1.0
github.com/siderolabs/talos/pkg/machinery v1.8.3
golang.org/x/sys v0.27.0
)

require gopkg.in/yaml.v3 v3.0.1 // indirect
10 changes: 10 additions & 0 deletions installers/rock5a/src/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/siderolabs/go-copy v0.1.0 h1:OIWCtSg+rhOtnIZTpT31Gfpn17rv5kwJqQHG+QUEgC8=
github.com/siderolabs/go-copy v0.1.0/go.mod h1:4bF2rZOZAR/ags/U4AVSpjFE5RPGdEeSkOq6yR9YOkU=
github.com/siderolabs/talos/pkg/machinery v1.8.3 h1:raK1oLzSMpwpy/AqkeFyBYkJS+QuOnlRMznVl/rZ25k=
github.com/siderolabs/talos/pkg/machinery v1.8.3/go.mod h1:cNR2TELu2T9AzYOHAoNr/7ZS3ZVDLzM/KnuOr4XW4s4=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
86 changes: 86 additions & 0 deletions installers/rock5a/src/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// 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 main

import (
_ "embed"
"fmt"
"os"
"path/filepath"

"github.com/siderolabs/go-copy/copy"
"github.com/siderolabs/talos/pkg/machinery/overlay"
"github.com/siderolabs/talos/pkg/machinery/overlay/adapter"
"golang.org/x/sys/unix"
)

const (
off int64 = 512 * 64
board = "rock5a"
dtb = "rockchip/rk3588s-rock-5a.dtb"
)

func main() {
adapter.Execute(&rock5a{})
}

type rock5a struct{}

type rock5aExtraOptions struct{}

func (i *rock5a) GetOptions(extra rock5aExtraOptions) (overlay.Options, error) {
return overlay.Options{
Name: board,
KernelArgs: []string{
"cma=128MB",
"console=tty0",
"console=ttyS9,115200",
"console=ttyS2,115200",
"sysctl.kernel.kexec_load_disabled=1",
"talos.dashboard.disabled=1",
},
PartitionOptions: overlay.PartitionOptions{
Offset: 2048 * 10,
},
}, nil
}

func (i *rock5a) Install(options overlay.InstallOptions[rock5aExtraOptions]) error {
var f *os.File

f, err := os.OpenFile(options.InstallDisk, os.O_RDWR|unix.O_CLOEXEC, 0o666)
if err != nil {
return fmt.Errorf("failed to open %s: %w", options.InstallDisk, err)
}

defer f.Close() //nolint:errcheck

uboot, err := os.ReadFile(filepath.Join(options.ArtifactsPath, "arm64/u-boot", board, "u-boot-rockchip.bin"))
if err != nil {
return err
}

if _, err = f.WriteAt(uboot, off); err != nil {
return err
}

// NB: In the case that the block device is a loopback device, we sync here
// to ensure that the file is written before the loopback device is
// unmounted.
err = f.Sync()
if err != nil {
return err
}

src := filepath.Join(options.ArtifactsPath, "arm64/dtb", dtb)
dst := filepath.Join(options.MountPrefix, "/boot/EFI/dtb", dtb)

err = os.MkdirAll(filepath.Dir(dst), 0o600)
if err != nil {
return err
}

return copy.File(src, dst)
}
2 changes: 2 additions & 0 deletions profiles/pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ finalize:
to: /rootfs/profiles
- from: /pkg/rock4se
to: /rootfs/profiles
- from: /pkg/rock5a
to: /rootfs/profiles
- from: /pkg/rock5b
to: /rootfs/profiles
- from: /pkg/turingrk1
Expand Down
9 changes: 9 additions & 0 deletions profiles/rock5a/rock5a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
arch: arm64
platform: metal
secureboot: false
output:
kind: image
outFormat: .xz
imageOptions:
diskSize: 1306525696
diskFormat: raw

0 comments on commit 327266f

Please sign in to comment.