2023-11-12 17:55:15 +01:00
|
|
|
{
|
2023-02-07 00:19:53 +01:00
|
|
|
system = {
|
|
|
|
crossSystem = {
|
|
|
|
config = "mipsel-unknown-linux-musl";
|
|
|
|
gcc = {
|
|
|
|
abi = "32";
|
|
|
|
arch = "mips32"; # maybe mips_24kc-
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-09-28 13:17:30 +02:00
|
|
|
description = ''
|
2023-09-29 00:19:32 +02:00
|
|
|
GL.iNet GL-MT300N-v2
|
2023-09-28 13:17:30 +02:00
|
|
|
********************
|
|
|
|
|
2023-11-12 18:15:58 +01:00
|
|
|
The GL-MT300N-v2 "Mango" is is very similar to the :ref:`MT300A <GL.iNet GL-MT300A>, but is
|
|
|
|
based on the MT7628 chipset instead of MT7620. It's also marginally cheaper
|
|
|
|
and comes in a yellow case not a blue one. Be sure your device is
|
|
|
|
v2 not v1, which is a different animal and has only half as much RAM.
|
|
|
|
|
|
|
|
Installation
|
|
|
|
============
|
|
|
|
|
|
|
|
The stock vendor firmware is a fork of OpenWrt, meaning that the
|
2023-12-11 20:02:30 +01:00
|
|
|
binary created by :ref:`system-outputs-mtdimage` can be flashed
|
2023-11-12 18:15:58 +01:00
|
|
|
using the vendor web UI or the U-Boot emergency "unbrick" routine.
|
|
|
|
|
|
|
|
For flashing from an existing Liminix system (we think) it
|
|
|
|
is necessary to first boot into a :ref:`system-outputs-kexecboot`
|
|
|
|
system, otherwise you'll be overwriting flash partitions while
|
|
|
|
they're in use - and that might not end well.
|
2023-09-29 00:19:32 +02:00
|
|
|
|
|
|
|
Vendor web page: https://www.gl-inet.com/products/gl-mt300n-v2/
|
|
|
|
|
|
|
|
OpenWrt web page: https://openwrt.org/toh/gl.inet/gl-mt300n_v2
|
|
|
|
|
2023-09-28 13:17:30 +02:00
|
|
|
'';
|
|
|
|
|
2023-11-12 19:37:33 +01:00
|
|
|
module = { pkgs, config, lib, lim, ...}:
|
2023-02-07 00:19:53 +01:00
|
|
|
let
|
2023-03-09 20:30:57 +01:00
|
|
|
inherit (pkgs.liminix.networking) interface;
|
|
|
|
inherit (pkgs.liminix.services) oneshot;
|
2023-03-10 01:48:47 +01:00
|
|
|
inherit (pkgs.pseudofile) dir symlink;
|
2023-03-18 20:17:58 +01:00
|
|
|
inherit (pkgs) openwrt;
|
2023-03-10 01:48:47 +01:00
|
|
|
|
2023-03-09 20:30:57 +01:00
|
|
|
mac80211 = pkgs.mac80211.override {
|
|
|
|
drivers = ["mt7603e"];
|
2023-07-13 20:24:59 +02:00
|
|
|
klibBuild = config.system.outputs.kernel.modulesupport;
|
2023-03-09 20:30:57 +01:00
|
|
|
};
|
2023-03-10 19:51:07 +01:00
|
|
|
wlan_firmware = pkgs.fetchurl {
|
2023-03-10 01:48:47 +01:00
|
|
|
url = "https://github.com/openwrt/mt76/raw/f24b56f935392ca1d35fae5fd6e56ef9deda4aad/firmware/mt7628_e2.bin";
|
2023-03-10 19:51:07 +01:00
|
|
|
hash = "sha256:1dkhfznmdz6s50kwc841x3wj0h6zg6icg5g2bim9pvg66as2vmh9";
|
2023-03-10 01:48:47 +01:00
|
|
|
};
|
2023-02-07 00:19:53 +01:00
|
|
|
in {
|
2023-12-10 17:38:53 +01:00
|
|
|
imports = [
|
|
|
|
../../modules/arch/mipsel.nix
|
|
|
|
../../modules/outputs/tftpboot.nix
|
2023-12-11 20:02:30 +01:00
|
|
|
../../modules/outputs/mtdimage.nix
|
2023-12-10 17:38:53 +01:00
|
|
|
../../modules/outputs/jffs2.nix
|
|
|
|
];
|
2023-03-10 01:48:47 +01:00
|
|
|
filesystem = dir {
|
|
|
|
lib = dir {
|
|
|
|
firmware = dir {
|
|
|
|
"mt7628_e2.bin" = symlink wlan_firmware;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-03-03 23:52:33 +01:00
|
|
|
hardware = {
|
2023-12-11 20:02:30 +01:00
|
|
|
defaultOutput = "mtdimage";
|
2023-11-12 19:47:31 +01:00
|
|
|
loadAddress = lim.parseInt "0x80000000";
|
2023-11-12 19:50:47 +01:00
|
|
|
entryPoint = lim.parseInt "0x80000000";
|
2023-03-11 00:24:05 +01:00
|
|
|
|
|
|
|
flash = {
|
2023-11-12 21:39:06 +01:00
|
|
|
address = lim.parseInt "0xbc050000";
|
|
|
|
size = lim.parseInt "0xfb0000";
|
|
|
|
eraseBlockSize = 65536;
|
2023-03-11 00:24:05 +01:00
|
|
|
};
|
2023-04-26 23:16:15 +02:00
|
|
|
rootDevice = "/dev/mtdblock5";
|
2023-03-11 00:24:05 +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/mt7628an_glinet_gl-mt300n-v2.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 00:26:44 +02:00
|
|
|
networkInterfaces =
|
|
|
|
let
|
|
|
|
inherit (config.system.service.network) link;
|
|
|
|
inherit (config.system.service) vlan;
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
down = "swconfig dev switch0 set reset";
|
|
|
|
};
|
|
|
|
in rec {
|
|
|
|
eth = link.build { ifname = "eth0"; dependencies = [swconfig]; };
|
|
|
|
# lan and wan ports are both behind a switch on eth0
|
|
|
|
lan = vlan.build {
|
|
|
|
ifname = "eth0.1";
|
|
|
|
primary = eth;
|
|
|
|
vid = "1";
|
|
|
|
};
|
|
|
|
wan = vlan.build {
|
|
|
|
ifname = "eth0.2";
|
|
|
|
primary = eth;
|
|
|
|
vid = "2";
|
|
|
|
};
|
|
|
|
wlan = link.build {
|
|
|
|
ifname = "wlan0";
|
|
|
|
dependencies = [ mac80211 ];
|
2023-03-09 20:30:57 +01:00
|
|
|
};
|
|
|
|
};
|
2023-02-10 18:54:33 +01:00
|
|
|
};
|
2023-02-11 14:28:25 +01:00
|
|
|
boot.tftp = {
|
2023-03-10 01:48:47 +01:00
|
|
|
# 20MB seems to give enough room to uncompress the kernel
|
|
|
|
# without anything getting trodden on. 10MB was too small
|
2023-11-12 19:37:33 +01:00
|
|
|
loadAddress = lim.parseInt "0x1400000";
|
2023-02-11 14:28:25 +01:00
|
|
|
};
|
2023-03-03 23:52:33 +01:00
|
|
|
|
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 = {
|
|
|
|
|
|
|
|
RALINK = "y";
|
2023-02-22 20:17:47 +01:00
|
|
|
PCI = "y";
|
2023-02-10 18:54:33 +01:00
|
|
|
SOC_MT7620 = "y";
|
|
|
|
|
|
|
|
SERIAL_8250_CONSOLE = "y";
|
|
|
|
SERIAL_8250 = "y";
|
|
|
|
SERIAL_CORE_CONSOLE = "y";
|
|
|
|
SERIAL_OF_PLATFORM = "y";
|
|
|
|
|
|
|
|
CONSOLE_LOGLEVEL_DEFAULT = "8";
|
|
|
|
CONSOLE_LOGLEVEL_QUIET = "4";
|
|
|
|
|
|
|
|
MTD = "y";
|
|
|
|
MTD_BLOCK = "y"; # fix undefined ref to register_mtd_blktrans_dev
|
|
|
|
|
2023-03-11 00:24:05 +01:00
|
|
|
SPI = "y";
|
|
|
|
MTD_SPI_NOR = "y";
|
|
|
|
SPI_MT7621 = "y";
|
|
|
|
SPI_MASTER= "y";
|
|
|
|
SPI_MEM= "y";
|
|
|
|
|
2023-02-10 18:54:33 +01:00
|
|
|
REGULATOR = "y";
|
|
|
|
REGULATOR_FIXED_VOLTAGE = "y";
|
|
|
|
|
|
|
|
NET = "y";
|
|
|
|
ETHERNET = "y";
|
|
|
|
|
|
|
|
PHYLIB = "y";
|
|
|
|
AT803X_PHY="y";
|
|
|
|
FIXED_PHY="y";
|
|
|
|
GENERIC_PHY="y";
|
|
|
|
NET_VENDOR_RALINK = "y";
|
|
|
|
NET_RALINK_RT3050 = "y";
|
|
|
|
NET_RALINK_SOC="y";
|
2023-02-22 20:17:47 +01:00
|
|
|
SWPHY = "y";
|
2023-02-10 18:54:33 +01:00
|
|
|
|
|
|
|
GPIOLIB="y";
|
|
|
|
GPIO_MT7621 = "y";
|
|
|
|
|
2023-03-10 19:42:32 +01:00
|
|
|
PHY_RALINK_USB = "y";
|
|
|
|
|
2023-02-22 19:28:48 +01:00
|
|
|
EARLY_PRINTK = "y";
|
2023-02-10 18:54:33 +01:00
|
|
|
|
2023-02-22 19:28:48 +01:00
|
|
|
PRINTK_TIME = "y";
|
2023-09-01 00:50:07 +02:00
|
|
|
} // lib.optionalAttrs (config.system.service ? vlan) {
|
|
|
|
SWCONFIG = "y";
|
2023-09-02 18:28:40 +02:00
|
|
|
} // lib.optionalAttrs (config.system.service ? watchdog) {
|
|
|
|
RALINK_WDT = "y"; # watchdog
|
|
|
|
MT7621_WDT = "y"; # or it might be this one
|
2023-02-10 18:54:33 +01:00
|
|
|
};
|
2023-02-07 00:19:53 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|