liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

default.nix (7130B)


      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         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         # MEDIATEK_WATCHDOG = "y";
     96         NET_MEDIATEK_SOC = "y";
     97         NET_MEDIATEK_SOC_WED = "y";
     98         NET_MEDIATEK_STAR_EMAC = "y"; # this enables REGMAP_MMIO
     99         NET_VENDOR_MEDIATEK = "y";
    100         PCIE_MEDIATEK = "y";
    101 
    102         BLOCK = "y"; # move this to base option
    103 
    104         SPI_MASTER = "y";
    105         SPI = "y";
    106         SPI_MEM="y";
    107         SPI_MTK_NOR="y";
    108         SPI_MTK_SNFI = "y";
    109 
    110         MTD = "y";
    111         MTD_BLOCK = "y";
    112         MTD_RAW_NAND = "y";
    113         MTD_NAND_MTK = "y";
    114         MTD_NAND_MTK_BMT = "y";      # Bad-block Management Table
    115         MTD_NAND_ECC_MEDIATEK= "y";
    116         MTD_NAND_ECC_SW_HAMMING= "y";
    117         MTD_SPI_NAND= "y";
    118         MTD_OF_PARTS = "y";
    119         MTD_NAND_CORE= "y";
    120         MTD_SPI_NOR= "y";
    121         MTD_SPLIT_FIRMWARE= "y";
    122         MTD_SPLIT_FIT_FW= "y";
    123 
    124 
    125         MMC = "y";
    126         MMC_BLOCK = "y";
    127         MMC_CQHCI = "y";
    128         MMC_MTK = "y";
    129 
    130         # Distributed Switch Architecture is needed
    131         # to make the ethernet ports visible
    132         NET_DSA="y";
    133         NET_DSA_MT7530="y";
    134         NET_DSA_TAG_MTK="y";
    135 
    136         PSTORE = "y";
    137         PSTORE_RAM = "y";
    138         PSTORE_CONSOLE = "y";
    139         PSTORE_DEFLATE_COMPRESS = "n";
    140 
    141         SERIAL_8250 = "y";
    142         SERIAL_8250_CONSOLE = "y";
    143         SERIAL_8250_MT6577="y";
    144         # SERIAL_8250_NR_UARTS="3";
    145         # SERIAL_8250_RUNTIME_UARTS="3";
    146         SERIAL_OF_PLATFORM="y";
    147 
    148         # Must enble hardware watchdog drivers. Else the device reboots after several seconds
    149         WATCHDOG = "y";
    150         MEDIATEK_WATCHDOG = "y";
    151       };
    152       conditionalConfig = {
    153         WLAN= {
    154           MT7615E = "m";
    155           MT7622_WMAC = "y";
    156           MT7915E = "m";
    157         };
    158       };
    159     };
    160     boot = {
    161       commandLine = [ "console=ttyS0,115200" ];
    162       tftp.loadAddress = lim.parseInt "0x4007ff28";
    163       imageFormat = "fit";
    164     };
    165     filesystem =
    166       let inherit (pkgs.pseudofile) dir symlink;
    167            in
    168              dir {
    169                lib = dir {
    170                  firmware = dir {
    171                    mediatek = symlink firmware;
    172                  };
    173                };
    174              };
    175 
    176     hardware =
    177       let
    178         openwrt = pkgs.openwrt;
    179         mac80211 =  pkgs.kmodloader.override {
    180           targets = ["mt7615e" "mt7915e"];
    181           inherit (config.system.outputs) kernel;
    182         };
    183       in {
    184         ubi = {
    185           minIOSize = "2048";
    186           eraseBlockSize = "126976";
    187           maxLEBcount = "1024"; # guessing
    188         };
    189 
    190         defaultOutput = "ubimage";
    191         # the kernel expects this to be on a 2MB boundary. U-Boot
    192         # (I don't know why) has a default of 0x41080000, which isn't.
    193         # We put it at the 32MB mark so that tftpboot can put its rootfs
    194         # image and DTB underneath, but maybe this is a terrible waste of
    195         # RAM unless the kernel is able to reuse it later. Oh well
    196         loadAddress = lim.parseInt "0x42000000";
    197         entryPoint = lim.parseInt "0x42000000";
    198         rootDevice = "ubi0:liminix";
    199         dts = {
    200           src = "${openwrt.src}/target/linux/mediatek/dts/mt7622-linksys-e8450-ubi.dts";
    201           includes =  [
    202             "${openwrt.src}/target/linux/mediatek/dts"
    203             "${config.system.outputs.kernel.modulesupport}/arch/arm64/boot/dts/mediatek/"
    204           ];
    205         };
    206 
    207         # - 0x000000000000-0x000008000000 : "spi-nand0"
    208         #         - 0x000000000000-0x000000080000 : "bl2"
    209         #         - 0x000000080000-0x0000001c0000 : "fip"
    210         #         - 0x0000001c0000-0x0000002c0000 : "factory"
    211         #         - 0x0000002c0000-0x000000300000 : "reserved"
    212         #         - 0x000000300000-0x000008000000 : "ubi"
    213 
    214         networkInterfaces =
    215           let
    216             inherit (config.system.service.network) link;
    217             inherit (config.system.service) bridge;
    218           in rec {
    219             wan = link.build { ifname = "wan"; };
    220             lan1 = link.build { ifname = "lan1"; };
    221             lan2 = link.build { ifname = "lan2"; };
    222             lan3 = link.build { ifname = "lan3"; };
    223             lan4 = link.build { ifname = "lan4"; };
    224             lan = lan3;
    225 
    226             wlan = link.build {
    227               ifname = "wlan0";
    228               dependencies = [ mac80211 ];
    229             };
    230             wlan5 = link.build {
    231               ifname = "wlan1";
    232               dependencies = [ mac80211 ];
    233             };
    234           };
    235       };
    236       };
    237   };
    238 }