NixOS on ARM/NanoPC-T4: Difference between revisions
imported>Tmountain No edit summary |
imported>Jmesmon m update links to current domain friendlyelec.com |
||
(16 intermediate revisions by 2 users not shown) | |||
Line 28: | Line 28: | ||
The board '''boots NixOS from eMMC''' and will also load NixOS via its integrated microSD reader. | The board '''boots NixOS from eMMC''' and will also load NixOS via its integrated microSD reader. | ||
The official documentation, which is comprehensive, can be found on [https://wiki. | The official documentation, which is comprehensive, can be found on [https://wiki.friendlyelec.com/wiki/index.php/NanoPC-T4 the FriendlyElec wiki]. | ||
U-Boot for this board is not entirely open, incorporating a binary blob for the tertiary program loader (TPL). Compilation instructions are featured in section 15.7 of [http://wiki. | U-Boot for this board is not entirely open, incorporating a binary blob for the tertiary program loader (TPL). Compilation instructions are featured in section 15.7 of [http://wiki.friendlyelec.com/wiki/index.php/NanoPC-T4 the FriendlyElec wiki], and a build target is also provided in upstream u-boot ('''nanopc-t4-rk3399_defconfig'''). | ||
Pre-built u-boot images are available [https://github.com/tmountain/arch-nanopct4/tree/main/images/ here]. | Pre-built u-boot images are available [https://github.com/tmountain/arch-nanopct4/tree/main/images/ here]. | ||
== Board Specific Installation Notes == | == Board Specific Installation Notes == | ||
=== Installation onto eMMC === | |||
These instructions assume that you have booted the NanoPC-T4 via an OS loaded via its microSD card. A recent Armbian boot image should flash and boot cleanly (follow their docs). | |||
The NanoPC-T4 reserves space for u-boot at the beginning of its eMMC and/or microSD. As a result, successful image installation relies upon a custom partitioning scheme. | The NanoPC-T4 reserves space for u-boot at the beginning of its eMMC and/or microSD. As a result, successful image installation relies upon a custom partitioning scheme. | ||
Line 50: | Line 53: | ||
Created a new partition 1 of type 'Linux filesystem' and of size 14.6 GiB. | Created a new partition 1 of type 'Linux filesystem' and of size 14.6 GiB. | ||
Command (m for help): w | Command (m for help): w | ||
# Make the filesystem | |||
# mkfs.ext4 /dev/mmcblk2p1 | |||
# set the disk label (crucially important) | |||
# tune2fs -L NIXOS_SD /dev/mmcblk2p1 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 58: | Line 66: | ||
# dd if=uboot.img of=/dev/mmcblk2 seek=16384 conv=notrunc | # dd if=uboot.img of=/dev/mmcblk2 seek=16384 conv=notrunc | ||
# dd if=trust.bin of=/dev/mmcblk2 seek=24576 conv=notrunc | # dd if=trust.bin of=/dev/mmcblk2 seek=24576 conv=notrunc | ||
</syntaxhighlight> | |||
==== Boot and RootFS ==== | |||
The latest linux kernel is working with this board. Instead of building the image yourself you can fetch the latest sd-image from hydra and dd the created images onto the separate partitions. | |||
You can find recent successful builds [https://hydra.nixos.org/job/nixos/release-20.09/nixos.sd_image.aarch64-linux here]. | |||
<syntaxHighlight lang=bash> | |||
# get the latest link directly from hydra | |||
# wget https://hydra.nixos.org/build/135139819/download/1/nixos-sd-image-20.09.2623.97a13fb97fc-aarch64-linux.img.zst -O sd.img.zst | |||
# unzstd sd.img.zst | |||
# udisksctl loop-setup -f sd.img -r | |||
# copy the root filesystem to the partition you created earlier | |||
# mkdir eemc imgroot | |||
# mount /dev/mmcblk2p1 eemc | |||
# mount /dev/loop0p2 imgroot | |||
# cd imgroot | |||
# tar cf - . | (cd ../eemc && tar xvf -) | |||
# sync | |||
# cd .. && umount eemc imgroot | |||
</syntaxhighlight> | |||
After writing the filesystem, shutdown the system completely (power off state), remove the SD card, power it back up, and if everything went well, it should boot into Nix via eMMC. | |||
==== Bypassing eMMC to boot SD ==== | |||
From a fully powered off state, hold the Boot button and then long-press the power button to power up the board. Continue holding the Boot button for ~5 seconds, and the board will be forced to enter the MASKROM mode which bypasses the eMMC MBR. | |||
==== UART ==== | |||
The base images are configured to boot up with a serial TTY ( RX/TX UART ) @ 115200 Baud. I had to replace <code>console=ttyS0,115200n8</code> with <code>console=ttyS2,115200n8</code> in /boot/extlinux/extlinux.conf to make the serial console work. | |||
Note: the NanoPC-T4 UART defaults to the Debug UART Pin Spec which is adjacent to the USB-C port and is not part of the 40 Pin GPIO Pin Spec (see the aforementioned wiki). | |||
=== Networking === | |||
The NanoPC-T4 integrated wifi does not work out of the box. Getting it to work requires the following steps: | |||
<syntaxHighlight lang=bash> | |||
# mkdir -p /lib/firmware/brcm | |||
# cp brcmfmac4356-sdio.txt /lib/firmware/brcm/ | |||
# rmmod brcmfmac | |||
# modprobe brcmfmac | |||
# wpa_supplicant -B -i wlan0 -c <(wpa_passphrase $YOUR_SSID $YOUR_PASSWORD) | |||
</syntaxhighlight> | |||
You can get a copy of brcmfmac4356-sdio.txt [https://gist.githubusercontent.com/tmountain/e6c9e5da504b46db029f5cc5ccf47492/raw/d5086b8028c5eb5c760137b12a84c517cccb9734/brcmfmac4356-sdio.txt here]. | |||
=== Bluetooth Messages During Install === | |||
Depending on your hardware, the default boot image can be extremely noisy regarding messages related to bluetooth. If you would like to turn these off (temporarily), you can do the following. | |||
<syntaxHighlight lang=bash> | |||
# echo "install bluetooth /bin/false" > /etc/modprobe.d/blacklist.conf | |||
# reboot | |||
</syntaxhighlight> | </syntaxhighlight> |