Typhoon Race 2010 in Hong Kong
2010年11月25日 星期四
2010年11月17日 星期三
Real-Time Object Detection by Stefan Hintersser running on linux Intel X86
Computer Version is an interesting topic, I found an implementation of real-time object detection which is really work on my linux X86.
Stefan Hintersser home page
http://campar.in.tum.de/Main/StefanHinterstoisser
Document
http://campar.in.tum.de/personal/hinterst/index/project/CVPR10.pdf
Although the author says it can work on linux but not really tested.
Now, let's do some fix to get it work.
1.Download and install source code and all necessary libraries
Source code
http://campar.in.tum.de/personal/hinterst/index/downloads.html
OpenCV
ESM
ftp://ftp-sop.inria.fr/evolution/malis/software/ESM/ESMkitLin_0_4.tar.gz
Install in
$DOT_vs_1.0/resources/ESM/ESMkitLin
Intel IPP
I'm running with Intel IPP 6.0.1.071. it installed in /opt
1.Create Makefile
CC=gcc
AR=ar
CFLAGS=-Wall -O3 -funroll-loops -msse2 -I./include -I/usr/include/opencv -I/opt/intel/ipp/6.0.1.071/ia32/include -I./resources/ESM/ESMkitLin/inc
LDFLAGS=-L/opt/intel/ipp/6.0.1.071/ia32/lib -lcv -lcvaux -lhighgui -lcxcore -lippcvmerged -lippmemerged -lippmmerged -lippccmerged -lipprmerged -lippiemerged -lippimerged -lippsemerged -lippsmerged -lippsrmerged -lippcore -lm
LIBS=src/cv_camera.o src/cv_utilities.o src/cv_esm.o
%.o : %.cc
$(CC) -c $(CFLAGS) $< -o $@
all : main_dot2D main_dot3D
main_dot2D : ${LIBS} src/main_dot2D.o
${CC} -o $@ ${LIBS} src/main_dot2D.o ${LDFLAGS} resources/ESM/ESMkitLin/lib/ESMlib.a
main_dot3D : ${LIBS} src/main_dot3D.o
${CC} -o $@ ${LIBS} src/main_dot3D.o ${LDFLAGS} resources/ESM/ESMkitLin/lib/ESMlib.a
clean :
rm -rf src/*.o
2.Then make.
After successful compile and link
run ./main_dot2D
The program almost eating all CPU resource and window shows nothing.
I found the camera frame rate seems too high (90 fps !!!)
So I try to reduce the frame rate by change
int l_key = cvWaitKey(1);
to
int l_key = cvWaitKey(60);
Now it's worked ...



Stefan Hintersser home page
http://campar.in.tum.de/Main/StefanHinterstoisser
Document
http://campar.in.tum.de/personal/hinterst/index/project/CVPR10.pdf
Although the author says it can work on linux but not really tested.
Now, let's do some fix to get it work.
1.Download and install source code and all necessary libraries
Source code
http://campar.in.tum.de/personal/hinterst/index/downloads.html
OpenCV
ESM
ftp://ftp-sop.inria.fr/evolution/malis/software/ESM/ESMkitLin_0_4.tar.gz
Install in
$DOT_vs_1.0/resources/ESM/ESMkitLin
Intel IPP
I'm running with Intel IPP 6.0.1.071. it installed in /opt
1.Create Makefile
CC=gcc
AR=ar
CFLAGS=-Wall -O3 -funroll-loops -msse2 -I./include -I/usr/include/opencv -I/opt/intel/ipp/6.0.1.071/ia32/include -I./resources/ESM/ESMkitLin/inc
LDFLAGS=-L/opt/intel/ipp/6.0.1.071/ia32/lib -lcv -lcvaux -lhighgui -lcxcore -lippcvmerged -lippmemerged -lippmmerged -lippccmerged -lipprmerged -lippiemerged -lippimerged -lippsemerged -lippsmerged -lippsrmerged -lippcore -lm
LIBS=src/cv_camera.o src/cv_utilities.o src/cv_esm.o
%.o : %.cc
$(CC) -c $(CFLAGS) $< -o $@
all : main_dot2D main_dot3D
main_dot2D : ${LIBS} src/main_dot2D.o
${CC} -o $@ ${LIBS} src/main_dot2D.o ${LDFLAGS} resources/ESM/ESMkitLin/lib/ESMlib.a
main_dot3D : ${LIBS} src/main_dot3D.o
${CC} -o $@ ${LIBS} src/main_dot3D.o ${LDFLAGS} resources/ESM/ESMkitLin/lib/ESMlib.a
clean :
rm -rf src/*.o
2.Then make.
After successful compile and link
run ./main_dot2D
The program almost eating all CPU resource and window shows nothing.
I found the camera frame rate seems too high (90 fps !!!)
So I try to reduce the frame rate by change
int l_key = cvWaitKey(1);
to
int l_key = cvWaitKey(60);
Now it's worked ...
2010年9月24日 星期五
Rowboat Android Overlay Setup
There are some trick to setup omap overlay
1. omap_vout omap_vout: probed for an unknown device
To fix this problem set u-boot environment variable
setenv optargs 'init=/init omapdss.def_disp=dvi omapfb.mode=dvi:1280x1024MR-16@60 vram=4M omapfb.vram=0:4M'
http://groups.google.com/group/beagleboard/browse_thread/thread/ff11355c5834a187
2.TIDmaiVideoSink params
Make sure what video output you are using ...
gst-launch-0.10 -v videotestsrc ! TIDmaiVideoSink videoStd=VGA videoOutput=DVI sync=false
gst-launch-0.10 filesrc location=/sdcard/video.mp4 ! typefind ! qtdemux name=demux demux.video_00 ! queue ! TIViddec2 ! TIDmaiVideoSink videoStd=VGA videoOutput=DVI sync=false
3.Resolution issue
Refer this mail
Juan,
Juan Garibay wrote:
> Hi,
>
> I was facing the same issue described by Abdi and I followed the instructions described in the following link:
> http://code.google.com/p/rowboat/wiki/ConfigureAndBuild#External_Display
> Here it is specified to use "omap-dss.def_disp" and "omapfb.video_mode" without mentioning the kernel version constrains, it would be nice to update it.
ok
>
> Using the parameters mentioned by Vladimir, I am able to set different resolutions however the highest resolution for which it works is 1280x720MR-16@60. According to the "Video modes for external display" section from this link:
> http://code.google.com/p/rowboat/wiki/SimpleTests
> The BeagleBoard should also support 1280x1024MR-16@60 , 1440x900MR-16@60, 1440x1050MR-16@60,1600x1024MR-16@60 but I am getting the following error:
try to add these option in your kernel command line: vram=XXX
for example for 1280x1024MR-16@60 you should add vram=4M
1440x1050MR-16@60, vram=6M
1600x1024MR-16@60, vram=7M
etc, the equation to calculate the vram value is x_res*y_rex*4
Regards,
Vladimir
>
> omaplfb: OMAPLFB_Init: OMAPLFBInit failed
>
> Can anyone help me on this?
>
> I am using a Beagle C2, rowboat-eclair-dsp.xml and as display a TV that supports fullHD (1920x1080) so it should not be an issue.
>
> Regards,
> Juan Garibay
>
>
>
>
>
> > Date: Wed, 15 Sep 2010 18:20:49 +0400
> > From: batareich@gmail.com
> > To: rowboat@googlegroups.com
> > Subject: Re: [rowboat] Display resolution
> >
> > abdi farah wrote:
> > > Hi,
> > >
> > >
> > > I would like to know how to change the display resolution using
> > > rowboat-android.
> > > I manage to port rowboat-android 2.1 to beagleboard revc4.
> > >
> > > i used the console commands:
> > >
> > > #Beagleboard# setenv bootcmd 'mmc init; fatload mmc 0 84000000 uImage; bootm 84000000'
> > > #Beagleboard# setenv bootargs 'mem=128M androidboot.console=ttyS2 console=tty0 console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw
> > >
> > > init=/init rootwait omapfb.video_mode=640x480MR-16@60'
> > these params are redundant since they are siutable for 2.6.29.
> > The 2.6.32 DSS takes these parameters from kernel command line -
> > omapdss.def_disp and omapfb.mode, f.e:
> > omapdss.def_disp=dvi omapfb.mode=dvi:720x576MR-16@60
> >
> > >
> > > #Beagleboard# saveenv
> > > Beagleboard# reset
> > > i try to change the second line to my desired resolution. but it does
> > > not change anything.
> > >
> > > Best regards
> > > Abdi
1. omap_vout omap_vout: probed for an unknown device
To fix this problem set u-boot environment variable
setenv optargs 'init=/init omapdss.def_disp=dvi omapfb.mode=dvi:1280x1024MR-16@60 vram=4M omapfb.vram=0:4M'
http://groups.google.com/group/beagleboard/browse_thread/thread/ff11355c5834a187
2.TIDmaiVideoSink params
Make sure what video output you are using ...
gst-launch-0.10 -v videotestsrc ! TIDmaiVideoSink videoStd=VGA videoOutput=DVI sync=false
gst-launch-0.10 filesrc location=/sdcard/video.mp4 ! typefind ! qtdemux name=demux demux.video_00 ! queue ! TIViddec2 ! TIDmaiVideoSink videoStd=VGA videoOutput=DVI sync=false
3.Resolution issue
Refer this mail
Re: [rowboat] Display resolution
...| 寄件者: | Vladimir Barinov ... | |
| 收件者: | rowboat@googlegroups.com |
Juan,
Juan Garibay wrote:
> Hi,
>
> I was facing the same issue described by Abdi and I followed the instructions described in the following link:
> http://code.google.com/p/rowboat/wiki/ConfigureAndBuild#External_Display
> Here it is specified to use "omap-dss.def_disp" and "omapfb.video_mode" without mentioning the kernel version constrains, it would be nice to update it.
ok
>
> Using the parameters mentioned by Vladimir, I am able to set different resolutions however the highest resolution for which it works is 1280x720MR-16@60. According to the "Video modes for external display" section from this link:
> http://code.google.com/p/rowboat/wiki/SimpleTests
> The BeagleBoard should also support 1280x1024MR-16@60 , 1440x900MR-16@60, 1440x1050MR-16@60,1600x1024MR-16@60 but I am getting the following error:
try to add these option in your kernel command line: vram=XXX
for example for 1280x1024MR-16@60 you should add vram=4M
1440x1050MR-16@60, vram=6M
1600x1024MR-16@60, vram=7M
etc, the equation to calculate the vram value is x_res*y_rex*4
Regards,
Vladimir
>
> omaplfb: OMAPLFB_Init: OMAPLFBInit failed
>
> Can anyone help me on this?
>
> I am using a Beagle C2, rowboat-eclair-dsp.xml and as display a TV that supports fullHD (1920x1080) so it should not be an issue.
>
> Regards,
> Juan Garibay
>
>
>
>
>
> > Date: Wed, 15 Sep 2010 18:20:49 +0400
> > From: batareich@gmail.com
> > To: rowboat@googlegroups.com
> > Subject: Re: [rowboat] Display resolution
> >
> > abdi farah wrote:
> > > Hi,
> > >
> > >
> > > I would like to know how to change the display resolution using
> > > rowboat-android.
> > > I manage to port rowboat-android 2.1 to beagleboard revc4.
> > >
> > > i used the console commands:
> > >
> > > #Beagleboard# setenv bootcmd 'mmc init; fatload mmc 0 84000000 uImage; bootm 84000000'
> > > #Beagleboard# setenv bootargs 'mem=128M androidboot.console=ttyS2 console=tty0 console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw
> > >
> > > init=/init rootwait omapfb.video_mode=640x480MR-16@60'
> > these params are redundant since they are siutable for 2.6.29.
> > The 2.6.32 DSS takes these parameters from kernel command line -
> > omapdss.def_disp and omapfb.mode, f.e:
> > omapdss.def_disp=dvi omapfb.mode=dvi:720x576MR-16@60
> >
> > >
> > > #Beagleboard# saveenv
> > > Beagleboard# reset
> > > i try to change the second line to my desired resolution. but it does
> > > not change anything.
> > >
> > > Best regards
> > > Abdi
2010年9月15日 星期三
Extract Ubuntu initrd.img
mkdir initrd
cd initrd
cp /boot/initrd.img-2.6.32-21-generic-pae .
sudo mv initrd.img-2.6.32-21-generic-pae initrd.img-2.6.32-21-generic-pae.gz
sudo gzip -dc initrd.img-2.6.32-21-generic-pae.gz | sudo cpio -id
cd initrd
cp /boot/initrd.img-2.6.32-21-generic-pae .
sudo mv initrd.img-2.6.32-21-generic-pae initrd.img-2.6.32-21-generic-pae.gz
sudo gzip -dc initrd.img-2.6.32-21-generic-pae.gz | sudo cpio -id
2010年9月3日 星期五
Get default gateway in C language
紀錄一下這件看起來很簡單的事
呼叫 SxNetDefaultGateway() 傳回 default gateway
Source code below
/* numeric: & 0x8000: default instead of *,
* & 0x4000: host instead of net,
* & 0x0fff: don't resolve
*/
char *INET_rresolve(struct sockaddr_in *s_in, int numeric, uint32_t netmask)
{
/* addr-to-name cache */
struct addr {
struct addr *next;
struct sockaddr_in addr;
int host;
char name[1];
};
/*
static struct addr *cache = NULL;
struct addr *pn;
char *name;
uint32_t ad, host_ad;
int host = 0;
*/
uint32_t ad;
/* Grmpf. -FvK */
if (s_in->sin_family != AF_INET) {
#ifdef DEBUG
printf("rresolve: unsupported address family %d!",
s_in->sin_family);
#endif
errno = EAFNOSUPPORT;
return NULL;
}
ad = s_in->sin_addr.s_addr;
#ifdef DEBUG
printf("rresolve: %08x, mask %08x, num %08x", (unsigned)ad, netmask, numeric);
#endif
if (ad == INADDR_ANY) {
if ((numeric & 0x0FFF) == 0) {
if (numeric & 0x8000)
return strdup("default");
return strdup("*");
}
}
if (numeric & 0x0FFF)
return strdup(inet_ntoa(s_in->sin_addr));
return 0;
}
#ifndef RTF_UP
/* Keep this in sync with /usr/src/linux/include/linux/route.h */
#define RTF_UP 0x0001 /* route usable */
#define RTF_GATEWAY 0x0002 /* destination is a gateway */
#define RTF_HOST 0x0004 /* host entry (net otherwise) */
#define RTF_REINSTATE 0x0008 /* reinstate route after tmout */
#define RTF_DYNAMIC 0x0010 /* created dyn. (by redirect) */
#define RTF_MODIFIED 0x0020 /* modified dyn. (by redirect) */
#define RTF_MTU 0x0040 /* specific MTU for this route */
#ifndef RTF_MSS
#define RTF_MSS RTF_MTU /* Compatibility :-( */
#endif
#define RTF_WINDOW 0x0080 /* per route window clamping */
#define RTF_IRTT 0x0100 /* Initial round trip time */
#define RTF_REJECT 0x0200 /* Reject route */
#endif
static const unsigned flagvals[] = { /* Must agree with flagchars[]. */
RTF_GATEWAY,
RTF_HOST,
RTF_REINSTATE,
RTF_DYNAMIC,
RTF_MODIFIED,
#if ENABLE_FEATURE_IPV6
RTF_DEFAULT,
RTF_ADDRCONF,
RTF_CACHE
#endif
};
#define IPV4_MASK (RTF_GATEWAY|RTF_HOST|RTF_REINSTATE|RTF_DYNAMIC|RTF_MODIFIED)
#define IPV6_MASK (RTF_GATEWAY|RTF_HOST|RTF_DEFAULT|RTF_ADDRCONF|RTF_CACHE)
/* Must agree with flagvals[]. */
static const char flagchars[] =
"GHRDM"
#if ENABLE_FEATURE_IPV6
"DAC"
#endif
;
static void set_flags(char *flagstr, int flags)
{
int i;
*flagstr++ = 'U';
for (i = 0; (*flagstr = flagchars[i]) != 0; i++) {
if (flags & flagvals[i]) {
++flagstr;
}
}
}
const char *SxNetDefaultGateway()
{
char devname[64], flags[16];
static char *sdest = 0, *sgw = 0;
unsigned long d, g, m;
int flgs, ref, use, metric, mtu, win, ir;
struct sockaddr_in s_addr;
struct in_addr mask;
FILE *fp = fopen("/proc/net/route", "r");
if(!fp)
return 0;
if (fscanf(fp, "%*[^\n]\n") < 0) { /* Skip the first line. */
goto ERROR; /* Empty or missing line, or read error. */
}
while (1) {
int r;
r = fscanf(fp, "%63s%lx%lx%X%d%d%d%lx%d%d%d\n",
devname, &d, &g, &flgs, &ref, &use, &metric, &m,
&mtu, &win, &ir);
if (r != 11) {
if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */
break;
}
ERROR:
fclose(fp);
perror("fscanf");
return 0;
}
if (!(flgs & RTF_UP)) { /* Skip interfaces that are down. */
continue;
}
set_flags(flags, (flgs & IPV4_MASK));
#ifdef RTF_REJECT
if (flgs & RTF_REJECT) {
flags[0] = '!';
}
#endif
if(sdest) free(sdest);
if(sgw) free(sgw);
memset(&s_addr, 0, sizeof(struct sockaddr_in));
s_addr.sin_family = AF_INET;
s_addr.sin_addr.s_addr = d;
sdest = INET_rresolve(&s_addr, (0x0fff | 0x8000), m); /* 'default' instead of '*' */
s_addr.sin_addr.s_addr = g;
sgw = INET_rresolve(&s_addr, (0x0fff | 0x4000), m); /* Host instead of net */
mask.s_addr = m;
/* "%15.15s" truncates hostnames, do we really want that? */
/*
printf("%-15.15s %-15.15s %-16s%-6s", sdest, sgw, inet_ntoa(mask), flags);
if (netstatfmt) {
printf("%5d %-5d %6d %s\n", mtu, win, ir, devname);
} else {
printf("%-6d %-2d %7d %s\n", metric, ref, use, devname);
}
*/
if(flgs & RTF_GATEWAY) {
fclose(fp);
return sgw;
}
}
fclose(fp);
return 0;
}
呼叫 SxNetDefaultGateway() 傳回 default gateway
Source code below
/* numeric: & 0x8000: default instead of *,
* & 0x4000: host instead of net,
* & 0x0fff: don't resolve
*/
char *INET_rresolve(struct sockaddr_in *s_in, int numeric, uint32_t netmask)
{
/* addr-to-name cache */
struct addr {
struct addr *next;
struct sockaddr_in addr;
int host;
char name[1];
};
/*
static struct addr *cache = NULL;
struct addr *pn;
char *name;
uint32_t ad, host_ad;
int host = 0;
*/
uint32_t ad;
/* Grmpf. -FvK */
if (s_in->sin_family != AF_INET) {
#ifdef DEBUG
printf("rresolve: unsupported address family %d!",
s_in->sin_family);
#endif
errno = EAFNOSUPPORT;
return NULL;
}
ad = s_in->sin_addr.s_addr;
#ifdef DEBUG
printf("rresolve: %08x, mask %08x, num %08x", (unsigned)ad, netmask, numeric);
#endif
if (ad == INADDR_ANY) {
if ((numeric & 0x0FFF) == 0) {
if (numeric & 0x8000)
return strdup("default");
return strdup("*");
}
}
if (numeric & 0x0FFF)
return strdup(inet_ntoa(s_in->sin_addr));
return 0;
}
#ifndef RTF_UP
/* Keep this in sync with /usr/src/linux/include/linux/route.h */
#define RTF_UP 0x0001 /* route usable */
#define RTF_GATEWAY 0x0002 /* destination is a gateway */
#define RTF_HOST 0x0004 /* host entry (net otherwise) */
#define RTF_REINSTATE 0x0008 /* reinstate route after tmout */
#define RTF_DYNAMIC 0x0010 /* created dyn. (by redirect) */
#define RTF_MODIFIED 0x0020 /* modified dyn. (by redirect) */
#define RTF_MTU 0x0040 /* specific MTU for this route */
#ifndef RTF_MSS
#define RTF_MSS RTF_MTU /* Compatibility :-( */
#endif
#define RTF_WINDOW 0x0080 /* per route window clamping */
#define RTF_IRTT 0x0100 /* Initial round trip time */
#define RTF_REJECT 0x0200 /* Reject route */
#endif
static const unsigned flagvals[] = { /* Must agree with flagchars[]. */
RTF_GATEWAY,
RTF_HOST,
RTF_REINSTATE,
RTF_DYNAMIC,
RTF_MODIFIED,
#if ENABLE_FEATURE_IPV6
RTF_DEFAULT,
RTF_ADDRCONF,
RTF_CACHE
#endif
};
#define IPV4_MASK (RTF_GATEWAY|RTF_HOST|RTF_REINSTATE|RTF_DYNAMIC|RTF_MODIFIED)
#define IPV6_MASK (RTF_GATEWAY|RTF_HOST|RTF_DEFAULT|RTF_ADDRCONF|RTF_CACHE)
/* Must agree with flagvals[]. */
static const char flagchars[] =
"GHRDM"
#if ENABLE_FEATURE_IPV6
"DAC"
#endif
;
static void set_flags(char *flagstr, int flags)
{
int i;
*flagstr++ = 'U';
for (i = 0; (*flagstr = flagchars[i]) != 0; i++) {
if (flags & flagvals[i]) {
++flagstr;
}
}
}
const char *SxNetDefaultGateway()
{
char devname[64], flags[16];
static char *sdest = 0, *sgw = 0;
unsigned long d, g, m;
int flgs, ref, use, metric, mtu, win, ir;
struct sockaddr_in s_addr;
struct in_addr mask;
FILE *fp = fopen("/proc/net/route", "r");
if(!fp)
return 0;
if (fscanf(fp, "%*[^\n]\n") < 0) { /* Skip the first line. */
goto ERROR; /* Empty or missing line, or read error. */
}
while (1) {
int r;
r = fscanf(fp, "%63s%lx%lx%X%d%d%d%lx%d%d%d\n",
devname, &d, &g, &flgs, &ref, &use, &metric, &m,
&mtu, &win, &ir);
if (r != 11) {
if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */
break;
}
ERROR:
fclose(fp);
perror("fscanf");
return 0;
}
if (!(flgs & RTF_UP)) { /* Skip interfaces that are down. */
continue;
}
set_flags(flags, (flgs & IPV4_MASK));
#ifdef RTF_REJECT
if (flgs & RTF_REJECT) {
flags[0] = '!';
}
#endif
if(sdest) free(sdest);
if(sgw) free(sgw);
memset(&s_addr, 0, sizeof(struct sockaddr_in));
s_addr.sin_family = AF_INET;
s_addr.sin_addr.s_addr = d;
sdest = INET_rresolve(&s_addr, (0x0fff | 0x8000), m); /* 'default' instead of '*' */
s_addr.sin_addr.s_addr = g;
sgw = INET_rresolve(&s_addr, (0x0fff | 0x4000), m); /* Host instead of net */
mask.s_addr = m;
/* "%15.15s" truncates hostnames, do we really want that? */
/*
printf("%-15.15s %-15.15s %-16s%-6s", sdest, sgw, inet_ntoa(mask), flags);
if (netstatfmt) {
printf("%5d %-5d %6d %s\n", mtu, win, ir, devname);
} else {
printf("%-6d %-2d %7d %s\n", metric, ref, use, devname);
}
*/
if(flgs & RTF_GATEWAY) {
fclose(fp);
return sgw;
}
}
fclose(fp);
return 0;
}
2010年8月27日 星期五
Android 心得感想
還記的一年前Android大張旗鼓出現,偶當時也具有高度的興趣,因為base on linux而且open source.
而且google也在Android上導入open source所缺乏的重要軟體,例如Web Browser, 穩定的Java VM等.
這一年來偶接觸過兩個Android platform分別是TI OMAP 3530 & Samsung S3C6410, 軟體的部份有修改一些driver以符合Android的要求,簡單的JNI及Android application.偶嘗試以技術的角度將這些與Android的經歷紀錄下來.
1.Linux kernel
Linux kernel必須加上一些Android fix & driver才能跑Android.
例如,比較奇特的像是pmem driver,用來保留memory給Android使用.
坦白說為了特定application保留memory這件事偶個人覺得非常不妥,
一般都是保留給其他hardware使用像是DSP而且也不需要額外的driver來處理,
只要在kernel param設定mem=XXX就能保留剩下的memory,甚至是保留特定memory region也可透過類似方式達到.是效率或著是security issue非得用如此的作法不可嗎 ?
這只是冰山一角,還有其他特異的程式碼在系統中運作著.
事實上Linux Kernel的維護者已經在年初宣佈移除所有Android相關的程式碼.
2.Where is linux ?
第一次順利booting kernel啟動Android進入console之後偶發現一切都很陌生.
是的,的確有個shell,很難用的shell... OK,Android自己搞的shell.
每個指令的功能都陽春到不行,backspace & tab key都不能用.進入/etc目錄之後更是大吃一驚,在UNIX系統沿用多年的許多系統檔案都不見了,全部被Android一手包辦.
在Android 中init.rc這個檔案負責系統初始化的設定,如mount file system, init network 及週邊初始化.其中的script語法並非shell script而是Android自訂的key word所組成.
嗯,這真的不是Linux更不是UNIX like system.
Android是以linux kernel為核心基礎也僅只於此了.
3.Porting Android
Android 具有跨平台在不同CPU上工作的能力,但porting的工作則是各憑本事.
目前Embedded ARM CPU往往有許多特殊硬體的功能,例如2D, 3D graphic engine, video coder及camera interface等.
這些功能在linux kernel driver端常常就有許多新增的ioctl及操作流程,porting的困難是需要對driver及Android都有相當程度的了解才能進行的下去.
在開發環境上以往熟悉的Makefile已經被Android.mk取代,完全不同於傳統Embedded System.
Android對自身系統設計的文件並不多,但光從source code的量來看要能有詳細的文件確實是很難.
所以想要porting Android到產品等級絕對不是幾個有經驗的工程師就能作到其中的know how真的非常多.
4.Java VM
Android提供一個Java VM Engine - dalvik,我相當喜歡這樣的設計.dalvik提供一個可以達到同一個application java binary在不同平台執行,而且其效能不見得比native binary來的差.不過這不是絕對的,例如Android允許使用JNI的方式撰寫直接控制硬體或是連結close source binary.許多商業軟體就會透過這種方式達到保護自身利益.java binary跨平台的特性也因此弱化了.但不可否認的是使用Java 單一語言來開發application的確是很大的好處,尤其是Graphic Interface.如果是c/c++因為語言開放特性的關係就算有完整library也不是一件容易的事(例如QT, gtk).
而且google也在Android上導入open source所缺乏的重要軟體,例如Web Browser, 穩定的Java VM等.
這一年來偶接觸過兩個Android platform分別是TI OMAP 3530 & Samsung S3C6410, 軟體的部份有修改一些driver以符合Android的要求,簡單的JNI及Android application.偶嘗試以技術的角度將這些與Android的經歷紀錄下來.
1.Linux kernel
Linux kernel必須加上一些Android fix & driver才能跑Android.
例如,比較奇特的像是pmem driver,用來保留memory給Android使用.
坦白說為了特定application保留memory這件事偶個人覺得非常不妥,
一般都是保留給其他hardware使用像是DSP而且也不需要額外的driver來處理,
只要在kernel param設定mem=XXX就能保留剩下的memory,甚至是保留特定memory region也可透過類似方式達到.是效率或著是security issue非得用如此的作法不可嗎 ?
這只是冰山一角,還有其他特異的程式碼在系統中運作著.
事實上Linux Kernel的維護者已經在年初宣佈移除所有Android相關的程式碼.
2.Where is linux ?
第一次順利booting kernel啟動Android進入console之後偶發現一切都很陌生.
是的,的確有個shell,很難用的shell... OK,Android自己搞的shell.
每個指令的功能都陽春到不行,backspace & tab key都不能用.進入/etc目錄之後更是大吃一驚,在UNIX系統沿用多年的許多系統檔案都不見了,全部被Android一手包辦.
在Android 中init.rc這個檔案負責系統初始化的設定,如mount file system, init network 及週邊初始化.其中的script語法並非shell script而是Android自訂的key word所組成.
嗯,這真的不是Linux更不是UNIX like system.
Android是以linux kernel為核心基礎也僅只於此了.
3.Porting Android
Android 具有跨平台在不同CPU上工作的能力,但porting的工作則是各憑本事.
目前Embedded ARM CPU往往有許多特殊硬體的功能,例如2D, 3D graphic engine, video coder及camera interface等.
這些功能在linux kernel driver端常常就有許多新增的ioctl及操作流程,porting的困難是需要對driver及Android都有相當程度的了解才能進行的下去.
在開發環境上以往熟悉的Makefile已經被Android.mk取代,完全不同於傳統Embedded System.
Android對自身系統設計的文件並不多,但光從source code的量來看要能有詳細的文件確實是很難.
所以想要porting Android到產品等級絕對不是幾個有經驗的工程師就能作到其中的know how真的非常多.
4.Java VM
Android提供一個Java VM Engine - dalvik,我相當喜歡這樣的設計.dalvik提供一個可以達到同一個application java binary在不同平台執行,而且其效能不見得比native binary來的差.不過這不是絕對的,例如Android允許使用JNI的方式撰寫直接控制硬體或是連結close source binary.許多商業軟體就會透過這種方式達到保護自身利益.java binary跨平台的特性也因此弱化了.但不可否認的是使用Java 單一語言來開發application的確是很大的好處,尤其是Graphic Interface.如果是c/c++因為語言開放特性的關係就算有完整library也不是一件容易的事(例如QT, gtk).
2010年8月18日 星期三
Maemo 5 DBus 初探
DBus 在Maemo 5系統中是很重要的 IPC 功能,透過DBus可以控制許多硬體如LED, Keypad,甚至是撥電話及發簡訊.現在我想要在程式執行時LCD panel不要進入power saving而關閉也需要透過DBus.
1.Reference
http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/DBus/DBus_Basics
http://maemo.org/api_refs/5.0/5.0-final/mce-dev/dbus-names_8h.html#c9f233f336f9be78f223a31866455b80
http://www.mail-archive.com/maemo-developers@maemo.org/msg01889.html
2.以下的程式碼片段就是我想要的囉
1.Reference
http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/DBus/DBus_Basics
http://maemo.org/api_refs/5.0/5.0-final/mce-dev/dbus-names_8h.html#c9f233f336f9be78f223a31866455b80
http://www.mail-archive.com/maemo-developers@maemo.org/msg01889.html
2.以下的程式碼片段就是我想要的囉
DBusConnection *conn;
DBusMessage *msg = NULL;
DBusError dbus_error;
dbus_bool_t dresult;
#define MCE_SERVICE "com.nokia.mce"
#define MCE_REQUEST_PATH "/com/nokia/mce/request"
#define MCE_REQUEST_IF "com.nokia.mce.request"
#define MCE_PREVENT_BLANK_REQ "req_display_blanking_pause"
dbus_error_init(&dbus_error);
conn = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);
msg = dbus_message_new_method_call(MCE_SERVICE,
MCE_REQUEST_PATH,
MCE_REQUEST_IF,
MCE_PREVENT_BLANK_REQ);
if (msg == NULL)
return;
dresult = dbus_connection_send (conn, msg, NULL);
if (!dresult)
{
dbus_message_unref(msg);
return;
}
dbus_connection_flush(conn);
dbus_message_unref(msg);
訂閱:
文章 (Atom)