2023-02-07 00:19:53 +01:00
|
|
|
# GL.INet GL-MT300A
|
|
|
|
|
|
|
|
{
|
|
|
|
system = {
|
|
|
|
crossSystem = {
|
|
|
|
config = "mipsel-unknown-linux-musl";
|
|
|
|
gcc = {
|
|
|
|
abi = "32";
|
|
|
|
arch = "mips32"; # maybe mips_24kc-
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-03-07 20:11:12 +01:00
|
|
|
description = ''
|
|
|
|
WiFi on this device is provided by the rt2800soc module. It
|
2023-03-07 22:32:21 +01:00
|
|
|
expects firmware to be present in the "factory" MTD partition, so
|
|
|
|
- assuming we want to use the wireless - we need to build MTD
|
2023-03-07 20:11:12 +01:00
|
|
|
support into the kernel even if we're using TFTP root
|
|
|
|
'';
|
|
|
|
|
2023-09-01 00:50:07 +02:00
|
|
|
module = { pkgs, config, lib, ...}:
|
2023-02-07 00:19:53 +01:00
|
|
|
let
|
2023-03-07 20:10:12 +01:00
|
|
|
inherit (pkgs.liminix.networking) interface;
|
2023-03-18 20:17:58 +01:00
|
|
|
inherit (pkgs) openwrt;
|
2023-03-07 20:11:12 +01:00
|
|
|
mac80211 = pkgs.mac80211.override {
|
|
|
|
drivers = ["rt2800soc"];
|
2023-07-13 20:24:59 +02:00
|
|
|
klibBuild = config.system.outputs.kernel.modulesupport;
|
2023-03-07 20:11:12 +01:00
|
|
|
};
|
|
|
|
in {
|
2023-03-03 23:52:33 +01:00
|
|
|
hardware = {
|
2023-03-17 13:22:20 +01:00
|
|
|
defaultOutput = "tftpboot";
|
2023-02-10 19:20:01 +01:00
|
|
|
loadAddress = "0x80000000";
|
|
|
|
entryPoint = "0x80000000";
|
2023-03-08 21:35:41 +01:00
|
|
|
|
|
|
|
# Creating 5 MTD partitions on "spi0.0":
|
|
|
|
# 0x000000000000-0x000000030000 : "u-boot"
|
|
|
|
# 0x000000030000-0x000000040000 : "u-boot-env"
|
|
|
|
# 0x000000040000-0x000000050000 : "factory"
|
|
|
|
# 0x000000050000-0x000000fd0000 : "firmware"
|
|
|
|
# 2 uimage-fw partitions found on MTD device firmware
|
|
|
|
# Creating 2 MTD partitions on "firmware":
|
|
|
|
# 0x000000000000-0x000000260000 : "kernel"
|
|
|
|
# 0x000000260000-0x000000f80000 : "rootfs"
|
|
|
|
|
|
|
|
flash = {
|
|
|
|
address = "0xbc050000";
|
|
|
|
size ="0xf80000";
|
2023-04-23 19:23:05 +02:00
|
|
|
eraseBlockSize = "65536";
|
2023-03-08 21:35:41 +01:00
|
|
|
};
|
2023-04-26 23:16:15 +02:00
|
|
|
rootDevice = "/dev/mtdblock5";
|
2023-03-08 21:35:41 +01:00
|
|
|
|
2023-03-03 23:52:33 +01:00
|
|
|
dts = {
|
2023-03-18 20:17:58 +01:00
|
|
|
src = "${openwrt.src}/target/linux/ramips/dts/mt7620a_glinet_gl-mt300a.dts";
|
2023-03-03 23:52:33 +01:00
|
|
|
includes = [
|
2023-03-18 20:17:58 +01:00
|
|
|
"${openwrt.src}/target/linux/ramips/dts"
|
2023-03-03 23:52:33 +01:00
|
|
|
];
|
|
|
|
};
|
2023-08-31 19:27:07 +02:00
|
|
|
networkInterfaces =
|
|
|
|
let
|
|
|
|
inherit (config.system.service.network) link;
|
|
|
|
inherit (config.system.service) vlan;
|
|
|
|
inherit (pkgs.liminix.services) oneshot;
|
|
|
|
swconfig = oneshot {
|
|
|
|
name = "swconfig";
|
|
|
|
up = ''
|
|
|
|
PATH=${pkgs.swconfig}/bin:$PATH
|
|
|
|
swconfig dev switch0 set reset
|
|
|
|
swconfig dev switch0 set enable_vlan 1
|
|
|
|
swconfig dev switch0 vlan 1 set ports '1 2 3 4 6t'
|
|
|
|
swconfig dev switch0 vlan 2 set ports '0 6t'
|
|
|
|
swconfig dev switch0 set apply
|
|
|
|
'';
|
2023-09-15 21:42:36 +02:00
|
|
|
down = "${pkgs.swconfig}/bin/swconfig dev switch0 set reset";
|
2023-08-31 19:27:07 +02:00
|
|
|
};
|
|
|
|
in rec {
|
2023-09-15 21:42:36 +02:00
|
|
|
eth = link.build { ifname = "eth0"; };
|
2023-08-31 19:27:07 +02:00
|
|
|
# lan and wan ports are both behind a switch on eth0
|
|
|
|
lan = vlan.build {
|
|
|
|
ifname = "eth0.1";
|
|
|
|
primary = eth;
|
|
|
|
vid = "1";
|
2023-09-15 21:42:36 +02:00
|
|
|
dependencies = [swconfig eth];
|
2023-08-31 19:27:07 +02:00
|
|
|
};
|
|
|
|
wan = vlan.build {
|
|
|
|
ifname = "eth0.2";
|
|
|
|
primary = eth;
|
|
|
|
vid = "2";
|
2023-09-15 21:42:36 +02:00
|
|
|
dependencies = [swconfig eth];
|
2023-08-31 19:27:07 +02:00
|
|
|
};
|
|
|
|
wlan = link.build {
|
|
|
|
ifname = "wlan0";
|
|
|
|
dependencies = [ mac80211 ];
|
|
|
|
};
|
2023-03-07 20:10:12 +01:00
|
|
|
};
|
2023-02-10 18:54:33 +01:00
|
|
|
};
|
2023-02-11 14:28:25 +01:00
|
|
|
boot.tftp = {
|
|
|
|
loadAddress = "0x00A00000";
|
|
|
|
};
|
2023-02-10 18:54:33 +01:00
|
|
|
|
|
|
|
kernel = {
|
|
|
|
src = pkgs.fetchurl {
|
2023-02-07 00:19:53 +01:00
|
|
|
name = "linux.tar.gz";
|
|
|
|
url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.71.tar.gz";
|
|
|
|
hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
|
|
|
|
};
|
|
|
|
extraPatchPhase = ''
|
2023-03-18 20:17:58 +01:00
|
|
|
${openwrt.applyPatches.ramips}
|
2023-02-07 00:19:53 +01:00
|
|
|
'';
|
2023-02-10 18:54:33 +01:00
|
|
|
config = {
|
|
|
|
MIPS_ELF_APPENDED_DTB = "y";
|
|
|
|
OF = "y";
|
|
|
|
USE_OF = "y";
|
2023-02-07 00:19:53 +01:00
|
|
|
|
2023-02-10 18:54:33 +01:00
|
|
|
RALINK = "y";
|
2023-02-22 20:17:47 +01:00
|
|
|
PCI = "y";
|
2023-02-10 18:54:33 +01:00
|
|
|
SOC_MT7620 = "y";
|
2023-02-07 00:19:53 +01:00
|
|
|
|
2023-02-10 18:54:33 +01:00
|
|
|
SERIAL_8250_CONSOLE = "y";
|
|
|
|
SERIAL_8250 = "y";
|
|
|
|
SERIAL_CORE_CONSOLE = "y";
|
|
|
|
SERIAL_OF_PLATFORM = "y";
|
2023-02-07 00:19:53 +01:00
|
|
|
|
2023-02-10 18:54:33 +01:00
|
|
|
CONSOLE_LOGLEVEL_DEFAULT = "8";
|
|
|
|
CONSOLE_LOGLEVEL_QUIET = "4";
|
2023-02-07 00:19:53 +01:00
|
|
|
|
2023-02-10 18:54:33 +01:00
|
|
|
NET = "y";
|
|
|
|
NETDEVICES = "y";
|
|
|
|
ETHERNET = "y";
|
2023-03-07 23:49:33 +01:00
|
|
|
NET_VENDOR_RALINK = "y";
|
2023-02-22 20:17:47 +01:00
|
|
|
NET_RALINK_MDIO = "y";
|
|
|
|
NET_RALINK_MDIO_MT7620 = "y";
|
|
|
|
NET_RALINK_MT7620 = "y";
|
2023-08-31 00:26:44 +02:00
|
|
|
SWPHY = "y";
|
2023-02-22 20:17:47 +01:00
|
|
|
|
2023-03-07 20:11:12 +01:00
|
|
|
SPI = "y";
|
|
|
|
MTD_SPI_NOR = "y";
|
2023-03-07 23:49:33 +01:00
|
|
|
SPI_MT7621 = "y"; # } probably don't need both of these
|
2023-03-07 20:11:12 +01:00
|
|
|
SPI_RT2880 = "y"; # }
|
|
|
|
SPI_MASTER= "y";
|
|
|
|
SPI_MEM= "y";
|
|
|
|
|
2023-02-10 18:54:33 +01:00
|
|
|
MTD = "y";
|
|
|
|
MTD_CMDLINE_PARTS = "y";
|
|
|
|
MTD_BLOCK = "y"; # fix undefined ref to register_mtd_blktrans_devs
|
2023-02-07 00:19:53 +01:00
|
|
|
|
2023-02-22 19:28:48 +01:00
|
|
|
CPU_LITTLE_ENDIAN = "y";
|
2023-02-07 00:19:53 +01:00
|
|
|
|
2023-02-22 19:28:48 +01:00
|
|
|
CMDLINE_PARTITION = "y";
|
|
|
|
EARLY_PRINTK = "y";
|
2023-02-07 00:19:53 +01:00
|
|
|
|
2023-03-07 20:11:12 +01:00
|
|
|
NEW_LEDS = "y";
|
|
|
|
LEDS_CLASS = "y"; # required by rt2x00lib
|
|
|
|
|
2023-02-22 19:28:48 +01:00
|
|
|
PARTITION_ADVANCED = "y";
|
|
|
|
PRINTK_TIME = "y";
|
2023-09-01 00:50:07 +02:00
|
|
|
} // lib.optionalAttrs (config.system.service ? vlan) {
|
|
|
|
SWCONFIG = "y";
|
2023-02-10 18:54:33 +01:00
|
|
|
};
|
|
|
|
};
|
2023-02-07 00:19:53 +01:00
|
|
|
};
|
|
|
|
}
|