顯示具有 嵌入式系統 標籤的文章。 顯示所有文章
顯示具有 嵌入式系統 標籤的文章。 顯示所有文章

2013年1月6日 星期日

[Embedded] 最近很夯的開發板

最近跟一個朋友聊天, 他推薦了幾個最近很夯的開發板
1.Cubieboard, 由cubieTech所製作
2.UNO.Net, 國人自製

目前我的結論是, 好玩的東西太多了, 可是不同的東西的SDK常常都不相同, 每一種都買來玩玩看當然可以, 可是這就會花很多的時間在重複性的事情(比如說建立環境或是軟硬體整合), 但是產品最重要的價值是在解決問題, 而不是只是玩玩看而已, 希望大家不要陷入這種迷失, 共勉之

2012年7月19日 星期四

[Embedded] "Dynamic Library support not available" in PHP

最近寫PHP extension發現在x86上面跑得很好,但是拿到目標版上就沒反應了,startup_errors也沒有報錯,只好比較一下PHP information(php -i),發現目標版上的phpinfo有一行很詭異
Dynamic Library support not available
.
google了一下才知道原來是dlopen沒找到,因此無法順利載入shared library,解決方法就是

1.修改(增加)PHP的Makefile如下
1 LDFLAGS += -ldl    
2.修改(增加)/path/to/main/php.h如下
 22 #define HAVE_LIBDL 1         
3.修改/path/to/ext/standard/dl.c
 31 #if defined(HAVE_LIBDL)
 32 #include <stdlib.h>
 33 #include <stdio.h>
 34 #ifdef HAVE_STRING_H
to
 31 #if defined(HAVE_LIBDL) || HAVE_MACH_O_DYLD_H
 32 #include <stdlib.h>
 33 #include <stdio.h>
 34 #include <dlfcn.h>
 35 #ifdef HAVE_STRING_H

重新編譯,再執行一次php -i
Dynamic Library Support => enabled
搞定!!

2012年4月23日 星期一

[Embedded] undefined reference to `rpl_malloc'

今天在交叉編譯mhash時發生編譯的錯誤,
../lib/.libs/libmhash.so: undefined reference to `rpl_malloc'

一開始看不出什麼問題,後來爬了一下,才知道原來malloc被換掉了... 
所以把mhash_config.h的define註解掉就可以了

$ vim include/mutils/mhash_config.h
257 /* #define malloc rpl_malloc */ 

2012年3月12日 星期一

[Embedded] Cross Compile SQLite

現在的SoC是越來越強大了,搞的嵌入式系統都要安裝一堆軟體,存一堆資料,SQLite也不lite了...

編譯SQLite相當簡單,假設已經有toolchain長這樣,並且在你的PATH路徑
arm-linux-gcc

設定編譯參數
CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/path/to/install/sqlite3 --enable-readline --enable-threadsafe CFLAGS="-Wall -g -O2 -DSQLITE_MAX_LENGTH=2147483647 -DSQLITE_MAX_SQL_LENGTH=1073741824"

其實要講的是這幾個參數,現在都要開到最大才行...
SQLITE_MAX_LENGTH
The maximum number of bytes in a string or BLOB, 1 billion by default, max by 2147483647
SQLITE_MAX_SQL_LENGTH
The maximum number of bytes in the text of an SQL statement, 1000000 by default, max by 1073741824

reference: Limits In SQLite

2011年11月10日 星期四

[Embedded] Arduino

wiki上的介紹:
Arduino是一個基於開放原始碼的軟硬體平台,構建於開放原始碼simple I/O介面版,並且具有使用類似Java,C 語言的Processing/Wiring開發環境

最近在COSCUP看到這好玩的東西,而本次的COSCUP也邀請了David Cuartielles (Co-Funder of Arduino Platform)做Keynote:Arduino in the DIY Classroom,相關的演講還有使用Arduino開放平台建置智慧型插座,羊逃成熟時-以Arduino開發的互動設計商品RepRap 3D Printer

