1
0
Fork 0
mirror of https://github.com/samueldr/wip-pinebook-pro.git synced 2024-11-27 05:19:44 +01:00

Merge pull request #24 from samueldr/feature/2021-05-upgrades

Early 2021 upgrades
This commit is contained in:
Samuel Dionne-Riel 2021-05-20 17:38:40 -04:00 committed by GitHub
commit 201c9ef11d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 251 additions and 12669 deletions

100
README.md
View file

@ -15,46 +15,51 @@ Clone this repository somwhere, and in your configuration.nix
That entry point will try to stay unopinionated, while maximizing the hardware
compatibility.
## Compatibility
### Tested
## Current state
* X11 with modesetting
* Wi-Fi
* Brightness controls
* Speaker output
*A whole lot of untested*.
### Untested
You can look at the previous state to see that the basic stuff works. But I
find listing everything as working is hard.
* Bluetooth
What's untested and not working will be listed here at some point. Maybe.
### Known issues
* Suspend (or resume) fails.
#### `rockchipdrm` and `efifb`
### Tips
`CONFIG_FB_EFI` has been disabled in the customized kernel as `rockchipdrm`
will not render the VT if `efifb` is present.
Be careful if using the mainline kernel instead, as it will have
`CONFIG_FB_EFI` set to `y`.
#### *EFI* and poweroff
When booted using EFI, the system will not power off. It will stay seemingly
stuck with the LED and display turned off.
Power it off by holding the power button for a while (10-15 seconds).
Otherwise you might have a surprise and find the battery is flat!
The backlight can be controlled using `light` (`programs.light.enable`).
## Image build
> **NOTE**: These images will be built without an *Initial Boot Firmware*.
### SD image
```
$ ./build.sh
$ lsblk /dev/mmcblk0 && sudo dd if=$(echo result/sd-image/*.img) of=/dev/mmcblk0 bs=8M oflag=direct status=progress
$ nix-build -A sdImage
```
The `build.sh` script transmits parameters to `nix-build`, so e.g. `-j0` can
be used.
### ISO image
Once built, this image is self-sufficient, meaning that it should already be
booting, no need burn u-boot to it.
The required modules (and maybe a bit more) are present in stage-1 so the
display should start early enough in the boot process.
The LED should start up with the amber colour ASAP with this u-boot
configuration, as a way to show activity early. The kernel should set it to
green as soon as it can.
```
$ nix-build -A isoImage
```
## Note about cross-compilation
@ -64,41 +69,42 @@ When cross-compiled, all caveats apply. Here this mainly means that the kernel
will need to be re-compiled on the device on the first nixos-rebuild switch,
while most other packages can be fetched from the cache.
## `u-boot`
Assuming `/dev/mmcblk0` is an SD card.
For cross-compilation, you might have to provide a path to a known-good Nixpkgs
checkout. *(Left as an exercis to the reader.)*
```
$ nix-build -A pkgs.uBootPinebookPro
$ lsblk /dev/mmcblk0 && sudo dd if=result/idbloader.img of=/dev/mmcblk0 bs=512 seek=64 oflag=direct,sync && sudo dd if=result/u-boot.itb of=/dev/mmcblk0 bs=512 seek=16384 oflag=direct,sync
$ NIX_PATH=nixpkgs=/path/to/known/working/cross-compilation-friendly/nixpkgs
```
The eMMC has to be zeroed (in the relevant sectors) or else the RK3399 will use
the eMMC as a boot device first.
## *Initial Boot Firmware*
Alternatively, this u-boot can be installed to the eMMC.
> **NOTE**: The previously available customized *U-Boot* from this repository
> are not available anymore.
Installing to SPI has yet to be investigated.
### *Tow-Boot*
### Updating eMMC u-boot from NixOS
I highly suggest installing *Tow-Boot* to the SPI Flash.
**Caution:** this could render your system unbootable. Do this when you are in
a situation where you can debug and fix the system if this happens. With this
said, it should be safe enough.
- https://github.com/Tow-Boot/Tow-Boot
Having the firmware installed to SPI makes the device act basically like a
normal computer. No need for weird incantations to setup the initial boot
firmware.
Alternatively, starting from the *Tow-Boot* disk image on eMMC is easier to
deal with and understand than having to deal with *U-Boot* manually.
### Mainline *U-Boot*
Mainline U-Boot has full support for graphics since 2021.04. The current
unstable relases of Nixpkgs are at 2021.04 at least.
```
$ nix-build -A pkgs.uBootPinebookPro
$ lsblk /dev/disk/by-path/platform-fe330000.sdhci && sudo dd if=result/idbloader.img of=/dev/disk/by-path/platform-fe330000.sdhci bs=512 seek=64 oflag=direct,sync && sudo dd if=result/u-boot.itb of=/dev/disk/by-path/platform-fe330000.sdhci bs=512 seek=16384 oflag=direct,sync
$ nix-build -A pkgs.ubootPinebookPro
```
### Alternative boot order
If you rather USB and SD card is tried before the eMMC, `pkgs.uBootPinebookProExternalFirst`
can be installed, which has an alternative patch set added on top that will
change the boot order.
The SD image is built using the "alternative boot order" u-boot. Thus, flashing
the image to your eMMC keeps external devices bootable.
Note that the default U-Boot build does not do anything with LED on startup.
## Keyboard firmware

View file

