Add Fydetab Duo

This commit is contained in:
Tristan Ross
2025-08-18 21:40:57 -07:00
parent 3dac8a8725
commit d9b0f10475
13 changed files with 10008 additions and 0 deletions

17
fydetab/duo/README.md Normal file
View File

@@ -0,0 +1,17 @@
# Fydetab Duo
The Fydetab Duo is an open source and hackable tablet by FydeOS.
## Features
- Display: **works**
- GPU driver: **not working**
- WiFi: **working**
- Cellular: **untested**
- SD card: **untested**
- Sound: **untested**
- Fingerprint: **untested**
## Flashing
Flashing requires `rkdeveloptool` and using it to write the new bootloader and eMMC image. To flash, press and hold the mask rom button on the board. Ensure a USB C cable is already plugged into the host computer. Run `nix build .#nixosConfigurations.<hostname>.config.hardware.rockchip.platformFirmware` and then use `rkdeveloptool ul result/rk3588_spl_loader_v1.18.113.bin`. The NixOS image can then be downloaded using `rkdeveloptool wl 0`, it is recommended to use the disko image configuration which is provided.

43
fydetab/duo/ap6275p.nix Normal file
View File

@@ -0,0 +1,43 @@
{
lib,
stdenv,
fetchFromGitHub,
}:
stdenv.mkDerivation (_finalAttrs: {
pname = "ap6275p-firmware";
version = "2023-11-05";
src = fetchFromGitHub {
owner = "Joshua-Riek";
repo = "firmware";
rev = "621ac45f5d931522bc08b51b995b938778973d2a";
hash = "sha256-ksAOxZTnEka9SirHYxroLMbKi+99FY72X2z1pJhgYnY=";
};
compressFirmware = false;
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/lib/firmware/ap6275p
install -m644 ap6275p/BCM4362A2.hcd $out/lib/firmware/ap6275p/
install -m644 ap6275p/clm_bcm43752a2_pcie_ag.blob $out/lib/firmware/ap6275p/
install -m644 ap6275p/fw_bcm43752a2_pcie_ag.bin $out/lib/firmware/ap6275p/
install -m644 ap6275p/nvram_AP6275P.txt $out/lib/firmware/ap6275p/
install -m644 ap6275p/config.txt $out/lib/firmware/ap6275p/
mv $out/lib/firmware/ap6275p/nvram_AP6275P.txt $out/lib/firmware/ap6275p/nvram_ap6275p.txt
mv $out/lib/firmware/ap6275p/config.txt $out/lib/firmware/ap6275p/config_bcm43752a2_pcie_ag.txt
runHook postInstall
'';
meta = {
description = "Firmware for the AP6275P WiFi/Bluetooth module";
homepage = "https://github.com/Joshua-Riek/firmware";
license = lib.licenses.unfree;
};
})

View File

@@ -0,0 +1,44 @@
{
lib,
stdenv,
fetchurl,
autoPatchelfHook,
}:
stdenv.mkDerivation (_finalAttrs: {
pname = "brcm-patchram-plus";
version = "2024-08-23";
src = fetchurl {
url = "https://github.com/Linux-for-Fydetab-Duo/pkgbuilds/raw/fd5ebe4914f32c5a1c4fc15b4fb5a62bad2da1ea/fydetabduo-post-install/brcm_patchram_plus";
hash = "sha256-fZ1ximZcosZDYbveEkyMnasLWpcifaZ5CKz7QKtqKZQ=";
};
nativeBuildInputs = [
autoPatchelfHook
];
unpackPhase = ''
runHook preUnpack
cp --no-preserve=ownership,mode $src brcm_patchram_plus
chmod +x brcm_patchram_plus
runHook postUnpack
'';
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp brcm_patchram_plus $out/bin
autoPatchelf $out/bin/brcm_patchram_plus
runHook postInstall
'';
meta = {
license = lib.licenses.unfree;
mainProgram = "brcm_patchram_plus";
};
})

9549
fydetab/duo/config Normal file

File diff suppressed because it is too large Load Diff

28
fydetab/duo/config.nix Normal file
View File

