如何为路由器 RT-N14U/N56U/N65U/N11P/AC51U/AC54U/AC1200HP/N56UB1独立编译固件
登录系统后安装git工具
sudo apt-get update -y
sudo apt-get install git -y
进入“/opt”目录,运行git命令创建git仓库本地副本:
cd /opt
sudo git clone https://bitbucket.org/padavan/rt-n56u.git
这将复制所有源代码,创建一个本地git存储库。目录/opt/rt-n56u将是git存储库的根目录。 提示:必须在/opt/rt-n56u目录编译
阅读/opt/rt-n56u/readme.eng.txt文档 并 安装其中列出的所有必需软件包:
sudo apt-get update -y
sudo apt-get install autoconf automake autopoint bison build-essential flex gawk gettext git gperf libtool pkg-config zlib1g-dev libgmp3-dev libmpc-dev libmpfr-dev texinfo python-docutils -y
MC (midnight commander)不需要构建固件,但它将帮助您浏览目录,复制或编辑文件。
转到包含工具链源(交叉编译器和构建工具)的目录并构建它:
cd /opt/rt-n56u/toolchain-mipsel
sudo ./clean_sources
sudo ./build_toolchain
The result will be collected the target of toolchain /opt/rt-n56u/toolchain-mipsel/toolchain-3.4.x
If you plan to build the firmware with the kernel 3.0, you must build the appropriate version of tolchain:
cd /opt/rt-n56u/toolchain-mipsel
sudo ./clean_sources
sudo ./build_toolchain_3.0.x
The result will be collected the target of toolchain /opt/rt-n56u/toolchain-mipsel/toolchain-3.0.x
In the future, you will need these commands only if the toolchain will be updated.
现在进入带有源代码的目录:
cd /opt/rt-n56u/trunk
and edit file /opt/rt-n56u/trunk/.config to fit your needs.
Edit path to toolchain (if you need it):
CONFIG_TOOLCHAIN_DIR=/opt/rt-n56u/toolchain-mipsel
To build the firmware, for example, for router RT-N65U uncomment (remove the simbol #) the line:
CONFIG_FIRMWARE_PRODUCT_ID="RT-N65U"
and comment the line:
#CONFIG_FIRMWARE_PRODUCT_ID="RT-N56U"
Save the file after edit.
以上操作可使用下面替代,直接复制配置文件到 /opt/rt-n56u/trunk
cd /opt/rt-n56u/trunk
cp configs/templates/MI-R3G.confg .config
Clear source tree (every time before a new build)
sudo ./clear_tree
Build the firmware:
sudo ./build_firmware
Created custom firmware file will be in the directory ./path_to_your_dir/rt-n56u/trunk/images. If you want to save the firmware that you created earlier - copy it to another location, because the command clear_tree overwrites the directory images.
When repository updated a local source tree must be updated with command:
sudo git pull
If you made any changes to the local repository, when you upgrade tree some files could not be copied. In this case, you must give the command:
sudo git stash
sudo git pull
If toolchain sources (cross-compiler and tools for building) is changed you must re-build it:
cd /opt/rt-n56u/toolchain-mipsel
sudo ./clean_sources
sudo ./clean_toolchain
sudo ./build_toolchain
来源padavan / rt-n56u / wiki / EN / HowToMakeFirmware — Bitbucket
其他版本说明
https://github.com/hanwckf/rt-n56u.git
H大的编译交叉环境和编译固件Ubuntu不要自己加sudo,否则可能报错
# Debian/Ubuntu
sudo apt update
sudo apt install unzip libtool-bin curl cmake gperf gawk flex bison nano \
fakeroot kmod cpio git python3-docutils gettext automake autopoint \
texinfo build-essential help2man pkg-config zlib1g-dev libgmp3-dev \
libmpc-dev libmpfr-dev libncurses5-dev libltdl-dev wget libc-dev-bin
# Archlinux/Manjaro
sudo pacman -Syu --needed git base-devel cmake gperf ncurses libmpc \
gmp python-docutils vim rpcsvc-proto fakeroot cpio help2man
# Alpine
sudo apk add make gcc g++ cpio curl wget nano xxd kmod \
pkgconfig rpcgen fakeroot ncurses bash patch \
bsd-compat-headers python2 python3 zlib-dev \
automake gettext gettext-dev autoconf bison \
flex coreutils cmake git libtool gawk sudo
# CentOS 7
sudo yum update
sudo yum groupinstall "Development Tools"
sudo yum install ncurses-* flex byacc bison zlib-* texinfo gmp-* mpfr-* gettext \
libtool* libmpc-* gettext-* python-docutils nano help2man fakeroot
# CentOS 8
sudo yum update
sudo yum groupinstall "Development Tools"
sudo yum install ncurses-* flex byacc bison zlib-* gmp-* mpfr-* gettext \
libtool* libmpc-* gettext-* nano fakeroot
# CentOS 8不能直接通过yum安装texinfo,help2man,python-docutils。请去官网下载发行的安装包编译安装
# 以texinfo为例
# cd /usr/local/src
# sudo wget http://ftp.gnu.org/gnu/texinfo/texinfo-6.7.tar.gz
# sudo tar zxvf texinfo-6.7.tar.gz
# cd texinfo-6.7
# sudo ./configure
# sudo make
# sudo make install
cd /opt/rt-n56u/toolchain-mipsel
# (推荐)使用脚本下载预编译的工具链:
sh dl_toolchain.sh
# 或者,也可以从源码编译工具链,这需要一些时间:
./clean_toolchain
./build_toolchain
开始编译
cd /opt/rt-n56u/trunk
# 对于WSL环境,建议使用sudo进行编译,或者使用fakeroot-tcp代替fakeroot
fakeroot ./build_firmware_modify PSG1218
# 脚本第一个参数为路由型号,在trunk/configs/templates/中
# 编译好的固件在trunk/images里
# 首次编译完成后,如果需要再次编译其它固件,需要执行清理脚本:
./clear_tree
---
http://blog.xqlee.com/article/2412260938214669.html