OpenWrt - 编译
# 自行编译
本文以编译新路由 3 (newifi d2) 固件为例
- 首先装好 Linux 系统,推荐 Debian 11 或 Ubuntu LTS
- 不要用 root 用户进行编译
- 安装依赖
# 以参考1中最新依赖为准
sudo apt update -y
sudo apt full-upgrade -y
sudo apt install -y ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib \
git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev \
libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libtool lrzsz \
mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pyelftools \
libpython3-dev qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip \
vim wget xmlto xxd zlib1g-dev python3-setuptools
# 操作完成后建议reboot重启一下
笔记
安装依赖过程中提示:
Newer kernel available
The currently running kernel version is 5.15.0-84-generic which is not the expected kernel version 5.15.0-89-generic.Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting.
当前运行的内核版本是5.15.0-84-generic,这不是预期的内核版本5.15.0-89-generic。重新启动系统以加载新内核不会自动处理,因此大家应该考虑重新启动。
不知道对后续的编译是否有影响,我选择重启试一下。
- 下载源代码,更新 feeds 并选择配置
git clone https://github.com/coolsnowwolf/lede
cd lede
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig # 进入配置选择页面
配置
- Target System:
MediaTek Ralink MIPS
- Subtarget:
MT7621 based boards
- Target Profile:
Newifi D2
- 保存 (Save)
- 回到命令行,执行
# 下载 dl 库
make download -j8
# 编译固件 (-j 后面是线程数,第一次编译推荐用单线程)
make V=s -j8 # 单线程太慢了 直接干8线程
# 下载他人编译
# 物理机安装
材料
physdiskwrite -u 固件路径
# 选择要写入的硬盘
# y 确定
# 参考
上次更新: 2024/03/11, 22:37:05