编译自定制OpenWRT固件

参考教程

  1. 更新系统,安装编译信赖
1
2
3
4
5
sudo apt update -y
# sudo apt full-upgrade -y

sudo apt-get -y install build-essential asciidoc binutils bzip2 curl gawk gettext git libncurses5-dev libz-dev patch python3.5 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

  1. 下载源代码

打开科学上网工具,最好全局!以下源码三选一下载,也可以使用其他团队的源码!

1
2
3
4
5
6
7
8
9
git clone https://github.com/openwrt/openwrt                         # 官方版本
git clone https://github.com/coolsnowwolf/lede # lede版本
git clone -b 22.03 --single-branch https://github.com/Lienol/openwrt #lienol版本
git clone https://github.com/Lienol/openwrt.git
cd openwrt # 切换到文件目录

# 如需指定openwrt版本,可以使用以下命令
git tag # 查看稳定版,回车键拉到最低,按Q结束!
git checkout v22.03.3 # 指定版本,红色部分位版本号

Lienol大大配置的OpenWRT,默认是可以编译成功的。
只需要保证配置菜单的前三项设置与自己需要的固件型号一致的设置即可。

  1. 编译
1
2
3
4
./scripts/feeds clean
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
  1. 下载dl库
1
make -j8 download V=s
  1. 编译
1
2
3
make -j1 V=s

# 编译后的输出路径为:openwrt/bin/targets
  1. QuickStart

Run ./scripts/feeds update -a to obtain all the latest package definitions defined in feeds.conf / feeds.conf.default
Run ./scripts/feeds install -a to install symlinks for all obtained packages into package/feeds/
Run make menuconfig to select your preferred configuration for the toolchain, target system & firmware packages.
Run make to build your firmware. This will download all sources, build the cross-compile toolchain and then cross-compile the GNU/Linux kernel & all chosen applications for your target system.