openwrt 编译k2固件

​ 最近又想玩玩我的k2,别人的编译的固件老是没有我自己想要的插件,所以想自己编译一下。中间也踩了很多坑。

只记录关键步骤

  1. wsl子系统全局外网问题

windows使用Proxifier直接全局掌控,稳如老狗。

网上看了一些linux系统代理设置,但是无法全局,因此还是Proxifier永远的神。

  1. 添加其他feeds插件库
1
2
3
4
# 找到 feeds.conf.default ,可以利用everythings搜索
src-git kenzo https://github.com/kenzok8/openwrt-packages
src-git small https://github.com/kenzok8/small
src-git lienol https://github.com/Lienol/openwrt-package
  1. make menuconfig配置

参考上面第三个链接

  1. 编译前执行go环境设置 避免错误
1
2
export GO111MODULE=on
export GOPROXY=https://goproxy.cn,direct
  1. wsl系统编译
1
2
3
4
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make -j1 V=s
# 以上代码为大雕大佬推荐的单线程模式,-j1表示1线程
# 直接上最多 自己cpu线程 +1 就可以了 我是6核12线程
sudo PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make -j13 V=s
  1. 如果上面编码出现一下错误
1
2
3
4
5
6
7
8
9
configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)
See `config.log' for more details
make[3]: *** [/home/linux/myopenwrt/openwrt/build_dir/host/tar-1.28/.configured] Error 1
make[3]: Leaving directory `/home/linux/myopenwrt/openwrt/tools/tar'
make[2]: *** [tools/tar/compile] Error 2
make[2]: Leaving directory `/home/linux/myopenwrt/openwrt'
make[1]: *** [/home/linux/myopenwrt/openwrt/staging_dir/target-mips_34kc_musl-1.1.14/stamp/.tools_install_yynyynynynyyyyyyynyyyyyyyyyyyyynyyyyynnyynynyyyynnnyy] Error 2
make[1]: Leaving directory `/home/linux/myopenwrt/openwrt'
make: *** [world] Error 2

wsl编译命令 就修改为

1
sudo PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make FORCE_UNSAFE_CONFIGURE=1 -j13 V=s
  1. 刚开始编译怎么都没有 openwrt-ramips-mt7620-phicomm_psg1218a-squashfs-sysupgrade.bin 文件

网上搜索说 固件太大 就没有了,但是我在配置时只做了删除了怎么还更大呢。(未知)

然后我就什么都没有更改 直接编译一次,就成功了,然后再进行删除增加就可以了。

  1. copy 配置修改ip时,复制
1
2
3
4
5
6
7
8
192.168.2.12
24
255.255.255.255
192.168.2.1

192.168.31.2

192.168.31.23
  1. 分享一个 移动wsl子系统的软件 避免wsl系统太占C盘空间

下载:https://github.com/DDoSolitary/LxRunOffline/releases

案例:https://blog.bccn.net/%E9%9D%99%E5%A4%9C%E6%80%9D/67307

安装wsl子系统 ubuntu-20.04 和 LxRunOffline 软件

  1. 备份/还原WSL
  • 查看当前系统中存在的WSL
1
2
LxRunOffline.exe list or wsl -l
Ubuntu-20.04
  • 开始备份
1
./LxRunOffline.exe export -n Ubuntu-20.04 -f E:\wsl_ubuntu_bak.tar.gz
  • 还原WSL
1
2
./LxRunOffline.exe install -n Ubuntu -d D:\wsl_ubuntu -f E:\wsl_ubuntu_bak.tar.gz

  1. 直接移动(新装推荐用这个)
1
2
3
4
5
# 新建文件夹作为移动目标,如:D:\wsl_ubuntu
LxRunOffline move -n Ubuntu-20.04 -d D:\wsl_ubuntu
# 时间比较久,等待移动完成用下面命令查看
LxRunOffline get-dir -n Ubuntu-20.04

参考:

  1. https://github.com/coolsnowwolf/lede
  2. https://www.right.com.cn/forum/thread-5559590-1-1.html
  3. https://www.right.com.cn/forum/thread-344825-1-1.html
  4. https://blog.csdn.net/tiwsonchen/article/details/84924909
  5. https://github.com/hanxi/blog/issues/28