顯示具有 未分類資料夾 標籤的文章。 顯示所有文章
顯示具有 未分類資料夾 標籤的文章。 顯示所有文章

2012年8月6日 星期一

OpenCV 2.4.2 V4L2 Camera resolution bug fix

When using camera with opencv api, the default camera resolution is ALWAYS 160x120
From source code modules/highgui/src/cap_libv4l.cpp the default resolution should be 640x480

/* Defaults - If your board can do better, set it here.  Set for the most common type inputs. */
#define DEFAULT_V4L_WIDTH  640
#define DEFAULT_V4L_HEIGHT 480

I have study a little bit of modules/highgui/src/cap_libv4l.cpp then I found the problem.

   CvCaptureCAM_V4L * capture = (CvCaptureCAM_V4L*)cvAlloc(sizeof(CvCaptureCAM_V4L));
   if (!capture) {
      fprintf( stderr, "HIGHGUI ERROR: V4L: Could not allocate memory for capture process.\n");
      return NULL;
   }

   /* set the default size */
   capture->width  = DEFAULT_V4L_WIDTH;
   capture->height = DEFAULT_V4L_HEIGHT;

...
...

   /* w/o memset some parts  arent initialized - AKA: Fill it with zeros so it is clean */
   memset(capture,0,sizeof(CvCaptureCAM_V4L));

   /* Present the routines needed for V4L funtionality.  They are inserted as part of
      the standard set of cv calls promoting transparency.  "Vector Table" insertion. */
   capture->FirstCapture = 1;

   if (_capture_V4L2 (capture, deviceName) == -1) {

The memset instruction is called after setting width & height. @@

So, just move up memset behind alloc memory.

--- modules/highgui/src/cap_libv4l.cpp.org    2012-08-06 19:28:58.746347834 +0800
+++ modules/highgui/src/cap_libv4l.cpp    2012-08-06 19:29:42.510348966 +0800
@@ -1007,6 +1007,9 @@
       return NULL;
    }
 
+   /* w/o memset some parts  arent initialized - AKA: Fill it with zeros so it is clean */
+   memset(capture,0,sizeof(CvCaptureCAM_V4L));
+
    /* set the default size */
    capture->width  = DEFAULT_V4L_WIDTH;
    capture->height = DEFAULT_V4L_HEIGHT;
@@ -1028,8 +1031,6 @@
    /* Print the CameraNumber at the end of the string with a width of one character */
    sprintf(deviceName, "/dev/video%1d", index);
 
-   /* w/o memset some parts  arent initialized - AKA: Fill it with zeros so it is clean */
-   memset(capture,0,sizeof(CvCaptureCAM_V4L));
    /* Present the routines needed for V4L funtionality.  They are inserted as part of
       the standard set of cv calls promoting transparency.  "Vector Table" insertion. */
    capture->FirstCapture = 1;



2012年7月22日 星期日

Ubuntu 12.04 stutter sound

The stuttering sound while playing mp3 or video bother me for a while.
After some googling I found solution

1.Edit
/etc/pulse/client.conf

from

; extra-arguments = --log-target=syslog

to

; extra-arguments = --log-target=syslog --resample-method=ffmpeg

2.Edit
/etc/modprobe.d/alsa-base.conf

Add

options snd-hda-intel model=generic

3.reboot

2012年5月29日 星期二

S3C6410 MFC H.264 mp4 player (Bug fix)

In the previous post, I implement an mp4 player.
There's a problem confuse me.
The start of video frame seems broken. Then after some time (maybe seconds) the video frame goes well.

Finally, I found a way to solve it.
Just to decode the first frame twice. Really strange but work. Also there's some minor fix included

https://docs.google.com/open?id=0Bx901QMLr9WlVE1ldHVCaERkRkk

Patch

--- /home/gigijoe/mp4player.c    2012-05-29 16:11:06.094007930 +0800
+++ mp4player.c    2012-05-29 16:17:55.073995127 +0800
@@ -176,8 +176,12 @@
     pp_param.dst_width              = pp_param.dst_full_width;
     pp_param.dst_height             = pp_param.dst_full_height;
     pp_param.dst_color_space        = FB0_COLOR_SPACE;
+#if 1
     pp_param.out_path               = DMA_ONESHOT;
-
+#else
+        pp_param.out_path           = FIFO_FREERUN;
+        pp_param.scan_mode            = PROGRESSIVE_MODE;
+#endif
     ioctl(pp_fd, S3C_PP_SET_PARAMS, &pp_param);
     printf("stream width %d, height %d\n", pp_param.src_full_width, pp_param.src_full_height);
 
@@ -193,7 +197,7 @@
       return -1;
     }
 
-    memset(fb_addr, 0, fb_size);
+    //memset(fb_addr, 0, fb_size);
 
     s3c_win_info_t osd_info_to_driver;
     osd_info_to_driver.Bpp          = FB0_BPP;      // RGB16
@@ -212,6 +216,13 @@
     initialize = 1;
 
     //return 0;
+/*
+* Decode first frame again to avoid problem ...
+*/
+    if(SsbSipH264DecodeExe(handle, len) != SSBSIP_H264_DEC_RET_OK)  {
+      printf("MFC Decoder Configuration Failed.\n");
+      return -1;
+    }
   }
 
   unsigned int pYUVBuf[2];
@@ -229,6 +240,12 @@
   ioctl(fb_fd, FBIOGET_FSCREENINFO, &lcd_info);
   pp_param.dst_buf_addr_phy = lcd_info.smem_start;                  // LCD frame buffer
   ioctl(pp_fd, S3C_PP_SET_DST_BUF_ADDR_PHY, &pp_param);
+
+  struct pollfd test_fd;
+  test_fd.fd = pp_fd;
+  test_fd.events = POLLOUT|POLLERR;
+  poll(&test_fd, 1, 3000);
+
   ioctl(pp_fd, S3C_PP_START);
 
   return 0;
@@ -342,12 +359,15 @@
   AVCodecContext *codecContext = is->codec;
 
   long long delay = (1000000 * is->r_frame_rate.den) / (is->r_frame_rate.num);
-
-#if 0
+#if 1
   i = 0;
 #endif
   while(1)  {
     r = av_read_frame(formatContext, &pkt);
+    if(r != 0)  { /*  No more frame, seek head and replay */
+      av_seek_frame(formatContext, 0, 1, AVSEEK_FLAG_BACKWARD);
+      r = av_read_frame(formatContext, &pkt);
+    }
     if(r != 0)
       break;  /*  No more frame */
 
@@ -367,11 +387,16 @@
         i, pkt.stream_index, pkt.dts, pkt.size, pkt.data);
     av_pkt_dump(stdout, &pkt, 0);
 #endif
+    if(pkt.flags & PKT_FLAG_KEY)
+      printf("Key frame %d\n", i);
 
     unsigned char *lp = 0;
     int len = 0;
-    filterContext->filter->filter(filterContext, codecContext, NULL, &lp, &len, pkt.data, pkt.size, (pkt.flags | PKT_FLAG_KEY));
-
+ //   filterContext->filter->filter(filterContext, codecContext, NULL, &lp, &len, pkt.data, pkt.size, (pkt.flags | PKT_FLAG_KEY));
+    r = filterContext->filter->filter(filterContext, codecContext, NULL, &lp, &len, pkt.data, pkt.size, (pkt.flags));
+    if(r != 1)
+      printf("Frame %d : Fail to filter ...\n", i);
+//printf("Frame %d: %d\n", pkt.stream_index, len);
     decode_mfc(lp, len);
 
     av_free_packet(&pkt);
@@ -393,7 +418,7 @@
       } else
         break;
     }
-#if 0
+#if 1
     i++;
 #endif
   }
@@ -403,6 +428,10 @@
 
   avcodec_close(is->codec);
 
+  munmap(fb_addr, fb_size);
+    close(pp_fd);
+    close(fb_fd);
+
   deinit_mfc();
 
   return 0;


2012年4月10日 星期二

S3C6410 MFC H.264 mp4 player

S3C6410 can do hardware video decode including H.264.
There's an example code from Samsung shows how to hardware decode H.264 raw data, but in the real world application this is not so useful.
Decode & Playing H.264 mp4 file is more reality. So I would like to share the implementation.

I use ffmpeg library to decode mp4 mux in order to get H.264 raw data and then send it to S3C6410 MFC to decode and finally play on the LCD panel.

Requirement
ffmpeg-0.6.1
Samsung FIMV_MFC_V1.0

Source code
https://docs.google.com/open?id=0Bx901QMLr9WlTTR1a0ZKaXVobW8

The most important part is to handle data from

  av_read_frame(formatContext, &pkt);

if you pass pkt.data to decode you got fail to decode. Another filter is required.

  typedef struct H264BSFContext {
    uint8_t  length_size;
    uint8_t  first_idr;
    uint8_t *sps_pps_data;
    uint32_t size;
  } H264BSFContext;

  AVBitStreamFilterContext *filterContext = (AVBitStreamFilterContext *)malloc(sizeof(AVBitStreamFilterContext));
  filterContext->priv_data = (H264BSFContext *)malloc(sizeof(H264BSFContext));
  memset(filterContext->priv_data, 0, sizeof(H264BSFContext));
  filterContext->filter = &h264_mp4toannexb_bsf;
  filterContext->parser = 0;
  filterContext->next = 0;
...
  r = av_read_frame(formatContext, &pkt);
