OPENWRT开发虚拟机安装及配置开发编译环境

时间:2024-03-15 17:21:57

1、下载虚拟机VMWARE和UBUNTU

ubuntu-16.04.4-desktop-amd64.iso

VMware-workstation-full-14.1.2-8497320.exe

编译OpenWrt需要Linux环境或mac环境,不支持Windows,如果要在Windows上开发,那么肯定是要装虚拟机的。

Linux(建议使用Ubuntu14.04/16.04 32位/64位版本)

注意,在Ubuntu18.04上编译将无法通过,所以推荐使用低版本编译 
编译前要安装以下依赖:

  $ sudo apt-get update 
  $ 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-7-jdk


Ubuntu16.04 安装openjdk-7-jdk 

sudo apt-get install openjdk-7-jre 或者sudo apt-get install openjdk-7-jdk

Ubuntu16.04的安装源已经默认没有openjdk7了,所以要自己手动添加仓库,如下:

# 1. oracle openjdk ppa source
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-7-jdk  // OpenJdk 7安装


如果是64位,需要多操作如下步骤:

  $ sudo dpkg --add-architecture i386
  $ sudo apt-get update
  $ sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

2、下载LEDE源码

LEDE Source Code Repositories

Any LEDE development happens in the main openwrt.git repository which is accessible via both HTTP and HTTPS:

git clone https://git.openwrt.org/openwrt/openwrt.git

You can find a mirror of the repository on Github:

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

git clone https://git.openwrt.org/openwrt/openwrt.git/
cd openwrt

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

3、配置编译选项
打开网页https://downloads.lede-project.org/releases/17.01.4/targets/ramips/mt7628/;

里面有一个config.seed文件。把从config.seed文件拷贝到编译根目录openwrt,

执行cp config.seed .config

把默认的配置文件改写成已配置好的config文件。


make menuconfig

OPENWRT开发虚拟机安装及配置开发编译环境

Select exit and save your settings. Now build images. That may take some time:

首先执行make download 把所有的包文件及依赖文件下载完毕;

很多包都在http://sources.lede-project.org/  里

下载完成之后执行:

make

make完毕后会得到firmware升级文件;

Afterwards, the images can be found in ./bin/targets/ar71xx/generic/ - done. OPENWRT开发虚拟机安装及配置开发编译环境

  • The *-factory.bin images are for the first installation.
  • The *-sysupgrade.bin images are for the updating existing LEDE installations.

Notes:

  • For recompiling the images, just execute make again.
  • For faster compiling, use make -j N, where N is the number of CPU cores + 1. Be aware that this method is prone to errors during compiling. In case you encounter compile errors, your very first step is to compile again without -j N. Use of make download prior to parallel compilation is recommended to prevent some of these errors (-jN is generally safe for the download step for those with faster Internet connectivity.)
  • Change settings with make menuconfig and compile again.
  • You can include custom files in your image by placing them in <buildroot>/files, e.g. if you want to have my_config included in your image in the directory /etc/config/ ⇒ <buildroot>/files/etc/config/my_config. If the files directory doesn't exist on your buildsystem, then create it.