Skip to content

Commit

Permalink
Fix cn9130 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbaur committed Aug 19, 2023
1 parent b4f28b8 commit 0ec2cd3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 102 deletions.
2 changes: 1 addition & 1 deletion nixos-configurations/squash/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
(pkgs.writeShellScriptBin "update-firmware" ''
${config.programs.flashrom.package}/bin/flashrom \
--programmer linux_mtd:dev=0 \
--write ${config.system.build.firmware}/spi.img
--write ${config.system.build.firmware}
'');

systemd.services.reset-button = {
Expand Down
121 changes: 30 additions & 91 deletions nixos-modules/hardware/clearfog-cn913x.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,81 +10,35 @@
boot.kernelParams = [ "console=ttyS0,115200" "cma=256M" ];

boot.kernelPackages = pkgs.linuxPackages_5_15;
boot.kernelPatches = with pkgs; [
{
name = "0001-arm64-dts-cn913x-add-cn913x-based-COM-express-type-";
patch = "${cn913x_build_repo}/patches/linux/0001-arm64-dts-cn913x-add-cn913x-based-COM-express-type-.patch";
}
{
name = "0002-arm64-dts-cn913x-add-cn913x-COM-device-trees-to-the";
patch = "${cn913x_build_repo}/patches/linux/0002-arm64-dts-cn913x-add-cn913x-COM-device-trees-to-the.patch";
}
{
name = "0004-dts-update-device-trees-to-cn913x-rev-1";
patch = "${cn913x_build_repo}/patches/linux/0004-dts-update-device-trees-to-cn913x-rev-1.1.patch";
}
{
name = "0005-DTS-update-cn9130-device-tree";
patch = "${cn913x_build_repo}/patches/linux/0005-DTS-update-cn9130-device-tree.patch";
}
{
name = "0007-update-spi-clock-frequency-to-10MHz";
patch = "${cn913x_build_repo}/patches/linux/0007-update-spi-clock-frequency-to-10MHz.patch";
}
{
name = "0009-dts-cn9130-som-for-clearfog-base-and-pro";
patch = "${cn913x_build_repo}/patches/linux/0009-dts-cn9130-som-for-clearfog-base-and-pro.patch";
}
{
name = "0010-dts-add-usb2-support-and-interrupt-btn";
patch = "${cn913x_build_repo}/patches/linux/0010-dts-add-usb2-support-and-interrupt-btn.patch";
}
{
name = "0011-linux-add-support-cn9131-cf-solidwan";
patch = "${cn913x_build_repo}/patches/linux/0011-linux-add-support-cn9131-cf-solidwan.patch";
}
{
name = "0012-linux-add-support-cn9131-bldn-mbv";
patch = "${cn913x_build_repo}/patches/linux/0012-linux-add-support-cn9131-bldn-mbv.patch";
}
{
name = "0013-cpufreq-armada-enable-ap807-cpu-clk";
patch = "${cn913x_build_repo}/patches/linux/0013-cpufreq-armada-enable-ap807-cpu-clk.patch";
}
{
name = "0014-thermal-armada-ap806-Thermal-values-updated";
patch = "${cn913x_build_repo}/patches/linux/0014-thermal-armada-ap806-Thermal-values-updated.patch";
}
{
name = "0015-Documentation-bindings-armada-thermal-Added-armada-a";
patch = "${cn913x_build_repo}/patches/linux/0015-Documentation-bindings-armada-thermal-Added-armada-a.patch";
}
{
name = "0016-thermal-armada-ap807-Thermal-data-structure-added";
patch = "${cn913x_build_repo}/patches/linux/0016-thermal-armada-ap807-Thermal-data-structure-added.patch";
}
{
name = "0017-dts-armada-ap807-updated-thermal-compatibility";
patch = "${cn913x_build_repo}/patches/linux/0017-dts-armada-ap807-updated-thermal-compatibility.patch";
}
{
name = "0018-DPDK-support-for-MVPP2";
patch = "${cn913x_build_repo}/patches/linux/0018-DPDK-support-for-MVPP2.patch";
}
{
name = "0019-arm64-dts-cn9130-clearfog-base-add-m.2-gpios";
patch = "${cn913x_build_repo}/patches/linux/0019-arm64-dts-cn9130-clearfog-base-add-m.2-gpios.patch";
}
# {
# name = "0020-Switch-back-to-kernel-when-MUSDK-stops";
# patch = "${cn913x_build_repo}/patches/linux/0020-Switch-back-to-kernel-when-MUSDK-stops.patch";
# }
{
name = "0021-linux-cn9130-cf-solidwan-add-carrier-eeprom";
patch = "${cn913x_build_repo}/patches/linux/0021-linux-cn9130-cf-solidwan-add-carrier-eeprom.patch";
}
{
name = "cn913x-additions";
boot.kernelPatches =
# NOTE: patches that don't apply cleanly are commented out
(map
(patch: {
name = lib.replaceStrings [ ".patch" ] [ "" ] (builtins.baseNameOf patch);
inherit patch;
}) [
"${pkgs.cn913x_build_repo}/patches/linux/0001-cpufreq-armada-enable-ap807-cpu-clk.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0002-thermal-armada-ap806-Thermal-values-updated.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0003-Documentation-bindings-armada-thermal-Added-armada-a.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0004-thermal-armada-ap807-Thermal-data-structure-added.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0005-dts-armada-ap807-updated-thermal-compatibility.patch"
# "${pkgs.cn913x_build_repo}/patches/linux/0006-net-sfp-add-support-for-a-couple-of-copper-multi-rat.patch"
# "${pkgs.cn913x_build_repo}/patches/linux/0007-net-sfp-add-support-for-HXSX-ATRI-1-copper-SFP-modul.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0008-arm64-dts-cn913x-add-cn913x-based-COM-express-type-7.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0009-cn9130-som-for-clearfog-base-and-pro.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0010-linux-add-support-cn9131-cf-solidwan.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0011-linux-add-support-cn9131-bldn-mbv.patch"
# "${pkgs.cn913x_build_repo}/patches/linux/0012-DPDK-support-for-MVPP2.patch"
# "${pkgs.cn913x_build_repo}/patches/linux/0013-Switch-back-to-kernel-when-MUSDK-stops.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0014-linux-fix-5GB-ports-phy-support-cn9132.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0015-Add-phy-support-1G-eth-ports-Belden-cn9131.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0016-arm64-dts-cn9131-cf-solidwan-update-model-property-t.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0017-arm64-dts-cn9130-som-support-eeprom-replacement-part.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0018-arm64-dts-cn9131-cf-solidwan-add-alias-for-ethernet5.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0019-arm64-dts-cn9131-cf-solidwan-switch-cp0_phy0-to-auto.patch"
"${pkgs.cn913x_build_repo}/patches/linux/0020-arm64-dts-cn9131-cf-solidwan-enable-only-cp0-rtc.patch"
]) ++ [{
name = "cn913x-enablement";
patch = null;
extraStructuredConfig = with lib.kernel; {
ACPI_CPPC_CPUFREQ = yes;
Expand All @@ -107,22 +61,7 @@
USB_SERIAL_OPTION = yes;
USB_SERIAL_WWAN = yes;
};
}
{
name = "minification";
patch = null;
extraStructuredConfig = with lib.kernel; {
DRM = no;
MEDIA_SUPPORT = no;
SND = no;
PANEL = no;
SPEAKUP = no;
FB = lib.mkForce no;
INPUT_TOUCHSCREEN = no;
INPUT_MISC = no;
};
}
];
}];

hardware.deviceTree = {
enable = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ let
"${cn913x_build_repo}/patches/u-boot/0023-arm64-dts-cn9130-som-support-eeprom-replacement-part.patch"
"${cn913x_build_repo}/patches/u-boot/0024-board-cn913x-som-read-mac-addresses-from-eeprom.patch"
"${cn913x_build_repo}/patches/u-boot/0025-lib-tlv_eeprom-mac_read_from_eeprom-support-2-eeprom.patch"
"${cn913x_build_repo}/patches/u-boot/0026-board-cn9131-cf-solidwan-switch-cp0_phy0-to-auto-neg.patch"
./ramdisk-addr-r.patch
];
postPatch = ''
Expand All @@ -67,6 +68,10 @@ let
# prevent non-volatile memory environment from being used
extraConfig = ''
CONFIG_ENV_IS_NOWHERE=y
CONFIG_BLK=y
CONFIG_CMD_BOOTEFI=y
CONFIG_EFI_LOADER=y
CONFIG_PARTITIONS=y
'';

nativeBuildInputs = [
Expand Down Expand Up @@ -128,8 +133,7 @@ let
PLAT = "t9130";
in
gcc7Stdenv.mkDerivation {
inherit BL33 SCP_BL2;
name = "ubootCN9130_CF_Pro";
name = "atf-cn9130-clearfog-pro";
src = fetchFromGitHub {
owner = "ARM-software";
repo = "arm-trusted-firmware";
Expand All @@ -140,6 +144,7 @@ gcc7Stdenv.mkDerivation {
"${cn913x_build_repo}/patches/arm-trusted-firmware/0001-ddr-spd-read-failover-to-defualt-config.patch"
"${cn913x_build_repo}/patches/arm-trusted-firmware/0002-som-sdp-failover-using-crc-verification.patch"
];
env = { inherit BL33 SCP_BL2; };
nativeBuildInputs = [ openssl dtc git ];
hardeningDisable = [ "all" ];
dontStrip = true;
Expand All @@ -165,7 +170,7 @@ gcc7Stdenv.mkDerivation {
branchName = "mv-ddr-devel";
url = "https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell";
rev = "305d923e6bc4236cd3b902f6679b0aef9e5fa52d";
sha256 = "sha256-FtVIpOnwRbOYndrbN7Si8IzBx9prbeOkKSQOv7I9PCA=";
sha256 = "sha256-mgI84gDdzGLBzKaIyu7c/EtpFcUGEI+uNtYJfhzRd8U=";
};
in
''
Expand All @@ -174,8 +179,8 @@ gcc7Stdenv.mkDerivation {
'';
installPhase = ''
mkdir -p $out
dd bs=1M count=8 if=/dev/zero of=$out/spi.img
dd conv=notrunc if=build/${PLAT}/release/flash-image.bin of=$out/spi.img
dd bs=1M count=8 if=/dev/zero of=$out
dd conv=notrunc if=build/${PLAT}/release/flash-image.bin of=$out
'';
meta.platforms = [ "aarch64-linux" ];
}
11 changes: 6 additions & 5 deletions overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,20 @@ inputs: with inputs; {
CONFIG_SUPPORT_EMMC_BOOT=y
'';
postInstall = ''
dd bs=1M count=4 if=/dev/zero of=$out/spi.img
dd conv=notrunc if=$out/u-boot-with-spl.kwb of=$out/spi.img
dd bs=1M count=4 if=/dev/zero of=$out
dd conv=notrunc if=$out/u-boot-with-spl.kwb of=$out
'';
extraMeta.bootDevice = "spi";
};

cn913x_build_repo = prev.fetchFromGitHub {
owner = "solidrun";
repo = "cn913x_build";
rev = "e978cfc96430c1876c741656624e47744eaf9358";
hash = "sha256-NTLcn9EA8lI9rZxYwgrv5ddksr9hZwUMWLwIdX2qMDQ=";
rev = "d6d0577e6b6e86d29837618e9a02f5ee4ac136cb";
hash = "sha256-5PGu7XQxtg0AP9RovDDqmPuVnrNQow1bYaorAmUFQ7Q=";
};
ubootCN9130_CF_Pro = prev.callPackage ./uboot-cn9130-cf-pro.nix { inherit (final) cn913x_build_repo; };

cn9130ClearfogProFirmware = prev.callPackage ./cn9130-clearfog-pro-firmware.nix { inherit (final) cn913x_build_repo; };

bpiR3Firmware = prev.callPackage ./bpi-r3-firmware.nix { };

Expand Down

0 comments on commit 0ec2cd3

Please sign in to comment.