# openwrt on mt7688 ## 目的: 在openwrt上面編入自行開發的模組 ## 環境 * Host os:Ubuntu 16.04 * Guest os:hiwooya openwrt ## 作法: 步驟1~4參考關係圖: ![](https://i.imgur.com/lfo85pR.jpg) 步驟5參考關係圖: ![](https://i.imgur.com/JpWdGFE.jpg) 1. 按照程式裡面 **packages/utils/** 裡面的模組製作一份名為**test** 的模組,其中在test模組底下的Makefile裡的相關模組名稱皆需都改為**test** , 2. 如果在**test** 模組底下有用到其他函式庫如pthread、json-c,需在Makefile的**define Package/test** 底下加入 ```bash= DEPENDS:=+libpthread +libjson-c ``` 3. 在src資料夾底下是在一般linux系統下編寫程式所需要的檔案(c檔和h檔)以及Makefile 4. 假設這個模組有產生一個以上的執行檔(包含一個)**exec_a**、**exec_b**,則需在test底下Makefile裡面的 **define Package/test/install** 底下加入 ```bash= $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_BUILD_DIR)/exec_a $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/exec_b $(1)/usr/sbin/ ``` 5. 之後鍵入 **make menuconfig**到Utilities底下找到test的選項並勾成星號,之後儲存後並離開選單。 6. 鍵入 **make V=99**,之後等待編譯完成。 7. 若是成功可在**build_dir/target-mipsel_......** 底下看到找到test的資料夾,並在底下找到 **exec_a** 、**exec_b**兩個mips的執行檔。 8. 之後將 **/bin/ramips/openwrt-ramips-mt7628-HiWooya7628-squashfs-sysupgrade.bin**燒入即可。 如果需要單獨編譯某個模組則可以參考資料8,指令如下: ```bash= make V=99 package/util/module_name/compile ``` ## 參考資料 1. [OpenWRT交叉編譯nodeJS](https://zh.codeprj.com/blog/94a9fa1.html) 2. [OpwnWrt中文件夹`staging_dir`和`build_dir`的含义](https://blog.csdn.net/u014436243/article/details/105999980) 3. [OpenWRT的包依赖 package DEPEND](https://blog.csdn.net/stone8761/article/details/71125385) 4. [关于Openwrt编译出现“blobmsg_json.c json.h: No such file”的问题](https://www.codeleading.com/article/3113150436/) 5. [openwrt 缺少 libc.so.6 libm.so.6 libpthread.so.0](https://blog.csdn.net/xiaohu1996/article/details/99612738) 6. [Openwrt Package xxx is missing dependencies for the following libraries 问题分析](https://blog.csdn.net/fickyou/article/details/52794300) 7. [MT7688学习笔记(1)——搭建环境、编译烧写](https://blog.csdn.net/qq_36347513/article/details/81508385) 8. [模組編譯參數](http://cache.nxp.com/zh-Hans/files/FTF-DES-N1853.pdf) 9. [建立編譯環境 (SDK for .ipk 封裝)](https://openwrt-nctu.gitbook.io/project/openwrt-compile-env/openwrt-sdk-and-ipk-format) ###### tags: `linux` `openwrt` `linux`