2012年3月1日 星期四

Use VIM

1) 先將游標移到程式的某個文字串,再按以下按鍵:
  • '*' 往前找出此文字串 (按 n、N 繼續找)
  • '#' 往後找出此文字串 (按 n、N 繼續找)
  • 'gd' 將此文字串視為 local 變數,找到定義此 local 變數的地方 (如果有的話)
2) 其他追溯程式常見的動作:
  • '%' 找到被配的括號
  • '[[' 找到函數的開頭
  • ']]' 找到下一個函數的開頭

Use cscope

1) Install cscope:

sudo apt-get install cscope
mkdir -p ~/.vim/plugin
cd ~/.vim/plugin
wget http://cscope.sourceforge.net/cscope_maps.vim

2) Create cscope database for PROJECT:

cd PROJECT
cscope -bR

3)  Using cscope in VIM:

當你安裝好 cscope,而且建立好專案的 cscope 資料庫之後,將游標移到程式當中某個文字串,按 Ctrl+\ 再按以下按鍵:
  • 's': 即 Symbol,以此文字串當識別字,列出專案當中所有參考到此識別字的地方,包含定義和引用
  • 'g': 即 Global,以此文字串當作 global 變數或函數的名稱,跳到專案中定義此 global 變數或函數的地方 (這個功能有另一個與 ctags 相同的快速鍵 Ctrl-])
  • 'c': 即 Calls,以此文字串當函數名稱,找出所有呼叫到的此函數的函數
  • 't': 即 Text,列出專案中所有出現此文字串的地方 (包含註解)
  • 'e': 即 Egrep,以此文字串當 regular expression,用 egrep 方式來搜尋
  • 'f': 即 File,以此文字串當檔案名稱,開啟此檔案
  • 'i': 即 Includes,以此文字串當 header 檔名稱,列出所有 include 此檔案的檔案
  • 'd': 即 calleD,以此文字串當函數名稱,列出此函數所呼叫到的函數

2011年12月21日 星期三

gcc-4.5.2 regression test

1) Compile zlib-1.2.3
(x86)
./configure --prefix=/home/user/mingfeng_wu/installed/zlib
make clean
make
make install

(ARM)
./configure --prefix=/home/user/mingfeng_wu/installed/arm-uc-zlib

# !!!Modify Makefile manually
# -CC=gcc
# +CROSS=/home/user/mingfeng_wu/installed/crosstool-4.5.2/bin/arm-unknown-linux-uclibcgnueabi-
# +CC=$(CROSS)gcc
# -LDSHARED=gcc
# -CPP=gcc -E
# +LDSHARED=$(CROSS)gcc
# +CPP=$(CROSS)gcc -E
# -AR=ar rc
# +AR=$(CROSS)ar rc
# -RANLIB=ranlib
# +RANLIB=$(CROSS)ranlib

make clean
make
make install

2) Compile openssl-1.0.0d
(x86)
./Configure --prefix=/home/user/mingfeng_wu/installed/openssl os/compiler:gcc

make clean
make
make install

(ARM)
./Configure --prefix=/home/user/mingfeng_wu/installed/arm-uc-openssl os/compiler:arm-unknown-linux-uclibcgnueabi-gcc

make clean
make
make install

3) Compile openssh-5.9p1

Modify sshd_config with "Subsystem       sftp    /usr/local/libexec/sftp-server"

(x86)
./configure --prefix=/home/user/mingfeng_wu/installed/openssh \
            --with-libs \
            --with-zlib=/home/user/mingfeng_wu/installed/zlib \
            --with-ssl-dir=/home/user/mingfeng_wu/installed/openssl \
            --disable-etc-default-login \
            CC=gcc \
            AR=ar \
            RANLIB=ranlib

make clean
make
make install

(ARM)
./configure --host=arm-unknown-linux-uclibcgnueabi \
            --with-libs \
            --with-zlib=/home/user/mingfeng_wu/installed/arm-uc-zlib \
            --with-ssl-dir=/home/user/mingfeng_wu/installed/arm-uc-openssl \
            --disable-etc-default-login \
       CC=arm-unknown-linux-uclibcgnueabi-gcc \
       AR=arm-unknown-linux-uclibcgnueabi-ar \
       RANLIB=arm-unknown-linux-uclibcgnueabi-ranlib

make clean
make

/home/user/mingfeng/installed/crosstool-4.5.2/bin/arm-linux-strip scp sftp ssh ssh-add ssh-agent ssh-keygen ssh-keyscan sftp-server ssh-key
sign sshd

4) readme.ssh-transparent-login
1. Generate on your LOCAL machine a keypair with:

# ssh-keygen -t rsa (dont type in any password, just keep hitting enter) .

This will generate public/private rsa key pair in the directory of /root/.ssh:

/root/.ssh/id_rsa            (private key)

/root/.ssh/id_rsa.pub        (public key)

2. Make sure your private key resides under /root/.ssh on your LOCAL machine.

3. Also transfer the PRIVATE key to the machine which you want to automatically

login to. Put it under the directory /usr/local/etc.

