Skip to content

Commit

Permalink
feat: add support for helios64
Browse files Browse the repository at this point in the history
Add support for kobol helios64 board. It does not have a mainline u-boot
and hence needs to be patched in.

Signed-off-by: Hemanth Bollamreddi <[email protected]>
  • Loading branch information
blmhemu authored and frezbo committed Jul 22, 2024
1 parent b04b5de commit 1eef47f
Show file tree
Hide file tree
Showing 11 changed files with 2,407 additions and 0 deletions.
2,200 changes: 2,200 additions & 0 deletions artifacts/helios64/u-boot/patches/add-helios64.patch

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions artifacts/helios64/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>
43 changes: 43 additions & 0 deletions artifacts/helios64/u-boot/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# References:
# U-Boot:
# - https://u-boot.readthedocs.io/en/latest
name: u-boot-helios64
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-2022.07.tar.bz2
destination: u-boot.tar.bz2
sha256: "92b08eb49c24da14c1adbf70a71ae8f37cc53eeb4230e859ad8b6733d13dcf5e"
sha512: "e1b3621dafac876c644ffb3d24b6e2380f5a78454c420a5b17d174e3f0b57731a95cfbff28ae7d0af4493f4bbf8d21e7f9236d61bb2414ed12295332b3d557b6"
env:
SOURCE_DATE_EPOCH: {{ .BUILD_ARG_SOURCE_DATE_EPOCH }}
prepare:
# helios64-rk3399
- |
mkdir -p /usr/bin \
&& ln -sf /toolchain/bin/env /usr/bin/env \
&& ln -sf /toolchain/bin/python3 /toolchain/bin/python
pip3 install pyelftools setuptools
tar xf u-boot.tar.bz2 --strip-components=1
patch -p1 < /pkg/patches/uboot-byteorder.patch
patch -p1 < /pkg/patches/add-helios64.patch
- |
make helios64-rk3399_defconfig
build:
- |
make -j $(nproc) HOSTLDLIBS_mkimage="-lssl -lcrypto" BL31=/libs/arm-trusted-firmware/rk3399/bl31.elf
install:
- |
mkdir -p /rootfs/artifacts/arm64/u-boot/helios64
cp u-boot-rockchip.bin /rootfs/artifacts/arm64/u-boot/helios64
finalize:
- from: /rootfs
to: /rootfs
1 change: 1 addition & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
go 1.22.4

use (
./installers/helios64/src
./installers/nanopi-r4s/src
./installers/orangepi-r1-plus-lts/src
./installers/rock64/src
Expand Down
25 changes: 25 additions & 0 deletions installers/helios64/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: helios64
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 ./helios64 .
install:
- |
mkdir -p /rootfs/installers/
cp /pkg/src/helios64 /rootfs/installers/helios64
finalize:
- from: /rootfs
to: /rootfs
11 changes: 11 additions & 0 deletions installers/helios64/src/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module helios64

go 1.22.4

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

require gopkg.in/yaml.v3 v3.0.1 // indirect
10 changes: 10 additions & 0 deletions installers/helios64/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.7.5 h1:M02UZSDfN0BB4bXhTYDjEmVvAIX1GsAS45cyKh6+HHU=
github.com/siderolabs/talos/pkg/machinery v1.7.5/go.mod h1:OeamhNo92c3V96bddZNhcCgoRyzw2KWBtpma1lfchtg=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.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=
84 changes: 84 additions & 0 deletions installers/helios64/src/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// 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-kobol-helios64.dtb"
)

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

type helios64 struct{}

type helios64ExtraOptions struct{}

func (i *helios64) GetOptions(extra helios64ExtraOptions) (overlay.Options, error) {
return overlay.Options{
Name: "helios64",
KernelArgs: []string{
"console=tty1",
"console=ttyS2,1500000n8",
"usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u",
"sysctl.kernel.kexec_load_disabled=1",
"talos.dashboard.disabled=1",
},
PartitionOptions: overlay.PartitionOptions{
Offset: 2048 * 10,
},
}, nil
}

func (i *helios64) Install(options overlay.InstallOptions[helios64ExtraOptions]) 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/helios64/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)
}
7 changes: 7 additions & 0 deletions installers/pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: sbc-rockchip
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: helios64
- stage: nanopi-r4s
- stage: orangepi-r1-plus-lts
- stage: rock64
Expand All @@ -10,6 +11,8 @@ dependencies:
- stage: rock4cplus
- stage: rock4se
- stage: profiles
- stage: u-boot-helios64
platform: linux/arm64
- stage: u-boot-nanopi-r4s
platform: linux/arm64
- stage: u-boot-orangepi-r1-plus-lts
Expand All @@ -24,6 +27,10 @@ dependencies:
platform: linux/arm64
- stage: u-boot-rock4se
platform: linux/arm64
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}"
platform: linux/arm64
from: /dtb/rockchip/rk3399-kobol-helios64.dtb
to: /rootfs/artifacts/arm64/dtb/rockchip/rk3399-kobol-helios64.dtb
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}"
platform: linux/arm64
from: /dtb/rockchip/rk3399-nanopi-r4s.dtb
Expand Down
9 changes: 9 additions & 0 deletions profiles/helios64/helios64.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
2 changes: 2 additions & 0 deletions profiles/pkg.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: profiles
variant: scratch
finalize:
- from: /pkg/helios64
to: /rootfs/profiles
- from: /pkg/nanopi-r4s
to: /rootfs/profiles
- from: /pkg/orangepi-r1-plus-lts
Expand Down

0 comments on commit 1eef47f

Please sign in to comment.