Skip to content

Commit

Permalink
feat: jetson nano SoC
Browse files Browse the repository at this point in the history
Support Jetson Nano SoC

Depends on siderolabs/pkgs#380

Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
frezbo committed Jan 18, 2022
1 parent 1d8955e commit 6d8bea5
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 9 deletions.
1 change: 1 addition & 0 deletions .drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ local release = {
'_out/metal-pine64-arm64.img.xz',
'_out/metal-bananapi_m64-arm64.img.xz',
'_out/metal-libretech_all_h3_cc_h5-arm64.img.xz',
'_out/metal-jetson_nano-arm64.img.xz',
'_out/nocloud-amd64.raw.xz',
'_out/nocloud-arm64.raw.xz',
'_out/openstack-amd64.tar.gz',
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ COPY --from=pkg-libressl-arm64 / /rootfs
COPY --from=pkg-libseccomp-arm64 / /rootfs
COPY --from=pkg-linux-firmware-arm64 /lib/firmware/bnx2 /rootfs/lib/firmware/bnx2
COPY --from=pkg-linux-firmware-arm64 /lib/firmware/bnx2x /rootfs/lib/firmware/bnx2x
COPY --from=pkg-linux-firmware-arm64 /lib/firmware/rtl_nic /rootfs/lib/firmware/rtl_nic
COPY --from=pkg-linux-firmware-arm64 /lib/firmware/nvidia/tegra210 /rootfs/lib/firmware/nvidia/tegra210
COPY --from=pkg-lvm2-arm64 / /rootfs
COPY --from=pkg-libaio-arm64 / /rootfs
COPY --from=pkg-musl-arm64 / /rootfs
Expand Down Expand Up @@ -458,6 +460,9 @@ FROM build AS initramfs-archive-arm64
WORKDIR /initramfs
COPY --from=squashfs-arm64 /rootfs.sqsh .
COPY --from=init-build-arm64 /init .
# copying over firmware binary blobs to initramfs
COPY --from=pkg-linux-firmware-arm64 /lib/firmware/rtl_nic ./lib/firmware/rtl_nic
COPY --from=pkg-linux-firmware-arm64 /lib/firmware/nvidia/tegra210 ./lib/firmware/nvidia/tegra210
RUN find . -print0 \
| xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"
RUN set -o pipefail \
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NAME = Talos

ARTIFACTS := _out
TOOLS ?= ghcr.io/talos-systems/tools:v0.10.0-alpha.0-1-g67314b1
PKGS ?= v0.10.0-alpha.0-9-g6ce1a40
PKGS ?= v0.10.0-alpha.0-11-g5dd08a7
EXTRAS ?= v0.8.0-alpha.0-1-g7c1f3cc
GO_VERSION ?= 1.17
GOFUMPT_VERSION ?= v0.1.1
Expand Down Expand Up @@ -234,7 +234,7 @@ sbc-%: ## Builds the specified SBC image. Valid options are rpi_4, rock64, banan
@docker pull $(REGISTRY_AND_USERNAME)/imager:$(IMAGE_TAG)
@docker run --rm -v /dev:/dev --privileged $(REGISTRY_AND_USERNAME)/imager:$(IMAGE_TAG) image --platform metal --arch arm64 --board $* --tar-to-stdout | tar xz -C $(ARTIFACTS)

sbcs: sbc-rpi_4 sbc-rock64 sbc-bananapi_m64 sbc-libretech_all_h3_cc_h5 sbc-rockpi_4 sbc-pine64 ## Builds all known SBC images (Raspberry Pi 4 Model B, Rock64, Banana Pi M64, Radxa ROCK Pi 4, pine64, and Libre Computer Board ALL-H3-CC).
sbcs: sbc-rpi_4 sbc-rock64 sbc-bananapi_m64 sbc-libretech_all_h3_cc_h5 sbc-rockpi_4 sbc-pine64 sbc-jetson_nano ## Builds all known SBC images (Raspberry Pi 4 Model B, Rock64, Banana Pi M64, Radxa ROCK Pi 4, pine64, Libre Computer Board ALL-H3-CC and Jetson Nano).

.PHONY: iso
iso: ## Builds the ISO and outputs it to the artifact directory.
Expand Down
3 changes: 3 additions & 0 deletions internal/app/machined/pkg/runtime/v1alpha1/board/board.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/talos-systems/talos/internal/app/machined/pkg/runtime"
bananapim64 "github.com/talos-systems/talos/internal/app/machined/pkg/runtime/v1alpha1/board/bananapi_m64"
jetsonnano "github.com/talos-systems/talos/internal/app/machined/pkg/runtime/v1alpha1/board/jetson_nano"
libretechallh3cch5 "github.com/talos-systems/talos/internal/app/machined/pkg/runtime/v1alpha1/board/libretech_all_h3_cc_h5"
"github.com/talos-systems/talos/internal/app/machined/pkg/runtime/v1alpha1/board/pine64"
"github.com/talos-systems/talos/internal/app/machined/pkg/runtime/v1alpha1/board/rock64"
Expand Down Expand Up @@ -59,6 +60,8 @@ func newBoard(board string) (b runtime.Board, err error) {
b = &rock64.Rock64{}
case constants.BoardRockpi4:
b = &rockpi4.Rockpi4{}
case constants.BoardJetsonNano:
b = &jetsonnano.JetsonNano{}
default:
return nil, fmt.Errorf("unsupported board: %q", board)
}
Expand Down
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 jetsonnano

import (
"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"
)

// References
// - https://github.com/u-boot/u-boot/blob/v2021.10/configs/p3450-0000_defconfig#L8
// - https://github.com/u-boot/u-boot/blob/v2021.10/include/configs/tegra-common.h#L53
// - https://github.com/u-boot/u-boot/blob/v2021.10/include/configs/tegra210-common.h#L49
var dtb = "/dtb/nvidia/tegra210-p3450-0000.dtb"

// JetsonNano represents the JetsonNano board
//
// References:
// - https://developer.nvidia.com/embedded/jetson-nano-developer-kit
type JetsonNano struct{}

// Name implements the runtime.Board.
func (b *JetsonNano) Name() string {
return constants.BoardJetsonNano
}

// Install implements the runtime.Board.
func (b JetsonNano) Install(disk string) (err error) {
var f *os.File

if f, err = os.OpenFile(disk, os.O_RDWR|unix.O_CLOEXEC, 0o666); err != nil {
return err
}
//nolint:errcheck
defer f.Close()

// NB: In the case that the block device is a loopback device, we sync here
// to ensure that the file is written before the loopback device is
// unmounted.
err = f.Sync()
if err != nil {
return err
}

src := "/usr/install/arm64" + dtb
dst := "/boot/EFI" + dtb

err = os.MkdirAll(filepath.Dir(dst), 0o600)
if err != nil {
return err
}

err = copy.File(src, dst)
if err != nil {
return err
}

return nil
}

// KernelArgs implements the runtime.Board.
//
// References:
// - https://elinux.org/Jetson/Nano/Upstream to enable early console
// - http://en.techinfodepot.shoutwiki.com/wiki/NVIDIA_Jetson_Nano_Developer_Kit for other chips on the SoC
func (b JetsonNano) KernelArgs() procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("tty0").Append("ttyS0,115200"),
// even though PSCI works perfectly on the Jetson Nano, the kernel is stuck
// trying to kexec. Seems the drivers state is not reset properly.
// disabling kexec until we have further knowledge on this
procfs.NewParameter("sysctl.kernel.kexec_load_disabled").Append("1"),
}
}

