There is nothing in this commit except for the changes made by nix-shell -p nixfmt-rfc-style --run "nixfmt ." If this has mucked up your open branches then sorry about that. You can probably nixfmt them to match before merging
185 lines
5.0 KiB
Nix
185 lines
5.0 KiB
Nix
# GL.iNet GL-MT300A
|
|
|
|
{
|
|
system = {
|
|
crossSystem = {
|
|
config = "mipsel-unknown-linux-musl";
|
|
gcc = {
|
|
abi = "32";
|
|
arch = "mips32"; # maybe mips_24kc-
|
|
};
|
|
};
|
|
};
|
|
|
|
description = ''
|
|
GL.iNet GL-MT300A
|
|
*****************
|
|
|
|
The GL-MT300A is based on a MT7620 chipset.
|
|
|
|
For flashing from U-Boot, the firmware partition is from
|
|
0xbc050000 to 0xbcfd0000.
|
|
|
|
WiFi on this device is provided by the rt2800soc module. It
|
|
expects firmware to be present in the "factory" MTD partition, so
|
|
- assuming we want to use the wireless - we need to build MTD
|
|
support into the kernel even if we're using TFTP root.
|
|
|
|
Installation
|
|
============
|
|
|
|
The stock vendor firmware is a fork of OpenWrt, meaning that the
|
|
binary created by :ref:`system-outputs-mtdimage` can be flashed
|
|
using the vendor web UI or the U-Boot emergency "unbrick" routine.
|
|
|
|
Flashing over an existing Liminix system is not possible while
|
|
that system is running, otherwise you'll be overwriting flash
|
|
partitions while they're in use - and that might not end well.
|
|
Configure the system with :ref:`levitate` if you need to
|
|
make it upgradable.
|
|
|
|
Vendor web page: https://www.gl-inet.com/products/gl-mt300a/
|
|
|
|
OpenWrt web page: https://openwrt.org/toh/gl.inet/gl-mt300a
|
|
|
|
'';
|
|
|
|
module =
|
|
{
|
|
pkgs,
|
|
config,
|
|
lib,
|
|
lim,
|
|
...
|
|
}:
|
|
let
|
|
inherit (pkgs) openwrt;
|
|
mac80211 = pkgs.kmodloader.override {
|
|
targets = [ "rt2800soc" ];
|
|
inherit (config.system.outputs) kernel;
|
|
};
|
|
in
|
|
{
|
|
imports = [
|
|
../../modules/arch/mipsel.nix
|
|
../../modules/outputs/tftpboot.nix
|
|
../../modules/outputs/mtdimage.nix
|
|
../../modules/outputs/jffs2.nix
|
|
];
|
|
hardware = {
|
|
defaultOutput = "mtdimage";
|
|
loadAddress = lim.parseInt "0x80000000";
|
|
entryPoint = lim.parseInt "0x80000000";
|
|
|
|
# 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 = lim.parseInt "0xbc050000";
|
|
size = lim.parseInt "0xf80000";
|
|
eraseBlockSize = 65536;
|
|
};
|
|
rootDevice = "/dev/mtdblock5";
|
|
|
|
dts = {
|
|
src = "${openwrt.src}/target/linux/ramips/dts/mt7620a_glinet_gl-mt300a.dts";
|
|
includePaths = [
|
|
"${openwrt.src}/target/linux/ramips/dts"
|
|
];
|
|
};
|
|
networkInterfaces =
|
|
let
|
|
inherit (config.system.service.network) link;
|
|
inherit (config.system.service) vlan;
|
|
in
|
|
rec {
|
|
eth = link.build { ifname = "eth0"; };
|
|
# 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 ];
|
|
};
|
|
};
|
|
};
|
|
boot.tftp = {
|
|
loadAddress = lim.parseInt "0x00A00000";
|
|
appendDTB = true;
|
|
};
|
|
|
|
kernel = {
|
|
extraPatchPhase = ''
|
|
${openwrt.applyPatches.ramips}
|
|
${openwrt.applyPatches.rt2x00}
|
|
'';
|
|
config =
|
|
{
|
|
|
|
RALINK = "y";
|
|
PCI = "y";
|
|
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";
|
|
|
|
NET = "y";
|
|
ETHERNET = "y";
|
|
NET_VENDOR_RALINK = "y";
|
|
NET_RALINK_MDIO = "y";
|
|
NET_RALINK_MDIO_MT7620 = "y";
|
|
NET_RALINK_MT7620 = "y";
|
|
SWPHY = "y";
|
|
|
|
SPI = "y";
|
|
MTD_SPI_NOR = "y";
|
|
SPI_MT7621 = "y"; # } probably don't need both of these
|
|
SPI_RT2880 = "y"; # }
|
|
SPI_MASTER = "y";
|
|
SPI_MEM = "y";
|
|
|
|
MTD = "y";
|
|
MTD_BLOCK = "y"; # fix undefined ref to register_mtd_blktrans_devs
|
|
|
|
EARLY_PRINTK = "y";
|
|
|
|
NEW_LEDS = "y";
|
|
LEDS_CLASS = "y"; # required by rt2x00lib
|
|
|
|
PRINTK_TIME = "y";
|
|
}
|
|
// lib.optionalAttrs (config.system.service ? vlan) {
|
|
SWCONFIG = "y";
|
|
};
|
|
conditionalConfig = {
|
|
WLAN = {
|
|
WLAN_VENDOR_RALINK = "y";
|
|
RT2800SOC = "m";
|
|
RT2X00 = "m";
|
|
};
|
|
};
|
|
|
|
};
|
|
};
|
|
}
|