@ -1,16 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
PS4=" $ "
# Ugh, I would have liked to do it through a simpler `nix-build`, but as this
# needs to set `NIX_PATH` for use of `<nixpkgs/*>` imports, this is the better
# way to go.
set -x
exec env -i \
NIXPKGS_ALLOW_UNFREE=1 \
NIX_PATH="nixpkgs=channel:nixos-unstable" \
"$(command -v nix-build)" \
system.nix -A config.system.build.sdImage "$@"

View file

@ -1,24 +0,0 @@
{ config, pkgs, lib, ... }:
let
uboot = pkgs.uBootPinebookProExternalFirst;
in
{
imports = [
<nixpkgs/nixos/modules/profiles/base.nix>
<nixpkgs/nixos/modules/profiles/minimal.nix>
<nixpkgs/nixos/modules/profiles/installation-device.nix>
./nixos/sd-image-aarch64.nix
./pinebook_pro.nix
];
sdImage = {
manipulateImageCommands = ''
(PS4=" $ "; set -x
dd if=${uboot}/idbloader.img of=$img bs=512 seek=64 conv=notrunc
dd if=${uboot}/u-boot.itb of=$img bs=512 seek=16384 conv=notrunc
)
'';
compressImage = lib.mkForce false;
};
}

View file

@ -1,17 +1,41 @@
{
pkgs ? import <nixpkgs> {
overlays = [
(import ./overlay.nix)
];
}
}:
{ pkgs ? import <nixpkgs> {} }:
let pkgs' = pkgs; in
let
pkgs' = if builtins.currentSystem == "aarch64-linux"
then pkgs
else pkgs.pkgsCross.aarch64-multiplatform
pkgs = if !isCross then pkgs' else pkgs'.pkgsCross.aarch64-multiplatform;
inherit (pkgs) lib;
isCross = builtins.currentSystem != "aarch64-linux";
fromPkgs = path: pkgs.path + "/${path}";
evalConfig = import (fromPkgs "nixos/lib/eval-config.nix");
buildConfig = { system ? "aarch64-linux", configuration ? {} }:
evalConfig {
modules = (lib.optional isCross ./cross-hacks.nix)
++ [
"${./.}/pinebook_pro.nix"
configuration
(lib.mkIf isCross {
nixpkgs.crossSystem = {
system = "aarch64-linux";
};
})
];
}
;
base = buildConfig {};
in
{
pkgs = pkgs';
inherit (base) pkgs;
kernel_latest = base.pkgs.linuxPackages_pinebookpro_latest.kernel;
kernel_lts = base.pkgs.linuxPackages_pinebookpro_lts.kernel;
isoImage = (buildConfig {
configuration = (fromPkgs "nixos/modules/installer/cd-dvd/installation-cd-minimal.nix");
}).config.system.build.isoImage;
sdImage = (buildConfig {
configuration = (fromPkgs "nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix");
}).config.system.build.sdImage;
}

View file

@ -0,0 +1,41 @@
{ lib
, fetchFromGitLab
, fetchurl
, runCommandNoCC
}:
let
nhp = patch: sha256: let rev = "c74b23b8766e4cfc50d1197e6dcd08cc1625866f"; in fetchurl {
url = "https://raw.githubusercontent.com/nadiaholmquist/pbp-packages/${rev}/ap6256-firmware/${patch}";
inherit sha256;
};
in
runCommandNoCC "pinebookpro-ap6256-firmware" {
meta = with lib; {
license = licenses.unfreeRedistributable;
};
} ''
(PS4=" $ "; set -x
cp ${(nhp "BCM4345C5.hcd" "1vl3gkgdqdlhyg9dyflqi6icglr2pll6zr82147g69pfvp6ckv96")} "BCM4345C5.hcd"
cp ${(nhp "fw_bcm43456c5_ag.bin" "03qqgzjz152zaj9y0ppqqsqs03yzi8sb71rfvr29zc1xg1x74y3r")} "fw_bcm43456c5_ag.bin"
cp ${(nhp "brcmfmac43456-sdio.clm_blob" "0bi5y3qkqx95c6bb872slw0kig14c453r33j14qyb2f7id8m08lf")} "brcmfmac43456-sdio.clm_blob"
cp ${(nhp "nvram_ap6256.txt" "1zsnswiiwx50pbwl8574xa7z07v9iyfajxccbfrnc8ap99gzpvj3")} "nvram_ap6256.txt"
mkdir -p $out/lib/firmware/brcm
# https://github.com/nadiaholmquist/pbp-packages/blob/ded66e50064c55a56a958558ab35bc6bae444e72/ap6256-firmware/PKGBUILD#L22
# Bluetooth firmware
install -Dm644 "BCM4345C5.hcd" -t "$out/lib/firmware/"
install -Dm644 "BCM4345C5.hcd" "$out/lib/firmware/brcm/BCM.hcd"
install -Dm644 "BCM4345C5.hcd" -t "$out/lib/firmware/brcm/"
# Wifi firmware
install -Dm644 "nvram_ap6256.txt" -t "$out/lib/firmware/"
install -Dm644 "fw_bcm43456c5_ag.bin" "$out/lib/firmware/brcm/brcmfmac43456-sdio.bin"
install -Dm644 "brcmfmac43456-sdio.clm_blob" "$out/lib/firmware/brcm/brcmfmac43456-sdio.clm_blob"
install -Dm644 "nvram_ap6256.txt" "$out/lib/firmware/brcm/brcmfmac43456-sdio.radxa,rockpi4b.txt"
install -Dm644 "nvram_ap6256.txt" "$out/lib/firmware/brcm/brcmfmac43456-sdio.radxa,rockpi4c.txt"
install -Dm644 "nvram_ap6256.txt" "$out/lib/firmware/brcm/brcmfmac43456-sdio.pine64,pinebook-pro.txt"
install -Dm644 "nvram_ap6256.txt" "$out/lib/firmware/brcm/brcmfmac43456-sdio.pine64,rockpro64-v2.1.txt"
)
''