4. Transfer the PUBLIC key to the machine which you want to automatically login to.

  Under the directory /root/.ssh (create it if necessary) concatenate your public key

with the file authorized_keys (create file if needed) .

5. Make sure the authorized_keys on the REMOTE machine is not read or modifiable by

group or others by doing chmod 700 /root/.ssh/authorized_keys.

6. Make sure the /root/.ssh directory on the REMOTE machine is not read or modifiable

by group or others by doing chmod 700 /root/.ssh

7. You may need to enable empty password authentication (need root access) on the

REMOTE machine in the config file sshd_config. Make "Permitemptypasswords yes".

You also need to modify "Protocol 2,1" to "Protocol 2" and modify "HostKey

/etc/ssh/ssh_host_rsa_key" to "/usr/local/etc/id_rsa". Please refer to the attached.

8. Restart /usr/local/sbin/sshd daemon on REMOTE, and you can automatically login with

ssh/sftp without password on LOCAL.

5) gcc-4.5.2-no-mtune-sshscp.exp
# Board definition file for board "myboard_sshscp"
# How to compile C programs for this board
set_board_info compiler /home/user/mingfeng_wu/installed/crosstool-4.5.2/bin/arm-unknown-linux-uclibcgnueabi-gcc
set_board_info cflags ""

# Network address of board
set_board_info hostname 172.18.116.241

# How to log into this board via ssh and copy files via scp.
# Ideally, you'll set it up to not need a password to log in via ssh
# (see e.g. http://www-csli.stanford.edu/semlab/muri/system/howto/ssh.html).
set_board_info username root

#set_board_info shell_prompt    "[root@platform]#"
# For DejaGnu 1.4.3 and above; DejaGnu 1.4.2.x (Debian 3.0) ignores these settings!
set_board_info rsh_prog /usr/bin/ssh
set_board_info rcp_prog /usr/bin/scp

6) test_installed.remote
#! /bin/sh

# (C) 1998, 2000, 2002, 2003, 2007 Free Software Foundation
# Originally by Alexandre Oliva <oliva@dcc.unicamp.br>

# This script is Free Software, and it can be copied, distributed and
# modified as defined in the GNU General Public License.  A copy of
# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html

# This scripts assumes it lives in the contrib directory of the GCC
# source tree, so it will find the testsuite tree from its location.
# If you move it elsewhere, or want to use another testsuite tree, you
# can override the defaults with --srcdir=/some/dir/GCC or
# --testsuite=/some/dir/GCC/gcc/testsuite.  If you specify
# --testsuite, --srcdir will be ignored; otherwise, `/gcc/testsuite'
# will be appended to the srcdir.

# You may specify where the binaries to be tested should be picked up
# from.  If you specify --prefix=/some/dir, gcc, g++ and gfortran will be
# looked for at /some/dir/bin.  Each one may be overridden by
# specifying --with-gcc=/pathname/to/gcc, --with-g++=/pathname/to/g++
# and --with-gfortran=/pathname/to/gfortran.  If you specify --without-gcc,
# --without-g++ or --without-gfortran, the test for the specified program
# will be skipped.  By default, gcc, g++ and gfortran will be searched in
# the PATH.

# An additional argument may specify --tmpdir=/some/dir; by default,
# temporaries will be stored in the current directory, where the log
# files will be stored.

# The script will interpret arguments until it finds one it does not
# understand.  The remaining ones will be passed to `runtest'.  A
# double-dash can be used to explicitly separate the arguments to
# `test_installed' from the ones to `runtest'.

# This script should be run in an empty directory; it will refuse to
# run if it finds a file named site.exp in the current directory.


if test -f site.exp; then
    echo site.exp already exists >&2
    exit 1
fi

while true; do
  case "$1" in
  --with-testsuite=*) testsuite=`echo "$1" | sed 's/[^=]*=//'`; shift;;
  --srcdir=*) srcdir=`echo "$1" | sed 's/[^=]*=//'`; shift;;

  --prefix=*) prefix=`echo "$1" | sed 's/[^=]*=//'`; shift;;
  --with-gcc=*) GCC_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
  --with-g++=*) GXX_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
  --with-gfortran=*) GFORTRAN_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
  --without-gcc) GCC_UNDER_TEST=no; shift;;
  --without-g++) GXX_UNDER_TEST=no; shift;;
  --without-gfortran) GFORTRAN_UNDER_TEST=no; shift;;
  --without-objc) OBJC_UNDER_TEST=no; shift;;

  --tmpdir=*) tmpdir=`echo "$1" | sed 's/[^=]*=//'`; shift;;

  --help) cat <<\EOF
Runs the testsuite for an installed version of gcc/g++/gfortran/objc
Copyright (C) 1998  Free Software Foundation
by Alexandre Oliva <oliva@dcc.unicamp.br>

Supported arguments:

--help                        prints this page

--with-testsuite=/some/dir/gcc/testsuite   specify the testsuite directory
--srcdir=/some/dir            same as --with-testsuite=/some/dir/gcc/testsuite
                              [deduced from shell-script pathname]

