# Build openwrt and u-boot for mt7688 from source Host: Ubuntu 18.04 Target: openwrt ## 安裝相關ubuntu套件 ```bash= sudo apt-get install libncurses5-dev zlib1g-dev gawk flex patch git-core g++ subversion ``` ## 取得原始碼 ```bash= git clone https://github.com/hi-wooya/openwrt-hiwooya.git git clone https://github.com/hi-wooya/u-boot-hiwooya.git cd u-boot-hiwooya tar xvf buildroot-gcc342.tar.bz2 make CROSS_COMPILE=../u-boot-hiwooya/buildroot-gcc342/bin/mipsel-linux- ``` 之後變回得到uboot.bin。之後開始編譯openwrt ```bash= cd openwrt-hiwooya ./scripts/feeds update -a ./scripts/feeds install -a ``` 先新增三個patch 1. openwrt/tools/pkg-config/patches/001-glib-gdate-suppress-string-format-literal-warning.patch(資料八) 2. openwrt/tools/automake/patches/210-fix-bug-because-of-high-perl-version.patch(資料八) 3. openwrt/tools/mkimage/patches/200-compiler-support.patch(資料七) 之後會遇到"cfns.gperf:101:1: error: 'const char* libc_ ..."的問題,可以按照參考資料九的內容將兩個檔案(cfns.gperf和cfns.h)修該程式內容。 --- 之後下命令 ```bash= make V=99 ``` 成功編譯候會在**bin/rampips**下得到**openwrt-ramips-mt7688-HIWOOYA16128-squashfs-sysupgrade.bin**檔案。 ## 參考資料 1. [hi-wooya github](https://github.com/hi-wooya) 2. [GNU-A Downloads](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads) 3. [(七)ubuntu下编译openwrt内核的环境配置](https://www.cnblogs.com/zhangshenghui/p/6776128.html) 4. [hi-wooya/openwrt-hiwooya](https://github.com/hi-wooya/openwrt-hiwooya) 5. [解决perl高版本编译automake出错问题](https://blog.csdn.net/Javin_L/article/details/96011718) 6. [gdate.c:2497:7: error: format not a string literal, format string not checked ](https://blog.csdn.net/zmlovelx/article/details/81664043) 7. [解决编译openwrt mkimage时出现“linux/compiler-gcc7.h: No such file or directory”错误](https://blog.csdn.net/Javin_L/article/details/94745468) 8. [openwrt 编译坑](https://www.jianshu.com/p/3195df3f747d) 9. [openwrt报错:[PATCH] cfns: fix mismatch in gnu_inline attributes](https://blog.csdn.net/ScarletMeCarzy/article/details/104275607) 10. [[OpenWrt] patch 管理及 quil](http://lirobo.blogspot.com/2013/03/openwrt-patch-quilt.html) ###### tags: `openwrt` `mt7688` `linux`