如何自己编译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