--prefix=/some/dir            use gcc, g++ and gfortran from /some/dir/bin [PATH]
--with-gcc=/some/dir/bin/gcc  use specified gcc program [gcc]
--with-g++=/some/dir/bin/g++  use specified g++ program [g++]
--with-gfortran=/some/dir/bin/gfortran  use specified gfortran program [gfortran]
--without-gcc                 do not run gcc testsuite
--without-g++                 do not run g++ testsuite
--without-gfortran            do not run gfortran testsuite
--without-objc                do not run objc testsuite

--tmpdir=/some/dir            create temporaries and leave failed programs
                              at specified directory [.]

--   end of argument list; following arguments are passed to runtest
EOF
    exit
  ;;

  --) shift; break;;
  *) break;;
  esac
done

if test x"${testsuite+set}" != x"set" && test x"${srcdir+set}" != x"set"; then
  file=$0
  while [ -h $file ]; do
    file=`ls -l $file | sed s/'.* -> '//`
  done
  srcdir=`CDPATH=. && cd \`echo "$file" | sed 's,/*[^/]*$,,;s,^$,.,'\`/.. >/dev/null && ${PWDCMD-pwd}`
fi

CROSS_COMPILE=arm-unknown-linux-uclibcgnueabi-

cat >site.exp <<EOF
lappend boards_dir "/root/toolchain/gcc-test"
lappend boards_dir "/usr/share/dejagnu"
set rootme "."
set tmpdir "${tmpdir-`${PWDCMD-pwd}`}"
set srcdir "${testsuite-${srcdir}/gcc/testsuite}"
set CFLAGS ""
set CXXFLAGS ""
set HOSTCC "cc"
set HOSTCFLAGS ""
set GCC_UNDER_TEST "${GCC_UNDER_TEST-${prefix}${prefix+/bin/}${CROSS_COMPILE}gcc}"
set GXX_UNDER_TEST "${GXX_UNDER_TEST-${prefix}${prefix+/bin/}${CROSS_COMPILE}g++}"
set GFORTRAN_UNDER_TEST "${GFORTRAN_UNDER_TEST-${prefix}${prefix+/bin/}${CROSS_COMPILE}gfortran}"
set OBJC_UNDER_TEST "${OBJC_UNDER_TEST-${prefix}${prefix+/bin/}${CROSS_COMPILE}gcc}"
set target_triplet arm-unknown-linux-uclibcgnueabi
set target_alias arm-none-linux-uclibcgnueabi
EOF

test x"${GCC_UNDER_TEST}" = x"no" || runtest --tool gcc ${1+"$@"}
test x"${GXX_UNDER_TEST}" = x"no" || runtest --tool g++ ${1+"$@"}
test x"${GFORTRAN_UNDER_TEST}" = x"no" || runtest --tool gfortran ${1+"$@"}
test x"${OBJC_UNDER_TEST}" = x"no" || runtest --tool objc ${1+"$@"}

exit 0

7) run-gcc-4.5.2-sshscp.sh
#!/bin/bash

# increase stack size to 64MB to prevent limits-exprparen.c from segmentation fault
ulimit -s 65536
DATE=`date +%Y%m%d`

GCC=/home/user/mingfeng_wu/installed/crosstool-4.5.2

REGRESSION=/home/user/mingfeng_wu/work/GCC
rm -rf $REGRESSION/gcc-regression-test-${DATE}
mkdir -p $REGRESSION/gcc-regression-test-${DATE}
cd $REGRESSION/gcc-regression-test-${DATE}

DEJAGNULIBS="/usr/share/dejagnu" sh $REGRESSION/gcc-4.5.2/contrib/test_installed.remote --srcdir=$REGRESSION/gcc-4.5.2 --without-gfortran --without-objc --wi
th-gcc=${GCC}/bin/arm-unknown-linux-uclibcgnueabi-gcc --with-g++=${GCC}/bin/arm-unknown-linux-uclibcgnueabi-g++ --target_board=gcc-4.5.2-no-mtune-sshscp


8) For arm-unknown-linux-uclibcgnueabi-* toolchain to run gcc regression test
[mingfeng, 2011-11-07]

In host-Linux (not embedded Linux):
1. Do ssh/sftp transparent login. Please see "readme.ssh-transparent-login".
2. Copy "gcc-4.5.2-sshscp.exp" to /usr/share/dejagnu.
3. Copy "test_installed.remote" to gcc-4.5.2/contrib/.
4. Run script file "run-gcc-4.5.2-sshscp.sh"
5. Generate log
   $ cd gcc-regression-test-20111107
   $ ../gcc-4.5.2/contrib/test_summary > gcc-4.5.2-test_summary.log

2011年12月13日 星期二

OProfile in Linux

### Build Oprofile ###

1) Get source package

http://oprofile.sourceforge.net/download/
oprofile-0.9.7.tar.gz

http://www.gnu.org/s/libiconv/#downloading
libiconv-1.13.1.tar.gz

http://www.gnu.org/s/gettext/#downloading
gettext-0.18.1.1.tar.gz

http://www.gnu.org/software/binutils/
binutils-2.22.tar.bz2

http://freecode.com/projects/popt
popt-1.14.tar.gz

# Note that we should build (and application would check) dynamic link library

