liminix

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

default.nix (6884B)


      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.71.tar.gz";
     61         hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
     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     };
    149     boot = {
    150       commandLine = [ "console=ttyS0,115200" ];
    151       tftp.loadAddress = lim.parseInt "0x4007ff28";
    152       imageFormat = "fit";
    153     };
    154     filesystem =
    155       let inherit (pkgs.pseudofile) dir symlink;
    156            in
    157              dir {
    158                lib = dir {
    159                  firmware = dir {
    160                    mediatek = symlink firmware;
    161                  };
    162                };
    163              };
    164 
    165     hardware =
    166       let
    167         openwrt = pkgs.openwrt;
    168         mac80211 =  pkgs.mac80211.override {
    169           drivers = [
    170             "mt7615e"
    171             "mt7915e"
    172           ];
    173           klibBuild = config.system.outputs.kernel.modulesupport;
    174         };
    175       in {
    176         ubi = {
    177           minIOSize = "2048";
    178           eraseBlockSize = "126976";
    179           maxLEBcount = "1024"; # guessing
    180         };
    181 
    182         defaultOutput = "ubimage";
    183         # the kernel expects this to be on a 2MB boundary. U-Boot
    184         # (I don't know why) has a default of 0x41080000, which isn't.
    185         # We put it at the 32MB mark so that tftpboot can put its rootfs
    186         # image and DTB underneath, but maybe this is a terrible waste of
    187         # RAM unless the kernel is able to reuse it later. Oh well
    188         loadAddress = lim.parseInt "0x42000000";
    189         entryPoint = lim.parseInt "0x42000000";
    190         rootDevice = "ubi0:liminix";
    191         dts = {
    192           src = "${openwrt.src}/target/linux/mediatek/dts/mt7622-linksys-e8450-ubi.dts";
    193           includes =  [
    194             "${openwrt.src}/target/linux/mediatek/dts"
    195             "${config.system.outputs.kernel.modulesupport}/arch/arm64/boot/dts/mediatek/"
    196           ];
    197         };
    198 
    199         # - 0x000000000000-0x000008000000 : "spi-nand0"
    200         #         - 0x000000000000-0x000000080000 : "bl2"
    201         #         - 0x000000080000-0x0000001c0000 : "fip"
    202         #         - 0x0000001c0000-0x0000002c0000 : "factory"
    203         #         - 0x0000002c0000-0x000000300000 : "reserved"
    204         #         - 0x000000300000-0x000008000000 : "ubi"
    205 
    206         networkInterfaces =
    207           let
    208             inherit (config.system.service.network) link;
    209             inherit (config.system.service) bridge;
    210           in rec {
    211             wan = link.build { ifname = "wan"; };
    212             lan1 = link.build { ifname = "lan1"; };
    213             lan2 = link.build { ifname = "lan2"; };
    214             lan3 = link.build { ifname = "lan3"; };
    215             lan4 = link.build { ifname = "lan4"; };
    216             lan = lan3;
    217 
    218             wlan = link.build {
    219               ifname = "wlan0";
    220               dependencies = [ mac80211 ];
    221             };
    222             wlan5 = link.build {
    223               ifname = "wlan1";
    224               dependencies = [ mac80211 ];
    225             };
    226           };
    227       };
    228       };
    229   };
    230 }