網路上有許多不錯的資源,目前我看到繁體中文講得最詳細應該是arduino.tw台灣使用者社群Arduino入門教學這一系列的文章吧,未來有其他資訊再繼續補充吧

reference:
* arduino.tw台灣使用者社群
* Arduino入門教學
* INTERACTIVE2GO

2011年6月1日 星期三

[Embedded] How to Porting Qt to Target Board

本篇算是工作紀錄,說明如何移植Qt-4.6.2到某目標板,並能啟動examples下的fancybrowser,能支援中文字型,支援JavaScript,不喜勿入,也不說明是哪個板子,實際移植時還需視當時環境做調整

environment:
* host: ubuntu 10.04
* client: target board(?)

1. Get Source
host$ cd ~
host$ wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.6.2.tar.gz
host$ tar zxvf qt-everywhere-opensource-src-4.6.2.tar.gz


2. Settup Toolchain
2-1) add toolchain to environment variable
host$ vim ~/.bashrc
export MY_TOOLCHAIN=/path/to/toolchain    # add this line
export PATH=$PATH:$MY_TOOLCHAIN           # add this line
host$ source ~/.bashrc


3. Qmake
3-1) http://en.wikipedia.org/wiki/Qmake

3-2) modify [/path/to/qt]/mkspecs/qws/linux-arm-g++/qmake.conf
include(../../common/g++.conf)
include(../../common/linux.conf)
include(../../common/qws.conf)
QMAKE_CC            = /path/to/toolchain/gcc
QMAKE_CXX           = /path/to/toolchain/g++
QMAKE_LINK          = /path/to/toolchain/g++
QMAKE_LINK_SHLIB    = /path/to/toolchain/g++
QMAKE_AR            = /path/to/toolchain/ar cqs
QMAKE_OBJCOPY       = /path/to/toolchain/objcopy
QMAKE_STRIP         = /path/to/toolchain/strip
load(qt_config)

3-3) modify fancybrowser
host$ cd ~/qt-everywhere-opensource-src-4.6.2/example/webkit/fancybrowser
host$ vim main.cpp
#include 
#include "mainwindow.h"

int main(int argc, char * argv[])
{
    QApplication app(argc, argv, QApplication::GuiServer);
    QTextCodec *codec = QTextCodec::codecForName("UTF-8");  // add this line for supporting UTF-8 encodeing
    QTextCodec::setCodecForLocale(codec);                   // add this line
    QTextCodec::setCodecForCStrings(codec);                 // add this line
    QTextCodec::setCodecForTr(codec);                       // add this line
    QFont font("wenquanyi",6);                              // add this line for setting font name
    app.setFont(font);                                      // add this line
    MainWindow browser;
    browser.show();
    return app.exec();
}

host$ vim mainwindow.cpp
//! [2]
    view = new QWebView(this);
    view->load(QUrl("http://www.google.com.tw/"));
    view->settings()->setAttribute(QWebSettings::PluginsEnabled, true);            // add this line
    view->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);         // add this line
    view->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);  // add this line
    connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
    connect(view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
    connect(view, SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
    connect(view, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));


4. Config Parameters & Install
4-1) important parameter
-embedded arm                  // cross-compile for arm platform
-xplatform qws/linux-arm-g++   // cross-compile for arm platform with linux-arm-g++ qmake
-plugin-gfx-directfb           // display with directfb through plugin