2) Build libiconv-1.13.1

tar zxvf libiconv-1.13.1.tar.gz
mkdir build_libiconv
cd build_libiconv
../libiconv-1.13.1/configure --host=arm-unknown-linux-uclibcgnueabi --enable-shared --with-gnu-ld --prefix=/home/user/mingfeng_wu/installed/arm-uc-libiconv
make all install

3) Build gettext-0.18.1.1

tar zxvf gettext-0.18.1.1.tar.gz
cd gettext-0.18.1.1
patch -p1 < ../oprofile/gettext-spawn.patch
cd ..
mkdir build_gettext
cd build_gettext
../gettext-0.18.1.1/configure --host=arm-unknown-linux-uclibcgnueabi --enable-shared --with-gnu-ld --prefix=/home/user/mingfeng_wu/installed/arm-uc-gettext --with-libiconv-prefix=/home/user/mingfeng_wu/installed/arm-uc-libiconv
make
make install

4) Copy the libiconv.so library to GCC toolchain library (or certain path in LD_LIBRARY_PATH)
cp /home/user/mingfeng_wu/installed/arm-uc-libiconv/lib/libiconv.so.2.5.0 /home/user/mingfeng_wu/installed/crosstool-4.5.2/arm-unknown-linux-uclibcgnueabi/sysroot/lib/libiconv.so.2

5) Build binutils-2.22

tar xvjf /home/user/mingfeng_wu/src/GCC/binutils-2.22.tar.bz2
mkdir build_binutils
cd build_binutils
# need to --enable-shared, oprofile use libbfd.so
../binutils-2.22/configure --host=arm-unknown-linux-uclibcgnueabi --enable-shared --with-gnu-ld --enable-install-libbfd --prefix=/home/user/mingfeng_wu/installed/arm-uc-binutils
make
make install

6) Build popt-1.14

tar zxvf popt-1.14.tar.gz
cd popt-1.14
patch -p0 < popt_fix_va_copy.patch
mkdir build_popt
cd build_popt

ac_cv_va_copy=C99 ../popt-1.14/configure --host=arm-unknown-linux-uclibcgnueabi --enable-shared --disable-nls --with-gnu-ld --with-libiconv-prefix=/home/user/mingfeng_wu/installed/arm-uc-libiconv --prefix=/home/user/mingfeng_wu/installed/arm-uc-popt
make all install

7) Build oprofile

tar xvjf oprofile-0.9.7.tar.gz
cd oprofile-0.9.7
patch -p1 < ../oprofile/oprofile_remove_linux24_support.patch
cd ..
mkdir build_oprofile
cd build_oprofile
../oprofile-0.9.7/configure --host=arm-unknown-linux-uclibcgnueabi --with-binutils=/home/user/mingfeng_wu/installed/arm-uc-binutils --enable-dependency-tracking --enable-pch --enable-gcov --with-gnu-ld --with-kernel-support --with-linux=/home/user/mingfeng_wu/work/trunk/kernel/linux-2.6.35.12 --prefix=/home/user/mingfeng_wu/installed/arm-uc-oprofile --with-extra-libs=/home/user/mingfeng_wu/installed/arm-uc-popt/lib:/home/user/mingfeng_wu/installed/arm-uc-zlib/lib:/home/user/mingfeng_wu/installed/arm-uc-libiconv/lib:/home/user/mingfeng_wu/installed/arm-uc-gettext/lib:/home/user/mingfeng_wu/installed/arm-uc-binutils/lib --with-extra-includes=/home/user/mingfeng_wu/installed/arm-uc-binutils/include:/home/user/mingfeng_wu/installed/arm-uc-libiconv/include:/home/user/mingfeng_wu/installed/arm-uc-gettext/include:/home/user/mingfeng_wu/src/binutils-2.22/include:/home/user/mingfeng_wu/installed/arm-uc-popt/include
make
make install

### Build stage OK now, the following gives the patch ###
1) gettext-spawn.patch

--- a/gettext-tools/gnulib-lib/spawn.in.h    2010-11-18 19:49:42.424350565 +0300
+++ b/gettext-tools/gnulib-lib/spawn.in.h    2010-11-18 19:49:10.392349526 +0300
@@ -37,6 +37,10 @@
 # include <signal.h>
 #endif

+#ifdef __UCLIBC__
+# include <sched.h>
+#endif
+
 #include <sys/types.h>

 #ifndef __THROW


2) oprofile_remove_linux24_support.patch

diff -uNr oprofile-0.9.7/daemon.orig/Makefile.am oprofile-0.9.7/daemon/Makefile.am
--- oprofile-0.9.7/daemon.orig/Makefile.am    2011-12-12 09:56:12.513861000 +0800
+++ oprofile-0.9.7/daemon/Makefile.am    2011-12-12 09:57:06.264055000 +0800
@@ -1,4 +1,4 @@
-SUBDIRS = liblegacy .
+SUBDIRS = .

 oprofiled_SOURCES = \
     init.c \
@@ -49,7 +49,6 @@
 bin_PROGRAMS = oprofiled

 oprofiled_LDADD = \
