0%

OpenWrt系统编译

OpenWrt系统编译

OpenWrt 可以被描述为一个嵌入式的 Linux 发行版。(主流路由器固件有 dd-wrt,tomato,openwrt,padavan四类)对比一个单一的、静态的系统,OpenWrt的包管理提供了一个完全可写的文件系统,从应用程序供应商提供的选择和配置,并允许您自定义的设备,以适应任何应用程序。

注意

  1. 不要用 root 用户进行编译。
  2. 国内用户编译前准备好科学上网工具,有很多资源需要从国外网站下载。
  3. 默认登陆IP 192.168.1.1 密码 password。

编译命令

  1. 首先装好 Linux 系统,推荐 Debian 11 或 Ubuntu LTS。

  2. 安装编译依赖

    1
    2
    3
    4
    5
    6
    7
    8
    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-pip libpython3-dev qemu-utils \
    rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev
  3. 下载源代码,更新 feeds 并选择配置

    1
    2
    3
    4
    5
    git clone https://github.com/coolsnowwolf/lede
    cd lede
    ./scripts/feeds update -a
    ./scripts/feeds install -a
    make menuconfig
  4. 下载 dl 库,编译固件 (-j 后面是线程数,第一次编译推荐用单线程)

    1
    2
    make download -j8  # 下载资源,比较耗时
    make V=s -j1
  5. 二次编译

    1
    2
    3
    4
    5
    6
    7
    cd lede
    git pull
    ./scripts/feeds update -a
    ./scripts/feeds install -a
    make defconfig
    make download -j8
    make V=s -j$(nproc)
  6. 重新配置

    1
    2
    3
    rm -rf ./tmp && rm -rf .config
    make menuconfig
    make V=s -j$(nproc)
  7. 生成固件位置
    以树莓派3B为例:/lede-master/bin/targets/bcm27xx/bcm2710

参考资料

  1. Lean 的 Openwrt 源码仓库
  2. 树莓派4B 亲手打造一款Openwrt软路由(带编译固件-超详细) - RaspberryPi硬核系列(三)
  3. OpenWrt 编译 LuCI -> Applications 添加插件应用说明-L大
  4. openwrt插件