WIP: example of using the Archer AX23 as extender #7
|
@ -47,6 +47,7 @@
|
||||||
../../modules/arch/mipsel.nix
|
../../modules/arch/mipsel.nix
|
||||||
../../modules/outputs/tftpboot.nix
|
../../modules/outputs/tftpboot.nix
|
||||||
../../modules/outputs/tplink-safeloader.nix
|
../../modules/outputs/tplink-safeloader.nix
|
||||||
|
../../modules/outputs/jffs2.nix
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
kernel = {
|
kernel = {
|
||||||
|
@ -337,6 +338,8 @@
|
||||||
# to 0x8800000. Let's put it at the 100MB mark at
|
# to 0x8800000. Let's put it at the 100MB mark at
|
||||||
# 0x8000000+0x0640000=0x86400000
|
# 0x8000000+0x0640000=0x86400000
|
||||||
loadAddress = lim.parseInt "0x86400000";
|
loadAddress = lim.parseInt "0x86400000";
|
||||||
|
compressRoot = true;
|
||||||
|
replaceDtb = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
filesystem =
|
filesystem =
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
{ config, pkgs, lib, ... } :
|
||||||
|
let
|
||||||
|
secrets = import ./ax23-secrets.nix;
|
||||||
|
inherit (pkgs) serviceFns;
|
||||||
|
svc = config.system.service;
|
||||||
|
wirelessConfig = {
|
||||||
|
country_code = "NL";
|
||||||
|
ssid = "FRITZ!Box 7581 TN";
|
||||||
|
wpa_passphrase = secrets.wpa_passphrase;
|
||||||
|
auth_algs = 1; # 1=wpa2, 2=wep, 3=both
|
||||||
|
wpa = 2; # 1=wpa, 2=wpa2, 3=both
|
||||||
|
wpa_key_mgmt = "WPA-PSK";
|
||||||
|
wpa_pairwise = "TKIP CCMP"; # auth for wpa (may not need this?)
|
||||||
|
rsn_pairwise = "CCMP"; # auth for wpa2
|
||||||
|
wmm_enabled = 1;
|
||||||
|
bridge = "int";
|
||||||
|
};
|
||||||
|
|
||||||
|
in rec {
|
||||||
|
imports = [
|
||||||
|
../modules/wlan.nix
|
||||||
|
../modules/network
|
||||||
|
../modules/dhcp6c
|
||||||
|
../modules/ssh
|
||||||
|
../modules/bridge
|
||||||
|
../modules/hostapd
|
||||||
|
../modules/outputs/kexecboot.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
hostname = "yardbird";
|
||||||
|
|
||||||
|
boot.tftp = {
|
||||||
|
serverip = "192.168.0.1";
|
||||||
|
ipaddr = "192.168.0.2";
|
||||||
|
};
|
||||||
|
|
||||||
|
services.hostap = svc.hostapd.build {
|
||||||
|
interface = config.hardware.networkInterfaces.wlan;
|
||||||
|
params = {
|
||||||
|
# b/g/n/ax
|
||||||
|
hw_mode = "g";
|
||||||
|
channel = "2";
|
||||||
|
ieee80211n = 1;
|
||||||
|
driver="nl80211";
|
||||||
|
supported_rates="60 90 120 180 240 360 480 540";
|
||||||
|
basic_rates="60 120 240";
|
||||||
|
beacon_int="100";
|
||||||
|
ht_coex="0";
|
||||||
|
ht_capab="[LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][MAX-AMSDU-7935]";
|
||||||
|
ap_isolate="1";
|
||||||
|
bss_load_update_period="60";
|
||||||
|
chan_util_avg_period="600";
|
||||||
|
disassoc_low_ack="1";
|
||||||
|
skip_inactivity_poll="0";
|
||||||
|
preamble="1";
|
||||||
|
wmm_enabled="1";
|
||||||
|
ignore_broadcast_ssid="0";
|
||||||
|
uapsd_advertisement_enabled="1";
|
||||||
|
utf8_ssid="1";
|
||||||
|
multi_ap="0";
|
||||||
|
auth_algs="1";
|
||||||
|
wpa="0";
|
||||||
|
wds_bridge="";
|
||||||
|
bssid="5c:e9:31:63:90:48";
|
||||||
|
} // wirelessConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.hostap5 = svc.hostapd.build {
|
||||||
|
interface = config.hardware.networkInterfaces.wlan5;
|
||||||
|
params = rec {
|
||||||
|
# a/n/ac/ax
|
||||||
|
hw_mode = "a";
|
||||||
|
channel = 36;
|
||||||
|
#ht_capab = "[HT40+]";
|
||||||
|
vht_oper_chwidth = 1;
|
||||||
|
vht_oper_centr_freq_seg0_idx = channel + 6;
|
||||||
|
ieee80211ac = 1;
|
||||||
|
driver="nl80211";
|
||||||
|
country_code="NL";
|
||||||
|
ieee80211d="1";
|
||||||
|
ieee80211h="1";
|
||||||
|
beacon_int="100";
|
||||||
|
chanlist="36";
|
||||||
|
|
||||||
|
tx_queue_data2_burst="2.0";
|
||||||
|
|
||||||
|
#num_global_macaddr=1;
|
||||||
|
ieee80211n="1";
|
||||||
|
ht_coex="0";
|
||||||
|
ht_capab="[HT40+][LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][MAX-AMSDU-7935]";
|
||||||
|
#ieee80211ac="1";
|
||||||
|
#vht_oper_chwidth="1";
|
||||||
|
#vht_oper_centr_freq_seg0_idx="42";
|
||||||
|
vht_capab="[RXLDPC][SHORT-GI-80][TX-STBC-2BY1][SU-BEAMFORMER][SU-BEAMFORMEE][MU-BEAMFORMER][MU-BEAMFORMEE][RX-ANTENNA-PATTERN][TX-ANTENNA-PATTERN][RX-STBC-1][SOUNDING-DIMENSION-2][BF-ANTENNA-2][MAX-MPDU-7991][MAX-A-MPDU-LEN-EXP7]";
|
||||||
|
|
||||||
|
ap_isolate="1";
|
||||||
|
bss_load_update_period="60";
|
||||||
|
chan_util_avg_period="600";
|
||||||
|
disassoc_low_ack="1";
|
||||||
|
skip_inactivity_poll="0";
|
||||||
|
preamble="1";
|
||||||
|
wmm_enabled="1";
|
||||||
|
ignore_broadcast_ssid="0";
|
||||||
|
uapsd_advertisement_enabled="1";
|
||||||
|
utf8_ssid="1";
|
||||||
|
multi_ap="0";
|
||||||
|
eapol_version="1";
|
||||||
|
auth_algs="1";
|
||||||
|
wpa="1";
|
||||||
|
wpa_pairwise="CCMP TKIP";
|
||||||
|
wds_bridge="";
|
||||||
|
wpa_disable_eapol_key_retries="0";
|
||||||
|
wpa_key_mgmt="WPA-PSK";
|
||||||
|
bssid="5c:e9:31:63:90:47";
|
||||||
|
#default_macaddr
|
||||||
|
} // wirelessConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.int = svc.network.address.build {
|
||||||
|
interface = svc.bridge.primary.build { ifname = "int"; };
|
||||||
|
family = "inet"; address = "10.8.0.1"; prefixLength = 16;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.bridge = svc.bridge.members.build {
|
||||||
|
primary = services.int;
|
||||||
|
members = with config.hardware.networkInterfaces;
|
||||||
|
[ wlan
|
||||||
|
wlan5
|
||||||
|
lan1
|
||||||
|
lan2
|
||||||
|
lan3
|
||||||
|
lan4
|
||||||
|
wan
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.dhcpc = svc.network.dhcp.client.build {
|
||||||
|
interface = services.int;
|
||||||
|
|
||||||
|
# don't start DHCP until the hostname is configured,
|
||||||
|
# so it can identify itself to the DHCP server
|
||||||
|
dependencies = [ config.services.hostname ];
|
||||||
|
};
|
||||||
|
services.dhcp6c = svc.dhcp6c.client.build {
|
||||||
|
interface = services.int;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.sshd = svc.ssh.build { };
|
||||||
|
|
||||||
|
users.root = secrets.root;
|
||||||
|
|
||||||
|
defaultProfile.packages = with pkgs; [
|
||||||
|
tcpdump
|
||||||
|
# for arp
|
||||||
|
nettools
|
||||||
|
# for kexec booting
|
||||||
|
gnutar
|
||||||
|
];
|
||||||
|
}
|
|
@ -22,6 +22,16 @@ in {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
|
replaceDtb = mkOption {
|
||||||
|
description = ''
|
||||||
|
Replace DTB instead of overriding it.
|
||||||
|
|
||||||
|
Useful for older versions of uboot that don't support
|
||||||
|
overriding the DTB from the bootm/bootz command line.
|
||||||
|
'';
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
options.system.outputs = {
|
options.system.outputs = {
|
||||||
tftpboot = mkOption {
|
tftpboot = mkOption {
|
||||||
|
@ -63,8 +73,13 @@ in {
|
||||||
zimage = "bootz";
|
zimage = "bootz";
|
||||||
}; in choices.${cfg.kernelFormat};
|
}; in choices.${cfg.kernelFormat};
|
||||||
cmdline = concatStringsSep " " config.boot.commandLine;
|
cmdline = concatStringsSep " " config.boot.commandLine;
|
||||||
|
objcopy = "${pkgs.stdenv.cc.bintools.targetPrefix}objcopy";
|
||||||
|
stripAndZip = ''
|
||||||
|
${objcopy} -O binary -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id -S vmlinux.elf vmlinux.bin
|
||||||
|
rm -f vmlinux.bin.lzma ; lzma -k -z vmlinux.bin
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
pkgs.runCommand "tftpboot" { nativeBuildInputs = with pkgs.pkgsBuildBuild; [ lzma dtc ]; } ''
|
pkgs.runCommand "tftpboot" { nativeBuildInputs = with pkgs.pkgsBuildBuild; [ lzma dtc pkgs.stdenv.cc ubootTools ]; } ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
cd $out
|
cd $out
|
||||||
binsize() { local s=$(stat -L -c %s $1); echo $(($s + 0x1000 &(~0xfff))); }
|
binsize() { local s=$(stat -L -c %s $1); echo $(($s + 0x1000 &(~0xfff))); }
|
||||||
|
@ -77,12 +92,19 @@ in {
|
||||||
imageSize=$(binsize ${image})
|
imageSize=$(binsize ${image})
|
||||||
|
|
||||||
ln -s ${o.manifest} manifest
|
ln -s ${o.manifest} manifest
|
||||||
ln -s ${image} image
|
|
||||||
ln -s ${o.kernel} vmlinux # handy for gdb
|
ln -s ${o.kernel} vmlinux # handy for gdb
|
||||||
|
|
||||||
|
${if cfg.compressRoot && cfg.replaceDtb
|
||||||
|
then ''
|
||||||
|
echo "Having both compressRoot and replaceDtb enabled is not currently supported"
|
||||||
|
exit 1
|
||||||
|
'' else ""
|
||||||
|
}
|
||||||
|
|
||||||
${if cfg.compressRoot
|
${if cfg.compressRoot
|
||||||
then ''
|
then ''
|
||||||
lzma -z9cv ${o.rootfs} > rootfs.lz
|
lzma -z9cv ${o.rootfs} > rootfs.lz
|
||||||
|
# TODO this is no longer correct
|
||||||
rootfsLzStart=$(($imageStart + $imageSize))
|
rootfsLzStart=$(($imageStart + $imageSize))
|
||||||
rootfsLzSize=$(binsize rootfs.lz)
|
rootfsLzSize=$(binsize rootfs.lz)
|
||||||
''
|
''
|
||||||
|
@ -107,6 +129,13 @@ in {
|
||||||
cmd="liminix ${cmdline} mtdparts=phram0:''${rootfsSize}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsSize},${toString config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0";
|
cmd="liminix ${cmdline} mtdparts=phram0:''${rootfsSize}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsSize},${toString config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0";
|
||||||
fdtput -t s dtb /chosen bootargs "$cmd"
|
fdtput -t s dtb /chosen bootargs "$cmd"
|
||||||
|
|
||||||
|
# re-package image with updated dtb
|
||||||
|
cp ${o.kernel} vmlinux.elf; chmod +w vmlinux.elf
|
||||||
|
${objcopy} --update-section .appended_dtb=dtb vmlinux.elf
|
||||||
|
${stripAndZip}
|
||||||
|
# TODO don't hardcode mips, entryPoint, loadAddress, name
|
||||||
|
mkimage -A mips -O linux -T kernel -C lzma -a 0x80001000 -e 0x80001000 -n 'MIPS Liminix Linux' -d vmlinux.bin.lzma image
|
||||||
|
|
||||||
# dtc -I dtb -O dts -o /dev/stdout dtb | grep -A10 chosen ; exit 1
|
# dtc -I dtb -O dts -o /dev/stdout dtb | grep -A10 chosen ; exit 1
|
||||||
|
|
||||||
cat > boot.scr << EOF
|
cat > boot.scr << EOF
|
||||||
|
|
Loading…
Reference in New Issue