@@ -0,0 +1,28 @@
{
CONFIG_DEVTMPFS = "y";
CONFIG_CGROUPS = "y";
CONFIG_INOTIFY_USER = "y";
CONFIG_SIGNALFD = "y";
CONFIG_TIMERFD = "y";
CONFIG_EPOLL = "y";
CONFIG_SYSFS = "y";
CONFIG_PROC_FS = "y";
CONFIG_FHANDLE = "y";
CONFIG_CRYPTO_USER_API_HASH = "y";
CONFIG_CRYPTO_HMAC = "y";
CONFIG_CRYPTO_SHA256 = "y";
CONFIG_DMIID = "y";
CONFIG_AUTOFS_FS = "y";
CONFIG_TMPFS_POSIX_ACL = "y";
CONFIG_TMPFS_XATTR = "y";
CONFIG_SECCOMP = "y";
CONFIG_TMPFS = "y";
CONFIG_BLK_DEV_INITRD = "y";
CONFIG_EFI_STUB = "y";
CONFIG_MODULES = "y";
CONFIG_BINFMT_ELF = "y";
CONFIG_UNIX = "y";
CONFIG_NET = "y";
CONFIG_IP_NF_MATCH_RPFILTER = "m";
CONFIG_ATA_PIIX = "m";
}

129
fydetab/duo/default.nix Normal file
View File