View file

@ -1,35 +0,0 @@
{ stdenv
, fetchFromGitLab
, runCommandNoCC
}:
let
pinebook-firmware = fetchFromGitLab {
domain = "gitlab.manjaro.org";
owner = "tsys";
repo = "pinebook-firmware";
rev = "937f0d52d27d7712da6a008d35fd7c2819e2b077";
sha256 = "0qldxxlxk6f3gymkljphwy7dz3cl1gxsnijhng2l7rkrh7h6wgi2";
};
ap6256-firmware = fetchFromGitLab {
domain = "gitlab.manjaro.org";
owner = "manjaro-arm";
repo = "packages%2Fcommunity%2Fap6256-firmware";
rev = "a30bf312b268eab42d38fab0cc3ed3177895ff5d";
sha256 = "14gyb99j85xw07wrr9lilb1jz68y6r0n0b6x4ldl7d6igs988qwb";
};
in
runCommandNoCC "pinebookpro-firmware-2020-02-08" {
meta = with stdenv.lib; {
license = licenses.unfreeRedistributable;
};
} ''
(PS4=" $ "; set -x
mkdir -p $out/lib/firmware/{brcm,rockchip}
(cd ${ap6256-firmware}
cp -fv *.hcd *blob *.bin *.txt $out/lib/firmware/brcm/
)
cp -fv ${pinebook-firmware}/brcm/* $out/lib/firmware/brcm/
cp -fv ${pinebook-firmware}/rockchip/* $out/lib/firmware/rockchip/
)
''

View file

@ -1,71 +1,76 @@
{ stdenv
, pkgs
, lib
, kernelPatches
, buildPackages
, fetchFromGitLab
, perl
, buildLinux
, modDirVersionArg ? null
, ... } @ args:
# By design this is not "pinning" to any particular kernel version.
# This means that, by design, it may start failing once the patches don't apply.
# But, by design, this will track the kernel upgrades in Nixpkgs.
{ pkgs, lib, linux_latest, kernelPatches, fetchpatch, ... } @ args:
let
inherit (stdenv.lib)
concatStrings
intersperse
take
splitString
optionalString
;
version = "5.7";
additionalConfig = {
name = "pinebookpro-config-fixes";
patch = null;
extraConfig = ''
PCIE_ROCKCHIP y
PCIE_ROCKCHIP_HOST y
PCIE_DW_PLAT y
PCIE_DW_PLAT_HOST y
PHY_ROCKCHIP_PCIE y
PHY_ROCKCHIP_INNO_HDMI y
PHY_ROCKCHIP_DP y
ROCKCHIP_MBOX y
STAGING_MEDIA y
VIDEO_HANTRO y
VIDEO_HANTRO_ROCKCHIP y
USB_DWC2_PCI y
ROCKCHIP_LVDS y
ROCKCHIP_RGB y
'';
nhp = patch: sha256: let rev = "ded66e50064c55a56a958558ab35bc6bae444e72"; in {
name = patch;
patch = (fetchpatch {
url = "https://raw.githubusercontent.com/nadiaholmquist/pbp-packages/${rev}/linux-pbp/${patch}";
inherit sha256;
});
};
in
buildLinux (args // {
inherit version;
linux_latest.override({
kernelPatches = lib.lists.unique (kernelPatches ++ [
pkgs.kernelPatches.bridge_stp_helper
pkgs.kernelPatches.request_key_helper
pkgs.kernelPatches.export_kernel_fpu_functions."5.3"
additionalConfig
# Kernel configuration
{
# None of these *need* to be set to `y`.
# But eh, it works too
name = "pinebookpro-config";
patch = null;
extraConfig = ''
PCIE_ROCKCHIP y
PCIE_ROCKCHIP_HOST y
PCIE_DW_PLAT y
PCIE_DW_PLAT_HOST y
PHY_ROCKCHIP_PCIE y
PHY_ROCKCHIP_INNO_HDMI y
PHY_ROCKCHIP_DP y
ROCKCHIP_MBOX y
USB_DWC2_PCI y
ROCKCHIP_LVDS y
ROCKCHIP_RGB y
'';
}
{
name = "video-hantro-config";
patch = null;
extraConfig = ''
STAGING_MEDIA y
VIDEO_HANTRO m
VIDEO_HANTRO_ROCKCHIP y
'';
}
{
# When efifb is used, rockchipdrm won't render the VT.
name = "rk3399-efifb-config";
patch = null;
extraConfig = ''
FB_EFI n
'';
}
# Misc. community patches
# None are *required* for basic function.
# https://github.com/nadiaholmquist/pbp-packages/tree/master/linux-pbp
(nhp "0007-mmc-core-pwrseq_simple-disable-mmc-power-on-shutdown.patch" "1d16gjgds670dzpkb8jjlymcpp1inab3mlzbpfdinrgvfy4pywhi")
(nhp "0011-typec-displayport-some-devices-have-pin-assignments-reversed.patch" "02dbkjkr4x407cysr9b0ps34izhq7p3gk9q7rz5abmazgcz62y4g")
(nhp "0012-usb-typec-tcpm-Add-generic-extcon-for-tcpm-enabled-devices.patch" "1icfy8vmwm0f825bgndhmdiskrryzpsbnrfhgvpbxwjrvwmkvlar")
(nhp "0013-usb-typec-tcpm-Add-generic-extcon-to-tcpm.patch" "0qiyf42g9jd8inb85gkj6bacbid88wb3hbn3144ja3xfss1l04cw")
(nhp "0014-arm64-rockchip-add-DP-ALT-rockpro64.patch" "03k13jgcnz7wmks1y1fgzpjj2yvi114cbvprmnkyf8xrjns7x5q0")
(nhp "0015-ayufan-drm-rockchip-add-support-for-modeline-32MHz-e.patch" "0z51whv0bjj45l5z3q4v0rqdvz62dh4qg8ccd87la9ga8y1v14cy")
(nhp "0021-usb-typec-bus-Catch-crash-due-to-partner-NULL-value.patch" "0a4zd7ihd9pj6djgcj4ayaw7ff0xs9wqgmcvhwchwy766js3l5rp")
(nhp "0022-phy-rockchip-typec-Set-extcon-capabilities.patch" "0pqq856g0yndxvg9ipbx1jv6j4ldvapgzvxzvpirygc7f0wdrz49")
(nhp "0023-usb-typec-altmodes-displayport-Add-hacky-generic-altmode.patch" "1vldwg3zwrx2ppqgbhc91l48nfmjkmwwdsyq6mq6f3l1cwfdn62q")
(nhp "0024-arm64-dts-rockchip-setup-USB-type-c-port-as-dual-dat.patch" "0zwwyhryghafga36mgnazn6gk88m2rvs8ng5ykk4hhg9pi5bgzh9")
(nhp "0026-arm64-dts-rockchip-add-typec-extcon-hack.patch" "1kri47nkm6qgsqgkxzgy6iwhpajcx9xwd4rf8dldr6prb9f6iv3p")
(nhp "pbp-2d-fix.patch" "1hwd6clk1qnjyd4jl7kjn9pnilijz4brh1p5dnv8jzr2ajx2346j")
]);
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
modDirVersion = if (modDirVersionArg == null) then concatStrings (intersperse "." (take 3 (splitString "." "${version}.0"))) else modDirVersionArg;
# branchVersion needs to be x.y
extraMeta.branch = concatStrings (intersperse "." (take 2 (splitString "." version)));
src = fetchFromGitLab {
domain = "gitlab.manjaro.org";
owner = "tsys";
repo = "linux-pinebook-pro";
rev = "a8f4db8a726e5e4552e61333dcd9ea1ff35f39f9";
sha256 = "1vbach0y28c29hjjx4sc9hda4jxyqfhv4wlip3ky93vf4gxm2fij";
};
postInstall = (optionalString (args ? postInstall) args.postInstall) + ''
mkdir -p "$out/nix-support"
cp -v "$buildRoot/.config" "$out/nix-support/build.config"
'';
} // (args.argsOverride or {}))
})
//
(args.argsOverride or {})

View file

@ -1,18 +1,27 @@
{ pkgs, lib, linux_5_4, kernelPatches, ... } @ args:
# By design this is only softly "pinning" to a particular major version.
# By design, this will track the kernel upgrades in Nixpkgs.
# It is unlikely patches won't apply on the LTS version.
{ pkgs, lib, linux_5_10, kernelPatches, fetchpatch, ... } @ args:
linux_5_4.override({
# The way the linux kernel is composed, kernelPatches will end up filled-in twice...
# Not entirely sure why.
let
nhp = patch: sha256: let rev = "ded66e50064c55a56a958558ab35bc6bae444e72"; in {
name = patch;
patch = (fetchpatch {
url = "https://raw.githubusercontent.com/nadiaholmquist/pbp-packages/${rev}/linux-pbp/${patch}";
inherit sha256;
});
};
in
linux_5_10.override({
kernelPatches = lib.lists.unique (kernelPatches ++ [
pkgs.kernelPatches.bridge_stp_helper
pkgs.kernelPatches.request_key_helper
pkgs.kernelPatches.export_kernel_fpu_functions."5.3"
# Kernel configuration
{
name = "pinebookpro-5.4-lts.patch";
patch = ./pinebookpro-5.4-lts.patch;
}
{
name = "pinebookpro-config-fixes";
# None of these *need* to be set to `y`.
# But eh, it works too
name = "pinebookpro-config";
patch = null;
extraConfig = ''
PCIE_ROCKCHIP y
@ -23,14 +32,44 @@ linux_5_4.override({
PHY_ROCKCHIP_INNO_HDMI y
PHY_ROCKCHIP_DP y
ROCKCHIP_MBOX y
STAGING_MEDIA y
VIDEO_HANTRO m
VIDEO_HANTRO_ROCKCHIP y
USB_DWC2_PCI y
ROCKCHIP_LVDS y
ROCKCHIP_RGB y
'';
}
{
name = "video-hantro-config";
patch = null;
extraConfig = ''
STAGING_MEDIA y
VIDEO_HANTRO m
VIDEO_HANTRO_ROCKCHIP y
'';
}
{
# When efifb is used, rockchipdrm won't render the VT.
name = "rk3399-efifb-config";
patch = null;
extraConfig = ''
FB_EFI n
'';
}
# Misc. community patches
# None are *required* for basic function.
# https://github.com/nadiaholmquist/pbp-packages/tree/master/linux-pbp
(nhp "0007-mmc-core-pwrseq_simple-disable-mmc-power-on-shutdown.patch" "1d16gjgds670dzpkb8jjlymcpp1inab3mlzbpfdinrgvfy4pywhi")
(nhp "0011-typec-displayport-some-devices-have-pin-assignments-reversed.patch" "02dbkjkr4x407cysr9b0ps34izhq7p3gk9q7rz5abmazgcz62y4g")
(nhp "0012-usb-typec-tcpm-Add-generic-extcon-for-tcpm-enabled-devices.patch" "1icfy8vmwm0f825bgndhmdiskrryzpsbnrfhgvpbxwjrvwmkvlar")
(nhp "0013-usb-typec-tcpm-Add-generic-extcon-to-tcpm.patch" "0qiyf42g9jd8inb85gkj6bacbid88wb3hbn3144ja3xfss1l04cw")
(nhp "0014-arm64-rockchip-add-DP-ALT-rockpro64.patch" "03k13jgcnz7wmks1y1fgzpjj2yvi114cbvprmnkyf8xrjns7x5q0")
(nhp "0015-ayufan-drm-rockchip-add-support-for-modeline-32MHz-e.patch" "0z51whv0bjj45l5z3q4v0rqdvz62dh4qg8ccd87la9ga8y1v14cy")
(nhp "0021-usb-typec-bus-Catch-crash-due-to-partner-NULL-value.patch" "0a4zd7ihd9pj6djgcj4ayaw7ff0xs9wqgmcvhwchwy766js3l5rp")
(nhp "0022-phy-rockchip-typec-Set-extcon-capabilities.patch" "0pqq856g0yndxvg9ipbx1jv6j4ldvapgzvxzvpirygc7f0wdrz49")
(nhp "0023-usb-typec-altmodes-displayport-Add-hacky-generic-altmode.patch" "1vldwg3zwrx2ppqgbhc91l48nfmjkmwwdsyq6mq6f3l1cwfdn62q")
(nhp "0024-arm64-dts-rockchip-setup-USB-type-c-port-as-dual-dat.patch" "0zwwyhryghafga36mgnazn6gk88m2rvs8ng5ykk4hhg9pi5bgzh9")
(nhp "0026-arm64-dts-rockchip-add-typec-extcon-hack.patch" "1kri47nkm6qgsqgkxzgy6iwhpajcx9xwd4rf8dldr6prb9f6iv3p")
(nhp "pbp-2d-fix.patch" "1hwd6clk1qnjyd4jl7kjn9pnilijz4brh1p5dnv8jzr2ajx2346j")
]);
})
//

File diff suppressed because it is too large Load diff

View file

@ -1,46 +0,0 @@
{ config, lib, pkgs, ... }:
let
extlinux-conf-builder =
import <nixpkgs/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.nix> {
pkgs = pkgs.buildPackages;
};
in
{
imports = [
./sd-image.nix
];
boot.loader.grub.enable = false;
boot.loader.generic-extlinux-compatible.enable = true;
boot.consoleLogLevel = lib.mkDefault 7;
boot.kernelParams = [
"cma=32M"
#"console=ttyS0,115200n8" "console=ttyAMA0,115200n8" "console=tty0"
"console=ttyS2,1500000n8"
"earlycon=uart8250,mmio32,0xff1a0000" "earlyprintk"
# The last console parameter will be where the boot process will print
# its messages. Comment or move abot ttyS2 for better serial debugging.
"console=tty0"
];
services.mingetty.serialSpeed = [ 1500000 115200 57600 38400 9600 ];
boot.initrd.availableKernelModules = [
];
sdImage = {
populateRootCommands = ''
mkdir -p ./files/boot
${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./files/boot
'';
};
# the installation media is also the installation target,
# so we don't want to provide the installation configuration.nix.
installer.cloneConfig = false;
}

View file

@ -1,176 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
rootfsImage = pkgs.callPackage <nixpkgs/nixos/lib/make-ext4-fs.nix> ({
inherit (config.sdImage) storePaths;
#compressImage = false;
populateImageCommands = config.sdImage.populateRootCommands;
volumeLabel = "NIXOS_SD";
} // optionalAttrs (config.sdImage.rootPartitionUUID != null) {
uuid = config.sdImage.rootPartitionUUID;
});
in
{
options.sdImage = {
imageName = mkOption {
default = "${config.sdImage.imageBaseName}-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.img";
description = ''
Name of the generated image file.
'';
};
imageBaseName = mkOption {
default = "nixos-sd-image";
description = ''
Prefix of the name of the generated image file.
'';
};
storePaths = mkOption {
type = with types; listOf package;
example = literalExample "[ pkgs.stdenv ]";
description = ''
Derivations to be included in the Nix store in the generated SD image.
'';
};
rootPartitionUUID = mkOption {
type = types.nullOr types.str;
default = null;
example = "14e19a7b-0ae0-484d-9d54-43bd6fdc20c7";
description = ''
UUID for the main NixOS partition on the SD card.
'';
};
gapSize = mkOption {
type = types.int;
# This is probably way too much... meh.
default = 30;
internal = true;
description = ''
Gap before the partition, to put u-boot into.
'';
};
populateRootCommands = mkOption {
example = literalExample "''\${extlinux-conf-builder} -t 3 -c \${config.system.build.toplevel} -d ./files/boot''";
description = ''
Shell commands to populate the ./files directory.
All files in that directory are copied to the
root (/) partition on the SD image. Use this to
populate the ./files/boot (/boot) directory.
'';
};
manipulateImageCommands = mkOption {
default = ":";
description = ''
Additional manipulations to do to the image.
For example, embedding the right u-boot.
'';
};
compressImage = mkOption {
type = types.bool;
default = true;
description = ''
Whether the SD image should be compressed using
<command>bzip2</command>.
'';
};
};
config = {
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
};
};
sdImage.storePaths = [ config.system.build.toplevel ];
system.build.sdImage = pkgs.callPackage ({ stdenv, dosfstools, e2fsprogs,
mtools, libfaketime, utillinux, bzip2/*, zstd*/ }: stdenv.mkDerivation {
name = config.sdImage.imageName;
nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime utillinux bzip2 /*zstd */];
inherit (config.sdImage) compressImage;
buildCommand = ''
mkdir -p $out/nix-support $out/sd-image
export img=$out/sd-image/${config.sdImage.imageName}
echo "${pkgs.stdenv.buildPlatform.system}" > $out/nix-support/system
if test -n "$compressImage"; then
echo "file sd-image $img.bz2" >> $out/nix-support/hydra-build-products
else
echo "file sd-image $img" >> $out/nix-support/hydra-build-products
fi
#echo "Decompressing rootfs image"
#zstd -d --no-progress "${rootfsImage}" -o ./root-fs.img
cp -v "${rootfsImage}" ./root-fs.img
# Gap in front of the first partition, in MiB
gap=8
# Create the image file sized to fit the gap and /, plus slack.
rootSizeBlocks=$(du -B 512 --apparent-size ./root-fs.img | awk '{ print $1 }')
gapSizeBlocks=$((${toString config.sdImage.gapSize} * 1024 * 1024 / 512))
imageSize=$((rootSizeBlocks * 512 + gapSizeBlocks * 512 + gap * 1024 * 1024))
truncate -s $imageSize $img
# type=b is 'W95 FAT32', type=83 is 'Linux'.
# The "bootable" partition is where u-boot will look file for the bootloader
# information (dtbs, extlinux.conf file).
sfdisk $img <<EOF
label: dos
start=$((gap + ${toString config.sdImage.gapSize}))M, type=83, bootable
EOF
# Copy the rootfs into the SD image
eval $(partx $img -o START,SECTORS --nr 1 --pairs)
dd conv=notrunc if=./root-fs.img of=$img seek=$START count=$SECTORS
${config.sdImage.manipulateImageCommands}
if test -n "$compressImage"; then
bzip2 $img
fi
'';
}) {};
boot.postBootCommands = ''
# On the first boot do some maintenance tasks
if [ -f /nix-path-registration ]; then
set -euo pipefail
set -x
# Figure out device names for the boot device and root filesystem.
rootPart=$(${pkgs.utillinux}/bin/findmnt -n -o SOURCE /)
bootDevice=$(lsblk -npo PKNAME $rootPart)
# Resize the root partition and the filesystem to fit the disk
echo ",+," | sfdisk -N1 --no-reread $bootDevice
${pkgs.parted}/bin/partprobe
${pkgs.e2fsprogs}/bin/resize2fs $rootPart
# Register the contents of the initial Nix store
${config.nix.package.out}/bin/nix-store --load-db < /nix-path-registration
# nixos-rebuild also requires a "system" profile and an /etc/NIXOS tag.
touch /etc/NIXOS
${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
# Prevents this from running on later boots.
rm -f /nix-path-registration
fi
'';
};
}

