generated from siderolabs/sbc-template
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support the Pine64 SOQuartz CM4 module
An RK3566-based compute module in the RPi CM4 form factor Signed-off-by: Tom Plant <[email protected]>
- Loading branch information
Showing
12 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: rkbin | ||
variant: scratch | ||
shell: /toolchain/bin/bash | ||
dependencies: | ||
- stage: base | ||
steps: | ||
- sources: | ||
- url: https://github.com/rockchip-linux/rkbin/archive/{{ .rkbin_ref }}.tar.gz | ||
destination: rkbin.tar.gz | ||
sha256: "{{ .rkbin_sha256 }}" | ||
sha512: "{{ .rkbin_sha512 }}" | ||
env: | ||
SOURCE_DATE_EPOCH: {{ .BUILD_ARG_SOURCE_DATE_EPOCH }} | ||
install: | ||
- | | ||
mkdir -p /rootfs/rkbin | ||
tar xf rkbin.tar.gz --strip-components=1 -C /rootfs/rkbin | ||
finalize: | ||
- from: /rootfs | ||
to: /libs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# References: | ||
# U-Boot: | ||
# - https://u-boot.readthedocs.io/en/latest | ||
name: u-boot-soquartz-cm4 | ||
variant: scratch | ||
shell: /toolchain/bin/bash | ||
dependencies: | ||
- stage: base | ||
- stage: rkbin | ||
steps: | ||
- sources: | ||
- url: https://ftp.denx.de/pub/u-boot/u-boot-{{ .uboot_version }}.tar.bz2 | ||
destination: u-boot.tar.bz2 | ||
sha256: "{{ .uboot_sha256 }}" | ||
sha512: "{{ .uboot_sha512 }}" | ||
env: | ||
SOURCE_DATE_EPOCH: {{ .BUILD_ARG_SOURCE_DATE_EPOCH }} | ||
prepare: | ||
# soquartz-cm4-rk3566 | ||
- | | ||
mkdir -p /usr/bin \ | ||
&& ln -sf /toolchain/bin/env /usr/bin/env \ | ||
&& ln -sf /toolchain/bin/python3 /toolchain/bin/python | ||
pip3 install pyelftools | ||
tar xf u-boot.tar.bz2 --strip-components=1 | ||
- | | ||
make soquartz-cm4-rk3566_defconfig | ||
# use binary firmware, pending ATF support | ||
# https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/16952 | ||
build: | ||
- | | ||
make -j $(nproc) HOSTLDLIBS_mkimage="-lssl -lcrypto" BL31=/libs/rkbin/bin/rk35/rk3568_bl31_v1.44.elf ROCKCHIP_TPL=/libs/rkbin/bin/rk35/rk3566_ddr_1056MHz_v1.21.bin SCP=/dev/null | ||
install: | ||
- | | ||
mkdir -p /rootfs/artifacts/arm64/u-boot/soquartz-cm4 | ||
cp u-boot-rockchip.bin /rootfs/artifacts/arm64/u-boot/soquartz-cm4 | ||
finalize: | ||
- from: /rootfs | ||
to: /rootfs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: soquartz-cm4 | ||
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 ./soquartz-cm4 . | ||
install: | ||
- | | ||
mkdir -p /rootfs/installers/ | ||
cp /pkg/src/soquartz-cm4 /rootfs/installers/soquartz-cm4 | ||
finalize: | ||
- from: /rootfs | ||
to: /rootfs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module soquartz-cm4 | ||
|
||
go 1.22.1 | ||
|
||
require ( | ||
github.com/siderolabs/go-copy v0.1.0 | ||
github.com/siderolabs/talos/pkg/machinery v1.7.0-alpha.1 | ||
golang.org/x/sys v0.16.0 | ||
) | ||
|
||
require gopkg.in/yaml.v3 v3.0.1 // indirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.7.0-alpha.1 h1:0pURmnbzsu19reku8OjN1DkeAxgkmuxmKgDgbFT3228= | ||
github.com/siderolabs/talos/pkg/machinery v1.7.0-alpha.1/go.mod h1:H2+5QeGXYi2Q7RhBNUAD6dhc9LmdJ2AUXtiAWRXtWBc= | ||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= | ||
golang.org/x/sys v0.16.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= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// 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 | ||
|
||
func main() { | ||
adapter.Execute(&soquartzCM4{}) | ||
} | ||
|
||
type soquartzCM4 struct{} | ||
|
||
type soquartzCM4ExtraOptions struct{} | ||
|
||
func (i *soquartzCM4) GetOptions(extra soquartzCM4ExtraOptions) (overlay.Options, error) { | ||
kernelArgs := []string{ | ||
"console=tty0", | ||
"console=ttyS2,1500000n8", | ||
"sysctl.kernel.kexec_load_disabled=1", | ||
"talos.dashboard.disabled=1", | ||
} | ||
|
||
return overlay.Options{ | ||
Name: "soquartz-cm4", | ||
KernelArgs: kernelArgs, | ||
PartitionOptions: overlay.PartitionOptions{ | ||
Offset: 2048 * 10, | ||
}, | ||
}, nil | ||
} | ||
|
||
func (i *soquartzCM4) Install(options overlay.InstallOptions[soquartzCM4ExtraOptions]) 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/soquartz-cm4/u-boot-rockchip.bin")) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// we need an offset so can't use copy.File | ||
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 esure that the file is written before the loopback device is | ||
// unmounted. | ||
err = f.Sync() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// allows to copy a directory from the overlay to the target | ||
return copy.Dir(filepath.Join(options.ArtifactsPath, "arm64/dtb"), filepath.Join(options.MountPrefix, "/boot/EFI/dtb")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |