源码自:https://github.com/padavanonly/immortalwrt/tree/q20-pbboot

生成.config

创建目录并开启大小写敏感,否则会报错Build dependency: OpenWrt can only be built on a case-sensitive filesystem

fsutil.exe file setCaseSensitiveInfo <path> enable

后面发现可以是GitHub云编译生成config,但是这样配置需要等待GitHub建立环境,再用ssh连接,需要等,而且需要添加其他组件的时候,需要重新等它重新配置好环境,感觉刚尝试的时候还是本地编译比较好。

教程如下:https://p3terx.com/archives/build-openwrt-with-github-actions.html

而且本地编译可以跳过漫长的下载和tools以及toolchain的编译,节约了一部分时间。(但是不知道为什么我本地8线程没有他的四线程快,我这CPU不至于这么拉垮吧

默认功能支持

ipv6

选择extra packages,勾选 —> ipv6helper

(选定这个后Network —> odhcp6c、Network —> odhcpd-ipv6only、LuCI —> Protocols —> luci-proto-ipv6、LuCI —> Protocols —> luci-proto-ppp等几项会自动选择)

sfe加速

再Luci→Application找到turboacc勾上就行

添加自定义包

design主题 https://github.com/gngpp/luci-theme-design

luci-app-nat6-helper https://github.com/Ausaci/luci-app-nat6-helper

git clone https://github.com/gngpp/luci-theme-design.git  package/luci-theme-design
git clone https://github.com/3401797899/luci-app-ddns-go.git package/ddns-go
git clone https://github.com/Ausaci/luci-app-nat6-helper.git package/nat6-helper

云编译的话将上述命令加入diy-part1.sh中即可。

自定义功能

需要设置一些默认值什么的可以在diy-part1.sh和diy-part2.sh中添加代码。

例如:

需要在turboacc启动的时候关闭mtkhnat。(不知道237大佬用的什么硬件nat,无法进行nat6,只好给关了,开sfe。)

在diy-part2.sh中添加

echo '#!/bin/sh /etc/rc.common

START=99
STOP=10

start(){
rmmod mtkhnat
}' > package/base-files/files/etc/init.d/stop-mtkhnat

需要修改默认的lan口网段。

在diy-part2.sh中添加

sed -i 's/192.168.6.1/192.168.1.1/g' package/base-files/files/bin/config_generate

踩坑

  1. 搭建环境的话,如果使用的是Ubuntu22以上,需要将lib32gcc1改为lib32gcc-s1,python-docutils如果装不上的话,可以考虑不要了,目前没什么影响。

  2. 一定要确保owner是非root的当前用户,否则会报很多离谱的错误。如果出现报错,就找找日志里有没有出现提示无Permission的操作,将该目录的用户和组设置为当前用户即可。

    sudo chown $USER:$GROUPS /workdir
  3. 如果wsl出现git “chmod on config.lock failed: Operation not permitted”错误,可以参考这个教程https://www.youtube.com/watch?v=uTw50U9sMO8

  4. 自己修改插件的话,对于最后要编译成的可执行文件千万别用网页的方式上传到Github,会将执行权限抹掉,导致编译失败。
    image.png

  5. 编写插件如果出现了make[3]: *** No targets specified and no makefile found. Stop错误,将Compile和Configure配置上即可。

    define Build/Compile
    endef

    define Build/Configure
    endef
  6. 如果出现Makefile:31: *** missing separator. Stop.错误,应该是VSCode对缩进处理的问题。参考https://blog.csdn.net/rosemary512/article/details/110637963