OpenWRT for Raspberry Pi Model 3
概述
在 [OpenWrt Introduction] 中我们对 OpenWrt 的特性、目标、架构以及构建系统做了介绍。本文将更注重实践,一步步构建 OpenWrt 使其移植到 树莓派 Model 3B 开发板。虽然我们可以直接下载编译好的固件,但也会失去自己动手做的乐趣。
环境准备
安装依赖
构建系统依赖一些软件包,这些软件包在大部分 Linux 发行版系统上已经安装。但如果一部分依赖没有安装,构建会失败,这时候需要根据错误信息发现未安装的依赖包。
在 Ubuntu 系统上:$ sudo apt update
$ sudo apt install build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext git libncurses5-dev libssl-dev python3-distutils rsync unzip zlib1g-dev file wget
新建用户openwrt(可选)
为了获得更干净的构建环境,我们可以新建一个openwrt用户(其他名字亦可):
sudo groupadd openwrtsudo useradd -s /bin/bash -g openwrt -m -k /dev/null openwrt
设置口令:sudo passwd openwrt
切换用户:cd /home/openwrtsu openwrt
构建
下载源代码
git clone https://git.openwrt.org/openwrt/openwrt.git
更新并选择分支
git pullgit checkout <XXXX>
我们使用最新的 22.03.3 版本
更新和安装 feeds
./scripts/feeds update -a./scripts/feeds install -a : 安装所有获取的包的符号链接到package/feeds
配置
make menuconfig
具体配置选项:
- Target System 选择
BCM27xx - Subtarget 选择
BCM2710 boards (64bits) - Target Profile 自动选择为
Raspberry Pi 3B/3B+/3CM (64bit) - Target Image 至少选择
Gzip image- Kernel partition size 可以设置为
256M - Root filesystem partition size 可以设置为
1024M(具体根据SD卡容量)
- Kernel partition size 可以设置为
- Kernel Modules > USB Supports 可以全选
- Luci > Application:
- luci-app-dockerman 容器
- luci-app-frpc 内网穿透客户端
- luci-app-ddns 动态域名解析
- luci-app-mwan3 分流助手(多运营商网络)
- luci-app-samba4 SMB网络共享
- luci-app-ttyd 网页终端插件
- luci-app-wol 网络唤醒
- Luci -> Themes : 主题,可以全选
用户可以增加自己的扩展软件包或者 Luci 的扩展插件。
下载&编译
make -j8 download V=smake -j1