...
    unsigned char *lp = 0;
    int len = 0;
    filterContext->filter->filter(filterContext, codecContext, NULL, &lp, &len, pkt.data, pkt.size, (pkt.flags | PKT_FLAG_KEY)); -->> filter here

    decode_mfc(lp, len);




2012年3月6日 星期二

Ubuntu Intel I5-2500K & Z68 chipset

上次組裝電腦已經是6~7年前的事了,昨天終於下定決心把公司那台半古董桌機換下來,一方面增加工作效率也讓已經逐漸老化的硬碟退休.
之前已經在網路上研究了配備一陣子,主要還是與Ubuntu的相容性要好.最後定案的配備如下

Intel I5-2500K (有K的表示可超頻,貴幾百吧)
ASRock Z68 PRO3 GEN3 (這張Ubuntu直上,還有一個COM port,重點是便宜啊)
Kongston 4GB DDR3-1333 x 2 (共8G memory,這在十年前簡直是無法想像)
Seagate SATA3 1T ST1000DM003
CM Hyper 212 PLUS 塔型散熱器 (CPU不怕著涼的,裝大顆一點就對了)
振華400W power

裝好搬回來後直接裝Ubuntu 11.10,一路順暢都沒有什麼問題.
我最擔心的Intel HD 3000 graphic controller也能正常工作,Perfect

接著是一些監控系統資訊的方式
1.CPU 溫度

modprobe coretemp
sensors

gigijoe@gigijoe-i5-2500k:~$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Physical id 0:  +31.0°C  (high = +80.0°C, crit = +98.0°C)
Core 0:         +25.0°C  (high = +80.0°C, crit = +98.0°C)
Core 1:         +29.0°C  (high = +80.0°C, crit = +98.0°C)
Core 2:         +26.0°C  (high = +80.0°C, crit = +98.0°C)
Core 3:         +30.0°C  (high = +80.0°C, crit = +98.0°C)

2.硬體資訊
sudo lshw

3.CPU 超頻
現在的超頻很容易,直接在BIOS內用懶人設定選取希望的頻率即可.
3.3G -> 4.6G還蠻穩定的,CPU溫度只稍微上升.

在linux環境下cat /pro/cpuinfo會發現超頻之後的CPU clock一樣顯示是3.3G.
嗯,經過一番google後先試著用wine 跑 CPU-z這個Windows上廣泛使用的程式...失敗.
最後正解是一隻叫i7z的程式 http://code.google.com/p/i7z/


Cpu speed from cpuinfo 3292.00Mhz
cpuinfo might be wrong if cpufreq is enabled. To guess correctly try estimating
Linux's inbuilt cpu_khz code emulated now
True Frequency (without accounting Turbo) 3292 MHz
  CPU Multiplier 33x || Bus clock frequency (BCLK) 99.76 MHz

Socket [0] - [physical cores=4, logical cores=4, max online cores ever=4]
  TURBO ENABLED on 4 Cores, Hyper Threading OFF
  True Frequency 3391.76 MHz (99.76 x [34])
  Max TURBO Multiplier (if Enabled) with 1/2/3/4 Cores is  60x/60x/60x/60x
  Current Frequency 1793.89 MHz [99.76 x 17.98] (Max of below)
        Core [core-id]  :Actual Freq (Mult.)      C0%   Halt(C1)%  C3 %   C6 %
        Core 1 [0]:       1793.89 (17.98x)      38.2    38.7     9.4    31.1
        Core 2 [1]:       1655.03 (16.59x)      9.69    13.6    5.07    76.5
        Core 3 [2]:       1657.92 (16.62x)      2.77    2.38     1.3    94.9
        Core 4 [3]:       1618.08 (16.22x)         1    0.747      0    98.9



C0 = Processor running without halting
C1 = Processor running with halts (States >C0 are power saver)
C3 = Cores running with PLL turned off and core cache turned off
C6 = Everything in C3 + core state saved to last level cache
  Above values in table are in percentage over the last 1 sec

3.還有一個小問題是boot會卡在Checking Battery State.
按Ctrl+Alt+F1進 console login.
sudo apt-get install gdm
安裝過程中選lightdm

或是
sudo dpkg-reconfigure gdm

然後reboot就解決囉







2011年8月5日 星期五

Embedded Linux IPv6 ready logo phase-2

The past month I'm working on IPv6 ready test on an embedded linux platform.
Since the kernel is really old 2.6.10 and I have to do some porting from newer kernel to get IPv6 ready test pass. Last week I finally all pass and below are some tips.

1.The test node (TN) is FreeBSD 7.4 release with v6eval-3.3.2 / v6eval-remotes-3.0 / Self_Test_5.0.0

It's very important that to disable ipv6 autoconfiguration on TN, because the testing suit needs clean ipv6 environment.

To disable ipv6 autoconfiguration, edit /etc/rc.conf and set

ipv6_enable="NO"

then after TN boot, the ipv6 link local address (fe80:X) won't be exist.

2./usr/local/v6eval/etc/tn.def

#
# tn.def
#
#  Information about the Tester Node (TN)
#

#
# Remote Controal Configuration
#
RemoteDevice    cuad0
RemoteDebug     0
RemoteIntDebug  0
RemoteLog       1
RemoteSpeed     0
RemoteLogout    0
RemoteMethod    serial
#filter ipv6

#linkname       interface       BOGUS ether source address
#               name            of the Tester Interface
Link0           rl0             00:00:00:00:01:00
#Link1          de1             00:00:00:00:01:01
#Link2          de2             00:00:00:00:01:02
#Link3          de4             00:00:00:00:01:03

3./usr/local/v6eval/etc/nut.def

#
# nut.def
#
#  Information about the Node Under Test (NUT)
#

# System type
System          linux-v6

# System information
TargetName      FreeBSD/i386 4.9-RELEASE + kame-20040726-freebsd49-snap

# Name
HostName        HL200

# Type
#   host, router, special
Type            host

# Super user name and it's password
# if you select manual as "System", you don't care "User" and "Password"
#
User            root
Password        1234

#linkname       interface       The EXACT ether source address
#               name            of the Interface Under Test
Link0           eth0            00:AE:45:BC:84:1E
#Link0          eth0            00:60:37:c0:ff:ee
#Link1          fxp1            00:00:92:a7:6d:f6
#Link2          de0             00:c0:f6:b0:aa:ef
#Link3          de1             00:00:92:a7:6d:f8
#Link4          de2             00:90:27:14:ce:e3

4./usr/local/lib/perl5/site_perl/5.10.1/V6evalRemote.pm
This file is really important for self test. It makes the TN to communicate NUT through serial RS232 port. TN can login / logout NUT system even more reboot NUT.

So, find key words below in this file and get it right

    $Type="linux-v6";
    $Device="cuad0";
    $User="root";
    $Password="1234";

The TN will detect message from NUT to login / logout. For example "login: " and "Password: ". Also get it right for your NUT's Behavior

    # login prompt
    %prompt_user = (
           ...
           'linux-v6',         'login: ',
           ...
    );

    # password prompt
    %prompt_password = (
       ...
        'linux-v6',             'Password: ',
        ...
    );

    # command prompt
    %prompt_command = (
        ...
        'linux-v6',              '(\$|#) ',
        ...
    );

    and so on

5.Test TN <-RS232-> NUT
If you can see login screen or promopt, it works

touch /var/log/aculog
chown uucp:dialer /var/log/aculog
chmod 660 /var/log/aculog
cu -l /dev/cuad0
Connected

[root@HL200 ~]$

6.Remote test
To test if TN can login then logout NUT

/usr/local/v6eval/bin/linux-v6/loginout.rmt -o1

HL200 login: root
Password:


BusyBox v1.2.2 (2011.07.20-06:33+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

[root@HL200 ~]$
[root@HL200 ~]$ exit

7.Run self test

cd Self_Test_5-0-0
make clean
make ipv6ready_p2_host

8.Run parts of self test

There are 5 test sections, you can test separated.

cd nd.p2/
make clean
make ipv6ready_p2_host

Also can test only few items, for example test items 10 to 20

make AROPT="-s 10 -e 20" ipv6ready_p2_host

9.Embedded linux setup.
There are some sysctl for ipv6 need to be set correct.

echo 0 > /proc/sys/net/ipv6/conf/default/forwarding
echo 2 > /proc/sys/net/ipv6/conf/default/dad_transmits
echo 1 > /proc/sys/net/ipv6/conf/default/use_tempaddr
echo 2 > /proc/sys/net/ipv6/conf/default/accept_dad
echo 1 > /proc/sys/net/ipv6/conf/default/optimistic_dad
echo 1 > /proc/sys/net/ipv6/conf/default/accept_redirects

Remember to set promisc and allmulti to ethernet port.
Another tip is to sleep 10 seconds after the ethernet up then go login screen

ip -6 link set lo up
#ip -6 link set eth0 up
ifconfig eth0 up promisc allmulti

echo "Wait 10 secs..."            
sleep 10                          

10.Finally, fix /usr/local/v6eval/bin/unknown/ping6.rmt

########################################################################
use V6evalRemote;

rOpen() || goto error;

$NUTif = $rOpt_if;
$dstaddress = $rOpt_addr;
$rOpt_timeout = 5 if ! defined $rOpt_timeout;

if($rOpt_size < 1) {
    $rOpt_size = 2;
}

$pingpath = "ping6";
$pingopt  = "-n -c 1 -i 1 -s $rOpt_size -p 00 -w 2 -M want";
$ifopt    = "-I $NUTif" if $NUTif ne "";

rLogin($rOpt_timeout) || goto error;
rCommand("$pingpath $pingopt $ifopt $dstaddress", 15) || goto error;
rLogout($rOpt_timeout) || goto error;

rClose();
exit($V6evalRemote::exitPass);

error:
    rClose();
    exit($V6evalRemote::exitFail);

########################################################################





2011年6月20日 星期一

LeopardBoard DM368 ffmpeg

For the HD video I need libraries to support video / audio file mux. The ffmpeg is a good choice. With ffmpeg I can save H.264 raw data into mp4 file then play video on PC.

1.Download ffmpeg-0.6.1
Download ffmpeg-0.6.1 and put it in ~/LeopardBoard/DM368

2.Cross compile ffmpeg
I will install ffmpeg into the toolchain sub directory for convenience. My toolchain locate at /opt/arm-2009q1

$ cd ~/LeopardBoard/DM368/ffmpeg-0.6.1
$ mkdir build
$ cd build
$ ../configure --target-os=linux --arch=armv --cpu=armv5te --enable-cross-compile --cross-prefix=arm-none-linux-gnueabi- --prefix=/opt/arm-2009q1/arm-none-linux-gnueabi/libc/usr
$ make
$ sudo PATH=$PATH:/opt/arm-2009q1/bin make install

3.Apply patch to fix Makefile to prevent application link error and add new application video_encode_mp4.

ti-dvsdk_dm368-evm_4_02_00_06_dmai_2_20_00_15_ffmpeg.patch

There will be link error while compile application, so I did some modify to dmai_2_20_00_15/packages/ti/sdo/dmai/apps/Makefile.app

The new application is capable to record HD video and save it into mp4 file

4.Recompile DMAI

$ cd ~/LeopardBoard/DM368/original/ti-dvsdk_dm368-evm_4_02_00_06
$ make dmai

The new application video_encode_mp4 is located at dmai_2_20_00_15/packages/ti/sdo/dmai/apps/video_encode_mp4/linux/video_encode_mp4_dm368.x470MV

5.Running
Save 720p video into SD card with file name video_encode.mp4

$ cd /usr/share/ti/ti-dmai-apps
$ ./video_encode_mp4_dm368.x470MV -I camera -y 4 -c h264enc -i /dev/video0 -o /media/mmcblk0p2/video_encode.mp4 -e encode -b 2000000

6.Running with benchmark

$ ./video_encode_mp4_dm368.x470MV -I ca
mera -y 4 -c h264enc -i /dev/video0 -o /media/mmcblk0p2/video_encode.mp4 -e encode -b 8000000 --benchmark
Starting application...
davinci_resizer davinci_resizer.2: RSZ_G_CONFIG:0:1:124
vpfe-capture vpfe-capture: IPIPE Chained
vpfe-capture vpfe-capture: Resizer present
Leopard: switch to HD imager-MT9P031 video input
-----Exposure time = 2f2
-----Exposure time = 2f2
vpfe-capture vpfe-capture: width = 1280, height = 720, bpp = 1
vpfe-capture vpfe-capture: adjusted width = 1280, height = 720, bpp = 1, bytesperline = 1280, sizeimage = 1382400
vpfe-capture vpfe-capture: width = 1280, height = 720, bpp = 1
vpfe-capture vpfe-capture: adjusted width = 1280, height = 720, bpp = 1, bytesperline = 1280, sizeimage = 1382400
Output #0, mp4, to '/media/mmcblk0p2/video_encode.mp4':
    Stream #0.0: Video: 0x0000, yuv420p, 1280x720, q=2-31, 8000 kb/s, 90k tbn, 15 tbc
No frame read ...
...

Frame 26: Read time: 8431us
[27] Encode: 19808us
File write time: 3915us
Total: 32414us

 Frame 27: Read time: 9166us
[28] Encode: 19778us
File write time: 4592us
Total: 33793us

 Frame 28: Read time: 8517us
[29] Encode: 19796us
File write time: 5055us
Total: 33621us

 Frame 29: Read time: 8097us
[30] Encode: 28264us
File write time: 18042us
Total: 54664us

 Frame 30: Read time: 19820us
[31] Encode: 26007us
File write time: 18879us
Total: 64968us

 Frame 31: Read time: 21273us
[32] Encode: 19804us
File write time: 2930us
Total: 44265us

 Frame 32: Read time: 10147us
[33] Encode: 19743us
File write time: 2517us
Total: 32662us
...

Write file time about 2 ~ 5 ms, there's no need to write file in another thread.



2011年6月3日 星期五

Linux 3.0.0 rc1 released

Linux 終於在5月30日邁入新的重大版本 3.0
根據Linus的說法,這次的進版並沒有任何架構或API的重大變革,
而是Linus本人對於2.6.40以上的版本編號不認同以及2.X版本已歷經接近20年故有此進版動作.

回想Linux 2.2時代我才剛接觸Linux,
對Unix系統完全陌生還活在微軟帝國的勢力範圍,

而Linux 2.4時代進入職場開始真正使用並學習Linux.

時間過的真快啊,呵呵呵.

留一段 linux-omap 3.0.0-rc1 kernel build log 紀念這個重大的時刻.

  GEN     /home/gigijoe/BeagleBoard/build-linux-omap-2.6/Makefile
scripts/kconfig/conf --silentoldconfig Kconfig
  Using /home/gigijoe/BeagleBoard/linux-omap-2.6 as source for kernel
  GEN     /home/gigijoe/BeagleBoard/build-linux-omap-2.6/Makefile
make[2]: Nothing to be done for `all'.
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
make[2]: `include/generated/mach-types.h' is up to date.
  CALL    /home/gigijoe/BeagleBoard/linux-omap-2.6/scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  GZIP    kernel/config_data.gz
  IKCFG   kernel/config_data.h
  CC      kernel/configs.o
  LD      kernel/built-in.o
  LD      drivers/usb/storage/built-in.o
  LD      drivers/usb/built-in.o
  LD      drivers/built-in.o
  LD      vmlinux.o
  MODPOST vmlinux.o
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      .tmp_vmlinux1
  KSYM    .tmp_kallsyms1.S
  AS      .tmp_kallsyms1.o
  LD      .tmp_vmlinux2
  KSYM    .tmp_kallsyms2.S
  AS      .tmp_kallsyms2.o
  LD      vmlinux
  SYSMAP  System.map
  SYSMAP  .tmp_System.map
  OBJCOPY arch/arm/boot/Image
  Kernel: arch/arm/boot/Image is ready
  GZIP    arch/arm/boot/compressed/piggy.gzip
  AS      arch/arm/boot/compressed/piggy.gzip.o
  SHIPPED arch/arm/boot/compressed/lib1funcs.S
  AS      arch/arm/boot/compressed/lib1funcs.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage
  Kernel: arch/arm/boot/zImage is ready
  UIMAGE  arch/arm/boot/uImage
Image Name:   Linux-3.0.0-rc1-next-20110530-11
Created:      Sat Jun  4 04:59:29 2011
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    2830748 Bytes = 2764.40 kB = 2.70 MB
Load Address: 0x80008000
Entry Point:  0x80008000
  Image arch/arm/boot/uImage is ready
gigijoe@gigijoe-laptop:~/BeagleBoard/linux-omap-2.6$ ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make O=~/BeagleBoard/build-linux-omap-2.6 modules
  Using /home/gigijoe/BeagleBoard/linux-omap-2.6 as source for kernel
  GEN     /home/gigijoe/BeagleBoard/build-linux-omap-2.6/Makefile
make[2]: Nothing to be done for `all'.
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
make[2]: `include/generated/mach-types.h' is up to date.
  CALL    /home/gigijoe/BeagleBoard/linux-omap-2.6/scripts/checksyscalls.sh
  Building modules, stage 2.
  MODPOST 2 modules


2011年5月13日 星期五

Beagleboard xM - Camera board LI-5M03

玩了一陣子LI-BCM3M1 camera board發現不管什麼解析度都只能達到5~8fps.數據相當的難看,主要原因是driver限制住了.
到chip vendor Aptina網站找mt9t112 datasheet 竟然還要簽 NDA,發信去也不鳥我...Shit.

因此轉而試試五百萬畫素的LI-5M03, Aptina 有提供datasheet
http://www.aptina.com/products/image_sensors/mt9p031i12stc/
此外更提供給BeagleBoard XM driver source code放在github,我clone了一份.
https://github.com/gigijoe/BeagleBoard-xM

mt9p031 driver我有做一些修改
其中值得一提的是Camera輸出的影像非常暗,所以我把analog gain調高

@@ -538,12 +538,19 @@
     mdelay(200);
 
     ret |= mt9p031_set_params(priv->client, pix->width, pix->height);
-   
+#if 0   
     ret |= mt9p031_reg_write(client, REG_MT9P031_GREEN_1_GAIN, 0x0051);      //Green1_gain_reg
     ret |= mt9p031_reg_write(client, REG_MT9P031_BLUE_GAIN, 0x0051);      //Blue_gain_reg
     ret |= mt9p031_reg_write(client, REG_MT9P031_RED_GAIN, 0x0051);      //Red_gain_reg
     ret |= mt9p031_reg_write(client, REG_MT9P031_GREEN_2_GAIN, 0x0051);      //Green2_gain_reg
     ret |= mt9p031_reg_write(client, REG_MT9P031_GLOBAL_GAIN, 0x0008);        //Analog Gain
+#endif
+  ret |= mt9p031_reg_write(client, REG_MT9P031_GREEN_1_GAIN, 0x0079);   //Green1_gain_reg
+  ret |= mt9p031_reg_write(client, REG_MT9P031_BLUE_GAIN, 0x0079);    //Blue_gain_reg
+  ret |= mt9p031_reg_write(client, REG_MT9P031_RED_GAIN, 0x0079);   //Red_gain_reg
+  ret |= mt9p031_reg_write(client, REG_MT9P031_GREEN_2_GAIN, 0x0079);   //Green2_gain_reg
+  ret |= mt9p031_reg_write(client, REG_MT9P031_GLOBAL_GAIN, 0x0026);    //Analog Gain
+ 


這份driver source code 要自行擺放檔案到正確的位置,以及部份檔案需要手動剪貼.
基本上不困難,我就不在此詳述.更動檔案如下

arch/arm/mach-omap2/board-omap3beagle.c
arch/arm/mach-omap2/board-omap3beagle-camera.c
drivers/media/video/mt9p031.c
drivers/media/video/mt9p031.h
drivers/media/video/Makefile
drivers/media/video/Kconfig

設定mt9p031 kernel config 為
接著重新compile kernel及module並安裝至root file system.

如果driver 順利掛上,在kernel log會看到

mt9p031 2-0048: mt9p031 chip ID 1801

根據driver source 中 README提到可以透過sysfs更改camera 參數.我實際測試卻出現錯誤@@

# cd /sys/devices/platform/i2c_omap.2/i2c-2/2-0048/
# cat gain_val 24
# echo "40" > gain_val
[ 2209.002258] mt9p031 2-0048: Error setting gain.-121
[ 2209.006988] mt9p031: Global gain write failed

Camera 測試的可用gstreamer.
不過實際測試frame rate還是無法到達30fps應該是gstreamer效率的關係,
因此我修改TI提供的demo程式來讀取camera確實就能達到30fps.
接著再把以前曾經實做過的以TI DSP encode H.264加上去,最後再輸出打包為H264RTP封包.
source code放在github

https://github.com/gigijoe/BeagleBoard-xM-video_encode_v4l2_rtp

將project抓下來後請搬到
$DVSDK/dmai_2_20_00_14/packages/ti/sdo/dmai/apps/
cd $DVSDK
make dmai

執行檔位在
dmai_2_20_00_14/packages/ti/sdo/dmai/apps/video_encode_v4l2_rtp/linux/video_encode_v4l2_rtp_dm3730.x470MV

將它複製到root filesystem中 /usr/share/ti/ti-dmai-apps/

萬事具備,執行吧

BeagleBoard xM

cd /usr/share/ti/ti-dmai-apps/
./video_encode_v4l2_rtp_dm3730.x470MV -b 2000000 -c h264enc -i /dev/video0 -o 192.168.168.93 -p 1234 -r 640x480 --benchmark

PC : IP 192.168.168.93

gst-launch udpsrc port=1234 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" ! rtph264depay ! ffdec_h264 ! xvimagesink


最後在透過usb ethernet 傳送影像會hang住,網路上有人發生過但還沒有答案.

http://groups.google.com/group/beagleboard/browse_thread/thread/375026c833e1308b/528751f3690c7d5b?lnk=raot

[  103.995117] ------------[ cut here ]------------
[  103.999908] WARNING: at net/sched/sch_generic.c:255 dev_watchdog+0x17c/0x280()
[  104.007202] NETDEV WATCHDOG: usb0 (smsc95xx): transmit queue 0 timed out
[  104.014099] Modules linked in: sdmak lpm_omap3530 dsplinkk cmemk bufferclass_ti omaplfb pvrsrvkm ipv6 rtc_twl rtc_core mt9p031
[  104.025756] [ ] (unwind_backtrace+0x0/0xdc) from [ ] (warn_slowpath_common+0x48/0x60)
[  104.035247] [ ] (warn_slowpath_common+0x48/0x60) from [ ] (warn_slowpath_fmt+0x24/0x30)
[  104.044921] [ ] (warn_slowpath_fmt+0x24/0x30) from [ ] (dev_watchdog+0x17c/0x280)
[  104.054199] [ ] (dev_watchdog+0x17c/0x280) from [ ] (run_timer_softirq+0x268/0x378)
[  104.063568] [ ] (run_timer_softirq+0x268/0x378) from [ ] (__do_softirq+0xf0/0x1ec)
[  104.072784] [ ] (__do_softirq+0xf0/0x1ec) from [ ] (irq_exit+0x48/0x9c)
[  104.081024] [ ] (irq_exit+0x48/0x9c) from [ ] (asm_do_IRQ+0x74/0x90)
[  104.089019] [ ] (asm_do_IRQ+0x74/0x90) from [ ] (__irq_svc+0x44/0xa8)
[  104.097076] Exception stack(0xc0603f88 to 0xc0603fd0)
[  104.102172] 3f80:                   00000000 80000013 00f9982c 00000000 c0602000 c064db9c
[  104.110412] 3fa0: c002f014 c0605e68 8002cc0c 413fc082 0000001f 00000000 c06085b8 c0603fd0
[  104.118774] 3fc0: c0045450 c0036f1c 60000013 ffffffff
[  104.123962] [ ] (__irq_svc+0x44/0xa8) from [ ] (cpu_idle+0x78/0xbc)
[  104.131866] [ ] (cpu_idle+0x78/0xbc) from [ ] (start_kernel+0x260/0x2c0)
[  104.140197] [ ] (start_kernel+0x260/0x2c0) from [<80008034>] (0x80008034)
[  104.147827] ---[ end trace 640b83e4eff706c8 ]---

我猜應該是hardware的問題,因為我用USB Wifi也會當.
目前的解法是從USB otg port接USB hub再接USB wifi.
這樣,網路就不會斷了...

Reference :
http://maxgalemin.blogspot.com/2011/04/li-5m03-camera-on-beagleboard-xm.html

http://gitorious.org/rowboat/hardware-ti-omap3/blobs/e82865bd56a086480972fecdecc6f38308c05c35/liboverlay/v4l2_utils.c

http://blogold.chinaunix.net/u/19273/showart_2254379.html

http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/100/t/7826.aspx

http://e2e.ti.com/support/dsp/omap_applications_processors/f/447/p/87922/303994.aspx






2011年5月5日 星期四

BeagleBoard Uart Level Shift

There are three Uart port can be use on BeagleBoard, while Uart 3 as default console port, Uart 1 & 2 are free to use. There are many devices can be connect to Uart, such as GPS module, blue tooth module and PWM controller.

But, there's a serious problem. The BeagleBoard I/O works at 1.8v and for most of devices 1.8v is not "High" enough. So, I'm trying to higher the 1.8v signal to 5v signal.
Google this issue, I found the procdure is called "Level Shift" and can be done with two n-channel FET. The actual electronic circuit as below.

http://www-g.eng.cam.ac.uk/mmg/teaching/linearcircuits/mosfet.html

 

The n-channel FET is 2N7000
http://www.fairchildsemi.com/ds/2N/2N7000.pdf

According to BeagleBoard SRM (System Reference Manual), Uart 2 pins can be found on the expansion header.

PIN 6 - UART2_TX

Make sure the pin mux is correct configured. It should be work.




2011年5月4日 星期三

BeagleBoard i2c SRF08 example code

According to http://www.robot-electronics.co.uk/htm/srf08tech.shtml


i2c_srf08.h



/*
 * i2c_srf08.h : SRF08 ultra sonic range finder
 *
 *  (C) 2011 by Steve Chang
 *  stevegigijoe@yahoo.com.tw
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef _I2C_SRF08_H
#define _I2C_SRF08_H

#include "bool.h"

typedef struct I2cSrf08 I2cSrf08;

I2cSrf08 *I2cSrf08_DefaultInstance(char *device);
int I2cSrf08_Open(I2cSrf08 *is);
void I2cSrf08_Close(I2cSrf08 *is);
void I2cSrf08_SetMaxRange(I2cSrf08 *is, unsigned char range);
void I2cSrf08_SetMaxGain(I2cSrf08 *is, unsigned char gain);
int I2cSrf08_BlockRangeInCentimeters(I2cSrf08 *is);
int I2cSrf08_RangingInCentimeters(I2cSrf08 *is);
int I2cSrf08_GetRange(I2cSrf08 *is);

#endif


i2c_srf08.c


/*
 * i2c_srf08.c : SRF08 ultra sonic range finder
 *
 *  (C) 2011 by Steve Chang
 *  stevegigijoe@yahoo.com.tw
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#include
#include
#include
#include
#include
#include
#include

#include "i2c_srf08.h"

struct I2cSrf08  {
  int fd;
  char *device;
  unsigned char range;
  unsigned char gain;
  bool ranging;
};

I2cSrf08 *I2cSrf08_DefaultInstance(char *device)
{
  static I2cSrf08 i2csrf08;
 
  if(!device)
    return 0;

  memset(&i2csrf08, 0, sizeof(I2cSrf08));
 
  i2csrf08.device = strdup(device);
#if 0 
  i2csrf08.range = 0xff; /*  11 m : default */
  i2csrf08.range = 0x8c; /*  6 m */
  i2csrf08.range = 0x18; /*  1 m */
  i2csrf08.range = 0x1;  /*  86 mm */
  i2csrf08.range = 0x0;  /*  43 mm */
#endif
  i2csrf08.range = 0xff; /*  11 m : default */

#if 0
  i2csrf08.gain = 0x0; /*  min 94 */
  i2csrf08.gain = 0x1f; /* default & max 1025 */
#endif
  i2csrf08.gain = 0x1f;
 
  return &i2csrf08;
}