// PartitionOptions implements the runtime.Board.
func (b JetsonNano) PartitionOptions() *runtime.PartitionOptions {
return nil
}
5 changes: 4 additions & 1 deletion pkg/machinery/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

const (
// DefaultKernelVersion is the default Linux kernel version.
DefaultKernelVersion = "5.15.11-talos"
DefaultKernelVersion = "5.15.14-talos"

// KernelParamConfig is the kernel parameter name for specifying the URL.
// to the config.
Expand Down Expand Up @@ -57,6 +57,9 @@ const (
// BoardPine64 is the name of the Pine64.
BoardPine64 = "pine64"

// BoardJetsonNano is the name of the Jetson Nano.
BoardJetsonNano = "jetson_nano"

// BoardRock64 is the name of the Rock64.
BoardRock64 = "rock64"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You will need
- `talosctl`
- an SD card

Download the latest alpha `talosctl`.
Download the latest `talosctl`.

```bash
curl -Lo /usr/local/bin/talosctl https://github.com/talos-systems/talos/releases/latest/download/talosctl-$(uname -s | tr "[:upper:]" "[:lower:]")-amd64
Expand Down
117 changes: 117 additions & 0 deletions website/content/docs/v0.15/Single Board Computers/jetson_nano.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
title: "Jetson Nano"
description: "Installing Talos on Jetson Nano SBC using raw disk image."
---

## Prerequisites

You will need

- `talosctl`
- an SD card/USB drive
- [crane CLI](https://github.com/google/go-containerregistry/releases)

Download the latest `talosctl`.

```bash
curl -Lo /usr/local/bin/talosctl https://github.com/talos-systems/talos/releases/latest/download/talosctl-$(uname -s | tr "[:upper:]" "[:lower:]")-amd64
chmod +x /usr/local/bin/talosctl
```

## Flashing the firmware to on-board SPI flash

> Flashing the firmware only needs to be done once.
We will use the [R32.6.1 release](https://developer.nvidia.com/embedded/l4t/r32_release_v6.1/t210/jetson-210_linux_r32.6.1_aarch64.tbz2) for the Jetson Nano.
Most of the instructions is similar to this [doc](https://nullr0ute.com/2020/11/installing-fedora-on-the-nvidia-jetson-nano/) except that we'd be using a patched version of `u-boot` so that USB boot also works.

Before flashing we need the following:

- A USB-A to micro USB cable
- A jumper wire to enable recovery mode
- A HDMI monitor to view the logs if the USB serial adapter is not available
- A USB to Serial adapter with 3.3V TTL (optional)
- A 5V DC barrel jack

If you're planning to use the serial console follow the docuementation [here](https://www.jetsonhacks.com/2019/04/19/jetson-nano-serial-console/)

First start by downloading the Jetson Nano L4T release.

```bash
curl -SLO https://developer.nvidia.com/embedded/l4t/r32_release_v6.1/t210/jetson-210_linux_r32.6.1_aarch64.tbz2
```

Next we will extract the L4T release and replace the `u-boot` binary with the patched version.

```bash
tar xf jetson-210_linux_r32.6.1_aarch64.tbz2
cd Linux_for_Tegra
crane --platform=linux/arm64 export ghcr.io/talos-systems/u-boot:v0.10.0-alpha.0-11-g5dd08a7 - | tar xf - --strip-components=1 -C bootloader/t210ref/p3450-0000/ jetson_nano/u-boot.bin
```

Next we will flash the firmware to the Jetson Nano SPI flash.
In order to do that we need to put the Jetson Nano into Force Recovery Mode (FRC).
We will use the instructions from [here](https://developer.download.nvidia.com/embedded/L4T/r32_Release_v4.4/r32_Release_v4.4-GMC3/T210/l4t_quick_start_guide.txt)

- Ensure that the Jetson Nano is powered off.
There is no need for the SD card/USB storage/network cable to be connected
- Connect the micro USB cable to the micro USB port on the Jetson Nano, don't plug the other end to the PC yet
- Enable Force Recovery Mode (FRC) by placing a jumper across the FRC pins on the Jetson Nano
- For board revision *A02*, these are pins `3` and `4` of header `J40`
- For board revision *B01*, these are pins `9` and `10` of header `J50`
- Place another jumper across `J48` to enable power from the DC jack and connect the Jetson Nano to the DC jack `J25`
- Now connect the other end of the micro USB cable to the PC and remove the jumper wire from the FRC pins

Now the Jetson Nano is in Force Recovery Mode (FRC) and can be confirmed by running the following command

```bash
lsusb | grep -i "nvidia"
```

Now we can move on the flashing the firmware.

```bash
sudo ./flash p3448-0000-max-spi external
```

This will flash the firmware to the Jetson Nano SPI flash and you'll see a lot of output.
If you've connected the serial console you'll also see the progress there.
Once the flashing is done you can disconnect the USB cable and power off the Jetson Nano.

## Download the Image

Download the image and decompress it:

```bash
curl -LO https://github.com/talos-systems/talos/releases/latest/download/metal-jetson_nano-arm64.img.xz
xz -d metal-jetson_nano-arm64.img.xz
```

## Writing the Image

Now `dd` the image to your SD card/USB storage:

```bash
sudo dd if=metal-jetson_nano-arm64.img of=/dev/mmcblk0 conv=fsync bs=4M status=progress
```

| Replace `/dev/mmcblk0` with the name of your SD card/USB storage.

## Bootstrapping the Node

Insert the SD card/USB storage 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
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You will need
- `talosctl`
- an SD card

Download the latest alpha `talosctl`.
Download the latest `talosctl`.

```bash
curl -Lo /usr/local/bin/talosctl https://github.com/talos-systems/talos/releases/latest/download/talosctl-$(uname -s | tr "[:upper:]" "[:lower:]")-amd64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You will need
- `talosctl`
- an SD card

Download the latest alpha `talosctl`.
Download the latest `talosctl`.

```bash
curl -Lo /usr/local/bin/talosctl https://github.com/talos-systems/talos/releases/latest/download/talosctl-$(uname -s | tr "[:upper:]" "[:lower:]")-amd64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You will need
- `talosctl`
- an SD card

Download the latest alpha `talosctl`.
Download the latest `talosctl`.

```bash
curl -Lo /usr/local/bin/talosctl https://github.com/talos-systems/talos/releases/latest/download/talosctl-$(uname -s | tr "[:upper:]" "[:lower:]")-amd64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You will need
- `talosctl`
- an SD card

Download the latest alpha `talosctl`.
Download the latest `talosctl`.

```bash
curl -Lo /usr/local/bin/talosctl https://github.com/talos-systems/talos/releases/latest/download/talosctl-$(uname -s | tr "[:upper:]" "[:lower:]")-amd64
Expand Down
2 changes: 1 addition & 1 deletion website/content/docs/v0.15/Single Board Computers/rpi_4.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You will need
- `talosctl`
- an SD card

Download the latest alpha `talosctl`.
Download the latest `talosctl`.

```bash
curl -Lo /usr/local/bin/talosctl https://github.com/talos-systems/talos/releases/latest/download/talosctl-$(uname -s | tr "[:upper:]" "[:lower:]")-amd64
Expand Down

0 comments on commit 6d8bea5

Please sign in to comment.