编译技巧
# 自用编译的镜像, 不要使用root帐户, 创建新的帐户编译
docker pull registry.cn-hangzhou.aliyuncs.com/jcleng/wrt-ubuntu:20.04
docker exec -it -u $(id -u) mywork-wrt-1 bash
cd /srv/immortalwrt
# 本地代理环境, 给docker使用
export http_proxy=http://172.17.0.1:7892
export https_proxy=http://172.17.0.1:7892
git config --global http.proxy http://172.17.0.1:7892
git config --global https.proxy http://172.17.0.1:7892
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
# 根据需要选插件, 增加daed
./scripts/feeds update -a
./scripts/feeds install -a
curl ipinfo.io
make menuconfig
make download -j8
#记得在Target Images适当扩大系统分区和镜像大小
#系统分区,驱动或插件多的话需要适当扩大这个分区
#(128) Kernel partition size (in MB)
#文件系统分区,基本可以理解为安装后默认的/overlay分区大小
#(512) Root filesystem partition size (in MB)
#看看有没有没下完整的包,这是查看dl目录下有没有1k以下的文件,有的话建议删除重新下,很可能没下完整
find dl -size -1024c -exec ls -l {} \;
#删除
find dl -size -1024c -exec rm -f {} \;
# 如果要更换架构,例如要从 x86_64 换到 MediaTek Ralink MIPS 建议执行以下命令深度清理
rm -rf ./bin ./build_dir ./tmp ./staging_dir
make clean
make dirclean
# 如果分支变更,需要删除feeds
rm -rf feeds
# 如果需要对组件重新调整,则建议先删除旧配置
rm -rf .config
# 看error
make -j8 V=s || make -j1 V=s
# 只编译插件,PACKAGE_NAME=包名, 如果要导出.ipk需要在menuconfig选择[M]
make package/PACKAGE_NAME/compile
# 比如
make package/adguardhome/compile
make package/luci-app-adblock/compile
# feeds/packages/net/adguardhome
# ./bin/packages/mipsel_24kc/packages/adguardhome_0.107.46-1_mipsel_24kc.ipk
# ./bin/packages/mipsel_24kc/luci/luci-app-adblock_git-24.171.46678-4ec9a34_all.ipk
# 注:V=99 表示输出详细的 debug 信息
# 我这里是 x86_64 架构,编译完成插件包默认存放路径:~/openwrt/bin/packages/x86_64/base 目录下
- 成功一次
```shell
du ./ -hd 1
16M ./.git
8.0K ./.github
56K ./LICENSES
64K ./config
376K ./include
24M ./package
2.2M ./scripts
52M ./target
2.7M ./tools
514M ./feeds
756M ./dl
652K ./toolchain
177M ./tmp
1.9G ./staging_dir
12G ./build_dir
67M ./bin
15G ./
dl目录的文件进行手动下载,如果下载失败,可以手动下载重新编译
# push @mirrors, 'https://mirror01.download.immortalwrt.eu.org';
# push @mirrors, 'https://mirror2.immortalwrt.org/sources';
# push @mirrors, 'https://mirror.immortalwrt.org/sources';
# push @mirrors, 'https://sources.immortalwrt.org';
# push @mirrors, 'https://sources.cdn.immortalwrt.org';
push @mirrors, 'https://sources.cdn.openwrt.org';
push @mirrors, 'https://sources.openwrt.org';
# push @mirrors, 'https://mirror2.openwrt.org/sources';
在docker使用rootfs文件运行openwrt
# 还是存在一些问题,luci的web无法访问/ubus,还是用libvirt来操作能ok
docker image import immortalwrt-x86-64-generic-rootfs.tar.gz immortalwrt:latest
docker run -itd --name=immortalwrt immortalwrt:latest /sbin/init
docker ps|grep immortalwrt
docker exec -it immortalwrt bash
docker restart immortalwrt
JCG Q30 Pro刷写openwrt
# 过渡固件/底包: 在原始管理界面进行升级刷入, 获得uboot
wget https://firmware.download.immortalwrt.eu.org/237176253/mediatek/filogic/immortalwrt-mediatek-mt7981-mt7981-spim-nand-rfb-squashfs-sysupgrade.bin
# sha256sum
446d8766c079357367f647ef28587ec050ea2bf865980e54a2f29134c5fd5ede immortalwrt-mediatek-mt7981-mt7981-spim-nand-rfb-squashfs-sysupgrade.bin
# 上一步刷完固件之后,等待大约两分钟,然后断电,按住机身背部的 Reset 按键,上电开机。等待不到 10s 左右,红灯闪烁三下然后变成蓝灯,代表已进入 U-Boot 的恢复模式 WebUI。需要设置192.168.1.2段IP, 然后访问192.168.1.1
# 固件包, Factory 映像, 记得下载之后检查sha256sum
https://firmware-selector.immortalwrt.org/?version=23.05-SNAPSHOT&target=mediatek%2Ffilogic&id=jcg_q30-ubootmod
# 进入系统后有一些其他事情可以优化。目前固件默认没完全开启 WiFi 硬件转发加速,天灵修改这个配置之前,可能需要手动开启。SSH 或 TTYD 连接到路由器并执行:
opkg update && opkg install bridger
echo 'mt7915e wed_enable=Y' > /etc/modules.d/mt7915e
源地址
https://github.com/hanwckf/immortalwrt-mt798x
# 或者使用
https://github.com/x-wrt/x-wrt
# JCG Q30 Pro
https://downloads.x-wrt.com/rom/
busybox
# mips ar300m
https://www.busybox.net/downloads/binaries/1.21.1/busybox-mips
自建包使用构建完成的bin目录(带有targets和packages目录)
cat /etc/opkg/distfeeds.conf
src/gz jcleng_base https://dl.2011101.xyz/openwrt/ignet-ar300m/packages/mips_24kc/base
src/gz jcleng_kenzo https://dl.2011101.xyz/openwrt/ignet-ar300m/packages/mips_24kc/kenzo
src/gz jcleng_luci https://dl.2011101.xyz/openwrt/ignet-ar300m/packages/mips_24kc/luci
src/gz jcleng_packages https://dl.2011101.xyz/openwrt/ignet-ar300m/packages/mips_24kc/packages
src/gz jcleng_routing https://dl.2011101.xyz/openwrt/ignet-ar300m/packages/mips_24kc/routing
src/gz jcleng_small https://dl.2011101.xyz/openwrt/ignet-ar300m/packages/mips_24kc/small
src/gz jcleng_telephony https://dl.2011101.xyz/openwrt/ignet-ar300m/packages/mips_24kc/telephony
src/gz jcleng_nand_packages https://dl.2011101.xyz/openwrt/ignet-ar300m/targets/ath79/nand/packages
# 安装提示内核不兼容
已安装的软件包 kernel 版本不兼容,需要 5.15.158-1-49dcc59f… 而 5.15.150-1-1096a010… 已安装
# 升级内核; 手动下载 /targets/ath79/nand/packages/kernel_* 最新的内核.ipk文件, 然后进行
opkg install ./kernel_5.15.158-1-49dcc59fd2422905f47d70933d64a882_mips_24kc.ipk
opkg update
# 安装luci软件包之后ui不显示界面, 升级这个软件
luci-compat
编译加速,修改文件的下载地址
# golang国内加速
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
# 软件包加速
feeds.conf.default
# 修改为国内github加速地址: https://hub.njuu.cf/
定时重启crontab
# 增加到文件
crontab -e
# 在线: https://crontab.guru
# 凌晨3点重启
0 3 * * * /sbin/reboot
# 查看开启的任务
crontab -l