4-2) config with your library
host$ ./configure -embedded arm -xplatform qws/linux-arm-g++ -debug -fast -little-endian -no-largefile -accessibility -no-qt3support -webkit -javascript-jit -script -scripttools -qt-zlib -qt-gif -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -no-dbus -no-mmx -no-3dnow -no-sse -no-sse2 -openssl -no-gtkstyle -no-nas-sound -no-opengl -no-openvg -no-sm -no-xshape -no-xsync -no-xinerama -xcursor -no-xfixes -no-xrandr -no-xrender -no-mitshm -no-fontconfig -no-xinput -no-xkb -freetype -no-neon -no-glib -plugin-gfx-directfb -I/path/to/directfb/header -ldirectfb -I/path/to/library/header -L/path/to/shared/library -lg -lssl -lcrypto -lz -lm -lpng -ljpeg -lfreetype -lpthread -v -confirm-license
host$ make
host$ sudo make install

4-3) add Chinese font support(download wenquanyi_120_50.qpf here)
host$ cd /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib
host$ sudo rm -f fonts/*
host$ sudo vim fontdir
wqx wenquanyi_120_50.qpf QPF n 50 120
wqx wenquanyi_120_75.qpf QPF n 75 120
wqx wenquanyi_130_50.qpf QPF n 50 130
wqx wenquanyi_130_75.qpf QPF n 75 130
wqx wenquanyi_150_50.qpf QPF n 50 150
wqx wenquanyi_150_75.qpf QPF n 75 150
wqx wenquanyi_160_50.qpf QPF n 50 160
wqx wenquanyi_160_75.qpf QPF n 75 160
host$ sudo cp [/path/to]/wenquanyi_120_50.qpf fonts

4-4) copy shared library instead of symbolic link
host$ cd /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib
host$ sudo cp libQtNetwork.so.4.6.2 libQtNetwork.so.4
host$ sudo cp libQtNetwork.so.4.6.2 libQtNetwork.so.4.6
host$ sudo cp libQtNetwork.so.4.6.2 libQtNetwork.so
host$ sudo cp libQtGui.so.4.6.2 libQtGui.so.4
host$ sudo cp libQtGui.so.4.6.2 libQtGui.so.4.6
host$ sudo cp libQtGui.so.4.6.2 libQtGui.so
host$ sudo cp libQtCore.so.4.6.2 libQtCore.so.4
host$ sudo cp libQtCore.so.4.6.2 libQtCore.so.4.6
host$ sudo cp libQtCore.so.4.6.2 libQtCore.so
host$ sudo cp libQtXml.so.4.6.2 libQtXml.so.4
host$ sudo cp libQtXml.so.4.6.2 libQtXml.so.4.6
host$ sudo cp libQtXml.so.4.6.2 libQtXml.so
host$ sudo cp libQtMultimedia.so.4.6.2 libQtMultimedia.so.4.6
host$ sudo cp libQtMultimedia.so.4.6.2 libQtMultimedia.so.4
host$ sudo cp libQtMultimedia.so.4.6.2 libQtMultimedia.so
host$ sudo cp libQtScript.so.4.6.2 libQtScript.so.4.6
host$ sudo cp libQtScript.so.4.6.2 libQtScript.so.4
host$ sudo cp libQtScript.so.4.6.2 libQtScript.so
host$ sudo cp libQtScriptTools.so.4.6.2 libQtScriptTools.so.4.6
host$ sudo cp libQtScriptTools.so.4.6.2 libQtScriptTools.so.4
host$ sudo cp libQtScriptTools.so.4.6.2 libQtScriptTools.so
host$ sudo cp libQtSvg.so.4.6.2 libQtSvg.so.4.6
host$ sudo cp libQtSvg.so.4.6.2 libQtSvg.so.4
host$ sudo cp libQtSvg.so.4.6.2 libQtSvg.so
host$ sudo cp libQtWebKit.so.4.6.2 libQtWebKit.so.4.6
host$ sudo cp libQtWebKit.so.4.6.2 libQtWebKit.so.4
host$ sudo cp libQtWebKit.so.4.6.2 libQtWebKit.so
host$ sudo cp libQtSql.so.4.6.2 libQtSql.so.4
host$ sudo cp libQtSql.so.4.6.2 libQtSql.so.4.6
host$ sudo cp libQtSql.so.4.6.2 libQtSql.so

4-5) copy 3rd library (if configure with -openssl)
host$ sudo cp /path/to/libcrypto.so.1.0.0 .
host$ sudo cp /path/to/libssl.so.1.0.0 .
host$ sudo cp /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib/libcrypto.so.1.0.0 libcrypto.so
host$ sudo cp /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib/libssl.so.1.0.0 libssl.so


5. Display Qt Application in Target Board
5-1) setting QtEmbedded-4.6.2-arm environment variable
client# QTDIR=/path/to/QtEmbedded-4.6.2-arm
client# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QTDIR/lib
client# export QT_QWS_FONTDIR=$QTDIR/lib/fonts
client# export QT_PLUGIN_PATH=$QTDIR/plugins
client# export QWS_DISPLAY=directfb

5-2) execute fancybrowser
client# cd /path/to/QtEmbedded-4.6.2-arm
client# cd examples/webkit/fancybrowser
client# ./fancybrowser

reference: Qt for Embedded Linux Environment Variables

2011年3月10日 星期四

[Embedded] How to Cross Compile GNU Project Debugger

0.assume that your toolchain is
arm-linux-gcc
arm-linux-g++
arm-linux-ar
arm-linux-ld
arm-linux-as
arm-linux-strip
...
and under your PATH

1.download termcap
$ wget ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz

2.configure termcap
$ ./configure --target=arm-linux --prefix=/path/to/install/termcap

3.modify Makefile
$ vim Makefile
-CC = gcc
-AR = ar
-RANLIB = ranlib
+CC = arm-linux-gcc
+AR = arm-linux-ar
+RANLIB = arm-linux-ranlib

4.install
$ make && sudo make install

5.download GDB
$ wget ftp://ftp.gnu.org/gnu/gdb/gdb-6.7.1.tar.gz

6.configure GDB
$ env CPPFLAGS=-I/path/to/install/termcap/include LDFLAGS=-L/path/to/install/termcap/lib ./configure --target=arm-linux --prefix=/path/to/install/gdb

7.if error has occurred like this:
cc1: warnings being treated as errors
eval.c: In function 'evaluate_subexp_standard':
eval.c:1676: error: 'subscript_array' may be used uninitialized in this function
make[2]: *** [eval.o] Error 1
make[2]: Leaving directory `/usr/local/src/gdb-6.7.1/gdb'
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory `/usr/local/src/gdb-6.7.1'
make: *** [all] Error 2

patch code
--- insight-6.7.1.dfsg.1.orig/gdb/eval.c
+++ insight-6.7.1.dfsg.1/gdb/eval.c
@@ -1627,6 +1627,8 @@
if (nargs != ndimensions)
error (_("Wrong number of subscripts"));

+       memset(&subscript_array, 0, sizeof(subscript_array));
+
/* Now that we know we have a legal array subscript expression
let us actually find out where this element exists in the array. */

