Environment Preparation:
Virtual machine ready, 8-core CPU, 4GB RAM, recommended 40GB hard disk
1. Update Software#
sudo apt-get update
sudo apt-get upgrade
2. Install Dependencies#
sudo apt install -y ack antlr3 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-pyelftools \
libpython3-dev qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip \
vim wget xmlto xxd zlib1g-dev
3. Compile Firmware#
1. Download Source Code, choose any one of the three#
git clone https://github.com/openwrt/openwrt
# Official version
git clone https://github.com/coolsnowwolf/lede
# lede version
git clone -b 22.03 --single-branch https://github.com/Lienol/openwrt
# lienol version
2. Add Plugins or Themes#
After cloning any of the above versions, enter
Open the openwrt folder, find the feeds.conf.default file, open it, and add to the bottom!
src-git amlogic https://github.com/ophub/luci-app-amlogic Must add
src-git alist https://github.com/sbwml/luci-app-alist Alist plugin
src-git passwall_packages https://github.com/xiaorouji/openwrt-passwall.git;packages
src-git passwall_luci https://github.com/xiaorouji/openwrt-passwall.git;luci
src-git kenzo https://github.com/kenzok8/openwrt-packages
src-git argonnew https://github.com/jerrykuku/luci-theme-argon.git;main Theme
3. Update Source Code#
./scripts/feeds update -a
# Update source code
./scripts/feeds install -a
# Copy source code
4. Customize Plugins#
make menuconfig
If reconfiguration is needed
Method: Use the command
rm -rf ./tmp && rm -rf .config
make menuconfig
make V=s -j$(nproc)
5. Download dl library, compile firmware (the number after -j is the number of threads)#
make -j8 download V=s # Download dl library, V=s shows detailed task information
make V=s -j8 # 8 represents threads, adjust according to personal situation
If the compilation fails, you can execute the following commands:
“make clean” deletes files in the compilation directory /bin and /build_dir
“make dirclean” deletes not only the compilation directory but also the compilation tool directory, deletes files in /bin and /build_dir (make clean) as well as files in /staging_dir, /toolchain, /tmp, and /logs, generally only operated when changing CPU architecture.
6. Download Compiled Compressed Package#
After compilation, output path: home/username/openwrt/bin/targets
Appendix: Xiaomi R4A Gigabit Version .config Configuration File#
CONFIG_TARGET_ramips=y
CONFIG_TARGET_ramips_mt7621=y
CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-4a-gigabit=y
CONFIG_PACKAGE_6in4=y
CONFIG_PACKAGE_frpc=y
CONFIG_PACKAGE_ip6tables=y
CONFIG_PACKAGE_ipv6helper=y
CONFIG_PACKAGE_kmod-ip6tables=y
CONFIG_PACKAGE_kmod-ipt-nat6=y
CONFIG_PACKAGE_kmod-iptunnel=y
CONFIG_PACKAGE_kmod-iptunnel4=y
CONFIG_PACKAGE_kmod-nf-ipt6=y
CONFIG_PACKAGE_kmod-nf-log6=y
CONFIG_PACKAGE_kmod-nf-nat6=y
CONFIG_PACKAGE_kmod-nf-reject6=y
CONFIG_PACKAGE_kmod-sit=y
CONFIG_PACKAGE_luci-app-frpc=y
CONFIG_PACKAGE_luci-app-nps=y
CONFIG_PACKAGE_luci-i18n-frpc-zh-cn=y
CONFIG_PACKAGE_luci-i18n-nps-zh-cn=y
CONFIG_PACKAGE_luci-theme-argon-mod=y
CONFIG_PACKAGE_npc=y
Appendix: Enable Root Login SSH Permission on Ubuntu#
-
Switch to root after logging in as a normal user
sudo -i -
Create root administrator password
passwd root
- Enable root login
sudo sed -i 's/^#?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
- Enable password authentication
sudo sed -i 's/^#?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
- Restart ssh service
service sshd restart
Appendix: Method to Enable SSH Login:#
- Must switch to root user
sudo -i
- First update the software list and update software
sudo apt-get update
- First update the software list and update software
sudo apt-get upgrade
- Install ssh
apt-get install ssh
- Start ssh service
sudo /etc/init.d/ssh start