Skip to content

Commit 13cc3a9

Browse files
committed
feat: add Orange Pi 5 Plus support
Add Orange Pi 5 Plus support. Fixes: siderolabs#48 Signed-off-by: Ryan Persée <[email protected]>
1 parent 327266f commit 13cc3a9

File tree

13 files changed

+232
-0
lines changed

13 files changed

+232
-0
lines changed

Diff for: MAINTAINERS.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This document contains a list of maintainers in this repo. For now, you become a
1212
| nanopi-r4s | NanoPi R4S | [#4](https://github.com/siderolabs/sbc-rockchip/pull/4) | RK3399 | TBD (Initial PR moved from pkgs) | TBD |
1313
| nanopi-r5s | NanoPi R5S | [#16](https://github.com/siderolabs/sbc-rockchip/pull/16) | RK3568 | Nicklas Frahm | [nicklasfrahm](https://github.com/nicklasfrahm) |
1414
| orangepi-5 | Orange Pi 5 | [#47](https://github.com/siderolabs/sbc-rockchip/pull/47) | RK3588s | Laurin Streng | [laurinstreng](https://github.com/LaurinStreng) |
15+
| orangepi-5-plus | Orange Pi 5 Plus | [#52](https://github.com/siderolabs/sbc-rockchip/pull/52) | RK3588 | Ryan Persée | [rpersee](https://github.com/rpersee) |
1516
| orangepi-r1-plus-lts | Orange Pi R1 Plus LTS | [#9](https://github.com/siderolabs/sbc-rockchip/pull/9) | RK3328 | Giau. Tran Minh | [giautm](https://github.com/giautm) |
1617
| rock64 | Pine64 Rock64 | [#4](https://github.com/siderolabs/sbc-rockchip/pull/4) | RK3328 | TBD (Initial PR moved from pkgs) | TBD |
1718
| rockpi4 | Rock Pi 4A,Rock Pi 4B | [#1](https://github.com/siderolabs/sbc-rockchip/pull/1) | RK3399 | TBD (Initial PR moved from pkgs) | TBD |

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This repo provides the overlay for RockChip based Talos image.
1010
| nanopi-r5s | NanoPi R5S | RK3568 | Overlay for NanoPi R5S (only WAN, no NVMe) |
1111
| nanopi-r4s | NanoPi R4S | RK3399 | Overlay for NanoPi R4S |
1212
| orangepi-5 | Orange Pi 5 | RK3588s | Overlay for Orange Pi 5 |
13+
| orangepi-5-plus | Orange Pi 5 Plus | RK3588 | Overlay for Orange Pi 5 Plus |
1314
| orangepi-r1-plus-lts | Orange Pi R1 Plus LTS | RK3328 | Overlay for Orange Pi R1 Plus LTS |
1415
| rock64 | Pine64 Rock64 | RK3328 | Overlay for Pine64 Rock64 |
1516
| rockpi4 | Rock Pi 4A,Rock Pi 4B | RK3399 | Generic overlay for Rock Pi 4A and Rock Pi 4B |
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>

Diff for: artifacts/orangepi-5-plus/u-boot/pkg.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# References:
2+
# U-Boot:
3+
# - https://u-boot.readthedocs.io/en/latest
4+
name: u-boot-orangepi-5-plus
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+
13+
steps:
14+
- sources:
15+
- url: https://ftp.denx.de/pub/u-boot/u-boot-{{ .uboot_rk1_version }}.tar.bz2
16+
destination: u-boot.tar.bz2
17+
sha256: "{{ .uboot_rk1_sha256 }}"
18+
sha512: "{{ .uboot_rk1_sha512 }}"
19+
env:
20+
SOURCE_DATE_EPOCH: {{ .BUILD_ARG_SOURCE_DATE_EPOCH }}
21+
prepare:
22+
# orangepi-5-plus-rk3588
23+
- |
24+
mkdir -p /usr/bin
25+
ln -sf /toolchain/bin/env /usr/bin/env
26+
ln -sf /toolchain/bin/python3 /toolchain/bin/python
27+
28+
pip3 install pyelftools setuptools
29+
30+
tar xf u-boot.tar.bz2 --strip-components=1
31+
32+
for patch in $(find /pkg/patches -type f -name "*.patch" | sort); do
33+
echo "Applying $patch"
34+
patch -p1 < $patch || (echo "Failed to apply patch $patch" && exit 1)
35+
done
36+
- |
37+
make orangepi-5-plus-rk3588_defconfig
38+
build:
39+
- |
40+
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
41+
install:
42+
- |
43+
mkdir -p /rootfs/artifacts/arm64/u-boot/orangepi-5-plus
44+
cp -v -t /rootfs/artifacts/arm64/u-boot/orangepi-5-plus u-boot-rockchip.bin u-boot-rockchip-spi.bin
45+
finalize:
46+
- from: /rootfs
47+
to: /rootfs

Diff for: artifacts/orangepi-5-plus/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

Diff for: go.work

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use (
55
./installers/nanopi-r5s/src
66
./installers/nanopi-r4s/src
77
./installers/orangepi-5/src
8+
./installers/orangepi-5-plus/src
89
./installers/orangepi-r1-plus-lts/src
910
./installers/rock64/src
1011
./installers/rockpi4/src

Diff for: installers/orangepi-5-plus/pkg.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: orangepi-5-plus
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 ./orangepi-5-plus .
18+
install:
19+
- |
20+
mkdir -p /rootfs/installers/
21+
22+
cp -p /pkg/src/orangepi-5-plus /rootfs/installers/orangepi-5-plus
23+
finalize:
24+
- from: /rootfs
25+
to: /rootfs

Diff for: installers/orangepi-5-plus/src/go.mod

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module orangepi-5-plus
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

Diff for: installers/orangepi-5-plus/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=

Diff for: installers/orangepi-5-plus/src/main.go

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
dtb = "rockchip/rk3588-orangepi-5-plus.dtb"
22+
)
23+
24+
func main() {
25+
adapter.Execute(&opi5PlusInstaller{})
26+
}
27+
28+
type opi5PlusInstaller struct{}
29+
30+
type opi5PlusExtraOptions struct {
31+
SPIBoot bool `yaml:"spi_boot,omitempty"`
32+
}
33+
34+
func (i *opi5PlusInstaller) GetOptions(extra opi5PlusExtraOptions) (overlay.Options, error) {
35+
kernelArgs := []string{
36+
"console=tty0",
37+
"console=ttyS2,115200",
38+
"sysctl.kernel.kexec_load_disabled=1",
39+
"talos.dashboard.disabled=1",
40+
}
41+
return overlay.Options{
42+
Name: "orangepi-5-plus",
43+
KernelArgs: kernelArgs,
44+
PartitionOptions: overlay.PartitionOptions{
45+
Offset: 2048 * 10,
46+
},
47+
}, nil
48+
}
49+
50+
func (i *opi5PlusInstaller) Install(options overlay.InstallOptions[opi5PlusExtraOptions]) error {
51+
if !options.ExtraOptions.SPIBoot {
52+
uBootBin := filepath.Join(options.ArtifactsPath, "arm64/u-boot/orangepi-5-plus/u-boot-rockchip.bin")
53+
54+
if err := uBootLoaderInstall(uBootBin, options.InstallDisk); err != nil {
55+
return err
56+
}
57+
}
58+
59+
src := filepath.Join(options.ArtifactsPath, "arm64/dtb", dtb)
60+
dst := filepath.Join(options.MountPrefix, "boot/EFI/dtb", dtb)
61+
62+
if err := copyFileAndCreateDir(src, dst); err != nil {
63+
return err
64+
}
65+
66+
return nil
67+
}
68+
69+
func copyFileAndCreateDir(src, dst string) error {
70+
if err := os.MkdirAll(filepath.Dir(dst), 0o600); err != nil {
71+
return err
72+
}
73+
74+
return copy.File(src, dst)
75+
}
76+
77+
func uBootLoaderInstall(uBootBin, installDisk string) error {
78+
var f *os.File
79+
80+
f, err := os.OpenFile(installDisk, os.O_RDWR|unix.O_CLOEXEC, 0o666)
81+
if err != nil {
82+
return fmt.Errorf("failed to open %s: %w", installDisk, err)
83+
}
84+
85+
defer f.Close() //nolint:errcheck
86+
87+
uboot, err := os.ReadFile(uBootBin)
88+
if err != nil {
89+
return err
90+
}
91+
92+
if _, err = f.WriteAt(uboot, off); err != nil {
93+
return err
94+
}
95+
96+
// NB: In the case that the block device is a loopback device, we sync here
97+
// to esure that the file is written before the loopback device is
98+
// unmounted.
99+
err = f.Sync()
100+
return err
101+
}

Diff for: installers/pkg.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ dependencies:
66
- stage: nanopi-r5s
77
- stage: nanopi-r4s
88
- stage: orangepi-5
9+
- stage: orangepi-5-plus
910
- stage: orangepi-r1-plus-lts
1011
- stage: rock64
1112
- stage: rockpi4
@@ -24,6 +25,8 @@ dependencies:
2425
platform: linux/arm64
2526
- stage: u-boot-orangepi-5
2627
platform: linux/arm64
28+
- stage: u-boot-orangepi-5-plus
29+
platform: linux/arm64
2730
- stage: u-boot-orangepi-r1-plus-lts
2831
platform: linux/arm64
2932
- stage: u-boot-rock64
@@ -58,6 +61,10 @@ dependencies:
5861
platform: linux/arm64
5962
from: /dtb/rockchip/rk3588s-orangepi-5.dtb
6063
to: /rootfs/artifacts/arm64/dtb/rockchip/rk3588s-orangepi-5.dtb
64+
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}"
65+
platform: linux/arm64
66+
from: /dtb/rockchip/rk3588-orangepi-5-plus.dtb
67+
to: /rootfs/artifacts/arm64/dtb/rockchip/rk3588-orangepi-5-plus.dtb
6168
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}"
6269
platform: linux/arm64
6370
from: /dtb/rockchip/rk3328-orangepi-r1-plus-lts.dtb

Diff for: profiles/orangepi-5-plus/orangepi-5-plus.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

Diff for: profiles/pkg.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ finalize:
99
to: /rootfs/profiles
1010
- from: /pkg/orangepi-5
1111
to: /rootfs/profiles
12+
- from: /pkg/orangepi-5-plus
13+
to: /rootfs/profiles
1214
- from: /pkg/orangepi-r1-plus-lts
1315
to: /rootfs/profiles
1416
- from: /pkg/rock64

0 commit comments

Comments
 (0)