Skip to content

Commit

Permalink
# This is a combination of 5 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

feat: Orange PI 5

Setup the folder structure for Orange PI 5

# This is the commit message siderolabs#2:

feat: Orange PI 5

First attempt, not looking good :sad:

# This is the commit message siderolabs#3:

feat: Orangi PI 5

- Use mainline

# This is the commit message siderolabs#4:

feat: Orange PI 5

# This is the commit message siderolabs#5:

fix: cleanup
  • Loading branch information
MAHDTech committed Sep 3, 2024
1 parent b04b5de commit 3515fbd
Show file tree
Hide file tree
Showing 19 changed files with 684 additions and 3 deletions.
33 changes: 33 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"customizations": {
"vscode": {
"extensions": [
"arrterian.nix-env-selector",
"esbenp.prettier-vscode",
"exiasr.hadolint",
"github.copilot",
"github.copilot-chat",
"github.vscode-github-actions",
"kamadorueda.alejandra",
"mkhl.direnv",
"ms-azuretools.vscode-docker",
"nhoizey.gremlins",
"johnpapa.vscode-peacock",
"pinage404.nix-extension-pack",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker",
"supermaven.supermaven",
"tekumura.typos-vscode",
"timonwong.shellcheck",
"tuxtina.json2yaml",
"vscodevim.vim",
"wakatime.vscode-wakatime",
"yzhang.markdown-all-in-one",
"ms-vscode.makefile-tools"
]
}
},
"image": "ghcr.io/cachix/devenv:latest",
"overrideCommand": false,
"updateContentCommand": "devenv test"
}
131 changes: 131 additions & 0 deletions .devenv.flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
inputs =
let
version = "1.0.8";
system = "x86_64-linux";
devenv_root = "/home/mahdtech/Projects/GitHub/MAHDTech/sbc-rockchip";
devenv_dotfile = ./.devenv;
devenv_dotfile_string = ".devenv";
container_name = null;
devenv_tmpdir = "/run/user/1000/";
devenv_runtime = "/run/user/1000/devenv-e62ce0a";
devenv_istesting = false;

in {
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
devenv.url = "github:cachix/devenv?dir=src/modules";
} // (if builtins.pathExists (devenv_dotfile + "/flake.json")
then builtins.fromJSON (builtins.readFile (devenv_dotfile + "/flake.json"))
else { });

outputs = { nixpkgs, ... }@inputs:
let
version = "1.0.8";
system = "x86_64-linux";
devenv_root = "/home/mahdtech/Projects/GitHub/MAHDTech/sbc-rockchip";
devenv_dotfile = ./.devenv;
devenv_dotfile_string = ".devenv";
container_name = null;
devenv_tmpdir = "/run/user/1000/";
devenv_runtime = "/run/user/1000/devenv-e62ce0a";
devenv_istesting = false;

devenv =
if builtins.pathExists (devenv_dotfile + "/devenv.json")
then builtins.fromJSON (builtins.readFile (devenv_dotfile + "/devenv.json"))
else { };
getOverlays = inputName: inputAttrs:
map
(overlay:
let
input = inputs.${inputName} or (throw "No such input `${inputName}` while trying to configure overlays.");
in
input.overlays.${overlay} or (throw "Input `${inputName}` has no overlay called `${overlay}`. Supported overlays: ${nixpkgs.lib.concatStringsSep ", " (builtins.attrNames input.overlays)}"))
inputAttrs.overlays or [ ];
overlays = nixpkgs.lib.flatten (nixpkgs.lib.mapAttrsToList getOverlays (devenv.inputs or { }));
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = devenv.allowUnfree or false;
allowBroken = devenv.allowBroken or false;
permittedInsecurePackages = devenv.permittedInsecurePackages or [ ];
};
inherit overlays;
};
lib = pkgs.lib;
importModule = path:
if lib.hasPrefix "./" path
then if lib.hasSuffix ".nix" path
then ./. + (builtins.substring 1 255 path)
else ./. + (builtins.substring 1 255 path) + "/devenv.nix"
else if lib.hasPrefix "../" path
then throw "devenv: ../ is not supported for imports"
else
let
paths = lib.splitString "/" path;
name = builtins.head paths;
input = inputs.${name} or (throw "Unknown input ${name}");
subpath = "/${lib.concatStringsSep "/" (builtins.tail paths)}";
devenvpath = "${input}" + subpath;
devenvdefaultpath = devenvpath + "/devenv.nix";
in
if lib.hasSuffix ".nix" devenvpath
then devenvpath
else if builtins.pathExists devenvdefaultpath
then devenvdefaultpath
else throw (devenvdefaultpath + " file does not exist for input ${name}.");
project = pkgs.lib.evalModules {
specialArgs = inputs // { inherit inputs pkgs; };
modules = [
(inputs.devenv.modules + /top-level.nix)
{
devenv.cliVersion = version;
devenv.root = devenv_root;
devenv.dotfile = devenv_root + "/" + devenv_dotfile_string;
}
(pkgs.lib.optionalAttrs (inputs.devenv.isTmpDir or false) {
devenv.tmpdir = devenv_tmpdir;
devenv.runtime = devenv_runtime;
})
(pkgs.lib.optionalAttrs (inputs.devenv.hasIsTesting or false) {
devenv.isTesting = devenv_istesting;
})
(pkgs.lib.optionalAttrs (container_name != null) {
container.isBuilding = pkgs.lib.mkForce true;
containers.${container_name}.isBuilding = true;
})
] ++ (map importModule (devenv.imports or [ ])) ++ [
./devenv.nix
(devenv.devenv or { })
(if builtins.pathExists ./devenv.local.nix then ./devenv.local.nix else { })
];
};
config = project.config;