#define SRF08_I2C_ADDR  0x70

int I2cSrf08_Open(I2cSrf08 *is)
{
  is->fd = open(is->device, O_RDWR);
  if(is->fd == -1)
    return -1;
 
  if(ioctl(is->fd, I2C_SLAVE, SRF08_I2C_ADDR) < 0)  {
    printf("[SRF08] None exist device address 0x%x\n", SRF08_I2C_ADDR);
    close(is->fd);
    is->fd = 0;
    return -1;
  }
 
  unsigned char buf[2];
 
  buf[0] = 0x1; /*  Register 1  */
  buf[1] = is->gain;  /*  Gain */
  if(write(is->fd, buf, 2) != 2)
    return -1;

  buf[0] = 0x2; /*  Register 2  */
  buf[1] = is->range;  /*  Range */
  if(write(is->fd, buf, 2) != 2)
    return -1;
 
  return is->fd;
}

void I2cSrf08_Close(I2cSrf08 *is)
{
  if(is->fd)
    close(is->fd);
  is->fd = 0;
}

void I2cSrf08_SetMaxRange(I2cSrf08 *is, unsigned char range)
{
  is->range = range;
 
  unsigned char buf[2];
 
  buf[0] = 0x2; /*  Register 2  */
  buf[1] = is->range;  /*  Range */
  if(write(is->fd, buf, 2) != 2)
    printf("[SRF08] Fail to write !!!\n");
 
  return;
}

