From 2ceb9eb240e0d2c29fdf4d2153dda2a94b230792 Mon Sep 17 00:00:00 2001 From: Noel Georgi Date: Sat, 16 Mar 2024 18:56:48 +0530 Subject: [PATCH] feat: add jetson overlay Add NVIDIA Jetson family overlay. Signed-off-by: Noel Georgi --- .conform.yaml | 48 ++++++ .dockerignore | 7 + .github/renovate.json | 7 - .github/workflows/ci.yaml | 39 +++++ .github/workflows/slack-notify.yaml | 92 +++++++++++ .gitignore | 6 +- .kres.yaml | 2 +- Makefile | 156 ++++++++++++++++++ Pkgfile | 5 - README.md | 21 +-- artifacts/u-boot/pkg.yaml | 12 +- go.work | 2 +- hack/release.sh | 66 ++++++++ hack/release.toml | 11 ++ installers/board/src/main.go | 56 ------- installers/{board => jetson_nano}/pkg.yaml | 6 +- installers/{board => jetson_nano}/src/go.mod | 3 +- installers/{board => jetson_nano}/src/go.sum | 2 + installers/jetson_nano/src/main.go | 78 +++++++++ installers/pkg.yaml | 8 +- .../jetson_nano.yaml} | 2 +- profiles/pkg.yaml | 2 +- 22 files changed, 531 insertions(+), 100 deletions(-) create mode 100644 .conform.yaml create mode 100644 .dockerignore create mode 100644 .github/workflows/slack-notify.yaml create mode 100755 hack/release.sh create mode 100644 hack/release.toml delete mode 100644 installers/board/src/main.go rename installers/{board => jetson_nano}/pkg.yaml (72%) rename installers/{board => jetson_nano}/src/go.mod (78%) rename installers/{board => jetson_nano}/src/go.sum (83%) create mode 100644 installers/jetson_nano/src/main.go rename profiles/{board/board.yaml => jetson_nano/jetson_nano.yaml} (88%) diff --git a/.conform.yaml b/.conform.yaml new file mode 100644 index 0000000..1a04f63 --- /dev/null +++ b/.conform.yaml @@ -0,0 +1,48 @@ +# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. +# +# Generated on 2024-03-16T13:23:31Z by kres c2d361c. + +policies: + - type: commit + spec: + dco: true + gpg: + required: true + identity: + gitHubOrganization: siderolabs + spellcheck: + locale: US + maximumOfOneCommit: true + header: + length: 89 + imperative: true + case: lower + invalidLastCharacters: . + body: + required: true + conventional: + types: + - chore + - docs + - perf + - refactor + - style + - test + - release + scopes: + - .* + - type: license + spec: + root: . + skipPaths: + - .git/ + - testdata/ + includeSuffixes: + - .go + excludeSuffixes: + - .pb.go + - .pb.gw.go + header: | + // 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/. diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a654fb3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. +# +# Generated on 2024-03-16T13:23:31Z by kres c2d361c. + +* +!README.md +!pkg.yaml diff --git a/.github/renovate.json b/.github/renovate.json index 84f5e13..293f31d 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -31,13 +31,6 @@ } ], "packageRules": [ - { - "matchPackageNames": [ - "u-boot/u-boot", - "ARM-software/arm-trusted-firmware" - ], - "versioning": "regex:^(?\\d+)\\.(?\\d+)\\.?(?\\d+)?$" - }, { "matchPackagePatterns": [ "*" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 23e242e..b4cb978 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,3 +1,7 @@ +# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. +# +# Generated on 2024-03-16T13:23:31Z by kres c2d361c. + name: default concurrency: group: ${{ github.head_ref || github.run_id }} @@ -37,3 +41,38 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 + - name: Unshallow + run: | + git fetch --prune --unshallow + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + append: | + - endpoint: tcp://buildkit-arm64.ci.svc.cluster.local:1234 + platforms: linux/arm64 + driver: remote + endpoint: tcp://127.0.0.1:1234 + - name: Build + run: | + make + - name: Login to registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + password: ${{ secrets.GITHUB_TOKEN }} + registry: ghcr.io + username: ${{ github.repository_owner }} + - name: Push to registry + if: github.event_name != 'pull_request' + run: | + make PUSH=true + - name: release-notes + if: startsWith(github.ref, 'refs/tags/') + run: | + make release-notes + - name: Release + if: startsWith(github.ref, 'refs/tags/') + uses: crazy-max/ghaction-github-release@v2 + with: + body_path: _out/RELEASE_NOTES.md + draft: "true" diff --git a/.github/workflows/slack-notify.yaml b/.github/workflows/slack-notify.yaml new file mode 100644 index 0000000..8f5df38 --- /dev/null +++ b/.github/workflows/slack-notify.yaml @@ -0,0 +1,92 @@ +# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. +# +# Generated on 2024-03-16T13:23:31Z by kres c2d361c. + +name: slack-notify +"on": + workflow_run: + workflows: + - default + types: + - completed +jobs: + slack-notify: + runs-on: + - self-hosted + - generic + if: github.event.workflow_run.conclusion != 'skipped' + steps: + - name: Get PR number + id: get-pr-number + if: github.event.workflow_run.event == 'pull_request' + env: + GH_TOKEN: ${{ github.token }} + run: | + echo pull_request_number=$(gh pr view -R ${{ github.repository }} ${{ github.event.workflow_run.head_repository.owner.login }}:${{ github.event.workflow_run.head_branch }} --json number --jq .number) >> $GITHUB_OUTPUT + - name: Slack Notify + uses: slackapi/slack-github-action@v1 + with: + channel-id: proj-talos-maintainers + payload: | + { + "attachments": [ + { + "color": "${{ github.event.workflow_run.conclusion == 'success' && '#2EB886' || github.event.workflow_run.conclusion == 'failure' && '#A30002' || '#FFCC00' }}", + "fallback": "test", + "blocks": [ + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "${{ github.event.workflow_run.event == 'pull_request' && format('*Pull Request:* {0} (`{1}`)\n<{2}/pull/{3}|{4}>', github.repository, github.ref_name, github.event.repository.html_url, steps.get-pr-number.outputs.pull_request_number, github.event.workflow_run.display_title) || format('*Build:* {0} (`{1}`)\n<{2}/commit/{3}|{4}>', github.repository, github.ref_name, github.event.repository.html_url, github.sha, github.event.workflow_run.display_title) }}" + }, + { + "type": "mrkdwn", + "text": "*Status:*\n`${{ github.event.workflow_run.conclusion }}`" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Author:*\n`${{ github.actor }}`" + }, + { + "type": "mrkdwn", + "text": "*Event:*\n`${{ github.event.workflow_run.event }}`" + } + ] + }, + { + "type": "divider" + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Logs" + }, + "url": "${{ github.event.workflow_run.html_url }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Commit" + }, + "url": "${{ github.event.repository.html_url }}/commit/${{ github.sha }}" + } + ] + } + ] + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.gitignore b/.gitignore index 2cf20a6..c8ee014 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ -go.work.sum +# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. +# +# Generated on 2024-03-16T13:23:31Z by kres c2d361c. + _out +go.work.sum diff --git a/.kres.yaml b/.kres.yaml index f602815..a36c7e3 100644 --- a/.kres.yaml +++ b/.kres.yaml @@ -2,7 +2,7 @@ kind: pkgfile.Build spec: targets: - - sbc-board + - sbc-jetson extraBuildArgs: - PKGS_PREFIX - PKGS diff --git a/Makefile b/Makefile index 38a3f9b..c3dd042 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,162 @@ +# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. +# +# Generated on 2024-03-16T13:23:31Z by kres c2d361c. + +# common variables + +SHA := $(shell git describe --match=none --always --abbrev=8 --dirty) +TAG := $(shell git describe --tag --always --dirty --match v[0-9]\*) +ABBREV_TAG := $(shell git describe --tags >/dev/null 2>/dev/null && git describe --tag --always --match v[0-9]\* --abbrev=0 || echo 'undefined') +BRANCH := $(shell git rev-parse --abbrev-ref HEAD) +ARTIFACTS := _out +OPERATING_SYSTEM := $(shell uname -s | tr '[:upper:]' '[:lower:]') +GOARCH := $(shell uname -m | tr '[:upper:]' '[:lower:]') + +ifeq ($(GOARCH),x86_64) + GOARCH := amd64 +endif +REGISTRY ?= ghcr.io +USERNAME ?= siderolabs +REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME) KRES_IMAGE ?= ghcr.io/siderolabs/kres:latest +CONFORMANCE_IMAGE ?= ghcr.io/siderolabs/conform:latest + +# source date epoch of first commit + +INITIAL_COMMIT_SHA := $(shell git rev-list --max-parents=0 HEAD) +SOURCE_DATE_EPOCH := $(shell git log $(INITIAL_COMMIT_SHA) --pretty=%ct) + +# sync bldr image with pkgfile + +BLDR_RELEASE := v0.3.0 +BLDR_IMAGE := ghcr.io/siderolabs/bldr:$(BLDR_RELEASE) +BLDR := docker run --rm --user $(shell id -u):$(shell id -g) --volume $(PWD):/src --entrypoint=/bldr $(BLDR_IMAGE) --root=/src + +# docker build settings + +BUILD := docker buildx build +PLATFORM ?= linux/amd64,linux/arm64 +PROGRESS ?= auto +PUSH ?= false +CI_ARGS ?= +COMMON_ARGS = --file=Pkgfile +COMMON_ARGS += --provenance=false +COMMON_ARGS += --progress=$(PROGRESS) +COMMON_ARGS += --platform=$(PLATFORM) +COMMON_ARGS += --build-arg=SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) +COMMON_ARGS += --build-arg=PKGS_PREFIX="$(PKGS_PREFIX)" +COMMON_ARGS += --build-arg=PKGS="$(PKGS)" + +# extra variables + +PKGS_PREFIX ?= ghcr.io/siderolabs +PKGS ?= v1.7.0-alpha.0-33-g3aacf03 + +# targets defines all the available targets + +TARGETS = sbc-jetson + +# help menu + +export define HELP_MENU_HEADER +# Getting Started + +To build this project, you must have the following installed: + +- git +- make +- docker (19.03 or higher) + +## Creating a Builder Instance + +The build process makes use of experimental Docker features (buildx). +To enable experimental features, add 'experimental: "true"' to '/etc/docker/daemon.json' on +Linux or enable experimental features in Docker GUI for Windows or Mac. + +To create a builder instance, run: + + docker buildx create --name local --use + +If running builds that needs to be cached aggresively create a builder instance with the following: + + docker buildx create --name local --use --config=config.toml + +config.toml contents: + +[worker.oci] + gc = true + gckeepstorage = 50000 + + [[worker.oci.gcpolicy]] + keepBytes = 10737418240 + keepDuration = 604800 + filters = [ "type==source.local", "type==exec.cachemount", "type==source.git.checkout"] + [[worker.oci.gcpolicy]] + all = true + keepBytes = 53687091200 + +If you already have a compatible builder instance, you may use that instead. + +## Artifacts + +All artifacts will be output to ./$(ARTIFACTS). Images will be tagged with the +registry "$(REGISTRY)", username "$(USERNAME)", and a dynamic tag (e.g. $(IMAGE):$(TAG)). +The registry and username can be overridden by exporting REGISTRY, and USERNAME +respectively. + +endef + +all: $(TARGETS) ## Builds all targets defined. + +.PHONY: clean +clean: ## Cleans up all artifacts. + @rm -rf $(ARTIFACTS) + +$(ARTIFACTS): ## Creates artifacts directory. + @mkdir -p $(ARTIFACTS) + +target-%: ## Builds the specified target defined in the Pkgfile. The build result will only remain in the build cache. + @$(BUILD) --target=$* $(COMMON_ARGS) $(TARGET_ARGS) $(CI_ARGS) . + +local-%: ## Builds the specified target defined in the Pkgfile using the local output type. The build result will be output to the specified local destination. + @$(MAKE) target-$* TARGET_ARGS="--output=type=local,dest=$(DEST) $(TARGET_ARGS)" + +docker-%: ## Builds the specified target defined in the Pkgfile using the docker output type. The build result will be loaded into Docker. + @$(MAKE) target-$* TARGET_ARGS="$(TARGET_ARGS)" + +reproducibility-test-local-%: ## Builds the specified target defined in the Pkgfile using the local output type with and without cahce. The build result will be output to the specified local destination + @rm -rf $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b + @$(MAKE) local-$* DEST=$(ARTIFACTS)/build-a + @$(MAKE) local-$* DEST=$(ARTIFACTS)/build-b TARGET_ARGS="--no-cache" + @touch -ch -t $$(date -d @$(SOURCE_DATE_EPOCH) +%Y%m%d0000) $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b + @diffoscope $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b + @rm -rf $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b + +.PHONY: $(TARGETS) +$(TARGETS): + @$(MAKE) docker-$@ TARGET_ARGS="--tag=$(REGISTRY_AND_USERNAME)/$@:$(TAG) --push=$(PUSH)" + +.PHONY: deps.png +deps.png: ## Generates a dependency graph of the Pkgfile. + @$(BLDR) graph | dot -Tpng -o deps.png .PHONY: rekres rekres: @docker pull $(KRES_IMAGE) @docker run --rm --net=host --user $(shell id -u):$(shell id -g) -v $(PWD):/src -w /src -e GITHUB_TOKEN $(KRES_IMAGE) + +.PHONY: help +help: ## This help menu. + @echo "$$HELP_MENU_HEADER" + @grep -E '^[a-zA-Z%_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: release-notes +release-notes: + mkdir -p $(ARTIFACTS) + @ARTIFACTS=$(ARTIFACTS) ./hack/release.sh $@ $(ARTIFACTS)/RELEASE_NOTES.md $(TAG) + +.PHONY: conformance +conformance: + @docker pull $(CONFORMANCE_IMAGE) + @docker run --rm -it -v $(PWD):/src -w /src $(CONFORMANCE_IMAGE) enforce + diff --git a/Pkgfile b/Pkgfile index 848c09c..41046c9 100644 --- a/Pkgfile +++ b/Pkgfile @@ -2,10 +2,5 @@ format: v1alpha2 -vars: - # renovate: datasource=github-tags extractVersion=^v(?.*)$ depName=u-boot/u-boot - uboot_version: 2023.01 - uboot_sha256: 69423bad380f89a0916636e89e6dcbd2e4512d584308d922d1039d1e4331950f - uboot_sha512: 417a28267eb7875820d08fafc7316f164663609378637539e71648b0b9b7d28796b6c381717f31b0ab6472805fefd32628ef7d1b2e7b9f3c51c8ad122993f679 labels: org.opencontainers.image.source: https://github.com/siderolabs/sbc-raspberrypi diff --git a/README.md b/README.md index c185e90..2ac9062 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,9 @@ -# sbc-template +# sbc-jetson -This is a template repository to generate a new project for the SBC. +This repo provides the overlay for NVIDIA Jetson Talos image. -The template already contains an example of building and copying over `u-boot`. -This can be used as a starting point for your own project. +## Supported Overlay -## Requirements - -Using a sbc project templates assume docker is installed on your machine. - -## Usage - -* Create a new repository using this template. -* Start by replacing `board` to `` -* Update `installers//src/main.go` with your own logic. -* Run `make rekres` -* Now run `make help` on instructions on setting up `buildx` builder if one is not already setup. +| Overlay Name | Board | Description | +| ------------ | ----------- | ------------------- | +| jetson_nano | Jetson Nano | Jetson Nano overlay | diff --git a/artifacts/u-boot/pkg.yaml b/artifacts/u-boot/pkg.yaml index 868bd7b..8deb065 100644 --- a/artifacts/u-boot/pkg.yaml +++ b/artifacts/u-boot/pkg.yaml @@ -10,10 +10,10 @@ dependencies: - stage: base steps: - sources: - - url: https://ftp.denx.de/pub/u-boot/u-boot-{{ .uboot_version }}.tar.bz2 + - url: https://github.com/OE4T/u-boot-tegra/archive/refs/tags/v2022.07.tar.gz destination: u-boot.tar.bz2 - sha256: "{{ .uboot_sha256 }}" - sha512: "{{ .uboot_sha512 }}" + sha256: e8f03d0b3dc2d70db5833f0e6f3ac305c0de0d71ff823c7d6210edee68e29a46 + sha512: 986e79cfe56878f17750144c8e21f03a9f802d94b7e39ca7268336422f8ab99268d85a4debe5c8f48e25a31f8e1e37e02b3fad448c2737dee286fb07486a06ba env: SOURCE_DATE_EPOCH: {{ .BUILD_ARG_SOURCE_DATE_EPOCH }} prepare: @@ -23,15 +23,15 @@ steps: tar xf u-boot.tar.bz2 --strip-components=1 - | - make _defconfig + make p3450-0000_defconfig sed -i "s/CONFIG_TOOLS_LIBCRYPTO=y/# CONFIG_TOOLS_LIBCRYPTO is not set/" .config build: - | make -j $(nproc) HOSTLDLIBS_mkimage="-lssl -lcrypto" install: - | - mkdir -p /rootfs/artifacts/arm64/u-boot/board - cp -v u-boot.bin /rootfs/artifacts/arm64/u-boot/board + mkdir -p /rootfs/artifacts/arm64/u-boot/jetson_nano + cp -v u-boot.bin /rootfs/artifacts/arm64/u-boot/jetson_nano finalize: - from: /rootfs to: /rootfs diff --git a/go.work b/go.work index c35cdff..269f4d2 100644 --- a/go.work +++ b/go.work @@ -1,3 +1,3 @@ go 1.22.1 -use ./installers/board/src +use ./installers/jetson_nano/src diff --git a/hack/release.sh b/hack/release.sh new file mode 100755 index 0000000..7664fe7 --- /dev/null +++ b/hack/release.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. +# +# Generated on 2024-03-16T13:23:31Z by kres c2d361c. + +set -e + +RELEASE_TOOL_IMAGE="ghcr.io/siderolabs/release-tool:latest" + +function release-tool { + docker pull "${RELEASE_TOOL_IMAGE}" >/dev/null + docker run --rm -w /src -v "${PWD}":/src:ro "${RELEASE_TOOL_IMAGE}" -l -d -n -t "${1}" ./hack/release.toml +} + +function changelog { + if [ "$#" -eq 1 ]; then + (release-tool ${1}; echo; cat CHANGELOG.md) > CHANGELOG.md- && mv CHANGELOG.md- CHANGELOG.md + else + echo 1>&2 "Usage: $0 changelog [tag]" + exit 1 + fi +} + +function release-notes { + release-tool "${2}" > "${1}" +} + +function cherry-pick { + if [ $# -ne 2 ]; then + echo 1>&2 "Usage: $0 cherry-pick " + exit 1 + fi + + git checkout $2 + git fetch + git rebase upstream/$2 + git cherry-pick -x $1 +} + +function commit { + if [ $# -ne 1 ]; then + echo 1>&2 "Usage: $0 commit " + exit 1 + fi + + git commit -s -m "release($1): prepare release" -m "This is the official $1 release." +} + +if declare -f "$1" > /dev/null +then + cmd="$1" + shift + $cmd "$@" +else + cat <