1 -> Introduction to openWrt, download source code, compile

This article records the process of building the openWrt development environment and understanding of the openwrt system.

Section 1 Introduction to openwrt

The OpenWrt project started in January 2004, and its first version adopted the source code of LinkSys. After the LinkSys code charges, it is changed to adopt the officially released Linux kernel to integrate, and OpenWrt is completely modularized, and patches and drivers are continuously introduced. OpenWrt is a Linux-based smart router operating system, released under the GPL license agreement, and users can customize and install various application software.
The main feature of OpenWrt is its high scalability and writable file system. Developers do not need to completely recompile after every modification, as long as they compile their own software packages, so that users can customize the installation to manage the router.

Section 2 Build Compilation Environment The
build environment of this article is an ubuntu-16 64-bit system, with a good network environment and scientific Internet access (download the dependency package in the compilation environment).

2.1 Download the source code
Download the source code in the way of download rar package, don't use the way of git clone! ! ! Download the corresponding version according to your needs
https://github.com/openwrt/openwrt
This document uses the openwrt-19.07 version.

2.2 Install compile dependencies in ubuntu environment
Command line input

sudo apt-get update 

Then type

sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib antlr3 gperf wget curl swig rsync

Section 3 source code compilation

After entering the source directory of openwrt, execute the following statements in sequence. Warnings or error messages that appear during this period are generally lack of downloaded files and need to be resolved one by one.

./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig  # 建议:首次编译时,不要选择很多配置包,越简洁越好。如果参考此文章、编译源码的话请看完第4节。

The code does not contain third-party open source packages, only the link to the open source package address, and manually download the compilation dependency package

make -j1 download

Resolve missing packages in this process.

make -j1 V=s  # -j1 后面是线程数。第一次编译推荐用单线程,V=s 显示编译过程信息,便于解决出错问题。

Section 4 Compilation Process Record

Note:
Modify the content in the source download path feeds.conf.default file:

# 修改为 github.com
src-git packages https://git.openwrt.org/feed/packages.git
src-git luci https://git.openwrt.org/project/luci.git
src-git routing https://git.openwrt.org/feed/routing.git
src-git telephony https://git.openwrt.org/feed/telephony.git
src-git freifunk https://github.com/freifunk/openwrt-packages.git
#src-git video https://github.com/openwrt/video.git
#src-git targets https://github.com/openwrt/targets.git
#src-git management https://github.com/openwrt-management/packages.git
#src-git oldpackages http://git.openwrt.org/packages.git
#src-link custom /usr/src/openwrt/custom-feed

There were many errors during the entire compilation process, and it was a pity that not all records were left.
Error log

/home/laoli/routeOS/routing/build_dir/hostpkg/libubox-2020-12-12-35787769/blobmsg_json.c:23:24: fatal error: json/json.h: No such file or directory
  #include <json/json.h>                  
compilation terminated.

Solution:

// C 版本
sudo apt-get install libjson0-dev libjson0

// git 安装 未验证
git clone https://github.com/json-c/json-c.git
cd json-c
sh autogen.sh
./configure
make
sudo make install
// C ++ 版本
sudo apt-get install libjsoncpp-dev
// 以上两种方法都未能解决问题。

There are two types of common errors during compilation:

  1. In the compilation environment, the compilation dependency files are missing, such as the case of json-c.
  2. When configuring openwrt related functions, the dependency content conflicts.
    According to the error message, bing or google solve them one by one.

Reference materials:
OpenWrt official website: (https://openwrt.org/)
OpenWrt github: (https://github.com/openwrt/openwrt)
Dadiao's github: (https://github.com/coolsnowwolf/lede )
Jiangnan and Dong Shao's blog: (https://blog.csdn.net/qq_41453285/category_9376523.html)

Guess you like

Origin blog.csdn.net/weixin_38387929/article/details/111385829