void I2cSrf08_SetMaxGain(I2cSrf08 *is, unsigned char gain)
{
  if(gain > 0x1f)
    gain = 0x1f;
 
  is->gain = gain;
 
  unsigned char buf[2];
 
  buf[0] = 0x1; /*  Register 1  */
  buf[1] = is->gain;  /*  Gain */
  if(write(is->fd, buf, 2) != 2)
    printf("[SRF08] Fail to write !!!\n");
 
  return;
}

int I2cSrf08_BlockRangeInCentimeters(I2cSrf08 *is)
{
  unsigned char buf[2];
 
  buf[0] = 0x0; /*  Register 0  */
  buf[1] = 81;  /*  Range in centimeters */
  if(write(is->fd, buf, 2) != 2)
    return -1;
 
  while(1)  {
    usleep(65000);

    buf[0] = 0x0; /*  Register 0 : software reversion */
    if(write(is->fd, buf, 1) != 1)  {
      usleep(100);
      continue;
    }
   
    if(read(is->fd, buf, 1) != 1)  {
      usleep(100);
      continue;
    }
   
    if(buf[0] != 0xff)  /*  While ranging it returns 0xff */
      break;  /*  Range data ready now  */
  }
 
  int i;
  char hb, lb;
  unsigned short r = 0;
  for(i=0;i<17;i++) { /*  There are 17 echo buffers */
    buf[0] = 2 + (i << 1); /*  Register 2, 4, 6 ...  */
    if(write(is->fd, buf, 1) != 1)
      return -1;
    if(read(is->fd, buf, 1) != 1)
      return -1;
    hb = buf[0];

   
    buf[0] = 3 + (i << 1); /*  Register 3, 5, 7 ...  */
    if(write(is->fd, buf, 1) != 1)
      return -1;
    if(read(is->fd, buf, 1) != 1)
      return -1;
    lb = buf[0];

    if(hb == 0 && lb == 0)
      break;
/*   
    printf("High byte : %d\n", hb);
    printf("Low byte : %d\n", lb);
*/
    r = (hb << 8) + lb;
    printf("[SRF08] %dst echo range = %u\n", i, r);
  }
 
  return 0;
}

int I2cSrf08_RangingInCentimeters(I2cSrf08 *is)
{
  if(is->ranging == true)
    return 0;

  unsigned char buf[2];

  buf[0] = 0x0; /*  Register 0  */
  buf[1] = 81;  /*  Range in centimeters */
  if(write(is->fd, buf, 2) != 2)
    return -1;
 
  is->ranging = true;
 
  return 0;
}

int I2cSrf08_GetRange(I2cSrf08 *is)
{
  if(is->ranging == false)
    return 0;

  unsigned char buf[1];

  char hb, lb;

  buf[0] = 0x0; /*  Register 0 : software reversion */
  if(write(is->fd, buf, 1) != 1)
    return -1;
  if(read(is->fd, buf, 1) != 1) {
    printf("[SRF08] Fail to read !!!\n");
    return -1;
  }

  if(buf[0] == 0xff)  {
    printf("[SRF08] Range data not ready !!!\n");
    return -1;
  }

  buf[0] = 2; /*  Register 2, 4, 6 ...  */
  if(write(is->fd, buf, 1) != 1)
    return -1;

  if(read(is->fd, buf, 1) != 1)
    return -1;

  hb = buf[0];

  buf[0] = 3; /*  Register 3, 5, 7 ...  */
  if(write(is->fd, buf, 1) != 1)
    return -1;

  if(read(is->fd, buf, 1) != 1)
    return -1;

  lb = buf[0];

  is->ranging = false;
 
  if(hb == 0 && lb == 0)  {
    printf("[SRF08] Fail to get range !!!\n");
    return -1;
  }

  unsigned short r = (hb << 8) + lb;
 
  return (int)r;
}


ultra_sonic.c