8.modify Makefile
$ vim Makefile
-CC = gcc
-CXX = g++
+CC = arm-linux-gcc
+CXX = arm-linux-gcc++

9.make & check
$ make && make install
$ file /path/to/install/gdb/bin/gdb: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.27, dynamically linked (uses shared libs), not stripped


/** install gdb-7.3.1 @ 2011-12-14 **/
1.get source
wget http://ftp.gnu.org/gnu/gdb/gdb-7.3.1.tar.gz
wget ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz

2.configure termcap
$ ./configure --target=arm-linux --prefix=/path/to/termcap
$ make && sudo make install

3.configure gdb & gdbserver
$ cd gdb-7.3.1
$ env CPPFLAGS=-I/path/to/termcap/include LDFLAGS=-L/path/to/termcap/lib ./configure --target=arm-linux
$ make
$ file gdb/gdb
gdb/gdb: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.27, not stripped
$ file gdbserver
gdb/gdbserver/gdbserver: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.27, not stripped


reference:
* How to Cross Compile GNU Project Debugger a Step by Step Guide
* insight: FTBFS: configure: error: /bin/bash '../.././itcl/itk/configure' failed for itk
* Cross-compile GDB 6.8 for Android

[Embedded] How to Cross Compile tcpdump

0.assume that your toolchain is
arm-linux-gcc
arm-linux-g++
arm-linux-ar
arm-linux-ld
arm-linux-as
arm-linux-strip
...
and under your $PATH

1.download libpcap and tcpdump
$ wget http://www.tcpdump.org/release/libpcap-1.1.1.tar.gz
$ wget http://www.tcpdump.org/release/tcpdump-4.1.1.tar.gz

2.configure libpcap
$ CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/path/to/install

if error has occurred like this:
configure: error: pcap type not determined when cross-compiling; use --with-pcap=...

the type of packet capture could be found in configure
 6914 if test ! -z "$with_pcap" ; then
 6915     V_PCAP="$withval"
 6916 elif test -r /dev/bpf -o -h /dev/bpf ; then
 6917     #
 6918     # Cloning BPF device.
 6919     #
 6920     V_PCAP=bpf
 6921 
 6922 cat >>confdefs.h <<\_ACEOF
 6923 #define HAVE_CLONING_BPF 1
 6924 _ACEOF
 6925 
 6926 elif test -r /dev/bpf0 ; then
 6927     V_PCAP=bpf
 6928 elif test -r /usr/include/net/pfilt.h ; then
 6929     V_PCAP=pf
 6930 elif test -r /dev/enet ; then
 6931     V_PCAP=enet
 6932 elif test -r /dev/nit ; then
 6933     V_PCAP=snit
 6934 elif test -r /usr/include/sys/net/nit.h ; then
 6935     V_PCAP=nit
 6936 elif test -r /usr/include/linux/socket.h ; then
 6937     V_PCAP=linux
 6938 elif test -r /usr/include/net/raw.h ; then
 6939     V_PCAP=snoop
 6940 elif test -r /usr/include/odmi.h ; then
 6941     #
 6942     # On AIX, the BPF devices might not yet be present - they're
 6943     # created the first time libpcap runs after booting.
 6944     # We check for odmi.h instead.
 6945     #
 6946     V_PCAP=bpf
 6947 elif test -c /dev/bpf0 ; then       # check again in case not readable
 6948     V_PCAP=bpf
 6949 elif test -r /usr/include/sys/dlpi.h ; then
 6950     V_PCAP=dlpi
 6951 elif test -c /dev/enet ; then       # check again in case not readable
 6952     V_PCAP=enet
 6953 elif test -c /dev/nit ; then        # check again in case not readable
 6954     V_PCAP=snit
 6955 else
 6956     V_PCAP=null
 6957 fi
configure with pcap type=null could avoid error,
$ CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/path/to/install --with-pcap=null

OR
modify configure(mark cross-compiling linux version check)
$ vim configure
 6901 #if test -z "$with_pcap" && test "$cross_compiling" = yes; then
 6902 #   { { echo "$as_me:$LINENO: error: pcap type not determined when cross-compiling; use --with-pcap=..." >&5
 6903 #echo "$as_me: error: pcap type not determined when cross-compiling; use --with-pcap=..." >&2;}
 6904 #   { (exit 1); exit 1; }; }
 6905 #fi
 ...
 7237 #   if test $ac_cv_linux_vers = unknown ; then
 7238 #       { { echo "$as_me:$LINENO: error: cannot determine linux version when cross-compiling" >&5
 7239 #echo "$as_me: error: cannot determine linux version when cross-compiling" >&2;}
 7240 #   { (exit 1); exit 1; }; }
 7241 #   fi
 7242 #   if test $ac_cv_linux_vers -lt 2 ; then
 7243 #       { { echo "$as_me:$LINENO: error: version 2 or higher required; see the INSTALL doc for more info" >&5
 7244 #echo "$as_me: error: version 2 or higher required; see the INSTALL doc for more info" >&2;}
 7245 #   { (exit 1); exit 1; }; }
 7246 #   fi

