diff --git a/nixos-configurations/squash/default.nix b/nixos-configurations/squash/default.nix index 9b903359..87255693 100644 --- a/nixos-configurations/squash/default.nix +++ b/nixos-configurations/squash/default.nix @@ -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 = { diff --git a/nixos-modules/hardware/clearfog-cn913x.nix b/nixos-modules/hardware/clearfog-cn913x.nix index a1c816db..95d2b7ae 100644 --- a/nixos-modules/hardware/clearfog-cn913x.nix +++ b/nixos-modules/hardware/clearfog-cn913x.nix @@ -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; @@ -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; diff --git a/overlays/uboot-cn9130-cf-pro.nix b/overlays/cn9130-clearfog-pro-firmware.nix similarity index 94% rename from overlays/uboot-cn9130-cf-pro.nix rename to overlays/cn9130-clearfog-pro-firmware.nix index 407b5ae4..4ae1e7a6 100644 --- a/overlays/uboot-cn9130-cf-pro.nix +++ b/overlays/cn9130-clearfog-pro-firmware.nix @@ -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 = '' @@ -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 = [ @@ -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"; @@ -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; @@ -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 '' @@ -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" ]; } diff --git a/overlays/default.nix b/overlays/default.nix index bff0f395..fb10d088 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -151,8 +151,8 @@ 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"; }; @@ -160,10 +160,11 @@ inputs: with inputs; { 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 { };