NixOS on ARM/Orange Pi Zero2 H616: Difference between revisions
imported>Ein-shved No edit summary |
m Add category |
||
| (4 intermediate revisions by one other user not shown) | |||
| 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== | |||
The default console configuration from sd-image-aarch64 works out of the box. | |||
== Ethernet == | |||
Connected at 1Gbps mode. | |||
== 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> | <syntaxHighlight lang=nix> | ||
{ | { | ||
description = "Build image for | description = "Build image for OrangePi Zero 2"; | ||
inputs | inputs = { | ||
outputs = { self, nixpkgs }: | nixpkgs.url = github:nixos/nixpkgs/nixos-22.11; | ||
}; | |||
outputs = { self, nixpkgs }: let | |||
system = "aarch64-linux"; | 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 = [ | modules = [ | ||
# | # Default aarch64 SOC System | ||
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" | "${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 = { | images = { | ||
orangePiZero2 = nixosSystem.config.system.build.sdImage; | |||
}; | }; | ||
}; | }; | ||
| Line 82: | Line 138: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
{{note|Be careful with such firmware - the unstable kernel version may be harmfull}} | |||
== | === USB === | ||
The suggested master kernel supports only the onboard usb ports (not sure about USB type-C). If you want to use extension board or D+/D- pins, you need to add dts overlay to enable ehci and ohci ports. Just enable them all, putting this to configuration: | |||
<syntaxHighlight lang=nix> | |||
hardware.deviceTree = { | |||
enable = true; | |||
filter = "sun50i-h616-orangepi-zero2.dtb"; | |||
overlays = [ | |||
{ | |||
name = "sun50i-h616-orangepi-zero2.dtb"; | |||
dtsText = '' | |||
/dts-v1/; | |||
/plugin/; | |||
/ { | |||
compatible = "xunlong,orangepi-zero2", "allwinner,sun50i-h616"; | |||
}; | |||
&ehci0 { | |||
status = "okay"; | |||
}; | |||
&ehci1 { | |||
status = "okay"; | |||
}; | |||
&ehci2 { | |||
status = "okay"; | |||
}; | |||
&ehci3 { | |||
status = "okay"; | |||
}; | |||
&ohci0 { | |||
status = "okay"; | |||
}; | |||
&ohci1 { | |||
status = "okay"; | |||
}; | |||
= | &ohci2 { | ||
status = "okay"; | |||
}; | |||
&ohci3 { | |||
status = "okay"; | |||
}; | |||
''; | |||
} | |||
]; | |||
}; | |||
</syntaxHighlight> | |||
== | === WiFi === | ||
According to SOC [https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi dts], Wi-Fi does not supported yet in mainline. | |||
== HDMI == | === HDMI === | ||
According to SOC [https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi dts], HDMI does not supported yet in mainline. | |||
== Resources == | == Resources == | ||
| Line 104: | Line 208: | ||
* [http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/details/Orange-Pi-Zero-2.html Official product page] | * [http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/details/Orange-Pi-Zero-2.html Official product page] | ||
* [https://linux-sunxi.org/Xunlong_Orange_Pi_Zero2 wiki page] | * [https://linux-sunxi.org/Xunlong_Orange_Pi_Zero2 wiki page] | ||
[[Category:NixOS on ARM]] | |||