编译 R2S openwrt 固件

cyang Lv6

准备工作

  • 安装虚拟机安装
  • 下载 Ubuntu 22.04
  • 虚拟机安装 Ubuntu ,内存 8G,硬盘 100G

环境设置

  • 不要使用 root 账户编译,新建一个账户授予其 sudo 权限

  • 依次输入如下指令

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # 更新软件列表、升级软件包
    sudo sh -c "apt updated && apt upgrade -y"

    # 安装依赖
    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

    # 拉取源码
    git clone https://github.com/coolsnowwolf/lede.git openwrt

    # 选择 target 为 RockChip, SubTarget 为 RX33xx,以及 Lucci 中开始一些常用插件
    make menuconfig

编译过程

1
2
3
4
5
下载编译所需的软件包,注意下载很肯能会超时,可以多试几次,确保下载完成,首次用时超过10分钟,中途有 timeout 错误
make download -j8 V=s

# -j1:单线程编译,单线程编译可提高编译成功率
make -j1 V=s

编译完成后固件输出路径: /openwrt/bin/targets/ 之下。

其他

第一次编译,使用单线程,编译时间超过5小时,而且还编译失败了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/home/cyang/Desktop/openwrt/lede/staging_dir/host/bin/make_ext4fs -L rootfs -l 167772160 -b 4096 -m 0 -J -T 1650799518 /home/cyang/Desktop/openwrt/lede/build_dir/target-aarch64_generic_musl/linux-rockchip_armv8/root.ext4 /home/cyang/Desktop/openwrt/lede/build_dir/target-aarch64_generic_musl/root-rockchip/
Creating filesystem with parameters:
Size: 167772160
Block size: 4096
Blocks per group: 32768
Inodes per group: 5120
Inode size: 256
Journal blocks: 0
Label: rootfs
Blocks: 40960
Block groups: 2
Reserved blocks: 0
Reserved block group size: 15
error: ext4_allocate_best_fit_partial: failed to allocate 23 blocks, out of space?

解决方法:

1
2
#increasing the root filesystem partition size.
make menuconfig -> Target Images -> Root filesystem partition size (in MB)

之后需要二次编译:

1
2
3
make clean
# 二次编译可以优先使用多线程,报错会自动使用单线程,仍然报错会单线程执行编译并输出详细日志。第二次编译用 4 线程耗时 1小时10分钟,只有很简单的打印信息。
make -j$(nproc) || make -j1 || make -j1 V=s
1
2
3
4
5
6
7
8
9
10
11
12
13
make[3] -C feeds/luci/applications/luci-app-ddns compile
make[3] -C package/lean/default-settings compile
make[3] -C feeds/kenzo/luci-app-argon-config compile
make[3] -C feeds/kenzo/luci-app-argonne-config compile
make[3] -C feeds/kenzo/luci-app-passwall compile
make[3] -C feeds/packages/net/adblock compile
make[3] -C feeds/luci/applications/luci-app-adblock compile
make[2] package/install
make[2] target/install
make[3] -C target/linux install
make[2] package/index
make[2] json_overview_image_info
make[2] checksum
1
2
3
4
5
6
7
8
9
10
11
12
13
# output
cyang@cyang:~/Desktop/openwrt/lede/bin/targets/rockchip/armv8$ ll
total 126020
drwxr-xr-x 3 cyang cyang 4096 Apr 25 17:58 ./
drwxr-xr-x 3 cyang cyang 4096 Apr 25 17:07 ../
-rw-r--r-- 1 cyang cyang 3252 Apr 25 17:07 config.buildinfo
-rw-r--r-- 1 cyang cyang 395 Apr 25 17:07 feeds.buildinfo
-rw-r--r-- 1 cyang cyang 72288324 Apr 25 17:58 openwrt-rockchip-armv8-friendlyarm_nanopi-r2s-ext4-sysupgrade.img.gz
-rw-r--r-- 1 cyang cyang 11588 Apr 25 17:58 openwrt-rockchip-armv8-friendlyarm_nanopi-r2s.manifest
-rw-r--r-- 1 cyang cyang 56696968 Apr 25 17:58 openwrt-rockchip-armv8-friendlyarm_nanopi-r2s-squashfs-sysupgrade.img.gz
drwxr-xr-x 2 cyang cyang 16384 Apr 25 17:58 packages/
-rw-r--r-- 1 cyang cyang 644 Apr 25 17:58 sha256sums
-rw-r--r-- 1 cyang cyang 16 Apr 25 17:07 version.buildinfo

下载的文件要确保是正确的,如果你对你的网络质量没什么信心,可以先执行一下make download,将需要下载的数据准备好。
然后再执行以下两条命令,会自动筛选出刚刚下载的数据中,小于1kb的文件将他删除掉,因为小于1kb的文件都是下载出现问题的。然后再执行一遍make download会自动补全。

1
2
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;

如果需要再次编译,可以使用如下指令 clean

1
2
3
4
5
6
7
8
9
10
11
仅清理编译结果
make clean

清理所有编译文件
make dirclean

清理所有编译文件以及相关依赖
make distclean

恢复初始状态
git clean -xdf

参考链接

  • 标题: 编译 R2S openwrt 固件
  • 作者: cyang
  • 创建于 : 2022-04-24 21:17:23
  • 更新于 : 2022-04-24 21:17:23
  • 链接: https://blog.cyang.tech/2022/04/24/编译 R2S openwrt 固件/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
此页目录
编译 R2S openwrt 固件