Skip to content

Commit

Permalink
feat: rpi generic overlay
Browse files Browse the repository at this point in the history
Adds the `rpi_generic` overlay.

Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
frezbo committed Mar 7, 2024
1 parent 4b6ed12 commit 5000902
Show file tree
Hide file tree
Showing 26 changed files with 1,144 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-03-01T17:51:50Z by kres 1f8340d.

*
!README.md
!pkg.yaml
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-03-01T15:00:03Z by kres b661666.
# Generated on 2024-03-07T04:29:09Z by kres latest.

name: default
concurrency:
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-03-01T15:00:03Z by kres b661666.

_out
go.work.sum
19 changes: 19 additions & 0 deletions .kres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
kind: pkgfile.Build
spec:
targets:
- rpi_generic
extraBuildArgs:
- PKGS
- PKGS_PREFIX
makefile:
extraVariables:
- name: PKGS_PREFIX
defaultValue: ghcr.io/siderolabs
- name: PKGS
defaultValue: v1.7.0-alpha.0-33-g3aacf03
---
kind: common.Build
spec:
ignoredPaths:
- go.work.sum
162 changes: 162 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-03-07T04:29:09Z by kres latest.

# common variables

SHA := $(shell git describe --match=none --always --abbrev=8 --dirty)
TAG := $(shell git describe --tag --always --dirty)
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.2.3
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="$(PKGS)"
COMMON_ARGS += --build-arg=PKGS_PREFIX="$(PKGS_PREFIX)"

# extra variables

PKGS_PREFIX ?= ghcr.io/siderolabs
PKGS ?= v1.7.0-alpha.0-33-g3aacf03

# targets defines all the available targets

TARGETS = rpi_generic

# 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

18 changes: 18 additions & 0 deletions Pkgfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# syntax = ghcr.io/frezbo/bldr:v0.2.3-3-g65e6a18-dirty@sha256:bc696138e879cd2005d352f8d1963f8e22da8d523869a76c48ca86de37fcccc5

format: v1alpha2

vars:
TOOLS_IMAGE: ghcr.io/siderolabs/tools:v1.7.0-alpha.0-6-gb6b4d9e

# renovate: datasource=git-refs versioning=git depName=https://github.com/raspberrypi/firmware.git
raspberrypi_firmware_ref: dc94391863445ab867782d25ca6ae1e88579df5d
raspberrypi_firmware_sha256: a37041044b4d46e324dc03f64455a7c79a38aaf77d0bfc03e6ad7052fc217cd1
raspberrypi_firmware_sha512: cf5ed2ce16ee059c9c185ef53d079fb4a59720f1729c270480f2ffb46e5d990936ad58233486143f71d60116fd14e78edb81cd13feec1a787a47650d7eaaf56f

