OpenWrt v18.06.1下载编译全过程(MT7628AN+MT7612EN+64MB DDR+8M SNOR路由器)

我用一台ubuntu 12.04作为服务器,一台windows电脑开发用,两台电脑连接到同一个路由器上。

为了节省系统资源,我决定在windows端用ssh远程登录。

把ubuntu的SSH功能打开,

#设置root权限 sudo passwd root #输入新密码 su –      #切换到root用户下

apt-get install openssh-server

ps -e | grep ssh #有sshd,说明ssh服务已经启动,如果没有启动,输入:

service ssh start

#修改/etc/rc.local文件,在exit 0这一句的前面,添加/etc/init.d/ssh start可让此服务开机自动启动

#打开下面的文件,将PermitRootLogin的值改为yes gedit /etc/ssh/sshd_config

#因为root账户设置了密码,所以还要更改PermitEmptyPasswords为no,然后保存文件。

services ssh restart #重启ssh服务

在Windows电脑上,用SecureCRT等工具,可远程登录SSH服务器。

下载OpenWRT最新源码:

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

#查看所有的tag git tag

#查看最新稳定版本对应的版本号 git show v18.06.1

commit 70255e3d624cd393612069aae0a859d1acbbeeae Author: Jo-Philipp Wich [email protected] Date: Thu Aug 16 18:36:48 2018 +0200

OpenWrt v18.06.1: adjust config defaults

Signed-off-by: Jo-Philipp Wich <[email protected]>

diff –git a/feeds.conf.default b/feeds.conf.default index 763a269..9dddc19 100644 — a/feeds.conf.default +++ b/feeds.conf.default

#将最新源码切换到v18.06.1稳定版本对应的版本号 git reset –hard 70255e3d624cd393612069aae0a859d1acbbeeae

/config : configuration files for menuconfig /include : makefile configuration files /package : packages makefile and configuration /scripts : miscellaneous scripts used throughout the build process /target : makefile and configuration for building imagebuilder, kernel, sdk and the toolchain built by buildroot. /toolchain : makefile and configuration for building the toolchain /tools : miscellaneous tools used throughout the build process

网上的编译教程很多,为了避免走弯路,我还是以openwrt官网的参考资料为准:

#编译前,安装依赖的库和工具,Build system – Installation https://openwrt.org/docs/guide-developer/build-system/install-buildsystem

#Ubuntu 12.04 LTS:

sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip

#Updating Feeds:https://openwrt.org/docs/guide-developer/build-system/use-buildsystem #Installing in context of ./scripts/feeds script means “making package available in make menuconfig” rather than really installing or compiling package.

#Update feeds: ./scripts/feeds update -a

#Make downloaded package/packages available in make menuconfig:./scripts/feeds install

./scripts/feeds install -a -p luci

#安装all packages,可能会导致安装包过大,这里我先不执行: ./scripts/feeds install -a

#接下来是Image Configuration #Typical actions:

#run make menuconfig and set target; #run make defconfig to set default config for build system and device; #run make menuconfig and modify set of package; #run make download (download all dependency source files before final make, enables multi-core compilation); #run scripts/diffconfig.sh >mydiffconfig (save your changes in the text file mydiffconfig);

Target System (MediaTek Ralink MIPS) —>
Subtarget (MT76x8 based boards) —>
Target Profile (MediaTek MT7628 EVB) —>
LuCI—>Collections—– <> luci #添加Luci LuCI—>Translations—- <> luci-i18n-chinese #添加中文

#最后是编译,一般情况,使用一个简单的命令: make #默认安装,无提示 #或者make V=99 #V=99表示输出debug信息,V一定要大写 #或者make -j V=99 #如果要让CPU全速编译,就加上 -j 参数,第一次编译最好不带-j参数,常规用法为 <您cpu处理器的数目 + 1>

#编译错误与解决办法: configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check) #解决方法:export FORCE_UNSAFE_CONFIGURE=1

#编译错误:openwrt-ramips-***-XXX-squashfs-sysupgrade.bin is too big,failed to build firmware.

#解决方法:

git diff target/linux/ramips/image/mt76x8.mk diff –git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk index 21c5357..79b9680 100644 — a/target/linux/ramips/image/mt76x8.mk +++ b/target/linux/ramips/image/mt76x8.mk @@ -84,7 +84,7 @@ TARGET_DEVICES += miwifi-nano define Device/mt7628 DTS := MT7628 BLOCKSIZE := 64k