-    liblegacy/liblegacy.a \
     ../libabi/libabi.a \
     ../libdb/libodb.a \
     ../libop/libop.a \
diff -uNr oprofile-0.9.7/daemon.orig/Makefile.in oprofile-0.9.7/daemon/Makefile.in
--- oprofile-0.9.7/daemon.orig/Makefile.in    2011-12-12 09:56:12.402971000 +0800
+++ oprofile-0.9.7/daemon/Makefile.in    2011-12-12 09:57:29.143153000 +0800
@@ -70,7 +70,7 @@
     opd_extended.$(OBJEXT) opd_ibs.$(OBJEXT) \
     opd_ibs_trans.$(OBJEXT)
 oprofiled_OBJECTS = $(am_oprofiled_OBJECTS)
-oprofiled_DEPENDENCIES = liblegacy/liblegacy.a ../libabi/libabi.a \
+oprofiled_DEPENDENCIES = ../libabi/libabi.a \
     ../libdb/libodb.a ../libop/libop.a ../libutil/libutil.a
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -285,7 +285,7 @@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 topdir = @topdir@
-SUBDIRS = liblegacy .
+SUBDIRS = .
 oprofiled_SOURCES = \
     init.c \
     oprofiled.c \
@@ -331,7 +331,6 @@
 # -fno-omit-frame-pointer needed for daemon build: see ChangeLog-2004 02-23
 AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer
 oprofiled_LDADD = \
-    liblegacy/liblegacy.a \
     ../libabi/libabi.a \
     ../libdb/libodb.a \
     ../libop/libop.a \
diff -uNr oprofile-0.9.7/daemon.orig/oprofiled.c oprofile-0.9.7/daemon/oprofiled.c
--- oprofile-0.9.7/daemon.orig/oprofiled.c    2011-12-12 09:56:12.388988000 +0800
+++ oprofile-0.9.7/daemon/oprofiled.c    2011-12-12 09:58:06.699559000 +0800
@@ -77,7 +77,6 @@
 static char * ext_feature;
 static int showvers;
 static struct oprofiled_ops * opd_ops;
-extern struct oprofiled_ops opd_24_ops;
 extern struct oprofiled_ops opd_26_ops;

 #define OPD_IMAGE_FILTER_HASH_SIZE 32
@@ -477,9 +476,6 @@
 static struct oprofiled_ops * get_ops(void)
 {
     switch (op_get_interface()) {
-        case OP_INTERFACE_24:
-            printf("Using 2.4 OProfile kernel interface.\n");
-            return &opd_24_ops;
         case OP_INTERFACE_26:
             printf("Using 2.6+ OProfile kernel interface.\n");
             return &opd_26_ops;


3) popt_fix_va_copy.patch

--- configure.ac.orig    2011-12-08 17:16:11.092076000 +0800
+++ configure.ac    2011-12-08 17:16:17.376785000 +0800
@@ -43,7 +43,6 @@

 AC_ISC_POSIX
 AM_C_PROTOTYPES
-AC_CHECK_VA_COPY

 AC_CHECK_HEADERS(float.h glob.h langinfo.h libintl.h mcheck.h unistd.h)


### Below shows how to run OProfile on target system ###

# In host Linux

1) Modify .config file of Linux kernel. Add:

CONFIG_PROFILING=y
CONFIG_OPROFILE=y
CONFIG_HAVE_OPROFILE=y

and add  "oprofile.timer=1" to CMDLINE, like the following:

CONFIG_CMDLINE="mem=64M console=ttyS0,115200 init=/init oprofile.timer=1"

# In target platform
1) Create the mtab file to /etc/mtab with the following contents

nodev /dev/oprofile oprofilefs rw 0 0

cp /mnt/arm-uc-oprofile/mtab /etc

1) Set binary and library path

export PATH=/mnt/arm-uc-oprofile/bin:$PATH
export LD_LIBRARY_PATH=/mnt/arm-uc-oprofile/lib:$LD_LIBRARY_PATH

