Openwrt development peripheral preparation work: (zero) compile openwrt firmware

Foreword

During the development process, I found that the downloaded firmware does not have the functions I need, so I learned the operation of custom firmware.
This article will briefly describe how to compile your own firmware from scratch.
My firmware requirements are x86, with luci, with serial port driver ch341, and rt3070 driver.
Compiling custom firmware is an indispensable part of learning openwrt, remember!

Prepare compilation tools

In order to prevent the error that some tools are insufficient during the compilation process, first prepare the relevant content in advance.
Note: The following ... OK is similar to what I added to mark the progress. In actual use, you should enter something like :sudo apt-get install g++

sudo apt-get install g++  。。。OK
sudo apt-get install libncurses5-dev  …OK  
sudo apt-get install zlib1g-dev …OK
sudo apt-get install bison  …OK
sudo apt-get install flex   …OK
sudo apt-get install unzip  …OK
sudo apt-get install autoconf  …OK
sudo apt-get install gawk  …OK
sudo apt-get install make  …OK
sudo apt-get install gettext  …OK
sudo apt-get install gcc  …OK
sudo apt-get install binutils   …OK
sudo apt-get install patch  …OK
sudo apt-get install bzip2  …OK
sudo apt-get install libz-dev  …OK
sudo apt-get install asciidoc  …OK  
sudo apt-get install subversion  …OK
sudo apt-get install sphinxsearch  …OK
sudo apt-get install libtool   …OK
sudo apt-get install sphinx-common  …OK
sudo apt-get install libssl-dev  …OK
sudo apt-get install libssl0.9.8  …OK
sudo apt-get install git-core  …OK
sudo apt-get install build-essential   …OK
sudo apt-get install mercurial   …OK

Clone the required source code

Find an empty folder , open it in non-root mode , and then execute the following command
git clone git://github.com/openwrt/openwrt.git

Download components

Take the previous step, enter the directory,
cd openwrt
and then download and install the components

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

Note that sometimes the incomplete download of the component may cause an error in the installation process, usually only need to repeat the above 3 lines of instructions to solve.
At this point, if there is no error, you can proceed to the next step

Configuration function

The directory is unchanged, use the command
make menuconfig
and then an interface will open, roughly as follows
the upper half of the page that needs attention :
Insert picture description here
the lower half of the page that needs attention:

Insert picture description here

Select environmental model

Please choose according to your own equipment , I am a virtual machine, so choose x86_64
Insert picture description here

Drive related

Insert picture description here
After entering the drive-related items, focus on these few items I instructed, and then configure these related content.

Configure network related drivers

Insert picture description here
Because we want to play ppp dialing, these need to be selected.

Configure USB related drivers

Insert picture description here
Mainly two parts: one supports serial port to USBCH341 and the
Insert picture description here
other is for network card preparation

Configure wireless driver

Insert picture description here
I also forgot which one the 3070 was. I chose it all, without losing. (Some places have bugs in multiple choices, such as luci, you need to pay attention).

Add LUCI page

Insert picture description here
Insert picture description here
Insert picture description here
As shown in the figure, check the items.
I have suffered a loss here. Because I did not check the relevant items, I could not open the luci interface of ipv4, but only the interface of ipv6. I forgot which specific item, if the same problem occurs, please carefully check whether the luci related function is checked.
At present, it should be checked.

Configuration network related

Insert picture description here
It's still the same, mainly ppp

Save arrangement

Insert picture description here
Insert picture description here
Don't forget to save! !
Don't forget to save! !
Don't forget to save! !

(The important thing is said 3 times)

Perform compilation

Clear the old data
make clean
and compile. During the
make v=99
compilation process, such errors may occur:
···

  • check_data_file_clashes: Package libustream-openssl20150806 wants to install file /home/b/Desktop/test_openwrt/openwrt/build_dir/target-i386_pentium4_musl/root-x86/lib/libustream-ssl.so
    But that file is already provided by package * libustream-mbedtls20150806
  • opkg_install_cmd: Cannot install package libustream-openssl20150806.
  • check_data_file_clashes: Package nginx-mod-luci-ssl wants to install file /home/b/Desktop/test_openwrt/openwrt/build_dir/target-i386_pentium4_musl/root-x86/etc/nginx/conf.d/luci.locations
    But that file is already provided by package * nginx-mod-luci
  • check_data_file_clashes: Package nginx-mod-luci-ssl wants to install file /home/b/Desktop/test_openwrt/openwrt/build_dir/target-i386_pentium4_musl/root-x86/etc/uci-defaults/60_nginx-luci-support
    But that file is already provided by package * nginx-mod-luci
  • opkg_install_cmd: Cannot install package nginx-mod-luci-ssl.

