default.nix (4424B)
1 # GL.INet GL-MT300A 2 3 { 4 system = { 5 crossSystem = { 6 config = "mipsel-unknown-linux-musl"; 7 gcc = { 8 abi = "32"; 9 arch = "mips32"; # maybe mips_24kc- 10 }; 11 }; 12 }; 13 14 description = '' 15 WiFi on this device is provided by the rt2800soc module. It 16 expects firmware to be present in the "factory" MTD partition, so 17 - assuming we want to use the wireless - we need to build MTD 18 support into the kernel even if we're using TFTP root 19 ''; 20 21 module = { pkgs, config, ...}: 22 let 23 inherit (pkgs.liminix.networking) interface; 24 inherit (pkgs) openwrt; 25 mac80211 = pkgs.mac80211.override { 26 drivers = ["rt2800soc"]; 27 klibBuild = config.system.outputs.kernel.modulesupport; 28 }; 29 in { 30 hardware = { 31 defaultOutput = "tftpboot"; 32 loadAddress = "0x80000000"; 33 entryPoint = "0x80000000"; 34 35 # Creating 5 MTD partitions on "spi0.0": 36 # 0x000000000000-0x000000030000 : "u-boot" 37 # 0x000000030000-0x000000040000 : "u-boot-env" 38 # 0x000000040000-0x000000050000 : "factory" 39 # 0x000000050000-0x000000fd0000 : "firmware" 40 # 2 uimage-fw partitions found on MTD device firmware 41 # Creating 2 MTD partitions on "firmware": 42 # 0x000000000000-0x000000260000 : "kernel" 43 # 0x000000260000-0x000000f80000 : "rootfs" 44 45 flash = { 46 address = "0xbc050000"; 47 size ="0xf80000"; 48 eraseBlockSize = "65536"; 49 }; 50 rootDevice = "/dev/mtdblock5"; 51 52 dts = { 53 src = "${openwrt.src}/target/linux/ramips/dts/mt7620a_glinet_gl-mt300a.dts"; 54 includes = [ 55 "${openwrt.src}/target/linux/ramips/dts" 56 ]; 57 }; 58 networkInterfaces = rec { 59 # lan and wan ports are both behind a switch on eth0 60 eth = interface { device = "eth0"; }; 61 lan = interface { 62 type = "vlan"; 63 device = "eth0.1"; 64 link = "eth0"; 65 id = "1"; 66 dependencies = [eth]; 67 }; 68 wan = interface { 69 type = "vlan"; 70 device = "eth0.2"; 71 id = "2"; 72 link = "eth0"; 73 dependencies = [eth]; 74 }; 75 wlan = interface { 76 device = "wlan0"; 77 dependencies = [ mac80211 ]; 78 }; 79 }; 80 }; 81 boot.tftp = { 82 loadAddress = "0x00A00000"; 83 }; 84 85 kernel = { 86 src = pkgs.fetchurl { 87 name = "linux.tar.gz"; 88 url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.71.tar.gz"; 89 hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8="; 90 }; 91 extraPatchPhase = '' 92 ${openwrt.applyPatches.ramips} 93 ''; 94 config = { 95 MIPS_ELF_APPENDED_DTB = "y"; 96 OF = "y"; 97 USE_OF = "y"; 98 99 RALINK = "y"; 100 PCI = "y"; 101 SOC_MT7620 = "y"; 102 103 SERIAL_8250_CONSOLE = "y"; 104 SERIAL_8250 = "y"; 105 SERIAL_CORE_CONSOLE = "y"; 106 SERIAL_OF_PLATFORM = "y"; 107 108 CONSOLE_LOGLEVEL_DEFAULT = "8"; 109 CONSOLE_LOGLEVEL_QUIET = "4"; 110 111 NET = "y"; 112 NETDEVICES = "y"; 113 ETHERNET = "y"; 114 NET_VENDOR_RALINK = "y"; 115 NET_RALINK_MDIO = "y"; 116 NET_RALINK_MDIO_MT7620 = "y"; 117 NET_RALINK_MT7620 = "y"; 118 119 SPI = "y"; 120 MTD_SPI_NOR = "y"; 121 SPI_MT7621 = "y"; # } probably don't need both of these 122 SPI_RT2880 = "y"; # } 123 SPI_MASTER= "y"; 124 SPI_MEM= "y"; 125 126 # both the ethernet ports on this device (lan and wan) 127 # are behind a switch, so we need VLANs to do anything 128 # useful with them 129 130 VLAN_8021Q = "y"; 131 SWCONFIG = "y"; 132 SWPHY = "y"; 133 134 BRIDGE = "y"; 135 BRIDGE_VLAN_FILTERING = "y"; 136 BRIDGE_IGMP_SNOOPING = "y"; 137 138 MTD = "y"; 139 MTD_CMDLINE_PARTS = "y"; 140 MTD_BLOCK = "y"; # fix undefined ref to register_mtd_blktrans_devs 141 142 CPU_LITTLE_ENDIAN = "y"; 143 144 CMDLINE_PARTITION = "y"; 145 EARLY_PRINTK = "y"; 146 147 NEW_LEDS = "y"; 148 LEDS_CLASS = "y"; # required by rt2x00lib 149 150 PARTITION_ADVANCED = "y"; 151 PRINTK_TIME = "y"; 152 SQUASHFS = "y"; 153 SQUASHFS_XZ = "y"; 154 }; 155 }; 156 }; 157 }