Skip to content

Commit 0a7b43b

Browse files
authored
Merge pull request #259 from jakubgs/add-nanopc-t4
friendlyarm/nanopc-t4: init
2 parents 30f1a99 + ff1b798 commit 0a7b43b

File tree

4 files changed

+120
-1
lines changed

4 files changed

+120
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ See code for all available configurations.
9494
| [Dell XPS 15 9560, nvidia only][] | `<nixos-hardware/dell/xps/15-9560/nvidia>` |
9595
| [Dell XPS 15 9500][] | `<nixos-hardware/dell/xps/15-9500>` |
9696
| [Dell XPS 15 9500, nvidia][] | `<nixos-hardware/dell/xps/15-9500/nvidia>` |
97+
| FriendlyARM NanoPC-T4 | `<nixos-hardware/friendlyarm/nanopc-t4>` |
9798
| [Google Pixelbook][] | `<nixos-hardware/google/pixelbook>` |
9899
| [GPD MicroPC][] | `<nixos-hardware/gpd/micropc>` |
99100
| [Inverse Path USB armory][] | `<nixos-hardware/inversepath/usbarmory>` |
@@ -114,7 +115,7 @@ See code for all available configurations.
114115
| Lenovo ThinkPad T440s | `<nixos-hardware/lenovo/thinkpad/t440s>` |
115116
| Lenovo ThinkPad T440p | `<nixos-hardware/lenovo/thinkpad/t440p>` |
116117
| Lenovo ThinkPad T450s | `<nixos-hardware/lenovo/thinkpad/t450s>` |
117-
| Lenovo ThinkPad T460 | `<nixos-hardware/lenovo/thinkpad/t460>` |
118+
| Lenovo ThinkPad T460 | `<nixos-hardware/lenovo/thinkpad/t460>` |
118119
| Lenovo ThinkPad T460s | `<nixos-hardware/lenovo/thinkpad/t460s>` |
119120
| Lenovo ThinkPad T470s | `<nixos-hardware/lenovo/thinkpad/t470s>` |
120121
| Lenovo ThinkPad T480s | `<nixos-hardware/lenovo/thinkpad/t480s>` |

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
dell-xps-15-9560-nvidia = import ./dell/xps/15-9560/nvidia;
3030
dell-xps-15-9500 = import ./dell/xps/15-9500;
3131
dell-xps-15-9500-nvidia = import ./dell/xps/15-9500/nvidia;
32+
friendlyarm-nanopc-t4 = import ./friendlyarm/nanopc-t4;
3233
google-pixelbook = import ./google/pixelbook;
3334
gpd-micropc = import ./gpd/micropc;
3435
inversepath-usbarmory = import ./inversepath/usbarmory;

