NixOS on ARM/Orange Pi Zero2 H616: Difference between revisions
imported>Ein-shved No edit summary |
imported>Ein-shved Got working USB |
||
| Line 24: | Line 24: | ||
Upstream unstable NixOS AArch64 image will boot on the Orange Pi Zero2 (H616), using the proper upstream u-boot. | Upstream unstable NixOS AArch64 image will boot on the Orange Pi Zero2 (H616), using the proper upstream u-boot. | ||
The support of allwiner H616 soc was introduced to the Linux upstream kernel since 6.0 version, | The limited support of allwiner H616 soc was introduced to the Linux upstream kernel since 6.0 version, see [[#Periphery|periphery]] for details. | ||
== Board-specific installation notes == | == Board-specific installation notes == | ||
| Line 40: | Line 40: | ||
=== Better way === | === Better way === | ||
To get the more useful output from board better to build image with kernel which supports more periphery (like USB). See [[#Periphery|periphery]]. | |||
== Serial console== | == Serial console== | ||
| Line 92: | Line 50: | ||
Connected at 1Gbps mode. | Connected at 1Gbps mode. | ||
== USB == | == Periphery== | ||
Current newest numerated kernel version 6.1 does not contains full H616 sock support. At least some regulators and USB blocks are [https://github.com/torvalds/linux/blob/v6.1-rc8/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi missing] in DTS. But they are [https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi available] in master branch. | |||
Here is flake with which an image with better periphery support (at least - USB) may be build. | |||
<syntaxHighlight lang=nix> | |||
{ | |||
description = "Build image for OrangePi Zero 2"; | |||
inputs = { | |||
nixpkgs.url = github:nixos/nixpkgs/nixos-22.11; | |||
}; | |||
outputs = { self, nixpkgs }: let | |||
system = "aarch64-linux"; | |||
#Build manipulation | |||
stateVersion = "22.11"; # NixOS Version | |||
useUnstableKernel = true; # Set to false to use mainline kernel | |||
compressImage = true; # Set to false to disable image compressing | |||
pkgs = nixpkgs.legacyPackages.x86_64-linux.pkgsCross.aarch64-multiplatform; | |||
== | # Build unstable kernel | ||
kernel = | |||
with pkgs; | |||
with lib; | |||
buildLinux rec { | |||
kernelPatches = [ | |||
linuxKernel.kernelPatches.bridge_stp_helper | |||
linuxKernel.kernelPatches.request_key_helper | |||
]; | |||
src = fetchGit { | |||
url = git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git; | |||
rev = "8395ae05cb5a2e31d36106e8c85efa11cda849be"; | |||
}; | |||
version = "6.1.0"; | |||
modDirVersion = version; | |||
extraMeta.branch = versions.majorMinor version; | |||
}; | |||
# Boot related configuration | |||
bootConfig = let | |||
bootloaderPackage = pkgs.ubootOrangePiZero2; | |||
bootloaderSubpath = "/u-boot-sunxi-with-spl.bin"; | |||
# Disable ZFS support to prevent problems with fresh kernels. | |||
filesystems = pkgs.lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" | |||
"ntfs" "cifs" /* "zfs" */ "ext4" "vfat" | |||
]; | |||
in { | |||
system.stateVersion = stateVersion; | |||
boot.kernelPackages = if useUnstableKernel | |||
then pkgs.linuxPackagesFor kernel | |||
else pkgs.linuxPackages_latest; | |||
boot.supportedFilesystems = filesystems; | |||
boot.initrd.supportedFilesystems = filesystems; | |||
sdImage = { | |||
postBuildCommands = '' | |||
# Emplace bootloader to specific place in firmware file | |||
dd if=${bootloaderPackage}${bootloaderSubpath} of=$img \ | |||
bs=8 seek=1024 \ | |||
conv=notrunc # prevent truncation of image | |||
''; | |||
inherit compressImage; | |||
}; | |||
}; | |||
== | # NixOS configuration | ||
nixosSystem = nixpkgs.lib.nixosSystem rec { | |||
inherit system; | |||
modules = [ | |||
# Default aarch64 SOC System | |||
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" | |||
# Minimal configuration | |||
"${nixpkgs}/nixos/modules/profiles/minimal.nix" | |||
{ config = bootConfig; } | |||
# Put your configuration here. e.g. ./configuration.nix | |||
]; | |||
}; | |||
in { | |||
inherit system; | |||
# Run nix build .#images.orangePiZero2 to build image. | |||
images = { | |||
orangePiZero2 = nixosSystem.config.system.build.sdImage; | |||
}; | |||
}; | |||
} | |||
</syntaxHighlight> | |||
{{note|Be careful with such firmware - the unstable kernel version may be harmfull}} | |||
== Resources == | == Resources == | ||