make and install
$ sudo make && sudo make install

check
$ file /path/to/install/libpcap
/path/to/install/libpcap/lib/libpcap.so.1.1.1: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped

4.configure tcpdump
$ CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/path/to/install

if error has occurred like this:
configure: error: cannot determine linux version when cross-compiling

modify configure(mark cross-compiling linux version check)
$ vim configure
4393 #   if test "$cross_compiling" = yes; then
 4394 #       if test "${ac_cv_linux_vers+set}" = set; then
 4395 #  echo $ECHO_N "(cached) $ECHO_C" >&6
 4396 #else
 4397 #  ac_cv_linux_vers=unknown
 4398 #fi
 4399 #
 4400 #   else
 4401 #       if test "${ac_cv_linux_vers+set}" = set; then
 4402 #  echo $ECHO_N "(cached) $ECHO_C" >&6
 4403 #else
 4404 #  ac_cv_linux_vers=`uname -r 2>&1 | \
 4405 #           sed -n -e '$s/.* //' -e '$s/\..*//p'`
 4406 #fi
 4407 #
 4408 #   fi
 4409 #    { echo "$as_me:$LINENO: result: $ac_cv_linux_vers" >&5
 4410 #echo "${ECHO_T}$ac_cv_linux_vers" >&6; }
 4411 #   if test $ac_cv_linux_vers = unknown ; then
 4412 #       { { echo "$as_me:$LINENO: error: cannot determine linux version when cross-compiling" >&5
 4413 #echo "$as_me: error: cannot determine linux version when cross-compiling" >&2;}
 4414 #   { (exit 1); exit 1; }; }
 4415 #   fi

make and install
$ sudo make && sudo make install

if error has occurred like this:
./addrtoname.c: In function 'ipxsap_string':
./addrtoname.c:682: error: invalid 'asm': invalid operand for code 'w'
make: *** [addrtoname.o] Error 1

modify Makefile
$ vim Makefile
-INCLS = -I. -I./../libpcap-1.1.1  -I/usr/include -I$(srcdir)/missing
-DEFS = -DHAVE_CONFIG_H  -I./../libpcap-1.1.1  -I/usr/include -I$(srcdir)/missing  -D_U_="__attribute__((unused))"
+INCLS = -I. -I./../libpcap-1.1.1 -I$(prefix)/include -I$(srcdir)/missing
+DEFS = -DHAVE_CONFIG_H -I./../libpcap-1.1.1 -I$(prefix)/include -I$(srcdir)/missing -D_U_="__attribute__((unused))"

make and install again
$ sudo make && sudo make install

check
$ file /path/to/install/tcpdump/sbin/tcpdump
/path/to/install/tcpdump/sbin/tcpdump: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.27, not stripped


reference: 如何將tcpdump移植到arm嵌入式系統

2010年3月9日 星期二

[Embedded] The GNU configure and build system - Cross Compilation Tools

在做cross compilation的時候, 需要將手邊的程式編譯成可在目標裝置上執行的代碼, 這時候就會需要用到cross compiler中的系統參數了...

根據GCC documentation可以知道
--build: the machine you are building on
--host: the machine you are building for
--target: the machine that GCC will produce code for

翻譯一下就是build就是你現在使用的機器,host就是你編譯好的程序能夠運行的平台,target是編譯程序能夠處理的平台,一般使用在開發工具上

因此如果我們希望在x86環境下編譯一個可以在arm環境中處理mips的gcc,可能會類似 ./configure --build=i386-linux --host=arm-linux --target=mipsel-linux

reference:
* GCC documentation
* GNU Configure中的 build target和host的區別