/*
 * ultra_sonic.c : SRF08 ultra sonic range finder sample program
 *
 *  (C) 2011 by Steve Chang
 *  stevegigijoe@yahoo.com.tw
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#include

#include "i2c_srf08.h"

#define I2C_SRF08_DEVICE  "/dev/i2c-2"

int main(int argc, char **argv)
{
  I2cSrf08 *is = I2cSrf08_DefaultInstance(I2C_SRF08_DEVICE);
 
  int r = I2cSrf08_Open(is);
  if(r == -1) {
    printf("Fail to open %s\n", I2C_SRF08_DEVICE);
    goto leave;
  }

  while(1)
    I2cSrf08_BlockRangeInCentimeters(is);

leave:
  I2cSrf08_Close(is);

  return r;
}


The result as below

# ./ultra_sonic
[  851.740844] i2c_omap i2c_omap.2: Transmit error
[SRF08] 0st echo range = 32
[SRF08] 1st echo range = 86
[SRF08] 2st echo range = 150
[SRF08] 3st echo range = 216
[SRF08] 4st echo range = 280
[SRF08] 5st echo range = 344
[SRF08] 6st echo range = 410
[SRF08] 7st echo range = 474
[SRF08] 8st echo range = 560
[SRF08] 9st echo range = 795
[SRF08] 10st echo range = 926
[SRF08] 11st echo range = 1050
[SRF08] 0st echo range = 33
[SRF08] 1st echo range = 87
[SRF08] 2st echo range = 151
[SRF08] 3st echo range = 217
[SRF08] 4st echo range = 281
[SRF08] 5st echo range = 346
[SRF08] 6st echo range = 410
[SRF08] 7st echo range = 474
[SRF08] 8st echo range = 563
[SRF08] 9st echo range = 630
[SRF08] 10st echo range = 795





2011年4月8日 星期五

Beagleboard xM - Camera board

延續之前 DVSDK ,接著來看DSP Multimedia的應用

1.Beagleboard XM camera board
Leopard imaging inc 有一系列camera board支援BeagleBoard XM.
https://www.leopardimaging.com/Beagle_Board_xM_Camera.html\



有1.3M / 3M / 5M (百萬畫素) 鏡頭.其中 1.3M / 3M camera board 在 DVSDK 上已有driver.
我手邊有 LI-LBCM3M1 三百萬畫素 CMOS sensor mt9t111 (相容 mt9t112), DVSDK PSP linux已經包含mt9t112 driver.
載入camera driver需要修改bootloader 環境變數.
首先將SD card 連接至PC, 新增檔案BOOT/boot_dvi_lbcm3m1.cmd 如下

setenv bootargs 'console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw ip=off mem=55M@0x80000000 mpurate=1000  omap_vout.vid1_static_vrfb_alloc=y omapfb.vram=0:8M mem=384M@0x88000000 omapfb.mode=dvi:hd720 omapdss.def_disp=dvi rootwait vram=8M camera=lbcm3m1'
fatload mmc 0 80200000 uImage
bootm 80200000

接著產生 boot_dvi_lbcm3m1.scr

gigijoe@gigijoe-laptop:/media/BOOT$ mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'Execute Boot Script' -d boot_dvi_lbcm3m1.cmd boot_dvi_lbcm3m1.scr
Image Name:   Execute Boot Script
Created:      Tue Mar 29 20:19:04 2011
Image Type:   ARM Linux Script (uncompressed)
Data Size:    304 Bytes = 0.30 kB = 0.00 MB
Load Address: 0x00000000
Entry Point:  0x00000000
Contents:
   Image 0:      296 Bytes =    0 kB = 0 MB

增加camera=lbcm3m1,使相對應的driver會被自動載入.

root@beagleboard-dvsdk:~# lsmod
Module                  Size  Used by
sdmak                   3759  0
lpm_omap3530            6537  0
dsplinkk              124358  1 lpm_omap3530
cmemk                  21358  0
bufferclass_ti          4838  0
omaplfb                 8770  0
pvrsrvkm              129682  2 bufferclass_ti,omaplfb
ipv6                  249320  14
rtc_twl                 4263  0
rtc_core               12531  1 rtc_twl
mt9t112                 9329  0

2.Test camera board
首先先測試camera影像是否正常,最方便的方式是使用DVSDK built-in gstreamer
Camera device node 是 /dev/video0

gst-launch v4l2src always_copy=FALSE ! video/x-raw-yuv,width=640,height=480 ! queue max-size-buffers=8000 max-size-time=0 max-size-bytes=0 ! TIDmaiVideoSink videoStd=720P_60 videoOutput=AUTO numBufs=5

應該會在DVI output上看到影像



3.Play with camera board

現在來看實際上的應用,場景是將Camera board得到的影像透過DSP 壓縮成H.264格式,接著以RTP H.264封裝透過網路傳送到PC端,接著PC端將影像解壓縮並顯示在銀幕上

BeagleBoard XM : 192.168.168.89

gst-launch v4l2src always_copy=FALSE ! video/x-raw-yuv,width=640,height=480 ! queue max-size-buffers=8000 max-size-time=0 max-size-bytes=0 ! TIVidenc1 codecName=h264enc engineName=codecServer ! rtp264pay pt=96 ! multiudpsink client="192.168.168.56:1234"

PC : 192.168.168.56

gst-launch udpsrc port=1234 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" ! gstrtpjitterbuffer latency=100 ! rtph264depay ! ffdec_h264 ! xvimagesink



2011年3月30日 星期三

Beagleboard xM with TI DVSDK 4_01_00_09

Beagleboard xM 跟之前的 Beagleboard有相當多的差異,除了CPU / DSP 時脈的提昇,週邊也多了Ethernet, USB Hub 及 Camera interface.
不過 Nand flash 據說是因為成本的因素而拿掉了.因此Beagleboard xM只能經由 SD card boot.

TI DVSDK 提供很完整的多媒體展示,包含Media encode / decode, OpenGL 3D demo.
接下來將試著將Beagleboard xM DVSDK 安裝至 SD card.

1.參考DVSDK FAQ
http://processors.wiki.ti.com/index.php/DVSDK_4.x_FAQ#How_to_build_and_install_DVSDK_4.01_on_BeagleBoard-xM

根據DVSDK FAQ得知所需要的必要環境是 Ubuntu 10.04. Cross compile 為 CodeSourcery ARM 2009q1

2.Download DM3730 DVSDK 4.01 from TI
http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/dvsdk/DVSDK_4_00/latest/index_FDS.html
下載 dvsdk_dm3730-evm_4_01_00_09_setuplinux,大小約為1.5G.
下載時 TI 會要求帳號密碼,請自行註冊登入.注意帳號的Email 不能是yahoo之類的免費帳號.

下載完成後先變更檔案權限為可執行
$ chmod 755 dvsdk_dm3730-evm_4_01_00_09_setuplinux

執行安裝
$ ./dvsdk_dm3730-evm_4_01_00_09_setuplinux

3.Download patch script for DVSDK 4.01 to support BeagleBoard XM

http://processors.wiki.ti.com/images/5/5b/Setup-dvsdk-4-01-beaglexm-110126.zip

TI DVSDK並沒有支援Beagleboard xM,因此必須要做一些patch.
解開zip檔後會得到檔案 setup-dvsdk-4-01-beaglexm-110126.sh.
將它放在DVSDK root目錄,再依照以下內容修改 setup-dvsdk-4-01-beaglexm-110126.sh.



--- ../setup-dvsdk-4-01-beaglexm-110126.sh    2011-02-04 06:53:32.000000000 +0800
+++ setup-dvsdk-4-01-beaglexm-110126-fix.sh    2011-03-28 21:14:21.206840024 +0800
@@ -67,10 +67,10 @@
 
 # Comment out these 4 lines if you have direct internet connection
 
-PROXYHOST="foo.com"
-PROXYPORT="80"
-export http_proxy="http://${PROXYHOST}:${PROXYPORT}"
-export GIT_PROXY_COMMAND=./git-proxy.sh
+#PROXYHOST="foo.com"
+#PROXYPORT="80"
+#export http_proxy="http://${PROXYHOST}:${PROXYPORT}"
+#export GIT_PROXY_COMMAND=./git-proxy.sh
 
 # Generate git proxy command config script
 cat > git-proxy.sh <<_EOF
@@ -128,7 +128,9 @@
 
 # Apply the patches to the local repository
 for patchfile in ${XLOADPATCHESSTRIPPED} ; do
-    git am oepatches/$patchfile
+    git am --abort
+#    git am oepatches/$patchfile
+    git apply oepatches/$patchfile
 done
 
 cd ..



這個修改是為了可直接連上internet及修正 git am 所造成的 bug

4.變更權限並執行
$ chmod 755 setup-dvsdk-4-01-beaglexm-110126.sh
$ ./setup-dvsdk-4-01-beaglexm-110126.sh
這時這個script會自動去抓許多patch檔,並更新至DVSDK

5.編譯DVSDK
至DVSDK root目錄下

make clean
make all

6.安裝DVSDK 至 SD card

將SD card 連接至PC, 再來弄清楚device node為何 (用dmesg)
以我來說是 /dev/sdd

$ sudo bin/mksdboot.sh --device /dev/sdd --sdk ${PWD}
************************************************************
*         THIS WILL DELETE ALL THE DATA ON /dev/sdd        *
*                                                          *
*         WARNING! Make sure your computer does not go     *
*                  in to idle mode while this script is    *
*                  running. The script will complete,      *
*                  but your SD card may be corrupted.      *
*                                                          *
*         Press to confirm....                     *
************************************************************

unmounting device '/dev/sdd1'
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 0.904471 s, 1.2 MB/s
Disk /dev/sdd doesn't contain a valid partition table
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdd: 1949 cylinders, 255 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
 /dev/sdd: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdd1   *      0+      4       5-     40131    c  W95 FAT32 (LBA)
/dev/sdd2          5    1948    1944   15615180   83  Linux
/dev/sdd3          0       -       0          0    0  空
/dev/sdd4          0       -       0          0    0  空
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
Formating /dev/sdd1 ...
Formating /dev/sdd2 ...
mke2fs 1.41.11 (14-Mar-2010)
Image Name:   Execute uImage.bin
Created:      Mon Mar 28 20:31:49 2011
Image Type:   ARM Linux Script (uncompressed)
Data Size:    238 Bytes = 0.23 kB = 0.00 MB
Load Address: 0x00000000
Entry Point:  0x00000000
Contents:
   Image 0:      230 Bytes =    0 kB = 0 MB
Image Name:   Execute uImage.bin
Created:      Mon Mar 28 20:31:50 2011
Image Type:   ARM Linux Script (uncompressed)
Data Size:    289 Bytes = 0.28 kB = 0.00 MB
Load Address: 0x00000000
Entry Point:  0x00000000
Contents:
   Image 0:      281 Bytes =    0 kB = 0 MB
Select Primary display output:
 1: LCD
 2: DVI

Copying u-boot/mlo/uImage on /dev/sdd1
unmounting /dev/sdd1
Extracting filesystem on /dev/sdd2 ...
Creating matrix-gui-e symbolic link...done
unmounting /dev/sdd2
completed!
Updating FS with modified beagleboard-xM files
unmounting /dev/sdd2
Done



到這裡SD card已經準備好了

7.以SD card boot Beagleboard xM

boot成功最後會看到以下登入畫面,請以root登入,無須密碼.

Escape character is '^]'.

 _____                    _____           _         _  
|  _  |___ ___ ___ ___   |  _  |___ ___  |_|___ ___| |_
|     |  _| .'| . | . |  |   __|  _| . | | | -_|  _|  _|
|__|__|_| |__,|_  |___|  |__|  |_| |___|_| |___|___|_| 
              |___|                    |___|           

Arago Project http://arago-project.org beagleboard-dvsdk

Arago 2010.11 beagleboard-dvsdk

login: root
Last login: Thu Jan 13 23:28:57 on pts/0

來看看一些系統基本資訊

CPU跑1G Hz

root@beagleboard-dvsdk:~# cat /proc/cpuinfo
Processor       : ARMv7 Processor rev 2 (v7l)
BogoMIPS        : 996.74
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc08
CPU revision    : 2

Hardware        : OMAP3 Beagle Board
Revision        : 0020
Serial          : 0000000000000000


dsplink driver已經掛上,DSP可以使用了

root@beagleboard-dvsdk:~# lsmod
Module                  Size  Used by
sdmak                   3759  0
lpm_omap3530            6537  0
dsplinkk              124358  1 lpm_omap3530
cmemk                  21358  0
bufferclass_ti          4838  0
omaplfb                 8770  0
pvrsrvkm              129682  2 bufferclass_ti,omaplfb
ipv6                  249320  14
rtc_twl                 4263  0
rtc_core               12531  1 rtc_twl


將DVI 接頭接到 monitor 會看到 Demo 畫面,



Video encode / decode, OpenGL 3D Demo




還有一個Qt base browser



2011年3月14日 星期一

MySQL Setup

After compile & install MySQL there still something need to do.
In this case, MySQL install to /media/disk/usr/mysql
So, the $BASEDIR is /media/disk/usr/mysql

1.Create $BASEDIR/etc/my.cnf

# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password    = your_password
port        = 3306
socket        = /tmp/mysqld.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
user    = mysql
port        = 3306
socket        = /tmp/mysqld.sock
datadir        = /media/disk/usr/mysql/var
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
character-set-server=utf8
collation-server=utf8_general_ci


# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
server-id    = 1

# Uncomment the following if you want to log updates
#log-bin=mysql-bin

# binary logging format - mixed recommended
#binlog_format=mixed

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /media/disk/usr/mysql/var
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /media/disk/usr/mysql/var
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout

2.Create user mysql & group mysql

3.Change owner to user & group mysql
chown -R mysql:mysql /media/disk/usr/mysql/*

4.Install database
The datadir in my.cnf is the path to install database which is /media/disk/usr/mysql/var

Execute

# mysql_install_db --defaults-file=/media/disk/usr/mysql/etc/my.cnf --user=mysql

Installing MySQL system tables...
700101  0:34:10 [Warning] option 'myisam_max_extra_sort_file_size': unsigned value 2147483648 adjusted to 2147483647
OK
Filling help tables...
700101  0:34:10 [Warning] option 'myisam_max_extra_sort_file_size': unsigned value 2147483648 adjusted to 2147483647
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/media/disk/usr/mysql/bin/mysqladmin -u root password 'new-password'
/media/disk/usr/mysql/bin/mysqladmin -u root -h localhost password 'new-password'

Alternatively you can run:
/media/disk/usr/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /media/disk/usr/mysql ; /media/disk/usr/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /media/disk/usr/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /media/disk/usr/mysql/bin/mysqlbug script!

The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/

5.Setup MySQL user root password

# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

# mysql -u root mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.4.2-beta Source distribution

No entry for terminal type "vt102";
using dumb terminal settings.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> UPDATE user SET Password=PASSWORD('1234') where USER='root';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> exit
Bye

# killall -9 mysqld_safe mysqld
[2] - Killed                     bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking

6.Run MySQL server
# mysqld_safe --defaults-file=/media/disk/usr/mysql/etc/my.cnf &

7.Login MySQL

# mysql -u root -p

8.Example MySQL & php

mysql_connect.php

mysql_connect("localhost", "root", "1234") or die(mysql_error());
echo "Connected to MySQL
";
?>

mysql_select_db.php

mysql_connect("localhost", "root", "1234") or die(mysql_error());
echo "Connected to MySQL
";
mysql_select_db("test") or die(mysql_error());
echo "Connected to Database";
?>

Reference
http://amzshar.blogspot.com/2007/11/dba-mysqlsql.html



2011年1月28日 星期五

Cross Compile Lighttpd + PHP + MySQL for ARM (2)

5.Cross compile libiconv-1.13.1

$ CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar CXX=arm-none-linux-gnueabi-g++ ./configure --host=arm-linux --target=arm-linux --prefix=/opt/arm-2008q1/arm-none-linux-gnueabi/libc/usr --cache-file=/dev/null

$ make
$ sudo PATH=$PATH:/opt/arm-2008q1/bin make install

6.Cross compile libxml2-2.7.8

$ CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar CXX=arm-none-linux-gnueabi-g++ ./configure --host=arm-linux --target=arm-linux --prefix=/opt/arm-2008q1/arm-none-linux-gnueabi/libc/usr --cache-file=/dev/null

$ make
$ sudo PATH=$PATH:/opt/arm-2008q1/bin make install

7.Cross compile php-5.2.17

$ ac_cv_lib_mysqlclient_mysql_close=yes ac_cv_lib_mysqlclient_mysql_stmt_field_count=yes ac_cv_lib_mysqlclient_mysql_set_server_option=yes ac_cv_lib_mysqlclient_mysql_errno=yes ac_cv_func_iconv=yes CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar CXX=arm-none-linux-gnueabi-g++ ./configure --host=arm-linux --target=arm-linux --prefix=/home/gigijoe/BeagleBoard/rootfs/usr/local --disable-all --with-config-file-path=/rootfs/usr/local/etc --with-mysql=/home/gigijoe/BeagleBoard/rootfs/usr/local/mysql --with-mysqli=/home/gigijoe/BeagleBoard/rootfs/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysqld.sock --disable-rpath --enable-discard-path --enable-safe-mode --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-fastcgi --enable-force-cgi-redirect --enable-embedded-mysqli --with-libxml-dir=/opt/arm-2008q1/arm-none-linux-gnueabi/libc/usr --cache-file=/dev/null

$ make
$ make install

8.Cross compile lighttpd-1.4.28

$ CFLAGS="-I/home/gigijoe/BeagleBoard/rootfs/usr/local/mysql/include" CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar CXX=arm-none-linux-gnueabi-g++ ./configure --host=arm-linux --target=arm-linux --prefix=/home/gigijoe/BeagleBoard/rootfs/usr/local --with-mysql=/home/gigijoe/BeagleBoard/rootfs/usr/local/mysql --without-pcre --without-bzip2 --disable-ipv6 --cache-file=/dev/null

$ make
$ make install

9.ARM Target setup

記的將以上相關安裝到/opt/arm-2008q1/arm-none-linux-gnueabi/libc/usr的libraries複製到ARM target.

指定library搜尋路徑
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/mysql/lib

10.Reference

http://wiki.huihoo.com/index.php?title=FreeBSD_Lighttpd_PHP_MySQL

http://www.cmake.org/Wiki/CMake_Cross_Compiling

http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide

http://forge.mysql.com/wiki/CMake

http://redmine.lighttpd.net/wiki/1/TutorialConfiguration

http://www.memorybbs.com/cgi-bin/topic.cgi?forum=77&topic=92



Cross Compile Lighttpd + PHP + MySQL for ARM (1)

目標是要在ARM platform上跑HTTP Server並且支援PHP & MySQL.
HTTP server選擇lighttpd.整個cross comiple流程大致是先build MySQL,
因為PHP需要連結MySQL,再來是bulid PHP 最後才是lighttpd.
ARM cross compile 是 CodeSourcery 2008q1版本.

首先了解一下cross compile搜尋路徑
$ arm-none-linux-gnueabi-gcc -print-search-dirs
install: /opt/arm-2008q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.3/
programs: =/opt/arm-2008q1/bin/../libexec/gcc/arm-none-linux-gnueabi/4.2.3/:/opt/arm-2008q1/bin/../libexec/gcc/:/opt/arm-2008q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.3/../../../../arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi/4.2.3/:/opt/arm-2008q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.3/../../../../arm-none-linux-gnueabi/bin/
libraries: =/opt/arm-2008q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.3/:/opt/arm-2008q1/bin/../lib/gcc/:/opt/arm-2008q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.3/../../../../arm-none-linux-gnueabi/lib/arm-none-linux-gnueabi/4.2.3/:/opt/arm-2008q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.3/../../../../arm-none-linux-gnueabi/lib/:/opt/arm-2008q1/bin/../arm-none-linux-gnueabi/libc/lib/arm-none-linux-gnueabi/4.2.3/:/opt/arm-2008q1/bin/../arm-none-linux-gnueabi/libc/lib/:/opt/arm-2008q1/bin/../arm-none-linux-gnueabi/libc/usr/lib/arm-none-linux-gnueabi/4.2.3/:/opt/arm-2008q1/bin/../arm-none-linux-gnueabi/libc/usr/lib/

由以上libraries搜尋路徑偶選擇 /opt/arm-2008q1/arm-none-linux-gnueabi/libc/usr 作為相關所需libraries的安裝位置

1.Download & cross compile pcre-8.12 & ncurses-5.7

$ cd pcre-8.12/

$ CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar CXX=arm-none-linux-gnueabi-g++ ./configure --host=arm-linux --target=arm-linux --prefix=/opt/arm-2008q1/arm-none-linux-gnueabi/libc/usr --cache-file=/dev/null
$ make
$ sudo PATH=$PATH:/opt/arm-2008q1/bin make install

$ cd ../ncurses-5.7

$ CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar CXX=arm-none-linux-gnueabi-g++ ./configure --host=arm-linux --target=arm-linux --prefix=/opt/arm-2008q1/arm-none-linux-gnueabi/libc/usr --cache-file=/dev/null

$ make
$ sudo PATH=$PATH:/opt/arm-2008q1/bin make install

在make install 時加上PATH=$PATH:/opt/arm-2008q1/bin是為了在root權限下也能執行cross compiler.

2.Cross compile mysql-5.5.8

MySQL在5.5之後不在使用autoconf系統而採cmake.

建立 toolchain.cmake 內容如下

# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)

# specify the cross compiler
SET(CMAKE_C_COMPILER   /opt/arm-2008q1/bin/arm-none-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER /opt/arm-2008q1/bin/arm-none-linux-gnueabi-g++)
SET(CMAKE_STRIP           /opt/arm-2008q1/bin/arm-none-linux-gnueabi-strip)

# where is the target environment
SET(CMAKE_FIND_ROOT_PATH  /opt/arm-2008q1/arm-none-linux-gnueabi/libc)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

接著執行cmake

$ cmake -DCMAKE_TOOLCHAIN_FILE=./toolchain.cmake -DMYSQL_DATADIR=/var/lib/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DCMAKE_INSTALL_PREFIX=/home/gigijoe/BeagleBoard/rootfs/usr/local/mysql -DWITH_EMBEDDED_SERVER=1 -DCMAKE_C_COMPILER=arm-none-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-none-linux-gnueabi-g++ -DSTACK_DIRECTION=1

$ make VERBOSE=1

出現錯誤

[  2%] Building C object cmd-line-utils/libedit/CMakeFiles/edit.dir/term.c.o
cd /home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit && /opt/arm-2008q1/bin/arm-none-linux-gnueabi-gcc  -DHAVE_CONFIG_H -Wall -O2 -g -DDBUG_OFF -I/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit -I/home/gigijoe/BeagleBoard/mysql-5.5.8/include   -o CMakeFiles/edit.dir/term.c.o   -c /home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c
/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c:59:20: error: curses.h: No such file or directory
/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c: In function 'term_set':
/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c:928: warning: implicit declaration of function 'tgetent'
/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c:946: warning: implicit declaration of function 'tgetflag'
/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c:955: warning: implicit declaration of function 'tgetnum'
/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c:959: warning: implicit declaration of function 'tgetstr'
/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c:960: warning: passing argument 3 of 'term_alloc' makes pointer from integer without a cast
/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c: In function 'term_tputs':
/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c:1261: warning: implicit declaration of function 'tputs'
/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c: In function 'term_echotc':
/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c:1560: warning: assignment makes pointer from integer without a cast
make[2]: *** [cmd-line-utils/libedit/CMakeFiles/edit.dir/term.c.o] Error 1
make[2]: Leaving directory `/home/gigijoe/BeagleBoard/mysql-5.5.8'
make[1]: *** [cmd-line-utils/libedit/CMakeFiles/edit.dir/all] Error 2
make[1]: Leaving directory `/home/gigijoe/BeagleBoard/mysql-5.5.8'
make: *** [all] Error 2

修改 /home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit/term.c

#ifdef HAVE_CURSES_H
-#include
+#include
#endif
#ifdef HAVE_NCURSES_H
-#include
+#include
#endif
/* Don't use Solaris's term.h. */
#if (defined(HAVE_TERM_H) && !defined(__SunOS))
-#include
+#include
#endif

再次嘗試

$ make VERBOSE=1

出現錯誤

[ 28%] Generating ../include/mysqld_error.h, ../sql/share/english/errmsg.sys
cd /home/gigijoe/BeagleBoard/mysql-5.5.8/extra && ./comp_err --charset=/home/gigijoe/BeagleBoard/mysql-5.5.8/sql/share/charsets --out-dir=/home/gigijoe/BeagleBoard/mysql-5.5.8/sql/share/ --header_file=/home/gigijoe/BeagleBoard/mysql-5.5.8/include/mysqld_error.h --name_file=/home/gigijoe/BeagleBoard/mysql-5.5.8/include/mysqld_ername.h --state_file=/home/gigijoe/BeagleBoard/mysql-5.5.8/include/sql_state.h --in_file=/home/gigijoe/BeagleBoard/mysql-5.5.8/sql/share/errmsg-utf8.txt
./comp_err: 1: Syntax error: word unexpected (expecting ")")
make[2]: *** [include/mysqld_error.h] Error 2
make[2]: Leaving directory `/home/gigijoe/BeagleBoard/mysql-5.5.8'
make[1]: *** [extra/CMakeFiles/GenError.dir/all] Error 2
make[1]: Leaving directory `/home/gigijoe/BeagleBoard/mysql-5.5.8'
make: *** [all] Error 2

有個comp_err無法執行,先找出它在哪

$ find ./ -name "comp_err" -print
./extra/comp_err

看一下屬性

$ file ./extra/comp_err
./extra/comp_err: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped

嗯,看來需要先在host side compile mysql.

3.Compile mysql-5.5.8 for host

$ cmake -DMYSQL_DATADIR=/var/lib/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DWITH_EMBEDDED_SERVER=1 -DSTACK_DIRECTION=1

$ make VERBOSE=1

4.Continue cross compile mysql-5.5.8

以host版本comp_err覆蓋

$ cp ../../mysql-5.5.8/extra/comp_err extra/

$ make VERBOSE=1

出現錯誤

[ 75%] Building CXX object client/CMakeFiles/mysql.dir/sql_string.cc.o
cd /home/gigijoe/BeagleBoard/mysql-5.5.8/client && /opt/arm-2008q1/bin/arm-none-linux-gnueabi-g++   -DHAVE_CONFIG_H -DHAVE_DLOPEN -Wall -Wno-unused-parameter -fno-implicit-templates -fno-exceptions -fno-rtti -O2 -g -DDBUG_OFF -I/home/gigijoe/BeagleBoard/mysql-5.5.8/include -I/home/gigijoe/BeagleBoard/mysql-5.5.8/libmysql -I/home/gigijoe/BeagleBoard/mysql-5.5.8/regex -I/home/gigijoe/BeagleBoard/mysql-5.5.8/sql -I/home/gigijoe/BeagleBoard/mysql-5.5.8/strings -I/home/gigijoe/BeagleBoard/mysql-5.5.8/cmd-line-utils/libedit -I/home/gigijoe/BeagleBoard/mysql-5.5.8/client   -o CMakeFiles/mysql.dir/sql_string.cc.o -c /home/gigijoe/BeagleBoard/mysql-5.5.8/client/sql_string.cc
Linking CXX executable mysql
cd /home/gigijoe/BeagleBoard/mysql-5.5.8/client && /usr/bin/cmake -E cmake_link_script CMakeFiles/mysql.dir/link.txt --verbose=1
/opt/arm-2008q1/bin/arm-none-linux-gnueabi-g++    -Wall -Wno-unused-parameter -fno-implicit-templates -fno-exceptions -fno-rtti -O2 -g -DDBUG_OFF   CMakeFiles/mysql.dir/completion_hash.cc.o CMakeFiles/mysql.dir/mysql.cc.o CMakeFiles/mysql.dir/readline.cc.o CMakeFiles/mysql.dir/sql_string.cc.o  -o mysql  -lpthread ../libmysql/libmysqlclient.a ../cmd-line-utils/libedit/libedit.a -lz -lm -lrt -ldl -lpthread -lcurses
/opt/arm-2008q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.3/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lcurses
collect2: ld returned 1 exit status
make[2]: *** [client/mysql] Error 1
make[2]: Leaving directory `/home/gigijoe/BeagleBoard/mysql-5.5.8'
make[1]: *** [client/CMakeFiles/mysql.dir/all] Error 2
make[1]: Leaving directory `/home/gigijoe/BeagleBoard/mysql-5.5.8'
make: *** [all] Error 2

用以下方式修正

編輯
/home/gigijoe/BeagleBoard/mysql-5.5.8/client/CMakeFiles/mysql.dir/link.txt

/home/gigijoe/BeagleBoard/mysql-5.5.8/libmysqld/examples/CMakeFiles/mysql_embedded.dir/link.txt

將 -lcurses 成 -lncurses

$ make VERBOSE=1

出現錯誤

[ 76%] Generating mysql_fix_privilege_tables_sql.c
cd /home/gigijoe/BeagleBoard/mysql-5.5.8/scripts && /usr/bin/cmake -E chdir /home/gigijoe/BeagleBoard/mysql-5.5.8/scripts /bin/cat mysql_system_tables.sql mysql_system_tables_fix.sql > /home/gigijoe/BeagleBoard/mysql-5.5.8/scripts/mysql_fix_privilege_tables.sql
cd /home/gigijoe/BeagleBoard/mysql-5.5.8/scripts && /home/gigijoe/BeagleBoard/mysql-5.5.8/scripts/comp_sql mysql_fix_privilege_tables mysql_fix_privilege_tables.sql mysql_fix_privilege_tables_sql.c
/home/gigijoe/BeagleBoard/mysql-5.5.8/scripts/comp_sql: 1: Syntax error: word unexpected (expecting ")")
make[2]: *** [scripts/mysql_fix_privilege_tables_sql.c] Error 2
make[2]: Leaving directory `/home/gigijoe/BeagleBoard/mysql-5.5.8'
make[1]: *** [scripts/CMakeFiles/GenFixPrivs.dir/all] Error 2
make[1]: Leaving directory `/home/gigijoe/BeagleBoard/mysql-5.5.8'
make: *** [all] Error 2

以host版本comp_sql覆蓋

$ cp ../../mysql-5.5.8/scripts/comp_sql scripts/

$ make VERBOSE=1

出現錯誤

[ 78%] Generating lex_hash.h
cd /home/gigijoe/BeagleBoard/mysql-5.5.8/sql && ./gen_lex_hash > lex_hash.h
./gen_lex_hash: 1: Syntax error: word unexpected (expecting ")")
make[2]: *** [sql/lex_hash.h] Error 2
make[2]: Leaving directory `/home/gigijoe/BeagleBoard/mysql-5.5.8'
make[1]: *** [sql/CMakeFiles/GenServerSource.dir/all] Error 2
make[1]: Leaving directory `/home/gigijoe/BeagleBoard/mysql-5.5.8'
make: *** [all] Error 2

以host版本gen_lex_hash覆蓋

cp ../../mysql-5.5.8/sql/gen_lex_hash sql/

$ make VERBOSE=1

$ make install