diff --git a/.kres.yaml b/.kres.yaml index 584a083..814c5ff 100644 --- a/.kres.yaml +++ b/.kres.yaml @@ -2,7 +2,7 @@ kind: pkgfile.Build spec: targets: - - sbc-rockpi + - sbc-rockchip extraBuildArgs: - PKGS_PREFIX - PKGS diff --git a/Makefile b/Makefile index 35200a8..db51294 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2024-03-14T16:50:45Z by kres latest. +# Generated on 2024-03-17T12:10:50Z by kres latest. # common variables @@ -54,7 +54,7 @@ PKGS ?= v1.7.0-alpha.0-33-g3aacf03 # targets defines all the available targets -TARGETS = sbc-rockpi +TARGETS = sbc-rockchip # help menu diff --git a/Pkgfile b/Pkgfile index 6d700e7..64953ee 100644 --- a/Pkgfile +++ b/Pkgfile @@ -3,8 +3,8 @@ format: v1alpha2 vars: - # renovate: datasource=github-tags depName=ARM-software/arm-trusted-firmware - arm_trusted_firmware_version: v2.8.0 + # renovate: datasource=github-tags extractVersion=^v(?.*)$ depName=ARM-software/arm-trusted-firmware + arm_trusted_firmware_version: 2.8.0 arm_trusted_firmware_sha256: 60fad60eeb6840097f8e64f16093c06ddb2ef269c7a22affed02beaa6cefe466 arm_trusted_firmware_sha512: 958cf8f9e258638e59d0fbd8b053fce7d8a9ea2fc922686c9d20ea16f79f55219ac18a12ab240c528ee98e49c2e0eef4c963fdb255cc14b92437a5b3cffc8640 diff --git a/README.md b/README.md index 493d334..8ec88e0 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ -# sbc-rockpi +# sbc-rockchip -This repo provides the overlay for Rock Pi generic Talos image. +This repo provides the overlay for RockChip based Talos image. ## Supported Overlay | Overlay Name | Board | Description | | ------------ | --------------------- | --------------------------------------------- | +| nanopi-r4s | NanoPi R4S | Overlay for NanoPi R4S | +| rock64 | Pine64 Rock64 | Overlay for Pine64 Rock64 | | rockpi4 | Rock Pi 4A,Rock Pi 4B | Generic overlay for Rock Pi 4A and Rock Pi 4B | | rockpi4c | Rock Pi 4C | Overlay for Rock Pi 4C | diff --git a/artifacts/arm-trusted-firmware/rk3328/pkg.yaml b/artifacts/arm-trusted-firmware/rk3328/pkg.yaml new file mode 100644 index 0000000..5badfaa --- /dev/null +++ b/artifacts/arm-trusted-firmware/rk3328/pkg.yaml @@ -0,0 +1,36 @@ +name: arm-trusted-firmware-rk3328 +variant: scratch +shell: /toolchain/bin/bash +dependencies: + - stage: base +steps: + - sources: + - url: https://github.com/ARM-software/arm-trusted-firmware/archive/v{{ .arm_trusted_firmware_version }}.tar.gz + destination: arm-trusted-firmware.tar.gz + sha256: "{{ .arm_trusted_firmware_sha256 }}" + sha512: "{{ .arm_trusted_firmware_sha512 }}" + env: + SOURCE_DATE_EPOCH: {{ .BUILD_ARG_SOURCE_DATE_EPOCH }} + prepare: + - | + mkdir -p /usr/bin \ + && ln -sf /toolchain/bin/env /usr/bin/env + + tar xf arm-trusted-firmware.tar.gz --strip-components=1 + # rk3328 + build: + - | + make realclean + + # https://salsa.debian.org/debian/arm-trusted-firmware/-/commit/6424a59e08585af7f8a56f1e16ecc6a6b9e4ad7a + # https://salsa.debian.org/debian/arm-trusted-firmware/-/commit/6ed8f61df3b07bb22a68a0fc189ec3b3f7b00dbd + # https://developer.trustedfirmware.org/T996 + TF_LDFLAGS=--no-warn-rwx-segments CFLAGS=--param=min-pagesize=0 make -j $(nproc) PLAT=rk3328 DEBUG=0 bl31 + install: + - | + mkdir -p /rootfs/arm-trusted-firmware/rk3328 + + cp build/rk3328/release/bl31/bl31.elf /rootfs/arm-trusted-firmware/rk3328/bl31.elf +finalize: + - from: /rootfs + to: /libs diff --git a/artifacts/arm-trusted-firmware/m0/rk3399m0.bin b/artifacts/arm-trusted-firmware/rk3399/m0/rk3399m0.bin similarity index 100% rename from artifacts/arm-trusted-firmware/m0/rk3399m0.bin rename to artifacts/arm-trusted-firmware/rk3399/m0/rk3399m0.bin diff --git a/artifacts/arm-trusted-firmware/m0/rk3399m0pmu.bin b/artifacts/arm-trusted-firmware/rk3399/m0/rk3399m0pmu.bin similarity index 100% rename from artifacts/arm-trusted-firmware/m0/rk3399m0pmu.bin rename to artifacts/arm-trusted-firmware/rk3399/m0/rk3399m0pmu.bin diff --git a/artifacts/arm-trusted-firmware/patches/platform.mk.patch b/artifacts/arm-trusted-firmware/rk3399/patches/platform.mk.patch similarity index 100% rename from artifacts/arm-trusted-firmware/patches/platform.mk.patch rename to artifacts/arm-trusted-firmware/rk3399/patches/platform.mk.patch diff --git a/artifacts/arm-trusted-firmware/pkg.yaml b/artifacts/arm-trusted-firmware/rk3399/pkg.yaml similarity index 88% rename from artifacts/arm-trusted-firmware/pkg.yaml rename to artifacts/arm-trusted-firmware/rk3399/pkg.yaml index 1969b21..a27bd12 100644 --- a/artifacts/arm-trusted-firmware/pkg.yaml +++ b/artifacts/arm-trusted-firmware/rk3399/pkg.yaml @@ -1,11 +1,11 @@ -name: arm-trusted-firmware +name: arm-trusted-firmware-rk3399 variant: scratch shell: /toolchain/bin/bash dependencies: - stage: base steps: - sources: - - url: https://github.com/ARM-software/arm-trusted-firmware/archive/{{ .arm_trusted_firmware_version }}.tar.gz + - url: https://github.com/ARM-software/arm-trusted-firmware/archive/v{{ .arm_trusted_firmware_version }}.tar.gz destination: arm-trusted-firmware.tar.gz sha256: "{{ .arm_trusted_firmware_sha256 }}" sha512: "{{ .arm_trusted_firmware_sha512 }}" @@ -32,9 +32,9 @@ steps: TF_LDFLAGS=--no-warn-rwx-segments CFLAGS=--param=min-pagesize=0 make -j $(nproc) PLAT=rk3399 DEBUG=0 bl31 install: - | - mkdir -p /rootfs/arm-trusted-firmware/rockpi4 + mkdir -p /rootfs/arm-trusted-firmware/rk3399 - cp build/rk3399/release/bl31/bl31.elf /rootfs/arm-trusted-firmware/rockpi4/bl31.elf + cp build/rk3399/release/bl31/bl31.elf /rootfs/arm-trusted-firmware/rk3399/bl31.elf finalize: - from: /rootfs to: /libs diff --git a/artifacts/nanopi-r4s/u-boot/pkg.yaml b/artifacts/nanopi-r4s/u-boot/pkg.yaml new file mode 100644 index 0000000..6c38b31 --- /dev/null +++ b/artifacts/nanopi-r4s/u-boot/pkg.yaml @@ -0,0 +1,39 @@ +# References: +# U-Boot: +# - https://u-boot.readthedocs.io/en/latest +name: u-boot-nanopi-r4s +variant: scratch +shell: /toolchain/bin/bash +dependencies: + - stage: base + - stage: arm-trusted-firmware-rk3399 +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: + # nanopi-r4s + - | + mkdir -p /usr/bin \ + && ln -sf /toolchain/bin/env /usr/bin/env + + tar xf u-boot.tar.bz2 --strip-components=1 + - | + make nanopi-r4s-rk3399_defconfig + sed -i "s/CONFIG_TOOLS_LIBCRYPTO=y/# CONFIG_TOOLS_LIBCRYPTO is not set/" .config + build: + - | + make -j $(nproc) HOSTLDLIBS_mkimage="-lssl -lcrypto" BL31=/libs/arm-trusted-firmware/rk3399/bl31.elf + install: + - | + mkdir -p /rootfs/artifacts/arm64/u-boot/nanopi-r4s + cp u-boot-rockchip.bin /rootfs/artifacts/arm64/u-boot/nanopi-r4s + + cp rkspi_loader.img /rootfs/artifacts/arm64/u-boot/nanopi-r4s +finalize: + - from: /rootfs + to: /rootfs diff --git a/artifacts/rock64/u-boot/pkg.yaml b/artifacts/rock64/u-boot/pkg.yaml new file mode 100644 index 0000000..0e98544 --- /dev/null +++ b/artifacts/rock64/u-boot/pkg.yaml @@ -0,0 +1,37 @@ +# References: +# U-Boot: +# - https://u-boot.readthedocs.io/en/latest +name: u-boot-rock64 +variant: scratch +shell: /toolchain/bin/bash +dependencies: + - stage: base + - stage: arm-trusted-firmware-rk3328 +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: + # rock-pi-4-rk3399 + - | + mkdir -p /usr/bin \ + && ln -sf /toolchain/bin/env /usr/bin/env + + tar xf u-boot.tar.bz2 --strip-components=1 + - | + make rock64-rk3328_defconfig + sed -i "s/CONFIG_TOOLS_LIBCRYPTO=y/# CONFIG_TOOLS_LIBCRYPTO is not set/" .config + build: + - | + make -j $(nproc) HOSTLDLIBS_mkimage="-lssl -lcrypto" BL31=/libs/arm-trusted-firmware/rk3328/bl31.elf + install: + - | + mkdir -p /rootfs/artifacts/arm64/u-boot/rock64 + cp u-boot-rockchip.bin /rootfs/artifacts/arm64/u-boot/rock64 +finalize: + - from: /rootfs + to: /rootfs diff --git a/artifacts/rockpi4/u-boot/pkg.yaml b/artifacts/rockpi4/u-boot/pkg.yaml index 788abc8..c1a0db3 100644 --- a/artifacts/rockpi4/u-boot/pkg.yaml +++ b/artifacts/rockpi4/u-boot/pkg.yaml @@ -1,14 +1,12 @@ # References: # U-Boot: # - https://u-boot.readthedocs.io/en/latest -# Broadcom/RaspberryPi -# - https://github.com/u-boot/u-boot/blob/master/doc/board/broadcom/raspberrypi.rst name: u-boot-rockpi4 variant: scratch shell: /toolchain/bin/bash dependencies: - stage: base - - stage: arm-trusted-firmware + - stage: arm-trusted-firmware-rk3399 steps: - sources: - url: https://ftp.denx.de/pub/u-boot/u-boot-{{ .uboot_version }}.tar.bz2 @@ -33,7 +31,7 @@ steps: sed -i "s/CONFIG_TOOLS_LIBCRYPTO=y/# CONFIG_TOOLS_LIBCRYPTO is not set/" .config build: - | - make -j $(nproc) HOSTLDLIBS_mkimage="-lssl -lcrypto" BL31=/libs/arm-trusted-firmware/rockpi4/bl31.elf + make -j $(nproc) HOSTLDLIBS_mkimage="-lssl -lcrypto" BL31=/libs/arm-trusted-firmware/rk3399/bl31.elf # create spi image # https://github.com/armbian/build/blob/09e416e31cc01ece4533a65f02a470a4c21b90ea/config/sources/families/include/rockchip64_common.inc#L173-L178 diff --git a/artifacts/rockpi4c/u-boot/pkg.yaml b/artifacts/rockpi4c/u-boot/pkg.yaml index 9b47fde..b74de81 100644 --- a/artifacts/rockpi4c/u-boot/pkg.yaml +++ b/artifacts/rockpi4c/u-boot/pkg.yaml @@ -1,14 +1,12 @@ # References: # U-Boot: # - https://u-boot.readthedocs.io/en/latest -# Broadcom/RaspberryPi -# - https://github.com/u-boot/u-boot/blob/master/doc/board/broadcom/raspberrypi.rst name: u-boot-rockpi4c variant: scratch shell: /toolchain/bin/bash dependencies: - stage: base - - stage: arm-trusted-firmware + - stage: arm-trusted-firmware-rk3399 steps: - sources: - url: https://ftp.denx.de/pub/u-boot/u-boot-{{ .uboot_version }}.tar.bz2 @@ -33,7 +31,7 @@ steps: sed -i "s/CONFIG_TOOLS_LIBCRYPTO=y/# CONFIG_TOOLS_LIBCRYPTO is not set/" .config build: - | - make -j $(nproc) HOSTLDLIBS_mkimage="-lssl -lcrypto" BL31=/libs/arm-trusted-firmware/rockpi4/bl31.elf + make -j $(nproc) HOSTLDLIBS_mkimage="-lssl -lcrypto" BL31=/libs/arm-trusted-firmware/rk3399/bl31.elf # create spi image # https://github.com/armbian/build/blob/09e416e31cc01ece4533a65f02a470a4c21b90ea/config/sources/families/include/rockchip64_common.inc#L173-L178 diff --git a/go.work b/go.work index e7e0c46..ec227e5 100644 --- a/go.work +++ b/go.work @@ -1,6 +1,8 @@ go 1.22.1 use ( + ./installers/nanopi-r4s/src + ./installers/rock64/src ./installers/rockpi4/src ./installers/rockpi4c/src ) diff --git a/installers/nanopi-r4s/pkg.yaml b/installers/nanopi-r4s/pkg.yaml new file mode 100644 index 0000000..0ee14aa --- /dev/null +++ b/installers/nanopi-r4s/pkg.yaml @@ -0,0 +1,25 @@ +name: nanopi-r4s +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 ./nanopi-r4s . + install: + - | + mkdir -p /rootfs/installers/ + + cp /pkg/src/nanopi-r4s /rootfs/installers/nanopi-r4s +finalize: + - from: /rootfs + to: /rootfs diff --git a/installers/nanopi-r4s/src/go.mod b/installers/nanopi-r4s/src/go.mod new file mode 100644 index 0000000..a72fdb1 --- /dev/null +++ b/installers/nanopi-r4s/src/go.mod @@ -0,0 +1,11 @@ +module nanopi-r4s + +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 diff --git a/installers/nanopi-r4s/src/go.sum b/installers/nanopi-r4s/src/go.sum new file mode 100644 index 0000000..6a91086 --- /dev/null +++ b/installers/nanopi-r4s/src/go.sum @@ -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= diff --git a/installers/nanopi-r4s/src/main.go b/installers/nanopi-r4s/src/main.go new file mode 100644 index 0000000..d9a4ae7 --- /dev/null +++ b/installers/nanopi-r4s/src/main.go @@ -0,0 +1,83 @@ +// 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 + dtb = "rockchip/rk3399-nanopi-r4s.dtb" +) + +func main() { + adapter.Execute(&nanopir4s{}) +} + +type nanopir4s struct{} + +type nanopir4sExtraOptions struct{} + +func (i *nanopir4s) GetOptions(extra nanopir4sExtraOptions) (overlay.Options, error) { + return overlay.Options{ + Name: "nanopi-r4s", + KernelArgs: []string{ + "console=tty0", + "console=ttyS2,1500000n8", + "sysctl.kernel.kexec_load_disabled=1", + "talos.dashboard.disabled=1", + }, + PartitionOptions: overlay.PartitionOptions{ + Offset: 2048 * 10, + }, + }, nil +} + +func (i *nanopir4s) Install(options overlay.InstallOptions[nanopir4sExtraOptions]) 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/rockpi4/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 esure 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) +} diff --git a/installers/pkg.yaml b/installers/pkg.yaml index 1ea03fa..05e5e06 100644 --- a/installers/pkg.yaml +++ b/installers/pkg.yaml @@ -1,14 +1,28 @@ -name: sbc-rockpi +name: sbc-rockchip variant: scratch shell: /toolchain/bin/bash dependencies: + - stage: nanopi-r4s + - stage: rock64 - stage: rockpi4 - stage: rockpi4c - stage: profiles + - stage: u-boot-nanopi-r4s + platform: linux/arm64 + - stage: u-boot-rock64 + platform: linux/arm64 - stage: u-boot-rockpi4 platform: linux/arm64 - stage: u-boot-rockpi4c platform: linux/arm64 + - image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}" + platform: linux/arm64 + from: /dtb/rockchip/rk3399-nanopi-r4s.dtb + to: /rootfs/artifacts/arm64/dtb/rockchip/rk3399-nanopi-r4s.dtb + - image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}" + platform: linux/arm64 + from: /dtb/rockchip/rk3328-rock64.dtb + to: /rootfs/artifacts/arm64/dtb/rockchip/rk3328-rock64.dtb - image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}" platform: linux/arm64 from: /dtb/rockchip/rk3399-rock-pi-4b.dtb diff --git a/installers/rock64/pkg.yaml b/installers/rock64/pkg.yaml new file mode 100644 index 0000000..3fd6898 --- /dev/null +++ b/installers/rock64/pkg.yaml @@ -0,0 +1,25 @@ +name: rock64 +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 ./rock64 . + install: + - | + mkdir -p /rootfs/installers/ + + cp /pkg/src/rock64 /rootfs/installers/rock64 +finalize: + - from: /rootfs + to: /rootfs diff --git a/installers/rock64/src/go.mod b/installers/rock64/src/go.mod new file mode 100644 index 0000000..bceb67b --- /dev/null +++ b/installers/rock64/src/go.mod @@ -0,0 +1,11 @@ +module rock64 + +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 diff --git a/installers/rock64/src/go.sum b/installers/rock64/src/go.sum new file mode 100644 index 0000000..6a91086 --- /dev/null +++ b/installers/rock64/src/go.sum @@ -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= diff --git a/installers/rock64/src/main.go b/installers/rock64/src/main.go new file mode 100644 index 0000000..b79ea65 --- /dev/null +++ b/installers/rock64/src/main.go @@ -0,0 +1,83 @@ +// 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 + dtb = "rockchip/rk3328-rock64.dtb" +) + +func main() { + adapter.Execute(&rock64{}) +} + +type rock64 struct{} + +type rock64ExtraOptions struct{} + +func (i *rock64) GetOptions(extra rock64ExtraOptions) (overlay.Options, error) { + return overlay.Options{ + Name: "rock64", + KernelArgs: []string{ + "console=tty0", + "ttyS2,115200n8", + "sysctl.kernel.kexec_load_disabled=1", + "talos.dashboard.disabled=1", + }, + PartitionOptions: overlay.PartitionOptions{ + Offset: 2048 * 10, + }, + }, nil +} + +func (i *rock64) Install(options overlay.InstallOptions[rock64ExtraOptions]) 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/rock64/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 esure 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) +} diff --git a/installers/rockpi4c/src/main.go b/installers/rockpi4c/src/main.go index 518cb4e..f5d7cca 100644 --- a/installers/rockpi4c/src/main.go +++ b/installers/rockpi4c/src/main.go @@ -23,14 +23,14 @@ const ( ) func main() { - adapter.Execute(&rockPi4{}) + adapter.Execute(&rockPi4c{}) } -type rockPi4 struct{} +type rockPi4c struct{} -type rockPi4ExtraOptions struct{} +type rockPi4cExtraOptions struct{} -func (i *rockPi4) GetOptions(extra rockPi4ExtraOptions) (overlay.Options, error) { +func (i *rockPi4c) GetOptions(extra rockPi4cExtraOptions) (overlay.Options, error) { return overlay.Options{ Name: "rockpi4c", KernelArgs: []string{ @@ -45,7 +45,7 @@ func (i *rockPi4) GetOptions(extra rockPi4ExtraOptions) (overlay.Options, error) }, nil } -func (i *rockPi4) Install(options overlay.InstallOptions[rockPi4ExtraOptions]) error { +func (i *rockPi4c) Install(options overlay.InstallOptions[rockPi4cExtraOptions]) error { var f *os.File f, err := os.OpenFile(options.InstallDisk, os.O_RDWR|unix.O_CLOEXEC, 0o666) @@ -55,7 +55,7 @@ func (i *rockPi4) Install(options overlay.InstallOptions[rockPi4ExtraOptions]) e defer f.Close() //nolint:errcheck - uboot, err := os.ReadFile(filepath.Join(options.ArtifactsPath, "arm64/u-boot/rockpi4/u-boot-rockchip.bin")) + uboot, err := os.ReadFile(filepath.Join(options.ArtifactsPath, "arm64/u-boot/rockpi4c/u-boot-rockchip.bin")) if err != nil { return err } diff --git a/profiles/nanopi-r4s/nanopi-r4s.yaml b/profiles/nanopi-r4s/nanopi-r4s.yaml new file mode 100644 index 0000000..4013860 --- /dev/null +++ b/profiles/nanopi-r4s/nanopi-r4s.yaml @@ -0,0 +1,9 @@ +arch: arm64 +platform: metal +secureboot: false +output: + kind: image + outFormat: .xz + imageOptions: + diskSize: 1306525696 + diskFormat: raw diff --git a/profiles/pkg.yaml b/profiles/pkg.yaml index dfe7a79..b3bd060 100644 --- a/profiles/pkg.yaml +++ b/profiles/pkg.yaml @@ -1,6 +1,10 @@ name: profiles variant: scratch finalize: + - from: /pkg/nanopi-r4s + to: /rootfs/profiles + - from: /pkg/rock64 + to: /rootfs/profiles - from: /pkg/rockpi4 to: /rootfs/profiles - from: /pkg/rockpi4c diff --git a/profiles/rock64/rock64.yaml b/profiles/rock64/rock64.yaml new file mode 100644 index 0000000..4013860 --- /dev/null +++ b/profiles/rock64/rock64.yaml @@ -0,0 +1,9 @@ +arch: arm64 +platform: metal +secureboot: false +output: + kind: image + outFormat: .xz + imageOptions: + diskSize: 1306525696 + diskFormat: raw