friendlyarm/nanopc-t4/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Description
2+
3+
This document on how I configure [NixOS](https://nixos.org/) on [NanoPC-T4](https://wiki.friendlyarm.com/wiki/index.php/NanoPC-T4).
4+
5+
# Installation
6+
7+
To install NixOS on you can follow the [official instructions](https://nixos.wiki/wiki/NixOS_on_ARM/NanoPC-T4) and use the [pre-built images](https://github.com/tmountain/arch-nanopct4/tree/main/images/) from @tmountain. You can also build the U-Boot image yourself from `nixpkgs` based on changes added in [#111034](https://github.com/NixOS/nixpkgs/pull/111034).
8+
9+
## NixOS on NVMe with ZFS
10+
11+
It is possible to migrate the OS from the eMMC storage to the NVMe.
12+
13+
In my case I migrated `/`, `/nix`, and `/home`, leaving `/boot` on the eMMC.
14+
15+
Create the ZFS pool and three filesystems on the SSD:
16+
```sh
17+
zpool create -O xattr=sa -O acltype=posixacl -O mountpoint=none rpool /dev/nvme0n1
18+
for VOL in nix root home; do
19+
zfs create -o mountpoint=legacy rpool/$VOL
20+
mkdir /mnt/$VOL
21+
mount.zfs rpool/$VOL /mnt/$VOL
22+
done
23+
```
24+
Then sync the original filesystem on eMMC to the new volumes:
25+
```sh
26+
rsync -rax /. /mnt/root
27+
rsync -rax /nix/. /mnt/nix
28+
rsync -rax /home/. /mnt/home
29+
rsync -rax /boot/. /
30+
```
31+
Afterwards create a configuration that looks like this:
32+
```nix
33+
{
34+
# TODO: Make sure to update the eMMC device UUID!
35+
fileSystems."/boot" = { device = "/dev/disk/by-uuid/1234-5678"; fsType = "ext4"; };
36+
fileSystems."/" = { device = "rpool/root"; fsType = "zfs"; };
37+
fileSystems."/nix" = { device = "rpool/nix"; fsType = "zfs"; };
38+
fileSystems."/home" = { device = "rpool/home"; fsType = "zfs"; };
39+
}
40+
```
41+
And rebuild he system:
42+
```sh
43+
sudo nixos-rebuild boot
44+
```
45+
:warning: __IMPORTANT:__ After that it's necessary to run all the four `rsync` commands again to sync filesystems.
46+
47+
Once everything is synced you can finally reboot.
48+
49+
You should also clean up `/boot` afterwards.
50+
51+
# UART Debug Console
52+
53+
Device provides a Debug UART 4 Pin 2.54mm header connection, 3V level, 1500000bps.
54+
55+
To connect to you will need a USB to UART converter/receiver that supports the speed of 1500000bps.
56+
57+
The serial port parameters are [8-N-1](https://en.wikipedia.org/wiki/8-N-1).
58+
59+
A reader using `CP2102` chip did not work but `FT232RL` works fine:
60+
61+
![UART converter photo](https://github.com/NixOS/nixos-hardware/releases/download/not-a-release/FT232RL.jpg)
62+
63+
You can use `minicom` or `picocom` to connect:
64+
```
65+
sudo minicom -b 1500000 -D /dev/ttyUSB0
66+
sudo picocom -b 1500000 /dev/ttyUSB0
67+
```
68+
But you'll need to disable flow control with `Ctrl-A x`.
69+
70+
Here is a good overview of UART USB-to-Serial adapters:
71+
72+
* https://www.sjoerdlangkemper.nl/2019/03/20/usb-to-serial-uart/
73+
* https://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232R.pdf
74+
75+
Pin layout where #4 is next to USB-C port:
76+
77+
| Pin num.| #1 | #2 | #3 | #4 |
78+
|---------|-----|----|----|----|
79+
| Purpose | GND | V5 | TX | RX |
80+
81+
Remember that the `TX` and `RX` ports should be swapped between UART adapter and the board.
82+
83+
The V5 pin does not need to be connected if you're powering the board from another source.
84+
85+
See the full board diagram for more details:
86+
87+
![Board diagram](https://wiki.friendlyarm.com/wiki/images/b/bb/NanoPC-T4_1802_Drawing.png)
88+
89+
You can access the recovery console by holding the __Recovery__ button and then pressing the __Power__ button.
90+
For this to work the device will have to be off, which requires holding the __Power__ button long enough.
91+

friendlyarm/nanopc-t4/default.nix

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{ lib, pkgs, ... }:
2+
3+
{
4+
boot.loader = {
5+
grub.enable = lib.mkDefault false;
6+
# Enables the generation of /boot/extlinux/extlinux.conf.
7+
generic-extlinux-compatible.enable = lib.mkDefault true;
8+
};
9+
10+
# UART debug console bitrates.
11+
services.mingetty.serialSpeed = [ 1500000 115200 ];
12+
13+
# Enable additional firmware (such as Wi-Fi drivers).
14+
hardware.enableRedistributableFirmware = lib.mkDefault true;
15+
16+
# Fix for not detecting the M.2 NVMe SSD. Will cause recompilation.
17+
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.10") (lib.mkDefault pkgs.linuxPackages_latest);
18+
boot.kernelPatches = lib.mkDefault [{
19+
name = "pcie-rockchip-config.patch";
20+
patch = null;
21+
extraConfig = ''
22+
PHY_ROCKCHIP_PCIE y
23+
PCIE_ROCKCHIP_HOST y
24+
'';
25+
}];
26+
}

0 commit comments

Comments
 (0)