如何自己編譯openwrt固件


1,配置Linux虛擬機或者WSL ubuntu

2,根據大佬的git下載源碼

https://github.com/coolsnowwolf/lede

 

  • 首先裝好 Ubuntu 64bit,推薦 Ubuntu 20.04 LTS x64

 

  • 命令行輸入 sudo apt-get update ,然后輸入 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
  • 使用 git clone https://github.com/coolsnowwolf/lede 命令下載好源代碼,然后 cd lede 進入目錄

3,可以根據需要添加不同的feeds源

添加下面代碼到 openwrt 或 lede 源碼根目錄 feeds.conf.default 文件

src-git kenzo https://github.com/kenzok8/openwrt-packages
src-git small https://github.com/kenzok8/small

 

 4, 更新feeds

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

5,配置

make menuconfig

k2p 按如下配置

Target System => MediaTek Ralink MIPS
Subtarget => MT7621 based boards
Target Profile => Phicomm K2P

自定義插件

LuCI => Applications

選完之后save,會生成一個.config的文件

6,因為在本地經常失敗,所以建議進行在線編譯

Git上Fork這個項目:

https://github.com/P3TERX/Actions-OpenWrt

然后根據說明來:

  • Push .config file to the GitHub repository. - 上傳.config文件
  • Select Build OpenWrt on the Actions page. - 在action頁面選擇Build OpenWrt
  • Click the Run workflow button. - 直接點Run workflow
  • When the build is complete, click the Artifacts button in the upper right corner of the Actions page to download the binaries. - 等結束后,點進去,會看到有個文件可以下載,下載完解壓,會有個類似sysupgrade的文件,如果沒有,是因為固件超過了大小限制,k2p只能接受16M以下的

7,如果你在本地生成.config的時候有添加其他feeds到feeds.conf.default,那么在線編譯的時候,需要diy-part1.sh,添加類似於以下的命令:

# Add a feed source
echo 'src-git kenzo https://github.com/kenzok8/openwrt-packages' >>feeds.conf.default
echo 'src-git small https://github.com/kenzok8/small' >>feeds.conf.default

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM