R2S-编译固件
这里编译lean大神的lede。
一、开始前
首先考虑为啥要编译固件,OpenWRT和lede都有编译好的固件提供下载
-
Openwrt 官方编译的固件
-
其他固件
| 名称 | 地址 | 后台地址 | 密码 | 交换网口 |
|---|---|---|---|---|
| soffchen | github | 192.168.2.1 | password | 否 |
| OpenWrt-Rpi | github | 192.168.1.1 | password | 否 |
二、准备工作
用本地电脑科学上网也无法下载dl库,不清楚问题出在哪里,无奈用的vultr的国外机器。系统自然是推荐的Ubuntu20.04
- 下载用到的软件
sudo apt update
sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib antlr3 gperf wget curl swig rsync
如果用的root用户,先建一个普通的用户
# 建一个名为era的用户
useradd era -m -d /home/era -g root
passwd ear
三、配置编译
不要用root用户,虽然我也不知道用了会怎么样
首先 clone 项目
git clone https://github.com/coolsnowwolf/lede.git && cd lede
生成配置文件,执行
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
Target System 选择 Rockchip
Subtarget 选择 RK33xx boards (64 bit)
Target Profile 选择 FriendlyARM NanoPi R2S
保存退出
第一次编译选择平台后啥都不要动编译一次,提高编译成功率和折腾信心。然后下载dl库(我也不知道啥是dl库)。V=s 是说在执行时打印更详细的日志。-j 可以指定线程数, $(nproc)是本机可用线程数 。多线程可以加快速度,但是多线程也会增加出错率,个人理解设置超过本机的数字没有意义,反而系统需要为调度线程耗费性能。
make download -j $(nproc) V=s
下载成功就可以编译了。
make -j1 V=s
至此,你的第一个固件就编译完成了,生成的固件在bin/targets 目录下,先刷到机器上看看能不能用。
下面才是你自己编译固件的原因吧?那就做好出错的准备。在这里我建议你备份一下整个目录,如果后面出错了,可以从这里开始。
首先了解如果编译出错了怎么办呢。
执行以下两条命令,会自动筛选出刚刚下载的数据中,小于1kb的文件将他删除掉,因为小于1kb的文件都是下载出现问题的。然后再执行一遍make download会自动补全。
# 查找下载失败的dl
find dl -size -1024c -exec ls -l {} \;
# 删除下载失败的dl
find dl -size -1024c -exec rm -f {} \;
# 再重新下载
make download -j$(nproc)
# 再编译,这句话说先用多线程编译,如果报错就用单线程编译,如果还报错就再用详细模式编译
make -j$(nproc) || make -j1 || make -j1 V=s
或者试试编译脚本的clean功能
# 仅清理编译结果
make clean
# 清理所有编译文件
make dirclean
# 清理所有编译文件以及相关依赖
make distclean
# 恢复初始状态
git clean -xdf
可是我要说如果出错了,**这些都不怎么好用(玄学),还是在每一步修改之前备份一下,错了重来吧。
2.1 添加需要的包
LUCi列表解释 http://www.yizu.org/archives/758/
2.2 添加额外的包
找到包的仓库地址,比如https://github.com/vernesong/OpenClash,两种方式加入编译列表
- 将git仓库地址写入
feeds.conf.default
src-git packages https://github.com/coolsnowwolf/packages
src-git luci https://github.com/coolsnowwolf/luci
src-git routing https://git.openwrt.org/feed/routing.git
src-git telephony https://git.openwrt.org/feed/telephony.git
# src-git video https://github.com/openwrt/video.git
# src-git targets https://github.com/openwrt/targets.git
# src-git oldpackages http://git.openwrt.org/packages.git
# src-link custom /usr/src/openwrt/custom-feed
# 下面三行是新增的
src-git helloword https://github.com/fw876/helloworld
src-git passwall https://github.com/xiaorouji/openwrt-passwall
src-git openclash https://github.com/vernesong/OpenClash
然后执行
./scripts/feeds update -a && ./scripts/feeds install -a
- 手动clone仓库到
package目录下
另外,还有一些常用的工具包 https://github.com/kenzok8/openwrt-packages。
2.3 设置默认主题
把feeds/luci/collections/luci/Makefile中的luci-theme-bootstrap改成luci-theme-argon
# 删除自定义源默认的 argon 主题
rm -rf package/lean/luci-theme-argon
# 拉取 argon 原作者的源码
git clone -b 18.06 https://github.com/jerrykuku/luci-theme-argon.git package/lean/luci-theme-argon
# 替换默认主题为 luci-theme-argon
sed -i 's/luci-theme-bootstrap/luci-theme-argon/' feeds/luci/collections/luci/Makefile
2.4 设置lan地址
vim package/base-files/files/bin/config_generate
2.5 设置wifi
https://www.openwrt.pro/post-317.html
可以编译完再安装已有的驱动,在软件包搜索kmod,
打开/package/kernel
2.6 ipv6
# IPv6(未来运营商可能不再提供 IPv4 公网地址,有远程访问需求的建议加入)
Extra packages ---> ipv6helper (勾选此项即可,下面几项自动勾选)
Network ---> odhcp6c
Network ---> odhcpd-ipv6only
LuCI ---> Protocols ---> luci-proto-ipv6
LuCI ---> Protocols ---> luci-proto-ppp
web 界面的菜单
https://blog.csdn.net/l1315925504/article/details/51014371
https://www.bgegao.com/2020/03/1654.html
四、编译完成
固件会生成在 bin/targets 目录下
五、报错
这里我还收集了几个自己编译过程中出错的例子。
- 报错
./scripts/feeds update -a
Updating feed 'packages' from 'https://github.com/coolsnowwolf/packages' ...
已经是最新的。
Updating feed 'luci' from 'https://github.com/coolsnowwolf/luci' ...
已经是最新的。
Updating feed 'routing' from 'https://git.openwrt.org/feed/routing.git' ...
正克隆到 './feeds/routing'...
fatal: 无法访问 'https://git.openwrt.org/feed/routing.git/':server certificate verification failed. CAfile: none CRLfile: none
failed.
Updating feed 'telephony' from 'https://git.openwrt.org/feed/telephony.git' ...
正克隆到 './feeds/telephony'...
fatal: 无法访问 'https://git.openwrt.org/feed/telephony.git/':server certificate verification failed. CAfile: none CRLfile: none
failed.
Create index file './feeds/packages.index'
Create index file './feeds/luci.index'
Create index file './feeds/routing.index'
find: ‘feeds/routing’: 没有那个文件或目录
find: ‘feeds/routing’: 没有那个文件或目录
Create index file './feeds/telephony.index'
find: ‘feeds/telephony’: 没有那个文件或目录
find: ‘feeds/telephony’: 没有那个文件或目录
解决
git config --global http.sslVerify "false"
- 报错
time: package/boot/arm-trusted-firmware-rockchip-vendor/rk3328/download#45.31#2.85#66.78
100 1010k 0 1010k 0 0 5902 0 --:--:-- 0:02:55 --:--:-- 0
解决: 全局科学上网
Comments ()