1. 程式人生 > >zipgateway-2.61.0 移植到MTK openwrt-3.10.14

zipgateway-2.61.0 移植到MTK openwrt-3.10.14

zipgateway-2.61.0 移植到MTK  openwrt-3.10.14 過程中可能遇到的問題:一)編譯大致步驟
1)解壓zipgateway-2.61.0原始碼
2)在openwrt原始碼的package目錄中建立zipgateway-2.61.0-Source目錄;
3)參考zipgateway-2.61.0-Source\usr\local\WRTpackage\README 檔案拷貝zipgateway
    a)拷貝WRTpackage的檔案到openwrt中
      cp -r  xxx/zipgateway-2.61.0-Source/usr/local/WRTpackage    openwrt原始碼目錄/package/zipgateway-2.61.0-Source
    b) Makefile 更名為Makefile,並修改內容
        將所有@
[email protected]
  替換成 zipgateway
        將所有@[email protected] 替換成2.61.0
        將 $(PKG_BUILD_DIR)/src/ZIP_Router.linux   修改王維$(PKG_BUILD_DIR)/zipgateway
    c)Makefile 中增加“include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk”以支援cmake
     include $(INCLUDE_DIR)/package.mk
    
include $(INCLUDE_DIR)/cmake.mk    d) 拷貝zipgateway-2.61.0-Source\usr\local中的檔案到“openwrt原始碼目錄/package/zipgateway-2.61.0-Source/src”目錄
 4)make menuconfig 選上zipgateway對應的專案; 然後開始編譯二)libpcap 編譯不通過[ 97%] No patch step for 'libpcap'
[ 97%] No update step for 'libpcap'
[ 98%] Performing configure step for 'libpcap'
configure: loading site script/openwrt/include/site/mipsel-openwrt-linux-uclibc
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for gcc... /openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-uclibc-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/zipgateway-2.61.0/udprelay/libpcap-prefix/src/libpcap':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
make[6]: *** [udprelay/libpcap-prefix/src/libpcap-stamp/libpcap-configure] Error 1上面提示,如果是交叉編譯的話,需要在configure時指定引數"host"
可以在udprelay/CMakeLists.txt 找到如下資訊:
ExternalProject_Add(
  libpcap
  URL http://www.tcpdump.org/release/libpcap-1.5.3.tar.gz
  CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} LDFLAGS=${CMAKE_C_FLAGS} CFLAGS=${CMAKE_C_FLAGS}  --host=${CONFIGURE_HOST} --with-pcap=linux --enable-canusb=no --enable-dbus=no --without-flex --without-libnl --prefix=${CMAKE_BINARY_DIR}/stage
  BUILD_IN_SOURCE 1
)這裡對host的定義是: --host=${CONFIGURE_HOST},在udprelay/libpcap-prefix/src/libpcap/config.log中看到host複製為空, 那麼應該CONFIGURE_HOST未被正確複製;
參考原始碼中其他package對host的定義如下:
--host=mipsel-openwrt-linuxIt was created by LZO configure 2.08, which was
generated by GNU Autoconf 2.69.  Invocation command line was  $ ./configure --target=mipsel-openwrt-linux --host=mipsel-openwrt-linux --build=x86_64-redhat-linux --program-prefix= --program-suffix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls --enable-shared --enable-static## --------- ##
## Platform. ##
## --------- ##
【解決辦法】
修改zipgateway-2.61.0/CMakeLists.txt 中,增加如下行:(zipgateway應該是通過cmake/Rpi.cmake的檔案來指定該引數的,簡單起見我們直接修改CMakeLists.txt)
set(CONFIGURE_HOST mipsel-openwrt-linux)
由於這裡採用的是MTK晶片,所以host是mipsel-openwrt-linux例如
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})set(CONFIGURE_HOST mipsel-openwrt-linux)
if ( NOT LibUSB_LIBRARIES)
  
 find_package(LibUSB 1.0)endif()
三)在板子上執行出現如下的錯誤2349375 Opening config file /usr/local/etc/zipgateway.cfg
Starting Contiki
Opening eeprom file /usr/local/var/lib/zipgateway/eeprom.dat
Error opening eeprom file /usr/local/var/lib/zipgateway/eeprom.dat【解決辦法】
修改zipgateway-2.61.0/pkgconfig.h, 修改如下行;
由於在板子上沒有/usr/local目錄,所以修改為/var和/etc目錄/* directory for local state (default /var) */
//#define  INSTALL_LOCALSTATEDIR "/usr/local/var"
#define  INSTALL_LOCALSTATEDIR "/var"/* directory for config files (default /etc) */
//#define INSTALL_SYSCONFDIR "/usr/local/etc"
#define INSTALL_SYSCONFDIR "/etc"