-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds initial support for the Nano Pi R4S from Friendlyelec. This device is a networking focused rk3399 based SBC with two 1G ethernet interfaces, making it perfect for edge or SOHO deployments. Signed-off-by: Marvin Drees <[email protected]> Signed-off-by: Noel Georgi <[email protected]>
- Loading branch information
Showing
8 changed files
with
159 additions
and
5 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
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
88 changes: 88 additions & 0 deletions
88
internal/app/machined/pkg/runtime/v1alpha1/board/nanopi_r4s/nanopi_r4s.go
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,88 @@ | ||
// 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 nanopir4s | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/talos-systems/go-procfs/procfs" | ||
"golang.org/x/sys/unix" | ||
|
||
"github.com/talos-systems/talos/internal/app/machined/pkg/runtime" | ||
"github.com/talos-systems/talos/pkg/copy" | ||
"github.com/talos-systems/talos/pkg/machinery/constants" | ||
) | ||
|
||
var ( | ||
bin = fmt.Sprintf("/usr/install/arm64/u-boot/%s/u-boot-rockchip.bin", constants.BoardNanoPiR4S) | ||
off int64 = 512 * 64 | ||
dtb = "/dtb/rockchip/rk3399-nanopi-r4s.dtb" | ||
) | ||
|
||
// NanoPiR4S represents the Friendlyelec Nano Pi R4S board. | ||
// | ||
// Reference: https://wiki.friendlyelec.com/wiki/index.php/NanoPi_R4S | ||
type NanoPiR4S struct{} | ||
|
||
// Name implements the runtime.Board. | ||
func (n *NanoPiR4S) Name() string { | ||
return constants.BoardNanoPiR4S | ||
} | ||
|
||
// Install implements the runtime.Board. | ||
func (n *NanoPiR4S) Install(disk string) (err error) { | ||
file, err := os.OpenFile(disk, os.O_RDWR|unix.O_CLOEXEC, 0o666) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
defer file.Close() //nolint:errcheck | ||
|
||
uboot, err := os.ReadFile(bin) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Printf("writing %s at offset %d", bin, off) | ||
|
||
amount, err := file.WriteAt(uboot, off) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Printf("wrote %d bytes", amount) | ||
|
||
// 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. | ||
if err := file.Sync(); err != nil { | ||
return err | ||
} | ||
|
||
src := "/usr/install/arm64" + dtb | ||
dst := "/boot/EFI" + dtb | ||
|
||
if err := os.MkdirAll(filepath.Dir(dst), 0o600); err != nil { | ||
return err | ||
} | ||
|
||
return copy.File(src, dst) | ||
} | ||
|
||
// KernelArgs implements the runtime.Board. | ||
func (n *NanoPiR4S) KernelArgs() procfs.Parameters { | ||
return []*procfs.Parameter{ | ||
procfs.NewParameter("console").Append("tty0").Append("ttyS2,1500000n8"), | ||
procfs.NewParameter("sysctl.kernel.kexec_load_disabled").Append("1"), | ||
} | ||
} | ||
|
||
// PartitionOptions implements the runtime.Board. | ||
func (n *NanoPiR4S) PartitionOptions() *runtime.PartitionOptions { | ||
return &runtime.PartitionOptions{PartitionsOffset: 2048 * 10} | ||
} |
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
59 changes: 59 additions & 0 deletions
59
website/content/v1.3/talos-guides/install/single-board-computers/nanopi_r4s.md
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,59 @@ | ||
--- | ||
title: "Friendlyelec Nano PI R4S" | ||
description: "Installing Talos on a Nano PI R4S SBC using raw disk image." | ||
aliases: | ||
- ../../../single-board-computers/nanopi_r4s | ||
--- | ||
|
||
## Prerequisites | ||
|
||
You will need | ||
|
||
- `talosctl` | ||
- an SD card | ||
|
||
Download the latest `talosctl`. | ||
|
||
```bash | ||
curl -Lo /usr/local/bin/talosctl https://github.com/siderolabs/talos/releases/download/{{< release >}}/talosctl-$(uname -s | tr "[:upper:]" "[:lower:]")-amd64 | ||
chmod +x /usr/local/bin/talosctl | ||
``` | ||
|
||
## Download the Image | ||
|
||
Download the image and decompress it: | ||
|
||
```bash | ||
curl -LO https://github.com/siderolabs/talos/releases/download/{{< release >}}/metal-rockpi_4-arm64.img.xz | ||
xz -d metal-nanopi_r4s-arm64.img.xz | ||
``` | ||
|
||
## Writing the Image | ||
|
||
The path to your SD card can be found using `fdisk` on Linux or `diskutil` on macOS. | ||
In this example, we will assume `/dev/mmcblk0`. | ||
|
||
Now `dd` the image to your SD card: | ||
|
||
```bash | ||
sudo dd if=metal-nanopi_r4s-arm64.img of=/dev/mmcblk0 conv=fsync bs=4M | ||
``` | ||
|
||
## Bootstrapping the Node | ||
|
||
Insert the SD card to your board, turn it on and wait for the console to show you the instructions for bootstrapping the node. | ||
Following the instructions in the console output to connect to the interactive installer: | ||
|
||
```bash | ||
talosctl apply-config --insecure --mode=interactive --nodes <node IP or DNS name> | ||
``` | ||
|
||
Once the interactive installation is applied, the cluster will form and you can then use `kubectl`. | ||
|
||
## Retrieve the `kubeconfig` | ||
|
||
Retrieve the admin `kubeconfig` by running: | ||
|
||
```bash | ||
talosctl kubeconfig | ||
``` |