@@ -0,0 +1,129 @@
{
config,
pkgs,
lib,
...
}:
let
ap6275pFirmware = pkgs.callPackage ./ap6275p.nix { };
in
{
imports = [
../../rockchip
];
options.hardware.fydetab.duo = {
enablePanthor = lib.mkEnable "Panthor GPU driver";
};
config = {
boot = lib.mkMerge [
{
initrd.includeDefaultModules = false;
kernelPackages = pkgs.callPackage ./kernel.nix { };
extraModprobeConfig = ''
options bcmdhd firmware_path=${ap6275pFirmware}/lib/firmware/ap6275p/fw_bcm43752a2_pcie_ag.bin nvram_path=${ap6275pFirmware}/lib/firmware/ap6275p/nvram_AP6275P.txt conf_path=${ap6275pFirmware}/lib/firmware/ap6275p/config.txt
'';
kernelParams = [
"console=ttyFIQ0"
"console=tty1"
"console=both"
"earlycon=uart8250,mmio32,0xfeb50000"
];
kernelModules = [
"himax_tp"
"mh248-fyde"
"hci_uart"
];
}
(lib.mkIf config.hardware.bluetooth.enable {
kernelModules = [
"bluetooth"
];
})
];
hardware = {
deviceTree = lib.mkMerge [
{
name = "rockchip/rk3588s-fydetab-duo.dtb";
}
(lib.mkIf config.hardware.fydetab.duo.enablePanthor {
overlays = [
{
name = "fydetab-panthor-gpu";
dtsText = ''
/dts-v1/;
/plugin/;
#include <dt-bindings/clock/rk3588-cru.h>
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/power/rk3588-power.h>
/ {
compatible = "rockchip,rk3588s-tablet-12c-linux";
fragment@0 {
target = <&gpu>;
__overlay__ {
status = "disabled";
};
};
fragment@1 {
target = <&gpu_panthor>;
__overlay__ {
status = "okay";
mali-supply = <&vdd_gpu_s0>;
};
};
};
'';
}
];
})
];
rockchip = {
rk3588.enable = true;
platformFirmware = pkgs.callPackage ./u-boot.nix { };
};
firmware = lib.mkMerge [
# Only iwd is supported by the interface
(lib.mkIf config.networking.wireless.iwd.enable ap6275pFirmware)
(lib.mkIf config.hardware.graphics.enable (pkgs.callPackage ./mali-g610.nix { }))
(lib.mkIf config.hardware.sensor.iio.enable (pkgs.callPackage ./himax.nix { }))
];
};
systemd.services.bluetooth-fydetab = lib.mkIf config.hardware.bluetooth.enable {
description = "FydeTab Duo Bluetooth fix";
wantedBy = [ "multi-user.target" ];
serviceConfig.Type = "simple";
script = ''
${lib.getExe' pkgs.util-linux "rfkill"} block 0
${lib.getExe' pkgs.util-linux "rfkill"} block bluetooth
sleep 2
${lib.getExe' pkgs.util-linux "rfkill"} unblock 0
${lib.getExe' pkgs.util-linux "rfkill"} unblock bluetooth
sleep 1
${
lib.getExe (pkgs.callPackage ./brcm-patchram.nix { })
} --enable_hci --no2bytes --use_baudrate_for_download --tosleep 200000 --baudrate 1500000 --patchram ${ap6275pFirmware}/lib/firmware/ap6275p/BCM4362A2.hcd /dev/ttyS9
'';
};
services.udev = {
extraHwdb = ''
# Fydetab
evdev:input:b0018v0000p0000e0000*
EVDEV_ABS_00=::265
EVDEV_ABS_01=::166
'';
extraRules = ''
SUBSYSTEM=="iio" ATTR{name}=="lis2dw12" ENV{ACCEL_MOUNT_MATRIX}="1,0,0;0,-1,0;0,0,1"
SUBSYSTEM=="input", ENV{ID_INPUT_TABLET}=="1", ENV{LIBINPUT_CALIBRATION_MATRIX}="0 1 0 -1 0 1 0 0 1"
'';
};
};
}

34
fydetab/duo/himax.nix Normal file
View File

@@ -0,0 +1,34 @@
{
stdenv,
fetchurl,
lib,
}:
stdenv.mkDerivation (_finalAttrs: {
pname = "himax-firmware";
version = "2024-11-09";
src = fetchurl {
url = "https://github.com/Linux-for-Fydetab-Duo/pkgbuilds/raw/f4c012bd42d87f677370f987f703982d53cd233d/fydetabduo-post-install/Himax_firmware.bin";
};
compressFirmware = false;
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/lib/firmware
cp --no-preserve=ownership,mode $src $out/lib/firmware/Himax_firmware.bin
ls -ahl $out/lib/firmware
runHook postInstall
'';
meta = {
description = "Himax sensor firmware";
license = lib.licenses.unfree;
};
})

18
fydetab/duo/kernel.nix Normal file
View File

@@ -0,0 +1,18 @@
{
linuxPackagesFor,
linuxManualConfig,
fetchFromGitHub,
}:
linuxPackagesFor (linuxManualConfig rec {
version = "6.1.75";
modDirVersion = version;
src = fetchFromGitHub {
owner = "Linux-for-Fydetab-Duo";
repo = "linux-rockchip";
rev = "74a1657bc526e336ff66add2fa83a0522957c4cb";
hash = "sha256-Q0uCxebYw3c5Z/ZxCmTNyEfuYQQcPaw5qpvRTSWdtVo=";
};
configfile = ./config;
config = import ./config.nix;
features.netfilterRPFilter = true;
})

35
fydetab/duo/mali-g610.nix Normal file
View File

@@ -0,0 +1,35 @@
{
stdenv,
fetchurl,
lib,
}:
stdenv.mkDerivation (_finalAttrs: {
pname = "mali-g610-firmware";
version = "2024-08-23";
src = fetchurl {
url = "https://github.com/Linux-for-Fydetab-Duo/pkgbuilds/raw/f4c012bd42d87f677370f987f703982d53cd233d/mali-G610-firmware-rkr4/mali_csffw.bin";
hash = "sha256-Ei8ezBTS3g/pP8Al+Md+RTGr0AT6Fy/+aeQM19FdXGY=";
};
compressFirmware = false;
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/lib/firmware
cp --no-preserve=ownership,mode $src $out/lib/firmware/mali_csffw.bin
ls -ahl $out/lib/firmware
runHook postInstall
'';
meta = {
description = "Mali G610 firmware for Rockchip RK3588(S) using the rkr4 kernel or later";
license = lib.licenses.unfree;
};
})

98
fydetab/duo/u-boot.nix Normal file
View File

@@ -0,0 +1,98 @@
{
lib,
stdenv,
buildUboot,
armTrustedFirmwareRK3588,
rkbin,
fetchurl,
fetchFromGitHub,
}:
buildUBoot {
defconfig = "rk3588s_fydetab_duo_defconfig";
extraMeta.platforms = [ "aarch64-linux" ];
BL31 = "${armTrustedFirmwareRK3588}/bl31.elf";
ROCKCHIP_TPL = rkbin.TPL_RK3588;
CROSS_COMPILE_ARM64 = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}";
INI_LOADER = fetchurl {
url = "https://github.com/rockchip-linux/rkbin/raw/${rkbin.src.rev}/RKBOOT/RK3588MINIALL.ini";
hash = "sha256-87Vt6nXVt+jRrRatOlwGJXYqSj9nJz1LUfQnviIVb7I=";
};
version = "5.10.0";
filesToInstall = [
"idbloader.img"
"u-boot.itb"
"rk3588_spl_loader_v1.18.113.bin"
"tools/resource_tool"
];
NIX_CFLAGS_COMPILE = "-Wno-error=enum-int-mismatch -Wno-error=maybe-uninitialized";
extraMakeFlags = [
"CROSS_COMPILE_ARM64=${stdenv.cc.targetPrefix}"
];
extraPatches =
lib.attrValues (
lib.mapAttrs
(
name: hash:
pkgs.fetchpatch {
url = "https://github.com/openFyde/overlay-fydetab_duo-openfyde/raw/fd84c5302908dea6a819c2dcd025a2bf93b5d4e8/sys-boot/rk-uboot/files/rk8/${name}";
inherit hash;
}
)
{
"001-add-avdd-avee-in-rockchip_panel.patch" = "sha256-qmBdmSejcDn4ulvOTLjfBsNh6nl12sbobtX4mhTMMKY=";
"002-add-fydetab-support.patch" = "sha256-QlnhdkoOQcGxRiIOx1jNqDLb/abB/+l+hAQ8vKCpwOw=";
"003-match-display-config-with-kernel.patch" =
"sha256-hmICiAgYjjBryJIuNXOffiYTssKSaV1cDeSgRTdq51k=";
"004-enable-sdcard-for-fydetab.patch" = "sha256-xrZ1kuije6X+huvarDIGFhMy2Puq0XvlKa1ZfgGcwlQ=";
"005-display-logo-on-loader-mode.patch" = "sha256-NMQHJMl8s1NUrDSnUX8gAmSNaurBU+m0xKd4TtEPmz4=";
"006-update-deconfig.patch" = "sha256-ZukJEZjEFaN6F4+3VnHfkfdaOTQmkw3fdClk8OeOYRw=";
"007-add-deinit-after-show-bmp-add-ums-mode.patch" =
"sha256-4pHV+qiXMNHcIlC1ciFQsejVZvdnEhfs7QBbge9kHoM=";
"008-add-charging-mode.patch" = "sha256-AToALdx5mwyQ875ZnrpqbuUE9oGonH76RaUq6757U1E=";
"009-set-lowpower-to-3.patch" = "sha256-CYYmY8vQcOIiA3QPvZt+AgI/BbkykoKGqLECim7kAyw=";
"010-fix-compiling-issue.patch" = "sha256-hmiFFe0JuxXMPgeQFWI8qZop+VPmldxgs0Wowchswbs=";
"011-fix-battery-temp.patch" = "sha256-MXe5FGzGETZ3wpW7ur5rBLysdNlDMwiq7/LNxdDpA0E=";
"012-fix-make.patch" = "sha256-/8ZfhB04R4zIddOXJEx8GcnYoljYsGolbt/oQYsm/Xk=";
"013-change-exit-charge-level.patch" = "sha256-84zy5yzoHyAutVmbCvvB5t4uJFQGsMt3jTUgVs5SIog=";
"014-fix-spl-sdcard-issue.patch" = "sha256-jIHybAm9XKDbWF3xG4E9K8x2j5nfpHOp6/2gWDlQ6aU=";
}
)
++ [
./uboot-remove-sig-req.patch
];
src = fetchFromGitHub {
owner = "rockchip-linux";
repo = "u-boot";
rev = "63c55618fbdc36333db4cf12f7d6a28f0a178017";
hash = "sha256-OZmR6BLwCMK6lq9qmetIdrjSJJWcx7Po1OE9dBWL+Ew=";
};
extraConfig = ''
CONFIG_FIT_SIGNATURE=n
CONFIG_TPL_BUILD=y
CONFIG_SPL_FIT_SIGNATURE=n
CONFIG_SPL_FIT_ROLLBACK_PROTECT=n
CONFIG_CMD_FDT=y
CONFIG_DEFAULT_FDT_FILE="rk3588s-fydetab-duo.dtb"
CONFIG_CMD_PXE=y
'';
preBuild = ''
patchShebangs arch/arm/mach-rockchip/make_fit_atf.sh
patchShebangs arch/arm/mach-rockchip/decode_bl31.py
# Needs write access to generate the spl
cp -r ${rkbin.src} rkbin
chmod -R u+rw rkbin
export RKBIN_TOOLS=$(readlink -e rkbin/tools)
ln -s ${rkbin}/bin bin
cp ${rkbin.src}/tools/boot_merger tools/
cp ${rkbin.src}/tools/mkimage tools/
'';
postBuild = ''
sh ./make.sh --spl
sh ./make.sh --idblock
sh ./make.sh itb
mv idblock.bin idbloader.img
'';
}

View File

@@ -0,0 +1,11 @@
--- a/tools/Makefile 2025-08-17 22:31:27.653078358 -0700
+++ b/tools/Makefile 2025-08-17 22:30:09.551827481 -0700
@@ -54,7 +54,7 @@
hostprogs-y += mkenvimage
mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o
-hostprogs-y += dumpimage mkimage
+hostprogs-$(CONFIG_FIT_SIGNATURE) += dumpimage mkimage
hostprogs-$(CONFIG_FIT_SIGNATURE) += fit_info fit_check_sign
# Rockchip pack tools