第 1 節

Preparing the compilation environment

0瀏覽次數0訪問次數--跳出率--平均停留

Environment Description: This tutorial uses Ubuntu 22.04 as the environment.

Please ensure the compilation process is globally magical.

Basic compilation process

Set environment variables (not sure if useful):

注意使用root编译会报错,可以在/etc/profile 最后添加export FORCE_UNSAFE_CONFIGURE=1,然后执行
export FORCE_UNSAFE_CONFIGURE=1
  1. System software package update
sudo apt-get -y update && sudo apt-get -y upgrade
  1. Install dependencies and the compilation toolchain
sudo apt install -y ack antlr3 aria2 asciidoc autoconf automake autopoint binutils bison build-essential \
bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib \
git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev \
libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libtool lrzsz \
mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pip libpython3-dev qemu-utils \
rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev
  1. Download OpenWrt source code
git clone https://github.com/openwrt/openwrt.git && cd openwrt 
git clone https://github.com/coolsnowwolf/lede && cd lede

# 还有个
git clone https://github.com/istoreos/istoreos

(There are many source codes available; this tutorial uses the official source code and LEDE as examples.)

  1. Switch to the appropriate branch.

openwrt-22.03 has removed iptables. To avoid compatibility issues, temporarily switch to the openwrt-21.02 branch:

git checkout openwrt-21.02
  1. Update and install feed software sources.
./scripts/feeds update -a && ./scripts/feeds install -a

(The following is for campus network anti-detection deployment)

  1. Join module
git clone https://github.com/Zxilly/UA2F.git package/UA2F
git clone https://github.com/CHN-beta/rkp-ipid.git package/rkp-ipid
  1. Configuration Editing
make menuconfig

Configure and compile rdp-ipid:

  • Kernel modules → Other modules → kmod-rkp-ipid

Configure and compile ua2f:

  • Network → Routing and Redirection → UA2F

Configure and compile the iptables module (in Firewall)

Selected:

  • iptables-mod-filter
  • iptables-mod-ipopt
  • iptables-mod-u32

Basic Interface Configuration:

  • LuCI → Collections → luci (selected by default in LEDE)
  • LuCI → Modules → Translations → Chinese Simplified (zh_Hans) (already selected by default in LEDE)
  • LuCI → Modules → luci-compat
  • LuCI → Applications → luci-app-ttyd (web terminal)
  • LuCI → Themes → xxxxx (choose the admin interface theme as needed; if the router's storage is too small, it's recommended to keep the default).

Other configurations:

  • Add EXT4 hard disk format support: Kernel modules > Filesystem > kmod-fs-ext4
  • Add USB support (if not added, the keyboard may not respond): Kernel modules > USB Support

Network card driver configuration:

  • After checking, the network card uses the Intel I211-AT, which runs on the PCIe bus. The e1000e driver should be selected here.
  • Kernel modules > Network Devices
    Select the kmod-e1000e and kmod-igb drivers.

Wireless network card driver:

  • Find the RTL8821AE driver in the wireless drivers within the kernel.
  • Kernel modules > Wireless Drivers

Author: KANSUNG Link: https://www.jianshu.com/p/5190ab903820 Source: Jianshu

Add other tools (optional):

  • LuCI > Applications -> luci-app-openclash
  • LuCI > Applications -> luci-app-adblock
  • LuCI > Applications -> luci-app-ddns-go

Add necessary components:

  • Kernel modules -> Network Support -> kmod-tun (required for OpenClash TUN mode)

Exclude conflicting components:

  • Base system -> dnsmasq (uncheck, because dnsmasq-full is installed by default, and dnsmasq must be excluded to avoid conflict errors)

Edit the configuration file:

  • Using vim .config, add a line at the beginning (required by the UA2F plugin):
CONFIG_NETFILTER_NETLINK_GLUE_CT=y
  1. Compile and configure the kernel
make kernel_menuconfig
make -j1 V=sc kernel_menuconfig  # 日志更详细

Configuration path: Networking support → Networking options → Network packet filtering framework (Netfilter) (select it first before entering) Core Netfilter Configuration →

Select the following options:

  • Netfilter NFNETLINK interface
  • Netfilter LOG over NFNETLINK interface
  • Netfilter connection tracking support
  • Connection tracking netlink interface
  • NFQUEUE and NFLOG integration with Connection Tracking
  1. Compile Download the compilation tools:
make download -j$(nproc) V=s

Start compiling:

make -j$(nproc) V=s
make -j1 V=sc 2> build.log  # 错误输出到日志

For a second compilation, you need to update the source code:

git pull

Reconfigure If you need to reconfigure:

rm -rf ./tmp && rm -rf .config
make menuconfig
make -j$(($(nproc) + 1)) V=s   # 多线程编译失败后自动进入单线程编译,失败则输出详细日志

Clear old build artifacts:

make clean

Execute after large-scale source code updates or kernel updates to ensure compilation quality. This operation will delete files in the /bin and /build_dir directories.

Clean up old build artifacts, cross-compilation tools, toolchain directories, and similar items.

make dirclean

Must be executed before switching architectures for compilation. This operation deletes files in the /bin and /build_dir directories (make clean), as well as files in /staging_dir, /toolchain, /tmp, and /logs.

Clear files outside the OpenWrt source code (optional):

make distclean

Unless you are doing development and plan to push to a remote repository like GitHub, this is almost never needed. This operation is equivalent to make dirclean plus deleting the /dl, /feeds directories and the .config file.

Restore OpenWrt source code to its original state (optional):

git clean -xdf

If you have broken the source code or haven't compiled it in a long time.

Clear temporary files:

rm -rf tmp

Delete temporary files generated after running make menuconfig, including some package search information. After deletion, the packages in the package directory will be reloaded. If not deleted, some newly added packages may not appear.

Delete the build configuration file.

rm -f .config

If you deselect certain components without removing them, their dependent components will not be automatically deselected. Therefore, it is recommended to delete the components when adjustments are needed.

Note: Do not use the root user for any operations.

Copyright notice: This post is original content by the blogger, licensed under the CC 4.0 BY-SA copyright agreement. Please include the original source link and this notice when reposting.

Original link: https://blog.csdn.net/u010674953/article/details/129280724

音乐页