2) Setup /dev/oprofile/*

mv /etc/mtab /etc/mtab1
/mnt/arm-uc-oprofile/bin/opcontrol --init
mv /etc/mtab1 /etc/mtab
/mnt/arm-uc-oprofile/bin/opcontrol --init

3) Set up path to Linux kernel image

/mnt/arm-uc-oprofile/bin/opcontrol --vmlinux=/mnt/trunk_ST58200/kernel/linux-2.6.35.12/vmlinux

4) Start profiling

/mnt/arm-uc-oprofile/bin/opcontrol --start

5) Do any thing you want to profile

6) Stop profiling

/mnt/arm-uc-oprofile/bin/opcontrol --stop

7) Read report
/mnt/arm-uc-oprofile/bin/opreport -l

2011年5月25日 星期三

Build WLAN driver and Android Filesystem

1) Patch

Because there are too many warnings when building WLAN drivers. So I turn off the -Werror command line option in the EXTRA_CFLAGS, like

EXTRA_CFLAGS += -fsigned-char
#EXTRA_CFLAGS += -fsigned-char -Werror

Modified files:
1. /opt/L27.12.1-P2/mydroid/hardware/ti/wlan/wl1283/stad/build/linux/common.inc
2. /opt/L27.12.1-P2/mydroid/hardware/ti/wlan/

2) Script used to build WLAN drivers and Android Filesystem

#!/bin/bash
MYDROID=/opt/L27.12.1-P2/mydroid

mkdir -p logs
export KERNEL_DIR=/opt/L27.12.1-P2/kernel/android-2.6.35

# Build 127x station driver
cd $MYDROID/hardware/ti/wlan/wl1283/platforms/os/linux
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- TNETW=1273

# Build 127x softAp driver
cd $MYDROID/hardware/ti/wlan/wl1283_softAP/platforms/os/linux
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- TNETW=1273

cd $MYDROID
cp -Rfp device/ti/pandaboard/buildspec.mk.default buildspec.mk
#(required for rebuild only)
make clean
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- -j4 2>&1 |tee $MYDROID/logs/android_make.out

3) Finally, build errors

host StaticLib: libunz (out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/libunz.a)
echo out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/adler32.o out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/crc32.o out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/zutil.o out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/inflate.o out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/inftrees.o out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/inffast.o | xargs ar crsP  out/host/linux-x86/obj/STATIC_LIBRARIES/libunz_intermediates/libunz.a
host SharedLib: libfst (out/host/linux-x86/obj/lib/libfst.so)
host StaticLib: libtinyxml (out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/libtinyxml.a)
echo out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxml.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxmlparser.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxmlerror.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinystr.o | xargs ar crsP  out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/libtinyxml.a
host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
/usr/bin/ld: skipping incompatible /usr/lib/libncurses.so when searching for -lncurses
/usr/bin/ld: skipping incompatible /usr/lib/libncurses.a when searching for -lncurses
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
make: *** Waiting for unfinished jobs....
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl] Error 1
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libESR_Portable.so] Error 1
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libfst.so] Error 1
mingfeng@mingfeng-desktop:/opt/L27.12.1-P2/mydroid$

Build linux kernel (android-2.6.35)

1) Script used to build android-2.6.35

#!/bin/bash
# build kernel image
mkdir -p ./logs

#"mkimage" is located in your u-boot/tools/ directory.
export PATH=/opt/L27.12.1-P2/u-boot/tools:$PATH

#(required for rebuild only)
make ARCH=arm distclean
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- CFLAGS="-march=armv7-a+sec" panda_defconfig
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage 2>&1 |tee ./logs/kernel_make.out

# build kernel modules
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- modules 2>&1 |tee ./logs/kernel_modules.out


2) Error

  CC      security/smc/omap4/scxlnx_device_mshield.o
In file included from security/smc/omap4/scxlnx_util.h:29:0,
                 from security/smc/omap4/scxlnx_device_mshield.c:38:
include/linux/pagemap.h: In function 'fault_in_pages_readable':
include/linux/pagemap.h:415:16: warning: variable 'c' set but not used [-Wunused-but-set-variable]
  AS      security/smc/omap4/bridge_pub2sec.o
security/smc/omap4/bridge_pub2sec.S: Assembler messages:
security/smc/omap4/bridge_pub2sec.S:95: Error: selected processor does not support ARM mode `smc #0'
make[3]: *** [security/smc/omap4/bridge_pub2sec.o] Error 1
make[2]: *** [security/smc/omap4] Error 2
make[1]: *** [security/smc] Error 2
make: *** [security] Error 2
mingfeng@mingfeng-desktop:/opt/L27.12.1-P2/kernel/android-2.6.35$


3) Patch

--- security/smc/omap4/bridge_pub2sec.S.orig    2011-05-25 20:24:21.649675315 +0800
+++ security/smc/omap4/bridge_pub2sec.S 2011-05-25 20:26:39.429877396 +0800
@@ -74,6 +74,7 @@
        b       label_smc

 label_smc:
+       .arch_extension sec
        INVALIDATE_BTB
        dsb
        dmb



4) Audio fixes for kernel
cd ${YOUR_PATH}/L27.12.1-P2/kernel/android-2.6.35
git fetch http://review.omapzoom.org/p/kernel/omap refs/changes/01/13001/2 && git cherry-pick FETCH_HEAD
git fetch http://review.omapzoom.org/p/kernel/omap refs/changes/02/13002/2 && git cherry-pick FETCH_HEAD


5) EHCI fixes for kernel
cd ${YOUR_PATH}/L27.12.1-P2/kernel/android-2.6.35
git fetch http://review.omapzoom.org/p/kernel/omap refs/changes/17/13617/1 && git cherry-pick FETCH_HEAD


6) WLAN patches
Apply the following patches to enable wlan
cd ${YOUR_PATH}/L27.12.1-P2/kernel/android-2.6.35
git fetch http://review.omapzoom.org/p/kernel/omap refs/changes/02/12002/2 && git cherry-pick FETCH_HEAD
git fetch http://review.omapzoom.org/p/kernel/omap refs/changes/03/12003/1 && git cherry-pick FETCH_HEAD



7) patch for panda_defconfig

diff --git a/arch/arm/configs/panda_defconfig b/arch/arm/configs/panda_defconfig
index 2adf851..9d574e1 100644
--- a/arch/arm/configs/panda_defconfig
+++ b/arch/arm/configs/panda_defconfig
@@ -290,7 +290,6 @@ CONFIG_OMAP_DM_TIMER=y
 # CONFIG_OMAP_PM_NONE is not set
 # CONFIG_OMAP_PM_NOOP is not set
 CONFIG_OMAP_PM=y
-CONFIG_OMAP_HDMI_AUDIO_WA=y

 #
 # OMAP Board Type
@@ -808,6 +807,7 @@ CONFIG_KERNEL_DEBUGGER_CORE=y
 # CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_SENSORS_BH1780 is not set
 # CONFIG_SENSORS_AK8975 is not set
+# CONFIG_TWL6040_VIB is not set
 # CONFIG_CDC_TCXO is not set
 # CONFIG_DS1682 is not set
 # CONFIG_TI_DAC7512 is not set
@@ -830,7 +830,7 @@ CONFIG_UID_STAT=y
 #
 # Texas Instruments shared transport line discipline
 #
-CONFIG_TI_ST=m
+CONFIG_TI_ST=y
 CONFIG_HAVE_IDE=y
 # CONFIG_IDE is not set

@@ -888,7 +888,8 @@ CONFIG_KS8851=y
 # CONFIG_USB_KAWETH is not set
 # CONFIG_USB_PEGASUS is not set
 # CONFIG_USB_RTL8150 is not set
-# CONFIG_USB_USBNET is not set
+CONFIG_USB_USBNET=y
+CONFIG_USB_NET_SMSC95XX=y
 # CONFIG_USB_HSO is not set
 # CONFIG_USB_IPHETH is not set
 # CONFIG_WAN is not set
@@ -1275,7 +1276,7 @@ CONFIG_SSB_POSSIBLE=y
 #
 # CONFIG_SSB is not set
 CONFIG_MFD_SUPPORT=y
-# CONFIG_MFD_CORE is not set
+CONFIG_MFD_CORE=y
 # CONFIG_MFD_88PM860X is not set
 # CONFIG_MFD_SM501 is not set
 # CONFIG_MFD_ASIC3 is not set
@@ -1291,7 +1292,7 @@ CONFIG_TWL4030_CORE=y
 CONFIG_TWL6030_PWM=y
 CONFIG_TWL6030_POWEROFF=y
 CONFIG_TWL6030_GPADC=y
-# CONFIG_TWL6040_CODEC is not set
+CONFIG_TWL6040_CODEC=y
 # CONFIG_MFD_TMIO is not set
 # CONFIG_MFD_T7L66XB is not set
 # CONFIG_MFD_TC6387XB is not set
@@ -1368,7 +1369,6 @@ CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
 CONFIG_VIDEO_IR_I2C=y
 # CONFIG_VIDEO_VIVI is not set
 CONFIG_VIDEO_OMAP2_VOUT=y
-CONFIG_VIDEO_OMAP_GFX=m
 # CONFIG_VIDEO_SAA5246A is not set
 # CONFIG_VIDEO_SAA5249 is not set
 # CONFIG_SOC_CAMERA is not set
@@ -1553,7 +1553,49 @@ CONFIG_LOGO=y
 CONFIG_LOGO_LINUX_MONO=y
 CONFIG_LOGO_LINUX_VGA16=y
 CONFIG_LOGO_LINUX_CLUT224=y
-# CONFIG_SOUND is not set
+CONFIG_SOUND=y
+# CONFIG_SOUND_OSS_CORE is not set
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=y
+CONFIG_SND_JACK=y
+# CONFIG_SND_SEQUENCER is not set
+# CONFIG_SND_MIXER_OSS is not set
+# CONFIG_SND_PCM_OSS is not set
+# CONFIG_SND_HRTIMER is not set
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_SUPPORT_OLD_API=y
+CONFIG_SND_VERBOSE_PROCFS=y
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
+CONFIG_SND_DRIVERS=y
+# CONFIG_SND_DUMMY is not set
+# CONFIG_SND_MTPAV is not set
+# CONFIG_SND_SERIAL_U16550 is not set
+# CONFIG_SND_MPU401 is not set
+CONFIG_SND_ARM=y
+CONFIG_SND_SPI=y
+CONFIG_SND_USB=y
+# CONFIG_SND_USB_AUDIO is not set
+# CONFIG_SND_USB_UA101 is not set
+# CONFIG_SND_USB_CAIAQ is not set
+CONFIG_SND_SOC=y
+CONFIG_SND_OMAP_SOC=y
+CONFIG_SND_OMAP_SOC_ABE_DSP=y
+CONFIG_SND_OMAP_SOC_MCBSP=y
+CONFIG_SND_OMAP_SOC_MCPDM=y
+CONFIG_SND_OMAP_SOC_ABE=y
+CONFIG_SND_OMAP_SOC_VXREC=y
+CONFIG_SND_OMAP_SOC_OMAP4_PANDA=y
+CONFIG_SND_SOC_I2C_AND_SPI=y
+# CONFIG_SND_SOC_ALL_CODECS is not set
+CONFIG_SND_SOC_TWL6040=y
+# CONFIG_SOUND_PRIME is not set
 CONFIG_HID_SUPPORT=y
 CONFIG_HID=y
 # CONFIG_HIDRAW is not set
@@ -1633,7 +1675,8 @@ CONFIG_USB_OTG=y
 # USB Host Controller Drivers
 #
 # CONFIG_USB_C67X00_HCD is not set
-# CONFIG_USB_EHCI_HCD is not set
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
 # CONFIG_USB_OXU210HP_HCD is not set
 # CONFIG_USB_ISP116X_HCD is not set
 # CONFIG_USB_ISP1760_HCD is not set

Build x-loader

1) Script used to build x-loader

#!/bin/bash
mkdir -p ./logs
make distclean  
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- CFLAGS="-Wa,-march=armv7-a+sec" omap4430panda_config
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- ift 2>&1 | tee ./logs/x-loader_make.out


2) Error

arm-none-linux-gnueabi-gcc -Wa,-gstabs -D__ASSEMBLY__ -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__ -DTEXT_BASE=0x40304350 -I/opt/L27.12.1-P2/x-loader/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/build/arm-none-linux-gnueabi-4.6.0/lib/gcc/arm-none-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv7-a -mabi=apcs-gnu -c -o smc.o /opt/L27.12.1-P2/x-loader/cpu/omap4/smc.S
/opt/L27.12.1-P2/x-loader/cpu/omap4/smc.S: Assembler messages:
/opt/L27.12.1-P2/x-loader/cpu/omap4/smc.S:40: Error: selected processor does not support ARM mode `smc #0'
make[1]: *** [smc.o] Error 1
make[1]: Leaving directory `/opt/L27.12.1-P2/x-loader/cpu/omap4'
make: *** [cpu/omap4/libomap4.a] Error 2
mingfeng@mingfeng-desktop:/opt/L27.12.1-P2/x-loader$

3) Patches

--- x-loader/cpu/omap4/smc.S.orig       2011-05-25 20:06:00.188059813 +0800
+++ x-loader/cpu/omap4/smc.S    2011-05-25 20:04:02.757887581 +0800
@@ -29,6 +29,7 @@
  * @arg: Argument passed to ROM api (input in r1 will move to r0) 
  */  
 .globl omap_smc_rom