···
Solution: Uncheck:
nginx-mod-luci-ssl, nginx-mod-luci-ssl, libustream-openssl20150806
encounter this kind of error. If you want to carefully check the configuration options, whether you have selected more.
make menuconfig
Check carefully
and then compile again.
If you ca n’t find it, you can only
mv .config .config.bak
make clean
start from the beginning.

Get compilation results

After the compilation is completed, if there is no error and the compilation is terminated, there is a required burning file in the directory below (I need: openwrt-x86-generic-combined-squashfs.img.gz)
Insert picture description here

Record some pits:

make -C /home/b/Desktop/test_openwrt/openwrt/build_dir/target-x86_64_musl/linux-x86_64/linux-5.4.24 KCFLAGS="-ffile-prefix-map=/home/b/Desktop/test_openwrt/openwrt/build_dir/target-x86_64_musl=target-x86_64_musl" HOSTCFLAGS="-O2 -I/home/b/Desktop/test_openwrt/openwrt/staging_dir/host/include -I/home/b/Desktop/test_openwrt/openwrt/staging_dir/hostpkg/include -I/home/b/Desktop/test_openwrt/openwrt/staging_dir/target-x86_64_musl/host/include -Wall -Wmissing-prototypes -Wstrict-prototypes" CROSS_COMPILE="x86_64-openwrt-linux-musl-" ARCH="x86" KBUILD_HAVE_NLS=no KBUILD_BUILD_USER="" KBUILD_BUILD_HOST="" KBUILD_BUILD_TIMESTAMP="Wed Mar 18 22:55:51 2020" KBUILD_BUILD_VERSION="0" HOST_LOADLIBES="-L/home/b/Desktop/test_openwrt/openwrt/staging_dir/host/lib" KBUILD_HOSTLDLIBS="-L/home/b/Desktop/test_openwrt/openwrt/staging_dir/host/lib" CONFIG_SHELL="bash" V=''  cmd_syscalls= KERNELRELEASE=5.4.24 CC="x86_64-openwrt-linux-musl-gcc" M="/home/b/Desktop/test_openwrt/openwrt/build_dir/target-x86_64_musl/wifidog-ng-nossl" modules
make[4]: Entering directory `/home/b/Desktop/test_openwrt/openwrt/build_dir/target-x86_64_musl/linux-x86_64/linux-5.4.24'
  CC [M]  /home/b/Desktop/test_openwrt/openwrt/build_dir/target-x86_64_musl/wifidog-ng-nossl/main.o
/home/b/Desktop/test_openwrt/openwrt/build_dir/target-x86_64_musl/wifidog-ng-nossl/main.c:17:10: fatal error: net/netfilter/nf_nat_l3proto.h: No such file or directory
 #include <net/netfilter/nf_nat_l3proto.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[6]: *** [/home/b/Desktop/test_openwrt/openwrt/build_dir/target-x86_64_musl/wifidog-ng-nossl/main.o] Error 1
make[5]: *** [/home/b/Desktop/test_openwrt/openwrt/build_dir/target-x86_64_musl/wifidog-ng-nossl] Error 2
make[4]: *** [sub-make] Error 2
make[4]: Leaving directory `/home/b/Desktop/test_openwrt/openwrt/build_dir/target-x86_64_musl/linux-x86_64/linux-5.4.24'
make[3]: *** [/home/b/Desktop/test_openwrt/openwrt/build_dir/target-x86_64_musl/wifidog-ng-nossl/.built] Error 2
make[3]: Leaving directory `/home/b/Desktop/test_openwrt/openwrt/feeds/packages/net/wifidog-ng'
time: package/feeds/packages/wifidog-ng/nossl/compile#2.52#3.63#6.61
make[2]: *** [package/feeds/packages/wifidog-ng/compile] Error 2
make[2]: Leaving directory `/home/b/Desktop/test_openwrt/openwrt'
make[1]: *** [/home/b/Desktop/test_openwrt/openwrt/staging_dir/target-x86_64_musl/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/b/Desktop/test_openwrt/openwrt'

Solution: Give up the wifidog and look at the source code. The source code itself has a grammatical error, but I wo n’t fix it. I fumbled for a day and gave up.

Conclusion

The compilation speed is very slow, really slow. If you start from scratch after cleaning, it may take about 3 to 5 hours, depending on your performance and network speed (a lot of content needs to be downloaded from the Internet), there are many ways to Accelerate this speed, but for the player who compiles for the first time, it is still appropriate to use it after completing the process. If there is an error in the compilation, actively solve the error and then continue to compile, do not continue to compile directly, the error or the error will not disappear by itself (except for errors caused by the network)
I wish you all the best to get the desired firmware, come on |

Published 19 original articles · Liked5 · Visit 1283

Guess you like

Origin blog.csdn.net/ex_xyz/article/details/104964615