default.nix (7101B)
1 { 2 description = '' 3 Belkin RT-3200 / Linksys E8450 4 ****************************** 5 6 This device is based on a 64 bit Mediatek MT7622 ARM platform, 7 and is "work in progress" in Liminix. 8 9 .. note:: The factory flash image contains ECC errors that make it 10 incompatible with Liminix: you need to use the `OpenWrt 11 UBI Installer <https://github.com/dangowrt/owrt-ubi-installer>`_ to 12 rewrite the partition layout before you can flash 13 Liminix onto it (or even use it with 14 :ref:`system-outputs-tftpboot`, if you want the wireless 15 to work). 16 17 Hardware summary 18 ================ 19 20 - MediaTek MT7622BV (1350MHz) 21 - 128MB NAND flash 22 - 512MB RAM 23 - b/g/n wireless using MediaTek MT7622BV (MT7615E driver) 24 - a/n/ac/ax wireless using MediaTek MT7915E 25 26 27 Installation 28 ============ 29 30 Installation is currently a manual process (you need a :ref:`serial <serial>` conection and 31 TFTP) following the instructions at :ref:`system-outputs-ubimage` 32 33 ''; 34 35 system = { 36 crossSystem = { 37 config = "aarch64-unknown-linux-musl"; 38 }; 39 }; 40 41 module = {pkgs, config, lib, lim, ... }: 42 let firmware = pkgs.stdenv.mkDerivation { 43 name = "wlan-firmware"; 44 phases = ["installPhase"]; 45 installPhase = '' 46 mkdir $out 47 cp ${pkgs.linux-firmware}/lib/firmware/mediatek/{mt7915,mt7615,mt7622}* $out 48 ''; 49 }; 50 in { 51 imports = [ 52 ../../modules/arch/aarch64.nix 53 ../../modules/outputs/tftpboot.nix 54 ../../modules/outputs/ubifs.nix 55 ]; 56 config = { 57 kernel = { 58 src = pkgs.pkgsBuildBuild.fetchurl { 59 name = "linux.tar.gz"; 60 url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz"; 61 hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ="; 62 }; 63 extraPatchPhase = '' 64 ${pkgs.openwrt.applyPatches.mediatek} 65 ''; 66 config = { 67 PCI = "y"; 68 ARCH_MEDIATEK = "y"; 69 # ARM_MEDIATEK_CPUFREQ = "y"; 70 71 # needed for "Cannot find regmap for /infracfg@10000000" 72 MFD_SYSCON = "y"; 73 MTK_INFRACFG = "y"; 74 75 MTK_PMIC_WRAP = "y"; 76 NVMEM_MTK_EFUSE="y"; 77 # MTK_HSDMA="y"; 78 MTK_SCPSYS="y"; 79 MTK_SCPSYS_PM_DOMAINS="y"; 80 # MTK_THERMAL="y"; 81 MTK_TIMER="y"; 82 83 COMMON_CLK_MT7622 = "y"; 84 COMMON_CLK_MT7622_ETHSYS = "y"; 85 COMMON_CLK_MT7622_HIFSYS = "y"; 86 COMMON_CLK_MT7622_AUDSYS = "y"; 87 PM_CLK="y"; 88 89 REGMAP_MMIO = "y"; 90 CLKSRC_MMIO = "y"; 91 REGMAP = "y"; 92 93 MEDIATEK_GE_PHY = "y"; 94 # MEDIATEK_MT6577_AUXADC = "y"; 95 NET_MEDIATEK_SOC = "y"; 96 NET_MEDIATEK_SOC_WED = "y"; 97 NET_MEDIATEK_STAR_EMAC = "y"; # this enables REGMAP_MMIO 98 NET_VENDOR_MEDIATEK = "y"; 99 PCIE_MEDIATEK = "y"; 100 101 BLOCK = "y"; # move this to base option 102 103 SPI_MASTER = "y"; 104 SPI = "y"; 105 SPI_MEM="y"; 106 SPI_MTK_NOR="y"; 107 SPI_MTK_SNFI = "y"; 108 109 MTD = "y"; 110 MTD_BLOCK = "y"; 111 MTD_RAW_NAND = "y"; 112 MTD_NAND_MTK = "y"; 113 MTD_NAND_MTK_BMT = "y"; # Bad-block Management Table 114 MTD_NAND_ECC_MEDIATEK= "y"; 115 MTD_NAND_ECC_SW_HAMMING= "y"; 116 MTD_SPI_NAND= "y"; 117 MTD_OF_PARTS = "y"; 118 MTD_NAND_CORE= "y"; 119 MTD_SPI_NOR= "y"; 120 MTD_SPLIT_FIRMWARE= "y"; 121 MTD_SPLIT_FIT_FW= "y"; 122 123 124 MMC = "y"; 125 MMC_BLOCK = "y"; 126 MMC_CQHCI = "y"; 127 MMC_MTK = "y"; 128 129 # Distributed Switch Architecture is needed 130 # to make the ethernet ports visible 131 NET_DSA="y"; 132 NET_DSA_MT7530="y"; 133 NET_DSA_TAG_MTK="y"; 134 135 PSTORE = "y"; 136 PSTORE_RAM = "y"; 137 PSTORE_CONSOLE = "y"; 138 PSTORE_DEFLATE_COMPRESS = "n"; 139 140 SERIAL_8250 = "y"; 141 SERIAL_8250_CONSOLE = "y"; 142 SERIAL_8250_MT6577="y"; 143 # SERIAL_8250_NR_UARTS="3"; 144 # SERIAL_8250_RUNTIME_UARTS="3"; 145 SERIAL_OF_PLATFORM="y"; 146 147 # Must enble hardware watchdog drivers. Else the device reboots after several seconds 148 WATCHDOG = "y"; 149 MEDIATEK_WATCHDOG = "y"; 150 }; 151 conditionalConfig = { 152 WLAN= { 153 MT7615E = "m"; 154 MT7622_WMAC = "y"; 155 MT7915E = "m"; 156 }; 157 }; 158 }; 159 boot = { 160 commandLine = [ "console=ttyS0,115200" ]; 161 tftp.loadAddress = lim.parseInt "0x4007ff28"; 162 imageFormat = "fit"; 163 }; 164 filesystem = 165 let inherit (pkgs.pseudofile) dir symlink; 166 in 167 dir { 168 lib = dir { 169 firmware = dir { 170 mediatek = symlink firmware; 171 }; 172 }; 173 }; 174 175 hardware = 176 let 177 openwrt = pkgs.openwrt; 178 mac80211 = pkgs.kmodloader.override { 179 targets = ["mt7615e" "mt7915e"]; 180 inherit (config.system.outputs) kernel; 181 }; 182 in { 183 ubi = { 184 minIOSize = "2048"; 185 eraseBlockSize = "126976"; 186 maxLEBcount = "1024"; # guessing 187 }; 188 189 defaultOutput = "ubimage"; 190 # the kernel expects this to be on a 2MB boundary. U-Boot 191 # (I don't know why) has a default of 0x41080000, which isn't. 192 # We put it at the 32MB mark so that tftpboot can put its rootfs 193 # image and DTB underneath, but maybe this is a terrible waste of 194 # RAM unless the kernel is able to reuse it later. Oh well 195 loadAddress = lim.parseInt "0x42000000"; 196 entryPoint = lim.parseInt "0x42000000"; 197 rootDevice = "ubi0:liminix"; 198 dts = { 199 src = "${openwrt.src}/target/linux/mediatek/dts/mt7622-linksys-e8450-ubi.dts"; 200 includes = [ 201 "${openwrt.src}/target/linux/mediatek/dts" 202 "${config.system.outputs.kernel.modulesupport}/arch/arm64/boot/dts/mediatek/" 203 ]; 204 }; 205 206 # - 0x000000000000-0x000008000000 : "spi-nand0" 207 # - 0x000000000000-0x000000080000 : "bl2" 208 # - 0x000000080000-0x0000001c0000 : "fip" 209 # - 0x0000001c0000-0x0000002c0000 : "factory" 210 # - 0x0000002c0000-0x000000300000 : "reserved" 211 # - 0x000000300000-0x000008000000 : "ubi" 212 213 networkInterfaces = 214 let 215 inherit (config.system.service.network) link; 216 inherit (config.system.service) bridge; 217 in rec { 218 wan = link.build { ifname = "wan"; }; 219 lan1 = link.build { ifname = "lan1"; }; 220 lan2 = link.build { ifname = "lan2"; }; 221 lan3 = link.build { ifname = "lan3"; }; 222 lan4 = link.build { ifname = "lan4"; }; 223 lan = lan3; 224 225 wlan = link.build { 226 ifname = "wlan0"; 227 dependencies = [ mac80211 ]; 228 }; 229 wlan5 = link.build { 230 ifname = "wlan1"; 231 dependencies = [ mac80211 ]; 232 }; 233 }; 234 }; 235 }; 236 }; 237 }