Jump to content

NixOS on ARM: Difference between revisions

4,350 bytes removed ,  Tuesday at 20:56
m
m (Re-ordering sections)
 
(8 intermediate revisions by one other user not shown)
Line 9: Line 9:
At this moment in time (early 2024) '''only AArch64''' has full support upstream. With that said, neither armv6l or armv7l are being ignored, fixes are worked on and approved as needed. What's missing is support and builds being maintained in binary form. At the time of writing, no publicly available caches for armv6l or armv7l are available.<!-- please get in touch with samueldr on the NixOS on ARM channel if you want to share your own cache, before editing. We need to review the wording to make it crystal clear it's a user-provided cache. -->
At this moment in time (early 2024) '''only AArch64''' has full support upstream. With that said, neither armv6l or armv7l are being ignored, fixes are worked on and approved as needed. What's missing is support and builds being maintained in binary form. At the time of writing, no publicly available caches for armv6l or armv7l are available.<!-- please get in touch with samueldr on the NixOS on ARM channel if you want to share your own cache, before editing. We need to review the wording to make it crystal clear it's a user-provided cache. -->


'''For images links, including UEFI install''', skip to the [[NixOS on ARM#Installation|Installation]] section.
'''For images links, including UEFI install''', skip to the [[NixOS_on_ARM/Installation|Installation page]].


== Supported devices ==
== Supported devices ==
Line 65: Line 65:
-->
-->
<div class="table">
<div class="table">
{|class="table"
{| class="sortable table"
!width="2%"| Manufacturer
!width="2%"| Manufacturer
!width="2%"| Board
!width="2%"| Board
Line 83: Line 83:
|-
|-
| ASUS
| ASUS
| [[NixOS_on_ARM/Tinker Board|Tinker Board]]
| [[NixOS_on_ARM/ASUS Tinker Board|Tinker Board]]
| Rockchip RK3288
| Rockchip RK3288
| ARMv7
| ARMv7
Line 101: Line 101:
| [[NixOS_on_ARM/Banana Pi M64|Banana Pi M64]]
| [[NixOS_on_ARM/Banana Pi M64|Banana Pi M64]]
| Allwinner A64
| Allwinner A64
| ARMv8
| AArch64
| 4× Cortex-A53
| 4× Cortex-A53
| 2 GB
| 2 GB
Line 109: Line 109:
| [[NixOS_on_ARM/Banana Pi BPI-M5|Banana Pi BPI-M5]]
| [[NixOS_on_ARM/Banana Pi BPI-M5|Banana Pi BPI-M5]]
| Amlogic S905X3
| Amlogic S905X3
| ARMv8.2
| AArch64
| 4× Cortex-A55
| 4× Cortex-A55
| 4 GB LPDDR4
| 4 GB LPDDR4
Line 456: Line 456:
{{main|NixOS_on_ARM/Installation}}
{{main|NixOS_on_ARM/Installation}}


== NixOS installation & configuration ==
== Initial configuration ==


{{main|NixOS_on_ARM/Initial_Configuration}}
{{main|NixOS_on_ARM/Initial_Configuration}}
== Binary caches ==
=== AArch64 ===
The [https://hydra.nixos.org/ official NixOS Hydra] instance builds a full set of binaries (available on https://cache.nixos.org) for the AArch64 architecture on the nixpkgs-unstable and stable channels.
=== armv6l and armv7l ===
Some '''''users''''' have provided best effort caches for 32 bit ARM, but none are currently available.


== Troubleshooting ==
== Troubleshooting ==
Line 490: Line 480:


=== Details about the boot process ===
=== Details about the boot process ===
NixOS can be booted through [[NixOS on ARM/UEFI|UEFI]] on ARM too. The semantics are generally the same as on other architectures. Do note that the common use of Device Tree instead of ACPI in consumer-class hardware ''may'' make this a bit more awkward.


Otherwise, in SBC-class hardware, it is common that boards are generally expected to use U-Boot as the platform firmware and bootloader. See the section about [[U-Boot#Using NixOS with U-Boot|using NixOS with U-Boot]].  
NixOS can also be booted through [[NixOS on ARM/UEFI|UEFI]] on ARM. The semantics are generally the same as on other architectures. Do note that the common use of Device Tree instead of ACPI in consumer-class hardware [[NixOS_on_ARM/UEFI#Device_Trees|''may'' make this a bit more awkward]].


== Porting NixOS to new boards ==
Otherwise, in SBC-class hardware, it is common that boards are generally expected to use U-Boot as the platform firmware and bootloader. See the section about [[U-Boot#Using NixOS with U-Boot|using NixOS with U-Boot]].


=== The easiest way ===
== Binary caches ==


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.
=== AArch64 ===


<syntaxhighlight lang="shell-session">
The [https://hydra.nixos.org/ official NixOS Hydra] instance builds a full set of binaries (available on https://cache.nixos.org) for the AArch64 architecture on the nixpkgs-unstable and stable channels.
# 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>.
=== armv6l and armv7l ===
 
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 lang="shell-session">
$ 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 ubootPine64LTS in {{Nixpkgs Link|short=all-packages.nix|pkgs/top-level/all-packages.nix}}.
Some '''''users''''' have provided best effort caches in the past for 32 bit ARM, but none are currently available.
* 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.


== Getting Support ==
== Getting Support ==
trusted
602

edits