options = pkgs.nixosOptionsDoc {
options = builtins.removeAttrs project.options [ "_module" ];
# Unpack Nix types, e.g. literalExpression, mDoc.
transformOptions =
let isDocType = v: builtins.elem v [ "literalDocBook" "literalExpression" "literalMD" "mdDoc" ];
in lib.attrsets.mapAttrs (_: v:
if v ? _type && isDocType v._type then
v.text
else if v ? _type && v._type == "derivation" then
v.name
else
v
);
};
in
{
packages."${system}" = {
optionsJSON = options.optionsJSON;
inherit (config) info procfileScript procfileEnv procfile;
ci = config.ciDerivation;
};
devenv = config;
devShell."${system}" = config.shell;
};
}
11 changes: 8 additions & 3 deletions Pkgfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
# syntax = ghcr.io/siderolabs/bldr:v0.3.1
# syntax = ghcr.io/siderolabs/bldr:v0.3.2

format: v1alpha2

vars:
# renovate: datasource=github-tags extractVersion=^v(?<version>.*)$ depName=ARM-software/arm-trusted-firmware
# renovate: datasource=github-tags extractVersion=^lts-v(?<version>.*)$ depName=ARM-software/arm-trusted-firmware
arm_trusted_firmware_version: 2.10.4
arm_trusted_firmware_sha256: ba215404fe9db26e5f2cef3fdce17b7c8ed344a2a1d592dd01a5f1c5e72cfdbd
arm_trusted_firmware_sha512: 0b0e634ba7b1bf3d2a0ef429391f9a6c350abe373b0563e3932f0347246b773238593036674cbb958fffce36c7449f9ebb3ee340650a3184c3e052487fae656b

arm_trusted_firmware_unstable_commit: 44418fce30938ee483fbfc79cc32fde33753d1aa
arm_trusted_firmware_unstable_sha256: 96145fbc77088eedc666369ebbdf57d9a30cd6b6febe97a57ff89cb2f0eca9bd
arm_trusted_firmware_unstable_sha512: 02c4ceda492d50a8e356b284153ec639a0e31b3479891d941236861dc8d53caefdf63d868352b5ace6d1b7dc52003fa3f06f794f4d0f2306a58eab07f15fb062

# renovate: datasource=github-tags extractVersion=^v(?<version>.*)$ depName=u-boot/u-boot
uboot_version: 2024.07
uboot_sha256: f591da9ab90ef3d6b3d173766d0ddff90c4ed7330680897486117df390d83c8f
uboot_sha512: 678f44e2b9132140f0bf05c637e57e638c73c278611037a41824b3ebff2131af4dec0163da4664bb2e5c4fd8034ba8c95b93b57f7aa9f4c045da322d87c3b5e9