View file

@ -4,13 +4,6 @@ let
inherit (final) callPackage kernelPatches linuxPackagesFor;
in
{
# Alternative BSP u-boot, with nvme support if desired
# * https://gitlab.manjaro.org/manjaro-arm/packages/core/uboot-pinebookpro
uBootPinebookPro = callPackage ./u-boot {};
uBootPinebookProExternalFirst = callPackage ./u-boot {
externalFirst = true;
};
# The unqualified kernel attr is deprecated.
linux_pinebookpro = throw "The linux_pinebookpro attribute has been replaced by linux_pinebookpro_latest.";
linuxPackages_pinebookpro = throw "The linuxPackages_pinebookpro attribute has been replaced by linuxPackages_pinebookpro_latest.";
@ -21,6 +14,6 @@ in
linux_pinebookpro_lts = callPackage ./kernel/lts { kernelPatches = []; };
linuxPackages_pinebookpro_lts = linuxPackagesFor final.linux_pinebookpro_lts;
pinebookpro-firmware = callPackage ./firmware {};
pinebookpro-ap6256-firmware = callPackage ./firmware/ap6256-firmware.nix {};
pinebookpro-keyboard-updater = callPackage ./keyboard-updater {};
}

View file

@ -73,15 +73,10 @@
hardware.enableRedistributableFirmware = true;
hardware.firmware = [
pkgs.pinebookpro-firmware
pkgs.pinebookpro-ap6256-firmware
];
systemd.tmpfiles.rules = [
# Until suspend is fixed, this at least prevents the user from shooting
# themselves in the foot by suspending accidentally, then forced to restart
# the system forcibly..
"w /sys/power/mem_sleep - - - - s2idle"
# Tweak the minimum frequencies of the GPU and CPU governors to get a bit more performance
# https://github.com/elementary/os/blob/05a5a931806d4ed8bc90396e9e91b5ac6155d4d4/build-pinebookpro.sh#L288-L294
"w- /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq - - - - 1200000"

View file

@ -1,52 +0,0 @@
From f62ba28ac93ebc759d9774cbffe7ce6ae22a51c0 Mon Sep 17 00:00:00 2001
From: dhivael <dhivael.git@eno.space>
Date: Sat, 11 Jan 2020 15:04:46 +0100
Subject: [PATCH 1/5] rk3399: light pinebook power and standby leds during
early boot
this is a hack, but it works for now.
---
arch/arm/mach-rockchip/rk3399/rk3399.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-rockchip/rk3399/rk3399.c b/arch/arm/mach-rockchip/rk3399/rk3399.c
index 4fda93b1527..e24b39486d0 100644
--- a/arch/arm/mach-rockchip/rk3399/rk3399.c
+++ b/arch/arm/mach-rockchip/rk3399/rk3399.c
@@ -19,6 +19,8 @@
#include <asm/arch-rockchip/hardware.h>
#include <linux/bitops.h>
#include <power/regulator.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/pinctrl/rockchip.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -119,8 +121,8 @@ void board_debug_uart_init(void)
struct rk3399_grf_regs * const grf = (void *)GRF_BASE;
#ifdef CONFIG_TARGET_CHROMEBOOK_BOB
struct rk3399_pmugrf_regs * const pmugrf = (void *)PMUGRF_BASE;
- struct rockchip_gpio_regs * const gpio = (void *)GPIO0_BASE;
#endif
+ struct rockchip_gpio_regs * const gpio = (void *)GPIO0_BASE;
#if defined(CONFIG_DEBUG_UART_BASE) && (CONFIG_DEBUG_UART_BASE == 0xff180000)
/* Enable early UART0 on the RK3399 */
@@ -153,6 +155,14 @@ void board_debug_uart_init(void)
spl_gpio_set_pull(&pmugrf->gpio0_p, GPIO(BANK_B, 4), GPIO_PULL_NORMAL);
#endif /* CONFIG_TARGET_CHROMEBOOK_BOB */
+ {
+ // set GPIO0_A2/B3 to GPIO_ACTIVE_HIGH
+ // set GPIO0_A2/B3 to OUTPUT
+ int mask = (1UL << RK_PA2) | (1UL << RK_PB3);
+ setbits_le32(&gpio->swport_dr, mask);
+ setbits_le32(&gpio->swport_ddr, mask);
+ }
+
/* Enable early UART2 channel C on the RK3399 */
rk_clrsetreg(&grf->gpio4c_iomux,
GRF_GPIO4C3_SEL_MASK,
--
2.25.3

View file

@ -1,25 +0,0 @@
From f44bd5bb5fefea8404489c3e14f8537300fa3fb6 Mon Sep 17 00:00:00 2001
From: dhivael <dhivael.git@eno.space>
Date: Sat, 11 Jan 2020 15:12:34 +0100
Subject: [PATCH 2/5] reduce pinebook_pro bootdelay to 1
---
configs/pinebook-pro-rk3399_defconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/pinebook-pro-rk3399_defconfig b/configs/pinebook-pro-rk3399_defconfig
index 18b2d74253b..297cc5f17a5 100644
--- a/configs/pinebook-pro-rk3399_defconfig
+++ b/configs/pinebook-pro-rk3399_defconfig
@@ -10,7 +10,7 @@ CONFIG_DEBUG_UART_CLOCK=24000000
CONFIG_SPL_SPI_FLASH_SUPPORT=y
CONFIG_SPL_SPI_SUPPORT=y
CONFIG_DEBUG_UART=y
-CONFIG_BOOTDELAY=3
+CONFIG_BOOTDELAY=1
CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-pinebook-pro.dtb"
CONFIG_MISC_INIT_R=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
--
2.25.3

View file

@ -1,29 +0,0 @@
From dd52b971005271d615e63f4f946a0ee9331925bc Mon Sep 17 00:00:00 2001
From: dhivael <dhivael.git@eno.space>
Date: Sat, 11 Jan 2020 15:04:04 +0100
Subject: [PATCH 3/5] rockchip: move mmc1 before mmc0 in default boot order
on pinebooks mmc1 is the external card, which should take boot priority
over the internal emmc even if the emmc is bootable.
---
include/configs/rockchip-common.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/configs/rockchip-common.h b/include/configs/rockchip-common.h
index 0b9e24d1db4..6610f95b7b9 100644
--- a/include/configs/rockchip-common.h
+++ b/include/configs/rockchip-common.h
@@ -17,8 +17,8 @@
/* First try to boot from SD (index 0), then eMMC (index 1) */
#if CONFIG_IS_ENABLED(CMD_MMC)
#define BOOT_TARGET_MMC(func) \
- func(MMC, mmc, 0) \
- func(MMC, mmc, 1)
+ func(MMC, mmc, 1) \
+ func(MMC, mmc, 0)
#else
#define BOOT_TARGET_MMC(func)
#endif
--
2.25.3

View file

@ -1,55 +0,0 @@
From 4b11a4444983c997addc5c581da1ec287f27fa47 Mon Sep 17 00:00:00 2001
From: dhivael <dhivael.git@eno.space>
Date: Sat, 11 Jan 2020 15:04:04 +0100
Subject: [PATCH 4/5] rockchip: move usb0 after mmc1 in default boot order
now that we support booting from USB we should prefer USB boot over eMMC
boot. we still try to boot from SD cards first.
---
include/configs/rockchip-common.h | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/configs/rockchip-common.h b/include/configs/rockchip-common.h
index 6610f95b7b9..d743ebe83e6 100644
--- a/include/configs/rockchip-common.h
+++ b/include/configs/rockchip-common.h
@@ -16,11 +16,10 @@
/* First try to boot from SD (index 0), then eMMC (index 1) */
#if CONFIG_IS_ENABLED(CMD_MMC)
- #define BOOT_TARGET_MMC(func) \
- func(MMC, mmc, 1) \
- func(MMC, mmc, 0)
+ #define BOOT_TARGET_MMC(func, idx) \
+ func(MMC, mmc, idx)
#else
- #define BOOT_TARGET_MMC(func)
+ #define BOOT_TARGET_MMC(func, idx)
#endif
#if CONFIG_IS_ENABLED(CMD_NVME)
@@ -55,16 +54,18 @@
#ifdef CONFIG_ROCKCHIP_RK3399
#define BOOT_TARGET_DEVICES(func) \
- BOOT_TARGET_MMC(func) \
- BOOT_TARGET_NVME(func) \
+ BOOT_TARGET_MMC(func, 1) \
BOOT_TARGET_USB(func) \
+ BOOT_TARGET_NVME(func) \
+ BOOT_TARGET_MMC(func, 0) \
BOOT_TARGET_PXE(func) \
BOOT_TARGET_DHCP(func) \
BOOT_TARGET_SF(func)
#else
#define BOOT_TARGET_DEVICES(func) \
- BOOT_TARGET_MMC(func) \
+ BOOT_TARGET_MMC(func, 1) \
BOOT_TARGET_USB(func) \
+ BOOT_TARGET_MMC(func, 0) \
BOOT_TARGET_PXE(func) \
BOOT_TARGET_DHCP(func)
#endif
--
2.25.3

View file

@ -1,25 +0,0 @@
From 70ea0ddc9cea88ef06a685a09b2d407db60bceae Mon Sep 17 00:00:00 2001
From: Samuel Dionne-Riel <samuel@dionne-riel.com>
Date: Mon, 6 Jan 2020 20:16:27 -0500
Subject: [PATCH 5/5] HACK: Add changing LEDs signal at boot on pinebook pro
---
include/configs/pinebook-pro-rk3399.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/configs/pinebook-pro-rk3399.h b/include/configs/pinebook-pro-rk3399.h
index d478b19917d..3c7ca9e7600 100644
--- a/include/configs/pinebook-pro-rk3399.h
+++ b/include/configs/pinebook-pro-rk3399.h
@@ -8,6 +8,8 @@
#define __PINEBOOK_PRO_RK3399_H
#define ROCKCHIP_DEVICE_SETTINGS \
+ "beep_boop=led green:power on; led red:standby on; sleep 0.1; led green:power off; sleep 0.1; led green:power on; sleep 0.1; led red:standby off; sleep 0.1; led red:standby on\0" \
+ "bootcmd=run beep_boop; run distro_bootcmd\0" \
"stdin=serial,usbkbd\0" \
"stdout=serial,vidconsole\0" \
"stderr=serial,vidconsole\0"
--
2.25.3

View file

@ -1,75 +0,0 @@
{ buildUBoot
, lib
, python
, armTrustedFirmwareRK3399
, fetchpatch
, fetchFromGitLab
, fetchFromGitHub
, externalFirst ? false
}:
let
pw = id: sha256: fetchpatch {
inherit sha256;
name = "${id}.patch";
url = "https://patchwork.ozlabs.org/patch/${id}/raw/";
};
atf = armTrustedFirmwareRK3399.overrideAttrs(oldAttrs: {
src = fetchFromGitHub {
owner = "ARM-software";
repo = "arm-trusted-firmware";
rev = "9935047b2086faa3bf3ccf0b95a76510eb5a160b";
sha256 = "1a6pm0nbgm5r3a41nwlkrli90l2blcijb02li7h75xcri6rb7frk";
};
version = "2020-06-17";
});
in
(buildUBoot {
defconfig = "pinebook-pro-rk3399_defconfig";
extraMeta.platforms = ["aarch64-linux"];
BL31 = "${atf}/bl31.elf";
filesToInstall = [
"idbloader.img"
"u-boot.itb"
".config"
];
extraPatches = [
# Dhivael patchset
# ----------------
#
# Origin: https://git.eno.space/pbp-uboot.git/
# Forward ported to 2020.07
./0001-rk3399-light-pinebook-power-and-standby-leds-during-.patch
./0002-reduce-pinebook_pro-bootdelay-to-1.patch
# samueldr's patchset
# -------------------
./0005-HACK-Add-changing-LEDs-signal-at-boot-on-pinebook-pr.patch
] ++ lib.optionals (externalFirst) [
# Origin: https://git.eno.space/pbp-uboot.git/
# Forward ported to 2020.07
./0003-rockchip-move-mmc1-before-mmc0-in-default-boot-order.patch
./0004-rockchip-move-usb0-after-mmc1-in-default-boot-order.patch
];
})
.overrideAttrs(oldAttrs: {
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [
python
];
postPatch = oldAttrs.postPatch + ''
patchShebangs arch/arm/mach-rockchip/
'';
src = fetchFromGitLab {
domain = "gitlab.denx.de";
owner = "u-boot";
repo = "u-boot";
sha256 = "11154cxycw81dnmxfl10n2mgyass18jhjpwygqp7w1vjk9hgi4lw";
rev = "v2020.07";
};
})