+.arch_extension sec
 omap_smc_rom:
        push {r4-r11,lr}
        mov     r12,    r0

4) Build successfully

mingfeng@mingfeng-desktop:/opt/L27.12.1-P2/x-loader$ ls -la
總計 288
drwxr-xr-x 13 mingfeng mingfeng  4096 2011-05-25 20:09 .
drwxr-xr-x  6 mingfeng mingfeng  4096 2011-05-25 20:12 ..
-rw-r--r--  1 mingfeng mingfeng   908 2011-05-17 23:43 arm_config.mk
drwxr-xr-x 10 mingfeng mingfeng  4096 2011-05-17 23:43 board
-rwxr-xr-x  1 mingfeng mingfeng   242 2011-05-25 20:09 build.sh
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-25 20:08 common
-rw-r--r--  1 mingfeng mingfeng  5260 2011-05-17 23:43 config.mk
drwxr-xr-x  6 mingfeng mingfeng  4096 2011-05-17 23:43 cpu
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-25 20:08 disk
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-25 20:08 drivers
drwxr-xr-x  3 mingfeng mingfeng  4096 2011-05-17 23:43 fs
drwxr-xr-x  8 mingfeng mingfeng  4096 2011-05-17 23:43 .git
-rw-r--r--  1 mingfeng mingfeng   520 2011-05-17 23:43 .gitignore
drwxr-xr-x  5 mingfeng mingfeng  4096 2011-05-25 20:08 include
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-25 20:08 lib
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-18 22:17 logs
-rw-r--r--  1 mingfeng mingfeng  7529 2011-05-17 23:43 Makefile
-rwxr-xr-x  1 mingfeng mingfeng  1122 2011-05-17 23:43 mkconfig
-rw-r--r--  1 mingfeng mingfeng 21920 2011-05-25 20:08 MLO
-rw-r--r--  1 mingfeng mingfeng  3935 2011-05-17 23:43 README
drwxr-xr-x  2 mingfeng mingfeng  4096 2011-05-17 23:43 scripts
-rwxr-xr-x  1 mingfeng mingfeng  9642 2011-05-25 20:08 signGP
-rw-r--r--  1 mingfeng mingfeng  3279 2011-05-25 20:08 System.map
-rwxr-xr-x  1 mingfeng mingfeng 93779 2011-05-25 20:08 x-load
-rwxr-xr-x  1 mingfeng mingfeng 21400 2011-05-25 20:08 x-load.bin
-rw-r--r--  1 mingfeng mingfeng 21920 2011-05-25 20:08 x-load.bin.ift
-rw-r--r--  1 mingfeng mingfeng 29031 2011-05-25 20:08 x-load.map
mingfeng@mingfeng-desktop:/opt/L27.12.1-P2/x-loader$