Difference between revisions of "NixOS on ARM"

From NixOS Wiki
Jump to: navigation, search
m (Update deprecated SD image paths in example configs)
m (Removed protection from "NixOS on ARM")
 
(75 intermediate revisions by 37 users not shown)
Line 1: Line 1:
ARM support for NixOS is a work-in-progress, but is progressing quickly.
+
This section has been moved to the official NixOS Wiki:
  
The support varies depending on the architecture and the specific boards. The way the ARM integration is built into NixOS is by making generic builds the first-class citizens; as soon as there is upstream support for the board in the kernel and the bootloader, NixOS should work once updated to these versions. It is still possible, when needed, to build and use a customised bootloader and kernel for specific boards<sup>[[Talk:NixOS_on_ARM#NixOS_.22support.22_for_board-specific_kernels_or_bootloaders|[reference needed]]]</sup>. At this moment in time (early 2018) only AArch64 is planned for full support upstream. Though, neither armv6l or armv7l are being ignored, fixes are worked on and approved as needed; what's missing is support and upstream builds being maintained in binary form. Additional resources (and some sd card images) can be found courtesy of [https://github.com/illegalprime/nixos-on-arm illegalprime].
+
    ⇒ '''[https://wiki.nixos.org/wiki/NixOS_on_ARM NixOS on ARM]'''
  
== Supported devices ==
+
''— samueldr, Lead of NixOS on ARM.''
 
 
=== Upstream (NixOS) supported devices ===
 
 
 
NixOS has support for these boards using AArch64 architecture on the nixpkgs-unstable and stable channel.
 
 
 
Support for those board assumes as much is supported as Mainline Linux supports.
 
<!--
 
Order for the device table is:
 
* By manufacturer name, alphabetical.
 
* By release date, chronological (older first).
 
-->
 
{|class="table"
 
!width="2%"| Manufacturer
 
!width="2%"| Board
 
!width="2%"| SoC
 
!width="2%"| ISA
 
!width="2%"| CPU
 
!width="2%"| RAM
 
!width="2%"| Storage
 
|-
 
| Raspberry Pi Foundation
 
| [[NixOS_on_ARM/Raspberry_Pi_3|Raspberry Pi 3]]
 
| Broadcom BCM2837
 
| AArch64 / ARMv7
 
| 4× Cortex-A53 @ 1.2 GHz
 
| 1 GB
 
| SD/microSD
 
|-
 
| Raspberry Pi Foundation
 
| [[NixOS_on_ARM/Raspberry_Pi 4|Raspberry Pi 4]]
 
| Broadcom BCM2711
 
| AArch64 / ARMv7
 
| 4× Cortex-A53 @ 1.5 GHz
 
| 1-8 GB
 
| microSD
 
|}
 
=== Community supported devices ===
 
 
 
The installation images by '''@dezgeg''' should work on the following devices; follow the links for more details, like installation instructions and device-specific notes.
 
 
 
<!--
 
Order for the device table is:
 
* By manufacturer name, alphabetical.
 
* By release date, chronological (older first).
 
-->
 
<div class="table-responsive">
 
{|class="table"
 
!width="2%"| Manufacturer
 
!width="2%"| Board
 
!width="2%"| SoC
 
!width="2%"| ISA
 
!width="2%"| CPU
 
!width="2%"| RAM
 
!width="2%"| Storage
 
|-
 
| ASUS
 
| [[NixOS_on_ARM/Tinker Board|Tinker Board]]
 
| Rockchip RK3288
 
| ARMv7
 
| 4× Cortex-A17
 
| 2 GB
 
| microSD
 
|-
 
| Banana Pi
 
| [[NixOS_on_ARM/Banana Pi|Banana Pi]]
 
| Allwinner A20
 
| ARMv7
 
| 2× Cortex-A7
 
| 1 GB
 
| SD, SATA
 
|-
 
| Banana Pi M64
 
| [[NixOS_on_ARM/Banana Pi M64|Banana Pi M64]]
 
| Allwinner A64
 
| ARMv8
 
| 4× Cortex-A53
 
| 2 GB
 
| microSD, 8GB eMMc
 
|-
 
| BeagleBoard.org
 
| [[NixOS_on_ARM/BeagleBone_Black|BeagleBone Black]]
 
| TI AM335x
 
| ARMv7
 
| 1× Cortex-A8 @ 1 GHz
 
| 512 MB
 
| 4 GB eMMC, microSD
 
|-
 
| Firefly
 
| [[NixOS_on_ARM/Firefly_AIO-3399C|AIO-3399C]]
 
| Rockchip RK3399
 
| AArch64
 
| 2× Cortex-A72 @ 2.0 GHz, 4x Cortex-A53 @ 1.5 Ghz
 
| 2/4 GB
 
| 8/16 GB eMMC, microSD
 
|-
 
| FriendlyElec
 
| [[NixOS_on_ARM/NanoPC-T4|NanoPC-T4]]
 
| Rockchip RK3399
 
| AArch64
 
| 2× Cortex-A72 @ 2.0 GHz, 4x Cortex-A53 @ 1.5 Ghz
 
| 4 GB
 
| 16 GB eMMC, microSD, NVMe
 
|-
 
| Hardkernel
 
| [[NixOS_on_ARM/ODROID-HC1|ODROID-HC1 & ODROID-HC2]]
 
| Samsung Exynos 5422
 
| ARMv7
 
| 4 × Cortex-A15 @ 2GHz, 4 × Cortex-A7 @ 1.4GHz
 
| 2 GB
 
| microSD
 
|-
 
| Hardkernel
 
| [[NixOS_on_ARM/ODROID-C2|ODROID-C2]]
 
| Amlogic S905
 
| AArch64
 
| 4 × Cortex-A53 @ 1.5GHz
 
| 2 GB
 
| eMMC, microSD
 
|-
 
| Hardkernel
 
| [[NixOS_on_ARM/ODROID-HC4|ODROID-HC4]]
 
| Amlogic S905X3
 
| AArch64
 
| 4 × Cortex-A55 @ 1.8GHz
 
| 4 GB
 
| microSD
 
|-
 
| Libre Computer
 
| [[NixOS_on_ARM/Libre_Computer_ROC-RK3399-PC|ROC-RK3399-PC]]
 
| Rockchip RK3399
 
| AArch64
 
| 2× Cortex-A72 @ 2.0 GHz, 4x Cortex-A53 @ 1.5 Ghz
 
| 4 GB
 
| eMMC, microSD, NVMe
 
|-
 
| Linksprite
 
| [[NixOS_on_ARM/PcDuino3_Nano|pcDuino3 Nano]]
 
| Allwinner A20
 
| ARMv7
 
| 2× Cortex-A7 @ 1 GHz
 
| 1 GB
 
| 4 GB NAND, microSD, SATA
 
|-
 
| NVIDIA
 
| [[NixOS_on_ARM/Jetson TK1|Jetson TK1]]
 
| Tegra K1/T124
 
| ARMv7
 
| 4× Cortex-A15 @ 2.3 GHz
 
| 2 GB
 
| 16 GB eMMC, SD, SATA
 
|-
 
| Orange Pi
 
| [[NixOS_on_ARM/Orange_Pi_One|Orange Pi One]]
 
| Allwinner H3
 
| ARMv7
 
| 4× Cortex-A7 @ 1.2 GHz
 
| 512 MB
 
| microSD
 
|-
 
| Orange Pi
 
| [[NixOS_on_ARM/Orange_Pi_PC|Orange Pi PC]]
 
| Allwinner H3
 
| ARMv7
 
| 4× Cortex-A7 @ 1.6 GHz
 
| 1 GB
 
| SD/microSD
 
|-
 
| Orange Pi
 
| [[NixOS_on_ARM/Orange_Pi_Zero_Plus2_H5|Orange Pi Zero Plus2 (H5)]]
 
| Allwinner H5
 
| AArch64
 
| 4× Cortex-A53 @ 1.2 GHz
 
| 1 GB
 
| SD/microSD + 8GB eMMC
 
|-
 
| PINE64
 
| [[NixOS_on_ARM/PINE A64-LTS|PINE A64-LTS]]
 
| Allwinner R18
 
| AArch64
 
| 4× Cortex-A53 @ ? GHz
 
| 2 GB
 
| microSD & eMMC
 
|-
 
| PINE64
 
| [[NixOS_on_ARM/PINE64_Pinebook|Pinebook]]
 
| Allwinner A64
 
| AArch64
 
| 4× Cortex-A53 @ ? GHz
 
| 2 GB
 
| microSD & eMMC
 
|-
 
| PINE64
 
| [[NixOS_on_ARM/PINE64_Pinebook_Pro|Pinebook Pro]]
 
| Rockchip RK3399
 
| AArch64
 
| 2× Cortex-A72 @ 2.0 GHz, 4x Cortex-A53 @ 1.5 Ghz
 
| 4 GB
 
| microSD & eMMC
 
|-
 
| PINE64
 
| [[NixOS_on_ARM/PINE64_ROCK64|ROCK64]]
 
| Rockchip RK3328
 
| AArch64
 
| 4x Cortex-A53 @ 1.5 GHz
 
| 1/2/4 GB
 
| microSD/eMMC
 
|-
 
| PINE64
 
| [[NixOS_on_ARM/PINE64_ROCKPro64|ROCKPro64]]
 
| Rockchip RK3399
 
| AArch64
 
| 2× Cortex-A72 @ 2.0 GHz, 4x Cortex-A53 @ 1.5 Ghz
 
| 2/4 GB
 
| microSD/eMMC
 
|-
 
| Raspberry Pi Foundation
 
| [[NixOS_on_ARM/Raspberry_Pi|Raspberry Pi]]
 
| Broadcom BCM2835
 
| ARMv6
 
| 1× ARM1176 @ 700 MHz
 
| 256 MB / 512 MB
 
| SD/microSD
 
|-
 
| Raspberry Pi Foundation
 
| [[NixOS_on_ARM/Raspberry_Pi|Raspberry Pi 2]]
 
| Broadcom BCM2836
 
| ARMv7
 
| 4× Cortex-A7 @ 900 MHz
 
| 1 GB
 
| SD/microSD
 
|-
 
| Raspberry Pi Foundation
 
| [[NixOS_on_ARM/Raspberry_Pi 3|Raspberry Pi 3]]
 
| Broadcom BCM2837
 
| AArch64 / ARMv7
 
| 4× Cortex-A53 @ 1.2 GHz
 
| 1 GB
 
| SD/microSD
 
|-
 
| Raspberry Pi Foundation
 
| [[NixOS_on_ARM/Raspberry_Pi 4|Raspberry Pi 4]]
 
| Broadcom BCM2711
 
| AArch64 / ARMv7
 
| 4× Cortex-A53 @ 1.5 GHz
 
| 1-8 GB
 
| microSD
 
|-
 
| Toshiba
 
| [[NixOS_on_ARM/Toshiba AC100|AC100 (mini laptop)]]
 
| Tegra 2 250 (T20)
 
| ARMv7
 
| 2× Cortex-A9 @ 1 GHz
 
| 512 MB
 
| 8­­–32 GB eMMC, SD
 
|-
 
| Wandboard
 
| [[NixOS_on_ARM/Wandboard|Wandboard Solo/Dual/Quad]]
 
| Freescale i.MX6
 
| ARMv7
 
| 1×/2×/4× Cortex-A9 @ 1000 MHz
 
| 512 MB / 1 GB / 2 GB
 
| microSD, SATA
 
|}
 
</div>
 
 
 
==== Special Devices ====
 
 
 
It is possible to emulate an ARM platform with QEMU.
 
 
 
<div class="table-responsive">
 
{|class="table"
 
!width="2%"| Manufacturer
 
!width="2%"| Board
 
!width="2%"| SoC
 
!width="2%"| ISA
 
!width="2%"| CPU
 
!width="2%"| RAM
 
!width="2%"| Storage
 
|-
 
| QEMU
 
| [[NixOS_on_ARM/QEMU|QEMU]]
 
|
 
| ARMv7
 
| up to 8
 
| up to 2 GB
 
| Anything QEMU supports
 
|}
 
</div>
 
 
 
== Installation ==
 
 
 
=== Getting the installer ===
 
 
 
For AArch64 it is possible to download images from Hydra.
 
 
 
* [https://hydra.nixos.org/job/nixos/release-21.05/nixos.sd_image.aarch64-linux 21.05]
 
* [https://hydra.nixos.org/job/nixos/release-21.05/nixos.sd_image_new_kernel.aarch64-linux 21.05 (Latest kernel)]
 
* [https://hydra.nixos.org/job/nixos/release-20.09/nixos.sd_image.aarch64-linux 20.09 (LTS)]
 
* [https://hydra.nixos.org/job/nixos/release-20.09/nixos.sd_image_new_kernel.aarch64-linux 20.09 (Latest kernel)]
 
* [https://hydra.nixos.org/job/nixos/trunk-combined/nixos.sd_image.aarch64-linux unstable (LTS)]
 
* [https://hydra.nixos.org/job/nixos/trunk-combined/nixos.sd_image_new_kernel.aarch64-linux unstable (Latest kernel)]
 
 
 
On the page click on the latest successful build to get a download link under build products. If the image has the extension <code>.zst</code>, it will need to be decompressed before writing to installation device. Use <code>nix-shell -p zstd --run "unzstd <img-name>.img.zst"</code> to decompress the image.
 
 
 
=== Installation steps ===
 
 
 
The installation images come in two flavors: <code>sd-image-armv6l-linux.img</code> is built for the ARMv6 architecture and it comes with the Raspberry Pi kernel. sd-image-armv7l-linux.img is built for the ARMv7 architecture and comes with the mainline multiplatform ARMv7 kernel (multi_v7_defconfig). Make sure you download the correct image for your board!
 
 
 
The .img files can be directly written to a microSD/SD card (minimal recommended size: 4 GB) using dd. The SD card needs to be unmounted first. For more information, check [https://www.raspberrypi.org/documentation/installation/installing-images/linux.md Linux]  and for [https://www.raspberrypi.org/documentation/installation/installing-images/mac.md macOS]
 
 
 
The base images are configured to boot up with a serial TTY ( RX/TX UART ) @ 115200 Baud. That way you not necessarily have to have a HDMI Display and keyboard.
 
 
 
Note: I (kalbasit) had to replace <code>console=ttyS0,115200n8 console=ttyAMA0,115200n8 console=tty0</code> with <code>console=ttyS1,115200n8</code> in <code>/boot/extlinux/extlinux.conf</code> to make the serial console work on my Rasberry-Pi 3.
 
 
 
Continue with [[#NixOS installation & configuration]].
 
 
 
== Binary cache ==
 
 
 
=== AArch64 ===
 
 
 
Thanks to [https://github.com/grahamc @grahamc] and [https://www.packet.com/ Packet], the [https://hydra.nixos.org/ official NixOS Hydra] builds a full set of binaries (available on https://cache.nixos.org) for the AArch64 architecture on the nixpkgs-unstable channel. Starting with the 18.03 release  [https://hydra.nixos.org/jobset/nixos/release-18.03 the official Hydra instance will also build the stable channel] .
 
 
 
=== armv6l and armv7l ===
 
 
 
A binary cache, containing a [https://github.com/thefloweringash/thefloweringash-armv7/blob/master/release.nix subset] of [https://hydra.cons.org.nz/project/thefloweringash-armv7 several] channels, is hosted at https://app.cachix.org/cache/thefloweringash-armv7 .
 
 
 
=== Additional caches ===
 
 
 
* https://arm.cachix.org/ - <code>arm.cachix.org-1:5BZ2kjoL1q6nWhlnrbAl+G7ThY7+HaBRD9PZzqZkbnM=</code> 
 
(updated 2020-08-10: /nix/store/lxi1hq2p0fx5wr123q9yyfmh3ngqnrq5-nix-2.4pre20200721_ff314f1 nixpkgs: 96069f7d890b90cbf4e8b4b53e15b036210ac146)
 
(2020-08-11: NixOS image build uploaded)
 
 
 
== Build your own image ==
 
 
 
You can customize image by using the following snippet.
 
 
 
<syntaxHighlight lang=nix>
 
# save as sd-image.nix somewhere
 
{ ... }: {
 
  imports = [
 
    <nixpkgs/nixos/modules/installer/sd-card/sd-image-aarch64.nix>
 
  ];
 
  # put your own configuration here, for example ssh keys:
 
  users.extraUsers.root.openssh.authorizedKeys.keys = [
 
    "ssh-ed25519 AAAAC3NzaC1lZDI1.... username@tld"
 
  ];
 
}
 
</syntaxHighlight>
 
 
 
Then build with:
 
 
 
<syntaxHighlight lang=nix>
 
$ nix-build '<nixpkgs/nixos>' -A config.system.build.sdImage -I nixos-config=./sd-image.nix
 
</syntaxHighlight>
 
 
 
Note that this requires a machine with aarch64. You can however also build it from your laptop using an aarch64 remote builder as described in [[Distributed build]] or ask for access on the [https://github.com/nix-community/aarch64-build-box community aarch64 builder].
 
 
 
=== Compiling through QEMU ===
 
 
 
It is also possible to compile for aarch64 on your non-aarch64 local machine, or a remote builder, by registering QEMU as a binfmt wrapper for the aarch64 architecture. This <b>wrapper uses emulation</b> and will therefore be slower than comparable native machines.
 
 
 
To enable the binfmt wrapper on NixOS, add the following to <code>configuration.nix</code>
 
 
 
<syntaxHighlight lang=nix>
 
{
 
  boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
 
}
 
</syntaxHighlight>
 
 
 
If you are building on non-NixOS machine with QEMU binfmt wrapper configured, you will want to configure nix daemon to let it know that it can build for aarch64. Add the following line to <code>/etc/nix/nix.conf</code>:
 
<code>extra-platforms = aarch64-linux arm-linux</code>
 
 
 
If you want to build just one specific package, use this:
 
<syntaxHighlight lang=nix>
 
nix-build '<nixpkgs/nixos>' -A pkgs.theRequiredPackage --argstr system aarch64-linux -I nixos-config=/path/to/target/machine/nixos/config/copy
 
</syntaxHighlight>
 
(the last option should not be required on NixOS machines)
 
 
 
== Installer image with custom U-Boot ==
 
 
 
The [https://github.com/Mic92/nixos-aarch64-images Mic92/nixos-aarch64-images] repository provides a mechanism to modify the official NixOS installer to embed the board-specific U-Boot firmware required for different boards. This method does not require QEMU or native ARM builds since the existing Hydra-built U-Boot binaries are used.
 
 
 
== Board-specific installation notes ==
 
 
 
Depending on the board, some additional preparation steps might be needed to make the SD card bootable on your device. All of the board-specific installation notes are now found on their respective pages.
 
 
 
== Enable UART ==
 
 
 
If you try to use UART to log on NixOS, you might hang on the line "Starting kernel ...". To enable UART, you will need to add at the end of the line that contains <code>loglevel4</code> in the file <code>/extlinux/extlinux.conf</code> the text:
 
{{file|/extlinux/extlinux.conf||<nowiki>
 
    console=ttyAMA0,115200n8
 
</nowiki>}}
 
{{file|/extlinux/extlinux.conf||<nowiki>
 
    console=ttyS0,115200n8
 
</nowiki>}}
 
The actual device (<code>ttyAMA0</code>, <code>ttyS0</code>, <code>ttyS1</code>) will depend on the hardware.
 
 
 
== NixOS installation & configuration ==
 
 
 
{{outdated|The kernel version recommendations of this section are severely outdated. This section should be rewritten to be generic and refer people to the board-specific page. Only the board specific page should make recommendations about the kernel.}}
 
 
 
The installation image is actually a MBR partition table plus two partitions; a FAT16 /boot and a ext4 root filesystem. The image is designed such that it's possible to directly reuse the SD image's partition layout and "install" NixOS on the very same SD card by simply replacing the default configuration.nix and running nixos-rebuild. Using this installation method is strongly recommended, though if you know exactly what you're doing and how U-Boot on your board works, you can use nixos-install as usual. To help with the SD card installation method, the boot scripts on the image automatically resize the rootfs partition to fit the SD card on the first boot.
 
 
 
Use this as a template:
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
{ config, pkgs, lib, ... }:
 
{
 
  # NixOS wants to enable GRUB by default
 
  boot.loader.grub.enable = false;
 
  # Enables the generation of /boot/extlinux/extlinux.conf
 
  boot.loader.generic-extlinux-compatible.enable = true;
 
 
  # !!! If your board is a Raspberry Pi 1, select this:
 
  boot.kernelPackages = pkgs.linuxPackages_rpi;
 
  #  !!! If your board is a Raspberry Pi 3, select not latest (5.8 at the time)
 
  #  !!! as it is currently broken (see https://github.com/NixOS/nixpkgs/issues/97064)
 
  boot.kernelPackages = pkgs.linuxPackages;
 
  # !!! Otherwise (even if you have a Raspberry Pi 2), pick this:
 
  boot.kernelPackages = pkgs.linuxPackages_latest;
 
 
 
  # !!! This is only for ARMv6 / ARMv7. Don't enable this on AArch64, cache.nixos.org works there.
 
  nix.binaryCaches = lib.mkForce [ "https://app.cachix.org/cache/thefloweringash-armv7" ];
 
  nix.binaryCachePublicKeys = [ "thefloweringash-armv7.cachix.org-1:v+5yzBD2odFKeXbmC+OPWVqx4WVoIVO6UXgnSAWFtso=" ];
 
   
 
  # File systems configuration for using the installer's partition layout
 
  fileSystems = {
 
    # Prior to 19.09, the boot partition was hosted on the smaller first partition
 
    # Starting with 19.09, the /boot folder is on the main bigger partition.
 
    # The following is to be used only with older images.
 
    /*
 
    "/boot" = {
 
      device = "/dev/disk/by-label/NIXOS_BOOT";
 
      fsType = "vfat";
 
    };
 
    */
 
    "/" = {
 
      device = "/dev/disk/by-label/NIXOS_SD";
 
      fsType = "ext4";
 
    };
 
  };
 
   
 
  # !!! Adding a swap file is optional, but strongly recommended!
 
  # swapDevices = [ { device = "/swapfile"; size = 1024; } ];
 
}</nowiki>}}
 
Note: the default configuration.nix will contain something like <code>imports = [ <nixos/modules/installer/sd-card/sd-image-armv7l-multiplatform.nix> ];</code> do not include that in your final installation or you will experience interesting problems. It is only for building the installation image!
 
 
 
==== First rebuild on ARMv6 and ARMv7 ====
 
 
 
To make the unsupported ARM experience slightly less painful, the config template adds <code>nixos-arm.dezgeg.me</code> as a binary cache, which contains a small subset of packages on the unstable channel (though a caution for US users: the server hosting them is physically located in Finland). Note that the binary cache isn't enabled on the prebuilt images, so enable it via the command line when building for the first time:
 
 
 
<syntaxhighlight lang="bash">nixos-rebuild switch --fast --option binary-caches http://nixos-arm.dezgeg.me/channel --option binary-cache-public-keys nixos-arm.dezgeg.me-1:xBaUKS3n17BZPKeyxL4JfbTqECsT+ysbDJz29kLFRW0=%</syntaxhighlight>
 
 
 
== Details about the boot process ==
 
 
 
On NixOS, all ARM boards are expected to use U-Boot as the firmware and bootloader. NixOS uses [https://github.com/u-boot/u-boot/blob/master/doc/README.distro U-Boot's Generic Distro Configuration Concept] as the mechanism to communicate boot information (such as path to kernel zImage, initrd, DTB, command line arguments). For a quick TL;DR about the generic distro configuration support: U-Boot is scripted to scan all attached storage devices & partitions and look for a file named <code>/extlinux/extlinux.conf</code> or <code>/boot/extlinux/extlinux.conf</code> (which will be generated by NixOS, just like <code>/boot/grub/grub.cfg</code> is generated on PCs). The partition needs to have its "bootable" flag set.
 
 
 
U-Boot also provides an interactive shell and the generation selection menu (just like GRUB). However, support for input or display devices varies greatly, depending on the board. Details for what the boards support in relationship to the boot process are detailed in their respective pages.
 
 
 
== Porting NixOS to new boards ==
 
 
 
=== The easiest way ===
 
 
 
Assuming upstream U-Boot supports the board through a defconfig, it is possible possible to build U-Boot using the cross-compiling architecture from an x86_64 host. Here's a sample use.
 
 
 
<syntaxhighlight>
 
# Assuming you're in a recent nixpkgs checkout
 
$ nix-shell \
 
    -I "nixpkgs=$PWD" \
 
    -p 'let plat = pkgsCross.aarch64-multiplatform; in plat.buildUBoot{defconfig = "orangepi_zero_plus2_defconfig"; extraMeta.platforms = ["aarch64-linux"]; BL31 = "${plat.armTrustedFirmwareAllwinner}/bl31.bin"; filesToInstall = ["u-boot-sunxi-with-spl.bin"];}'
 
</syntaxhighlight>
 
 
 
For armv7 and armv6 <code>pkgsCross.arm-embedded</code> should work, this is available in the unstable channel (19.03 and following) by setting <code>-I "nixpkgs=/path/to/new-nixpkgs-checkout</code>.
 
 
 
This should build whatever is needed for, and then build U-Boot for the desired defconfig, then open a shell with the build in <code>$buildInputs</code>. Do note that this particular invocation may need more changes than only the defconfig if built for other than allwinner boards.
 
 
 
Here's an example command, for allwinner boards, on how to write to an SD card.
 
 
 
<syntaxhighlight>
 
$ sudo dd if=$buildInputs/u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8
 
</syntaxhighlight>
 
 
 
=== The easy way ===
 
 
 
''(if you're lucky)''
 
 
 
If your board is an ARMv7 board supported by multi_v7_defconfig and you have access to U-Boot on the board, getting <code>sd-image-armv7l-linux.img</code> to boot is the easiest option:
 
 
 
* If you're lucky and your U-Boot build comes with the extlinux.conf support built in, the image boots out-of-the-box. This is the case for all (upstream) Allwinner and Tegra U-Boots, for instance.
 
* Otherwise, you can get the boot information (path to kernel zImage, initrd, DTB, command line arguments) by extracting <code>extlinux.conf</code> from the boot partition of the image, and then attempt to boot it via the U-Boot shell, or some other mechanism that your board's distro uses (e.g. <code>uEnv.txt</code>).
 
 
 
==== Building U-Boot from your NixOS PC ====
 
 
 
Assuming
 
 
 
* Your board is supported upstream by U-Boot or there is a recent enough fork with <code>extlinux.conf</code> support.
 
* You do not have nix setup on an ARM device
 
* Your nix isn't setup for cross-compilation
 
 
 
It is still possible to build U-Boot using tools provided by NixOS.
 
 
 
In the following terminal session, replace <code>orangepi_pc_defconfig</code> with the appropriate board [http://git.denx.de/?p=u-boot.git;a=tree;f=configs;hb=HEAD from the configs folder] of U-Boot.
 
 
 
{{Commands|<nowiki>
 
$ nix-shell -E 'with import <nixpkgs> {}; stdenv.mkDerivation { name = "arm-shell"; buildInputs = [git gnumake gcc gcc-arm-embedded dtc]; }'
 
$ git clone git://git.denx.de/u-boot.git
 
$ cd u-boot
 
# We're checking out a version from before the use of `binman`.
 
# The dtc package is 1.4.2, which does not include `pylibftd`.
 
# Furthermore, I do not know how to package the library so it would be
 
# available in the python interpreter, making binman happy.
 
$ git checkout v2017.03
 
$ make -j4 CROSS_COMPILE=arm-none-eabi- orangepi_pc_defconfig
 
$ make -j4 CROSS_COMPILE=arm-none-eabi-
 
</nowiki>}}
 
 
 
The name of the final file will change depending on the board. For this specific build, and most Allwinner builds, the file will be named <code>u-boot-sunxi-with-spl.bin</code>.
 
 
 
You can flash this file to boot device with
 
 
 
{{Commands|<nowiki>
 
dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8
 
</nowiki>}}
 
 
 
Note: This mailing list contains a patch which may help some builds: https://lists.denx.de/pipermail/u-boot/2016-December/275664.html
 
 
 
=== The hard way ===
 
 
 
Alternatively/if all else fails, you can do it the hard way and bootstrap NixOS from an existing ARM Linux installation.
 
 
 
=== Contributing new boards to nixpkgs ===
 
 
 
* Add a new derivation for your board's U-Boot configuration, see for example ubootJetsonTK1 in {{Nixpkgs Link|short=all-packages.nix|pkgs/top-level/all-packages.nix}}.
 
* If your board's U-Boot configuration doesn't use the <code>extlinux.conf</code> format by default, create a patch to enable it. Some C hacking skills & U-Boot knowledge might be required. For some pointers, see this patch to enable it on the Versatile Express.
 
* Make a pull request, also containing the board-specific instructions. Ping '''@dezgeg''' for review and for building & hosting the U-Boots at http://nixos-arm.dezgeg.me/installer.
 
 
 
== Support ==
 
 
 
All ARM platforms are experimental. Only AArch64 platforms are currently being worked on for eventual support from NixOS.
 
 
 
There is a dedicated channel for the upstream effort on Matrix,
 
[https://matrix.to/#/#nixos-on-arm:nixos.org #nixos-on-arm:nixos.org].
 
 
 
== Resources ==
 
 
 
=== Subpages ===
 
 
 
The following is a list of all sub-pages of the ''NixOS on ARM'' topic.
 
 
 
{{Special:PrefixIndex/{{FULLPAGENAME}}/ |hideredirects=1 |stripprefix=1}}
 

Latest revision as of 11:58, 6 April 2024

This section has been moved to the official NixOS Wiki:

    ⇒ NixOS on ARM

— samueldr, Lead of NixOS on ARM.