Compare commits
5 Commits
2cc06b7110
...
d20b79e06a
Author | SHA1 | Date |
---|---|---|
Arnout Engelen | d20b79e06a | |
Arnout Engelen | 1a85d09077 | |
Arnout Engelen | 4cf7472df8 | |
Arnout Engelen | 63e3f2aa58 | |
Arnout Engelen | 61494fdc0c |
1
ci.nix
1
ci.nix
|
@ -11,6 +11,7 @@ let
|
||||||
devices = [
|
devices = [
|
||||||
"gl-ar750" "gl-mt300n-v2" "gl-mt300a"
|
"gl-ar750" "gl-mt300n-v2" "gl-mt300a"
|
||||||
"qemu" "qemu-aarch64" "qemu-armv7l"
|
"qemu" "qemu-aarch64" "qemu-armv7l"
|
||||||
|
"tp-archer-ax23"
|
||||||
];
|
];
|
||||||
vanilla = ./vanilla-configuration.nix;
|
vanilla = ./vanilla-configuration.nix;
|
||||||
for-device = name:
|
for-device = name:
|
||||||
|
|
|
@ -46,7 +46,8 @@
|
||||||
imports = [
|
imports = [
|
||||||
../../modules/arch/mipsel.nix
|
../../modules/arch/mipsel.nix
|
||||||
../../modules/outputs/tftpboot.nix
|
../../modules/outputs/tftpboot.nix
|
||||||
../../modules/outputs/tplink.nix
|
../../modules/outputs/tplink-safeloader.nix
|
||||||
|
../../modules/outputs/jffs2.nix
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
kernel = {
|
kernel = {
|
||||||
|
@ -326,15 +327,10 @@
|
||||||
MT7621_WDT = "y"; # or it might be this one
|
MT7621_WDT = "y"; # or it might be this one
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
tplink.board = "ARCHER-AX23-V1";
|
tplink-safeloader.board = "ARCHER-AX23-V1";
|
||||||
boot = {
|
boot = {
|
||||||
commandLine = [ "console=ttyS0,115200" ];
|
commandLine = [ "console=ttyS0,115200" ];
|
||||||
tftp = {
|
tftp = {
|
||||||
# IP addresses to use in the boot monitor when flashing/ booting
|
|
||||||
# over TFTP. If you are flashing using the stock firmware's Web UI
|
|
||||||
# then these dummy values are fine
|
|
||||||
ipaddr = "192.168.0.1"; # router address
|
|
||||||
serverip = "192.168.0.5"; # build machine or other tftp server
|
|
||||||
# Should be a segment of free RAM, where the tftp artifact
|
# Should be a segment of free RAM, where the tftp artifact
|
||||||
# can be stored before unpacking it to the 'hardware.loadAddress'
|
# can be stored before unpacking it to the 'hardware.loadAddress'
|
||||||
# The 'hardware.loadAddress' is 0x80001000, which suggests the
|
# The 'hardware.loadAddress' is 0x80001000, which suggests the
|
||||||
|
@ -342,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 =
|
||||||
|
@ -397,12 +395,12 @@
|
||||||
address = lim.parseInt "0xbc040000";
|
address = lim.parseInt "0xbc040000";
|
||||||
# 0x000000040000-0x000000fa0000
|
# 0x000000040000-0x000000fa0000
|
||||||
size = lim.parseInt "0xf60000";
|
size = lim.parseInt "0xf60000";
|
||||||
# guessed:
|
# TODO: find in /proc/mtd on a running system
|
||||||
eraseBlockSize = 65536;
|
eraseBlockSize = 65536;
|
||||||
};
|
};
|
||||||
|
|
||||||
# since this is mentioned in the partition table as well?
|
# since this is mentioned in the partition table as well?
|
||||||
defaultOutput = "tplink";
|
defaultOutput = "tplink-safeloader";
|
||||||
# taken from openwrt sysupgrade image:
|
# taken from openwrt sysupgrade image:
|
||||||
# openwrt-23.05.2-ramips-mt7621-tplink_archer-ax23-v1-squashfs-sysupgrade.bin: u-boot legacy uImage, MIPS OpenWrt Linux-5.15.137, Linux/MIPS, OS Kernel Image (lzma), 2797386 bytes, Tue Nov 14 13:38:11 2023, Load Address: 0X80001000, Entry Point: 0X80001000, Header CRC: 0X19F74C5B, Data CRC: 0XF685563C
|
# openwrt-23.05.2-ramips-mt7621-tplink_archer-ax23-v1-squashfs-sysupgrade.bin: u-boot legacy uImage, MIPS OpenWrt Linux-5.15.137, Linux/MIPS, OS Kernel Image (lzma), 2797386 bytes, Tue Nov 14 13:38:11 2023, Load Address: 0X80001000, Entry Point: 0X80001000, Header CRC: 0X19F74C5B, Data CRC: 0XF685563C
|
||||||
loadAddress = lim.parseInt "0x80001000";
|
loadAddress = lim.parseInt "0x80001000";
|
||||||
|
|
|
@ -24,10 +24,16 @@ in rec {
|
||||||
../modules/ssh
|
../modules/ssh
|
||||||
../modules/bridge
|
../modules/bridge
|
||||||
../modules/hostapd
|
../modules/hostapd
|
||||||
|
../modules/outputs/kexecboot.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
hostname = "yardbird";
|
hostname = "yardbird";
|
||||||
|
|
||||||
|
boot.tftp = {
|
||||||
|
serverip = "192.168.0.1";
|
||||||
|
ipaddr = "192.168.0.2";
|
||||||
|
};
|
||||||
|
|
||||||
services.hostap = svc.hostapd.build {
|
services.hostap = svc.hostapd.build {
|
||||||
interface = config.hardware.networkInterfaces.wlan;
|
interface = config.hardware.networkInterfaces.wlan;
|
||||||
params = {
|
params = {
|
||||||
|
@ -144,7 +150,10 @@ in rec {
|
||||||
users.root = secrets.root;
|
users.root = secrets.root;
|
||||||
|
|
||||||
defaultProfile.packages = with pkgs; [
|
defaultProfile.packages = with pkgs; [
|
||||||
figlet
|
tcpdump
|
||||||
#tcpdump
|
# for arp
|
||||||
|
nettools
|
||||||
|
# for kexec booting
|
||||||
|
gnutar
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ in
|
||||||
Combined kernel and FDT in uImage (U-Boot compatible) format
|
Combined kernel and FDT in uImage (U-Boot compatible) format
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
tplink = mkOption {
|
tplink-safeloader = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
};
|
};
|
||||||
u-boot = mkOption {
|
u-boot = mkOption {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -7,19 +7,19 @@
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types concatStringsSep;
|
inherit (lib) mkOption types concatStringsSep;
|
||||||
o = config.system.outputs;
|
o = config.system.outputs;
|
||||||
cfg = config.tplink;
|
cfg = config.tplink-safeloader;
|
||||||
in {
|
in {
|
||||||
options.tplink = {
|
options.tplink-safeloader = {
|
||||||
board = mkOption {
|
board = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
options.system.outputs = {
|
options.system.outputs = {
|
||||||
tplink = mkOption {
|
tplink-safeloader = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
description = ''
|
description = ''
|
||||||
tplink
|
tplink-safeloader
|
||||||
******
|
*****************
|
||||||
|
|
||||||
For creating 'safeloader' images for tp-link devices.
|
For creating 'safeloader' images for tp-link devices.
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ in {
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
system.outputs = rec {
|
system.outputs = rec {
|
||||||
tplink =
|
tplink-safeloader =
|
||||||
pkgs.runCommand "tplink" { nativeBuildInputs = with pkgs.pkgsBuildBuild; [ firmware-utils ]; } ''
|
pkgs.runCommand "tplink" { nativeBuildInputs = with pkgs.pkgsBuildBuild; [ firmware-utils ]; } ''
|
||||||
tplink-safeloader -B "${cfg.board}" -k "${o.uimage}" -r "${o.rootfs}" -o $out
|
tplink-safeloader -B "${cfg.board}" -k "${o.uimage}" -r "${o.rootfs}" -o $out
|
||||||
'';
|
'';
|
Loading…
Reference in New Issue