rkbin_commit: a2a0b89b6c8c612dca5ed9ed8a68db8a07f68bc0
# renovate: datasource=git-refs versioning=git depName=https://github.com/rockchip-linux/rkbin.git
rkbin_ref: a2a0b89b6c8c612dca5ed9ed8a68db8a07f68bc0
rkbin_sha256: 9df375316869daadbf874410f4097591c32cc2dca5a30fd328ea7a1cd8f8b6a8
rkbin_sha512: 715253b5ef5c7fbcbce8478d4dea5ad3d1b4b738da437b5f0e9b31eed20f9bcb86cab082e4c04c69b42b6ffcc2cbb1a31079b33b968bb76826ff0dd4f83043e1
labels:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This repo provides the overlay for RockChip based Talos image.
| Overlay Name | Board | Description |
| -------------------- | --------------------- | --------------------------------------------- |
| nanopi-r4s | NanoPi R4S | Overlay for NanoPi R4S |
| orangepi-5 | Orange Pi 5 | Overlay for Orange Pi 5 |
| orangepi-r1-plus-lts | Orange Pi R1 Plus LTS | Overlay for Orange Pi R1 Plus LTS |
| rock64 | Pine64 Rock64 | Overlay for Pine64 Rock64 |
| rockpi4 | Rock Pi 4A,Rock Pi 4B | Generic overlay for Rock Pi 4A and Rock Pi 4B |
Expand Down
40 changes: 40 additions & 0 deletions artifacts/arm-trusted-firmware/rk3588/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: arm-trusted-firmware-rk3588
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: base
steps:
- sources:
- url: https://github.com/ARM-software/arm-trusted-firmware/archive/{{ .arm_trusted_firmware_unstable_commit }}.tar.gz
destination: arm-trusted-firmware.tar.gz
sha256: "{{ .arm_trusted_firmware_unstable_sha256 }}"
sha512: "{{ .arm_trusted_firmware_unstable_sha512 }}"
env:
SOURCE_DATE_EPOCH: {{.BUILD_ARG_SOURCE_DATE_EPOCH}}
prepare:
- |
mkdir -p /usr/bin \
&& ln -sf /toolchain/bin/env /usr/bin/env
pip3 install setuptools
tar xf arm-trusted-firmware.tar.gz --strip-components=1
# rk3588
build:
- |
# https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/getting_started/initial-build.rst
export CROSS_COMPILE=/toolchain/bin/aarch64-linux-musl-
make realclean
# https://salsa.debian.org/debian/arm-trusted-firmware/-/commit/6424a59e08585af7f8a56f1e16ecc6a6b9e4ad7a
# https://developer.trustedfirmware.org/T996
CFLAGS=--param=min-pagesize=0 make -j $(nproc) PLAT=rk3588 DEBUG=0 bl31
install:
- |
mkdir -p /rootfs/arm-trusted-firmware/rk3588
cp build/rk3588/release/bl31/bl31.elf /rootfs/arm-trusted-firmware/rk3588/bl31.elf
finalize:
- from: /rootfs
to: /libs
15 changes: 15 additions & 0 deletions artifacts/orangepi-5/u-boot/patches/uboot-byteorder.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
index a4cb3bfde5..0ecd088f4a 100644
--- a/include/linux/byteorder/little_endian.h
+++ b/include/linux/byteorder/little_endian.h
@@ -7,7 +7,10 @@
#ifndef __LITTLE_ENDIAN_BITFIELD
#define __LITTLE_ENDIAN_BITFIELD
#endif
+
+#ifndef __BYTE_ORDER
#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif

#include <linux/compiler.h>
#include <linux/types.h>
47 changes: 47 additions & 0 deletions artifacts/orangepi-5/u-boot/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# References:
# U-Boot:
# - https://u-boot.readthedocs.io/en/latest
name: u-boot-orangepi-5
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: base
- stage: arm-trusted-firmware-rk3588
- stage: rkbin-rk3588
steps:
- sources:
- url: https://ftp.denx.de/pub/u-boot/u-boot-{{ .uboot_version }}.tar.bz2
destination: u-boot.tar.bz2
sha256: "{{ .uboot_sha256 }}"
sha512: "{{ .uboot_sha512 }}"
env:
SOURCE_DATE_EPOCH: "{{ .BUILD_ARG_SOURCE_DATE_EPOCH }}"
prepare:
# orangepi-5-rk3588
- |
mkdir -p /usr/bin \
&& ln -sf /toolchain/bin/env /usr/bin/env \
&& ln -sf /toolchain/bin/python3 /toolchain/bin/python
pip3 install pyelftools setuptools
tar xf u-boot.tar.bz2 --strip-components=1
patch -p1 < /pkg/patches/uboot-byteorder.patch
- |
make orangepi-5-rk3588s_defconfig
build:
- |
make -j $(nproc) \
HOSTLDLIBS_mkimage="-lssl -lcrypto" \
BL31=/libs/arm-trusted-firmware/rk3588/bl31.elf \
ROCKCHIP_TPL=/libs/rkbin/rk3588_ddr_1560MHz_v1.21.bin \
CONFIG_USB_HOST_ETHER=y \
CONFIG_USB_ETHER_RTL8152=y
install:
- |
mkdir -p /rootfs/artifacts/arm64/u-boot/orangepi-5
cp u-boot-rockchip.bin /rootfs/artifacts/arm64/u-boot/orangepi-5
finalize:
- from: /rootfs
to: /rootfs
28 changes: 28 additions & 0 deletions artifacts/rkbin/3588/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# References:
# Rockchip
# - https://github.com/rockchip-linux/rkbin/tree/master/bin/rk35
name: rkbin-rk3588
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: base
steps:
- sources:
- url: https://github.com/rockchip-linux/rkbin/archive/{{ .rkbin_ref }}.tar.gz
destination: rkbin.tar.gz
sha256: "{{ .rkbin_sha256 }}"
sha512: "{{ .rkbin_sha512 }}"
env:
SOURCE_DATE_EPOCH: {{.BUILD_ARG_SOURCE_DATE_EPOCH}}
prepare:
- |
tar xf rkbin.tar.gz --strip-components=1
build:
install:
- |
mkdir -p /rootfs/rkbin
cp bin/rk35/rk3588_ddr_lp4_2112MHz_* /rootfs/rkbin/
finalize:
- from: /rootfs
to: /libs
Loading

0 comments on commit 3515fbd

Please sign in to comment.