Skip to content

Commit c403f03

Browse files
committed
feat: add ODroid HC4 support
Adds support for the ODroid HC4 SBC. Signed-off-by: Brandon McNama <brandonmcnama@outlook.com>
1 parent a52d3cd commit c403f03

File tree

5 files changed

+186
-0
lines changed

5 files changed

+186
-0
lines changed

internal/app/machined/pkg/runtime/v1alpha1/board/board.go

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
jetsonnano "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/jetson_nano"
1818
libretechallh3cch5 "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/libretech_all_h3_cc_h5"
1919
nanopir4s "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/nanopi_r4s"
20+
odroidhc4 "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/odroid_hc4"
2021
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/pine64"
2122
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/rock64"
2223
rockpi4 "github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board/rockpi4"
@@ -70,6 +71,8 @@ func newBoard(board string) (b runtime.Board, err error) {
7071
b = &jetsonnano.JetsonNano{}
7172
case constants.BoardNanoPiR4S:
7273
b = &nanopir4s.NanoPiR4S{}
74+
case constants.BoardODroidHC4:
75+
b = &odroidhc4.ODroidHC4{}
7376
default:
7477
return nil, fmt.Errorf("unsupported board: %q", board)
7578
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 odroidhc4 provides the ODroid HC4 board implementation.
6+
package odroidhc4
7+
8+
import (
9+
"log"
10+
"os"
11+
"path/filepath"
12+
13+
"github.com/siderolabs/go-procfs/procfs"
14+
"golang.org/x/sys/unix"
15+
16+
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
17+
"github.com/siderolabs/talos/pkg/copy"
18+
"github.com/siderolabs/talos/pkg/machinery/constants"
19+
)
20+
21+
var dtb = "/amlogic/meson-sm1-odroid-hc4.dtb"
22+
23+
// ODroidHC4 represents the ODroid HC4.
24+
//
25+
// References:
26+
// - https://wiki.odroid.com/odroid-hc4/odroid-hc4
27+
// - https://wiki.odroid.com/odroid-hc4/software/partition_table
28+
// - https://github.com/u-boot/u-boot/blob/master/doc/board/amlogic/odroid-c4.rst
29+
type ODroidHC4 struct{}
30+
31+
// Name implements the runtime.Board.
32+
func (b *ODroidHC4) Name() string {
33+
return constants.BoardODroidHC4
34+
}
35+
36+
// Install implements the runtime.Board.
37+
func (b *ODroidHC4) Install(disk string) (err error) {
38+
var f *os.File
39+
40+
if f, err = os.OpenFile(disk, os.O_RDWR|unix.O_CLOEXEC, 0o666); err != nil {
41+
return err
42+
}
43+
//nolint:errcheck
44+
defer f.Close()
45+
46+
// NB: In the case that the block device is a loopback device, we sync here
47+
// to esure that the file is written before the loopback device is
48+
// unmounted.
49+
err = f.Sync()
50+
if err != nil {
51+
return err
52+
}
53+
54+
src := "/usr/install/arm64/dtb" + dtb
55+
dst := "/boot/EFI" + dtb
56+
57+
log.Printf("write %s to %s", src, dst)
58+
59+
err = os.MkdirAll(filepath.Dir(dst), 0o600)
60+
if err != nil {
61+
return err
62+
}
63+
64+
err = copy.File(src, dst)
65+
if err != nil {
66+
return err
67+
}
68+
69+
log.Printf("wrote %s to %s", src, dst)
70+
71+
return nil
72+
}
73+
74+
// KernelArgs implements the runtime.Board.
75+
func (b *ODroidHC4) KernelArgs() procfs.Parameters {
76+
return []*procfs.Parameter{
77+
// https://wiki.odroid.com/odroid-hc4/application_note/misc/dmesg_on_display
78+
procfs.NewParameter("console").Append("tty1").Append("ttyAML0,115200n8"),
79+
}
80+
}
81+
82+
// PartitionOptions implements the runtime.Board.
83+
func (b *ODroidHC4) PartitionOptions() *runtime.PartitionOptions {
84+
return &runtime.PartitionOptions{PartitionsOffset: 2048}
85+
}

internal/app/machined/pkg/runtime/v1alpha1/platform/vmware/vmware_other.go

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
//go:build !amd64
66

7+
// Package vmware provides the VMware platform implementation.
78
package vmware
89

910
import (

pkg/machinery/constants/constants.go

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ const (
8888
// BoardNanoPiR4S is the name of the Friendlyelec Nano Pi R4S.
8989
BoardNanoPiR4S = "nanopi_r4s"
9090

91+
// BoardODroidHC4 is the name of the HardKernel ODroid HC4.
92+
BoardODroidHC4 = "odroid_hc4"
93+
9194
// KernelParamHostname is the kernel parameter name for specifying the
9295
// hostname.
9396
KernelParamHostname = "talos.hostname"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: "ODroid HC4"
3+
description: "Installing Talos on an ODroid HC4 SBC using raw disk image."
4+
aliases:
5+
- ../../../single-board-computers/odroid_hc4
6+
---
7+
## Prerequisites
8+
9+
You will need:
10+
11+
- `talosctl`
12+
- A microSD card to prepare the unit with
13+
- An additional microSD card, USB stick, or SATA drive to boot Talos from
14+
15+
Download the latest `talosctl`:
16+
17+
```shell
18+
curl -Lo /usr/local/bin/talosctl https://github.com/siderolabs/talos/releases/download/v1.4.0/talosctl-$(uname -s | tr "[:upper:]" "[:lower:]")-amd64
19+
20+
chmod +x /usr/local/bin/talosctl
21+
```
22+
23+
## Download and Write the Image
24+
25+
Download the image and decompress it:
26+
27+
```shell
28+
curl -LO https://github.com/siderolabs/talos/releases/download/v1.4.0/metal-odroid_hc4-arm64.img.xz | xz -d -
29+
30+
xz -d metal-odroid_hc4-arm64.img.xz
31+
```
32+
33+
Write the image to the chosen boot media via [BalenaEtcher](https://www.balena.io/etcher) or `dd`.
34+
35+
## Prepare the Unit
36+
37+
### Erase factory bootloader
38+
39+
- Boot device to petitboot (no USB, SDCard, etc.), the default bootloader
40+
- In petitboot menu, select `Exit to shell`
41+
- Run the following:
42+
43+
```shell
44+
flash_eraseall /dev/mtd0
45+
flash_eraseall /dev/mtd1
46+
flash_eraseall /dev/mtd2
47+
flash_eraseall /dev/mtd3
48+
```
49+
50+
- Power cycle the device
51+
52+
### Install u-boot to SPI
53+
54+
- Flash [Armbian](https://www.armbian.com/odroid-hc4/) to a micro SD card with `dd` or [BalenaEtcher](https://www.balena.io/etcher).
55+
**A bootable USB stick or SATA drive will not work for this step**
56+
- Insert the Armbian micro SD card into the unit and power it on.
57+
- Once Armbian is booted, install `crane` via the following commands.
58+
Make sure the unit is connected to the Internet:
59+
60+
```shell
61+
curl -L https://api.github.com/repos/google/go-containerregistry/releases/latest |
62+
jq -r '.assets[] | select(.name | contains("Linux_arm64")) | .browser_download_url' |
63+
xargs curl -sL |
64+
tar zxvf - && \
65+
install crane /usr/bin
66+
```
67+
68+
- Extract the `u-boot` image from the Talos installer:
69+
70+
```shell
71+
mkdir _out
72+
crane --platform=linux/arm64 export ghcr.io/siderolabs/u-boot:v1.4.0 - | tar xf - --strip-components=1 -C _out odroid_hc4/u-boot.bin
73+
```
74+
75+
- Write `u-boot.bin` to the HC4's SPI/bootloader:
76+
77+
```shell
78+
dd if=_out/u-boot.bin of=/dev/mtdblock0 conv=fsync status=progress
79+
```
80+
81+
- Power off the unit
82+
83+
## Recover Factory Bootloader
84+
85+
**Note:** Only perform these steps if you want to use Hardkernel-published distributions.
86+
Performing these actions will render the unit unable to boot Talos unless the steps in this guide are repeated.
87+
88+
Taken from [the ODroid forums](https://forum.odroid.com/viewtopic.php?t=40906):
89+
90+
- Download the latest `spiupdate` and `spiboot` archives from [here](http://ppa.linuxfactory.or.kr/images/petitboot/odroidhc4/).
91+
- Flash the `spiupdate` image to a microSD card via `dd` or `dd` or [BalenaEtcher](https://www.balena.io/etcher).
92+
- Decompress the `spiboot` archive and copy the file it contains to the flashed SD card.
93+
Ensure the file is named `spiboot.img`.
94+
- Insert the microSD card into the unit and power it on

0 commit comments

Comments
 (0)