资讯详情

【openwrt】编译源码

准备工作

首先,我用的是系统ubuntu2004,openwrt版本是github最新版本的代码。

安装所需的软件

sudo apt-get install git g   make libncurses5-dev subversion libssl-dev gawk libxml-parser-perl unzip wget python xz-utils vim zlibc zlib1g zlib1g-dev openjdk-8-jdk build-essential ccache gettext xsltproc 

编译源码

下载源码

git clone https://github.com/openwrt/openwrt.git 

更新并安装软件包

切换到下载的源代码,输入以下指令

./scripts/feeds update -a  ./scripts/feeds install -a 

选择芯片

切换到源码目录,输入打开菜单,在顶层选择以下选项,我用卓钛JS7628。

Target System (MediaTek Ralink MIPS) Subtarget (MT76x8 based boards) Target Profile (Jotale JS76x8 32M) 

下载依赖

openwrt编译时,需要下载一些依赖包,切换到下载的源代码,输入以下指令

make download V=s 

开始编译

make V=s 

安装交叉编译链

切换到源码目录,输入打开菜单,在顶层选择以下选项

[*] Package the OpenWrt-based Toolchain 

选择后,重新编译以获得交叉编译链。输入以下指令,将交叉编译链解压到指定文件夹中。

mkdir ~/tool tar xvf ~/sources/openwrt/bin/targets/ramips/mt76x8/openwrt-toolchain-ramips-mt76x8_gcc-11.3.0_musl.Linux-x86_64.tar.xz -C ~/tool/ 

解压后,还需要将解压路径添加到环境变量中,因为解压路径太长,我顺便换了名字。

mv /home/moqi/tool/openwrt-toolchain-ramips-mt76x8_gcc-11.3.0_musl.Linux-x86_64/ /home/moqi/tool/openwrt-toolchain/ echo export STAGING_DIR="/home/moqi/sources/openwrt/staging_dir"  >> ~/.bashrc echo export PATH="$PATH:/home/moqi/tool/openwrt-toolchain/toolchain-mipsel_24kc_gcc-11.3.0_musl/bin" >> ~/.bashrc source ~/.bashrc 

输入命令行如果有以下输出证明,测试安装是否成功。

COLLECT_LTO_WRAPPER=/home/moqi/tool/openwrt-toolchain/toolchain-mipsel_24kc_gcc-11.3.0_musl/bin/../libexec/gcc/mipsel-openwrt-linux-musl/11.3.0/lto-wrapper Target: mipsel-openwrt-linux-musl Configured with: /home/moqi/sources/openwrt/build_dir/toolchain-mipsel_24kc_gcc-11.3.0_musl/gcc-11.3.0/configure --with-bugurl=http://bugs.openwrt.org/ --with-pkgversion='OpenWrt GCC 11.3.0 r19830-849ffbd5ab' --prefix=/home/moqi/sources/openwrt/staging_dir/toolchain-mipsel_24kc_gcc-11.3.0_musl --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=mipsel-openwrt-linux-musl --with-gnu-ld --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-multilib --disablelibmpx --disable-nls --disable-libssp --without-isl --without-cloog --with-host-libstdcxx=-lstdc++ --with-float=soft --with-gmp=/home/moqi/sources/openwrt/staging_dir/host --with-mpfr=/home/moqi/sources/openwrt/staging_dir/host --with-mpc=/home/moqi/sources/openwrt/staging_dir/host --disable-decimal-float --with-diagnostics-color=auto-if-env --enable-__cxa_atexit --disable-libstdcxx-dual-abi --with-default-libstdcxx-abi=new --with-mips-plt --with-headers=/home/moqi/sources/openwrt/staging_dir/toolchain-mipsel_24kc_gcc-11.3.0_musl/include --enable-languages=c,c++ --enable-shared --enable-threads --with-slibdir=/home/moqi/sources/openwrt/staging_dir/toolchain-mipsel_24kc_gcc-11.3.0_musl/lib --enable-lto --with-libelf=/home/moqi/sources/openwrt/staging_dir/host --disable-libsanitizer
Thread model: posix
...

添加编译选项

添加驱动

wifi驱动

Kernel modules  --->
    Wireless Drivers  --->
        <*> kmod-mt76........... MediaTek MT76x2/MT7603 wireless driver (metapackage)

添加软件

LUCI

LuCI  --->
    1. Collections  --->
        <*> luci................... LuCI interface with Uhttpd as Webserver (default)

单独编译源码

  1. 全新编译:
make ./package/utils/ugps/{clean,compile} V=s
  1. 单独编译:
make ./package/utils/ugps/compile V=s
  1. 清空:
make ./package/utils/ugps/clean V=s

标签: 5ab反装连接器

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台