# renovate: datasource=github-tags extractVersion=^v(?<version>.*)$ 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
21 changes: 21 additions & 0 deletions artifacts/raspberrypi-firmware/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: raspberrypi-firmware
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: base
steps:
- sources:
- url: https://github.com/raspberrypi/firmware/archive/{{ .raspberrypi_firmware_ref }}.tar.gz
destination: raspberrypi-firmware.tar.gz
sha256: "{{ .raspberrypi_firmware_sha256 }}"
sha512: "{{ .raspberrypi_firmware_sha512 }}"
prepare:
- |
tar -xzf raspberrypi-firmware.tar.gz --strip-components=1
install:
- |
mkdir -p /rootfs/artifacts/arm64/firmware/boot
cp -av boot/* /rootfs/artifacts/arm64/firmware/boot
finalize:
- from: /rootfs
to: /rootfs
44 changes: 44 additions & 0 deletions artifacts/u-boot/patches/0002-rpi-add-NVMe-to-boot-order.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 191b5f4e0408e40f35379fdaab6b37a7ad93e298 Mon Sep 17 00:00:00 2001
Message-Id: <191b5f4e0408e40f35379fdaab6b37a7ad93e298.1668448794.git.stefan@agner.ch>
In-Reply-To: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
References: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
From: Stefan Agner <[email protected]>
Date: Tue, 29 Dec 2020 23:34:52 +0100
Subject: [PATCH] rpi: add NVMe to boot order

The Compute Module 4 I/O Board can support a NVMe. Add NVMe to the boot
order.

Signed-off-by: Stefan Agner <[email protected]>
---
include/configs/rpi.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index cd8fe8b518..7257659932 100644
--- a/include/configs/rpi.h
+++ b/include/configs/rpi.h
@@ -131,6 +131,12 @@
#define BOOT_TARGET_MMC(func)
#endif

+#if CONFIG_IS_ENABLED(CMD_NVME)
+ #define BOOT_TARGET_NVME(func) func(NVME, nvme, 0)
+#else
+ #define BOOT_TARGET_NVME(func)
+#endif
+
#if CONFIG_IS_ENABLED(CMD_USB)
#define BOOT_TARGET_USB(func) func(USB, usb, 0)
#else
@@ -151,6 +157,7 @@

#define BOOT_TARGET_DEVICES(func) \
BOOT_TARGET_MMC(func) \
+ BOOT_TARGET_NVME(func) \
BOOT_TARGET_USB(func) \
BOOT_TARGET_PXE(func) \
BOOT_TARGET_DHCP(func)
--
2.38.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
From 644bd3743aa8771ef7ecb7b7239308d6da2a5b35 Mon Sep 17 00:00:00 2001
Message-Id: <644bd3743aa8771ef7ecb7b7239308d6da2a5b35.1668448794.git.stefan@agner.ch>
In-Reply-To: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
References: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
From: Stefan Agner <[email protected]>
Date: Thu, 23 Sep 2021 23:43:31 +0200
Subject: [PATCH] Revert "nvme: Correct the prps per page calculation method"

This reverts commit 859b33c948945f7904f60a2c12a3792d356d51ad.

If there is more than one PRP List the last entry is a pointer to
the next list. From the NVM Express specification:

"The last entry within a memory page, as indicated by the memory page
size in the CC.MPS field, shall be a PRP List pointer if there is more
than a single memory page of data to be transferred."

For the purpose of calculating the number of pages required for PRP
lists we should always assume that the last entry is required for
the next PRP list.

Signed-off-by: Stefan Agner <[email protected]>
Cc: Wesley Sheng <[email protected]>
---
drivers/nvme/nvme.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index 6d0d3f3ca2..73db80a294 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -52,7 +52,7 @@ static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,
u64 *prp_pool;
int length = total_len;
int i, nprps;
- u32 prps_per_page = page_size >> 3;
+ u32 prps_per_page = (page_size >> 3) - 1;
u32 num_pages;

length -= (page_size - offset);
--
2.38.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From de29ca70117fb2bfafa8b5699b34e9e94560b785 Mon Sep 17 00:00:00 2001
Message-Id: <de29ca70117fb2bfafa8b5699b34e9e94560b785.1668448794.git.stefan@agner.ch>
In-Reply-To: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
References: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
From: Stefan Agner <[email protected]>
Date: Thu, 7 Oct 2021 12:02:39 +0200
Subject: [PATCH] usb: xhci-brcm: Make driver compatible with downstream device
tree

The downstream device tree uses just "generic-xhci" as compatible
string. Use this string to make U-Boot work with the downstream Kernel.

Signed-off-by: Stefan Agner <[email protected]>
---
drivers/usb/host/xhci-brcm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-brcm.c b/drivers/usb/host/xhci-brcm.c
index fe17924028..0c6938187b 100644
--- a/drivers/usb/host/xhci-brcm.c
+++ b/drivers/usb/host/xhci-brcm.c
@@ -82,7 +82,7 @@ static int xhci_brcm_deregister(struct udevice *dev)
}

static const struct udevice_id xhci_brcm_ids[] = {
- { .compatible = "brcm,generic-xhci" },
+ { .compatible = "generic-xhci" },
{ }
};

--
2.38.1

Loading

0 comments on commit 5000902

Please sign in to comment.