ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

顯示具有 ProblemAndSolve 標籤的文章。 顯示所有文章
顯示具有 ProblemAndSolve 標籤的文章。 顯示所有文章

2014年2月5日 星期三

Segmentation fault -- Android C program debug

某個 C program - MccAccess,run 到後來會出現 Segmentation fault
然後沒有任何 message, 也沒有 core dump, kernel denug message 等。
要 debug (找出 fault 的位置)..

先是用 None-stripped version (包含 debug symbol).
在 out/target/product/ss7/obj/EXECUTABLES/MccAccess_intermediates/LINKED/ 下的 MccAccess 就是 none-stripped 版。

push 到system/bin/ 取代 stripped 版後。

再來,設定不限制 core dump size:
#ulimit -c unlimited

然後 run program, 讓他發生 core dump..

之後,在你所在目錄就會有 core dump file, 一般是 core.pid, pid 是那個 program 的 pid.
但是在這個 android 系統,沒有附加 pid,所以就是 core

接著開啟 gdb 吃 MccAccess 和 core:
# gdb /System/bin/MccAccess core

gdb 就會直接顯示最後的 fault 位置:
sh-4.2# gdb /system/bin/McuAccess core
GNU gdb (Linaro GDB) 7.3-2011.10
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-none-linux-gnueabi".
For bug reporting instructions, please see:
...
Reading symbols from /system/bin/McuAccess...done.

warning: exec file is newer than core file.
[New LWP 1108]
[New LWP 1107]
[New LWP 1109]
[New LWP 1110]
Core was generated by `McuAccess'.
Program terminated with signal 11, Segmentation fault.
#0  memcpy () at bionic/libc/arch-arm/bionic/memcpy.S:203
203     bionic/libc/arch-arm/bionic/memcpy.S: No such file or directory.
        in bionic/libc/arch-arm/bionic/memcpy.S

不清楚的話 (像,是在 std c lib 中),可以用 bt 列出 stack backtrace:
(gdb) bt
#0  memcpy () at bionic/libc/arch-arm/bionic/memcpy.S:203
#1  0x0000b2fe in CheckMcuCmdID () at RT/Tony/MccAccess/FunctionDef.c:484
#2  0x0000b636 in CheckRxDataFromMcu ()
    at RT/Tony0921/MccAccess/FunctionDef.c:754
#3  0x0000b6e2 in RxUart (arg=)
    at RT/Tony/MccAccess/FunctionDef.c:780
#4  0x00011c10 in __thread_entry (func=0xb6d1 , arg=0x0,
    tls=) at bionic/libc/bionic/pthread.c:213
#5  0x000117d0 in pthread_create (thread_out=, attr=0x159f0,
    start_routine=0xb6d1 , arg=0x0) at bionic/libc/bionic/pthread.c:349
#6  0x00000000 in ?? ()


這樣就很清楚了。


ref: debugging segment fault with gdb

2013年10月23日 星期三

firefox for amd64 . debian

debian squeeze, amd64, 安裝firefox 要用 64bit (x86_64)。
在 firefox download page 的都不是 64。
所以執起來會有一堆 lib, XPCOM load 不到的問題。

x86_64 版是用 google 找到的...
http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/latest/linux-x86_64/

download, 解開,執行... OK

2013年5月10日 星期五

Rainbow Tables -- 平衡的 "運算--查表" 式 暴力破解法

新同學給的:(总结)密码破解之王:Ophcrack彩虹表(Rainbow Tables)原理

這個好厲害,是暴力破解法耶。
適當的利用 cpu mips 縮減 "暴力table" 的 size 到合理大小。

2011年1月21日 星期五

libusb-dev , libusb.h & usb.h

libusb 的 header file 好像換掉了,不是 libusb.h,改成 usb.h

用 aptitude search libusb 可以看到有 libusb-dev 這個 package。
install 後,用 dpkg -L libusb-dev 看一下這個 package 裝了什麼東西:
$dpkg -L libusb-dev /usr/bin/libusb-config /usr/include/usb.h /usr/lib/libusb.a /usr/lib/libusb.la /usr/lib/pkgconfig /usr/lib/pkgconfig/libusb.pc /usr/lib/libusb.so 可以看到沒有 libusb.h ....

libusb.org 有說明 這個相容性問題 http://www.libusb.org/wiki/libusb-1.0#Backwardscompatibility
libusb-1.0 is not backwards compatible with libusb-0.1 - all function names are different, etc. 
However, libusb-1.0 is designed to be happily installable alongside libusb-0.1 (even in the default 
configuration) so the lack of backwards compatibility is not really a problem - users can have both 
libusb versions present on the same system without conflict.

That said, there is a libusb-compat-0.1 compatibility layer. This is a "wrapper" which converts 
libusb-0.1 function calls to their 1.0 equivalents. For more info, see libusb-compat-0.1.
所以..要麻 install libusb-0.1 ,不然就要 libusb-compat-0.1。
不然就要改code.

把 code 的 include libusb.h 改 usb.h 試試。
就 OK 了。



從 pkg -L libusb 的 list 可以看到,有提供 libusb-config。
試 run 一下:
$libusb-config Usage: libusb-config [OPTIONS] [LIBRARIES] Options: [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags] 可以知道,就像 libsdl,用 libusb-config --libs , libusb-config --cflags 會列出build 時的 參數。



ref : http://www.linuxquestions.org/questions/linux-newbie-8/ubuntu-9-10-include-libusb-libusb-h-802880/

2010年12月10日 星期五

more on serial programming - termios and read/write raw data

上次 tty (UART) 的測試,結果我丟一個 0x0d, 0x0a ,對方卻收到 0x0d,0x0d,0x0a。 因為tty 會特別處理 控制字元,用 termios structure 可以知道: tty = open("/dev/ttymxc2",O_RDWR | O_NOCTTY | O_NONBLOCK); tcgetattr(tty,&tio); printf("c_oflag:"); if(tio.c_oflag & OPOST){ printf("OPOST "); if( tio.c_oflag & ONLCR) printf("-ONLCR"); if( tio.c_oflag & OCRNL) printf("-OCRNL"); if( tio.c_oflag & ONOCR) printf("-ONOCR"); if( tio.c_oflag & ONLRET) printf("-ONLRET"); printf("\n"); } printf("c_iflag:"); if(tio.c_iflag & IGNBRK) printf("-IGNBRK"); if(tio.c_iflag & BRKINT) printf("-BRKINT"); if(tio.c_iflag & IGNPAR) printf("-IGNPAR"); if(tio.c_iflag & PARMRK) printf("-PARMRK"); if(tio.c_iflag & INPCK) printf("-INPCK"); if(tio.c_iflag & ISTRIP) printf("-ISTRIP"); if(tio.c_iflag & INLCR) printf("-INLCR"); if(tio.c_iflag & IGNCR) printf("-IGNCR"); if(tio.c_iflag & ICRNL) printf("-ICRNL"); if(tio.c_iflag & IUCLC) printf("-IUCLC"); if(tio.c_iflag & IXON) printf("-IXON"); if(tio.c_iflag & IXANY) printf("-IXANY"); if(tio.c_iflag & IXOFF) printf("-IXOFF"); if(tio.c_iflag & IMAXBEL) printf("-IMAXBEL"); printf("\n"); run 的結果是: c_oflag:OPOST -ONLCR c_iflag:-ICRNL-IXON 參考這一篇,有解釋每個 bit field 的意義。 ONLCR - 會把 0x0a 變成 0x0d,0x0a. 所以我要把 OPST 這個 bit clear 掉...
要 read raw data, 參考 這一篇 (Serial Proramming Guide in POSIX System)。 termios 的 lflag 是: options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); 如果是要 output raw data,就只要: options.c_oflag &= ~OPOST; ... 那篇文章最後就有 raw data input/output 的 code: int fd; struct termios options; /* open the port */ fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY); fcntl(fd, F_SETFL, 0); /* get the current options */ tcgetattr(fd, &options); /* set raw input, 1 second timeout */ options.c_cflag |= (CLOCAL | CREAD); options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); options.c_oflag &= ~OPOST; options.c_cc[VMIN] = 0; options.c_cc[VTIME] = 10; /* set the options */ tcsetattr(fd, TCSANOW, &options);
read tty 的動作 (block, no block , wait time, how many bytes.. etc) 是由 c_cc[VMIN], c_cc[VTIME] 的值決定的。 有關 c_cc[] 中 VMIN, VTIME 的功能: (ref : Nonecanonical Input)
  • VMIN : 至少收到多少 bytes 後 return
  • VTIME : 達成 收到 VMIN bytes 的條件後,多少時間 timout 後 return.
所以..
  • c_cc[VMIN], c_cc[VTIME] 的值都是 0 : 有沒有資料都會立刻 return,不過有資料的時候,會把資料都讀出來再return.
  • c_cc[VMIN]=0, c_cc[VTIME] 不是 0 : 等 c_cc[VTIME] 都沒有資料就 return.,如果有收到 data 就立刻 return
  • c_cc[VMIN] 不是 0, c_cc[VTIME] = 0 : 一定要等到收到 c_cc[VMIN] 個資料後才 return.
  • c_cc[VMIN], c_cc[VTIME] 都不是 0 : ..

後來又發現,對方送 0x0d, 0x0a,我收到 0x0a, 0x0a。 確認一下, c_iflag 要 mask 掉 + options.c_iflag &= ~(INLCR | IGNCR | ICRNL); 才行

2010年12月9日 星期四

install flash plugin failed in 10.10

10.10 amd64 在 install flash plugin 時,會出現要去 canonical download gz 檔的時候,沒有辦法 download. 這是因為她沒有看 系統的 proxy 設定。 在 launpad 也有列出這一項..Flash Plugin / Update Manager / PROXY not being honored 解決的方法就是 .... 到沒有 proxy 的地方去裝 XD
..等 install retry 20 次 fail 後,關掉 firefox,在 console 把http_proxy 環境變數設好,然後: sudo bash -c 'eval $(apt-config shell http_proxy Acquire::http::Proxy) dpkg-reconfigure flashplugin-installer' 就會正常經由 proxy download 了。

2010年3月2日 星期二

run another vncserver

這裡 看到的.. 原來可以這麼簡單,就直接 run 另一個 VNC server 起來。 這樣,前一個 qemu 起不來的問題就可以解了..
vncserver :1
啟動 vncserver,使用 graphic console 1 graphic console 0 是目前的 windows (除非你是在console mode)。 vncsever listen port 從 5900 開始,所以 console 1 是 5901

2010年2月25日 星期四

kernel building error on gcc 4.3 - __umoddi3()

真誇張:
busybox -- qemu boot with preload kernel -- ref jserv's tutorial -- build kernel fail 
-- workaround on CFLAG -- GCC 4.3 problem -- GCC 4.3 optimize functions -- example 
test code

繞了好大一圈,已經離 busybox 很遠了..
最後是 這一篇 王聰 先生的blog : __umoddi3()的問題 有比較清楚的說明: (copy 一下,以免消失.. 對不起)

以下 copy 自 王聰 先生的 blog 文章:
===========================================================
在編譯內核時有人遇到下面這個問題:

kernel/built-in.o: In function `getnstimeofday':
(.text+0xb6ae): undefined reference to `__umoddi3'
kernel/built-in.o: In function `getnstimeofday':
(.text+0xb6ce): undefined reference to `__udivdi3'

這個問題可以在用戶空間重現,不過不是很容易,我實驗了一下,在i386上,並不是所有的64位整數操作都會被轉化成
調用__umoddi3,gcc bugzilla上有演示程序,如下:
PLAIN TEXT
C:

  1.#define NSEC_PER_SEC  1000000000UL     
  2.int rmg(void);
  3.
  4.int main(void)
  5.{
  6.  /* int sec; */
  7.  return rmg();
  8.}
  9.
 10.int rmg(void)
 11.{
 12.  static unsigned long long nsec = 0;
 13.  static int sec = 0;
 14.  while (sec <1 ) {
 15.    nsec++;
 16.    while (__builtin_expect(nsec>= NSEC_PER_SEC, 0)) {
 17.    nsec -= NSEC_PER_SEC;
 18.    ++sec;
 19.    }
 20.  } 
 21.  return sec;
 22.}

這樣編譯它:% gcc -nostdlib -O2 -o umoddi3 umoddi3.c,就會得到:

/tmp/ccycM684.o: In function `rmg':
umoddi3.c:(.text+0x87): undefined reference to `__udivdi3'
collect2: ld returned 1 exit status

問題重現了。這裡的問題是,對於nsec來說,內層的循環其實等價於求模運算,gcc在優化時發現了這一點,而且硬件
本身也不支持對64位整數直接進行算術運算,所以gcc會把這一步優化成調用內部函數__udivdi3()和
__umoddi3(),這兩個函數在libgcc中(見gcc源代碼 gcc/libgcc2.c),libgcc默認和libc一樣是要被加載
的,但如果我們加了-nostdlib(Linux內核是更好的例子),這個問題就會出現了。

知道原因了,怎麼解決?網上有兩種方法,一種是像這個補丁那樣,在循環中插入下面這條內聯彙編:

asm("" : "+r"(ns));

這句是告訴gcc把ns這個變量放到寄存器中,並且既有讀操作也有寫操作,所以後面再用它時必須重新讀取,這樣就消
除了上面的優化。

另一種解決方法是添加新的編譯選項:-fno-tree-scev-cprop,這個選項似乎沒有文檔,至少我沒找到。說說它的
大體意思。scev 應該是SCalar EVolutions,什麼意思不知道。:( cprop應該是Copy PROPagation,這個應
該很容易理解,就是賦值的傳播,比如:

i = 10;
a = i;
b = i;

其實就是:

a = 10;
b = 10;

可見,編譯優化是門大學問,寫個編譯器絲毫不比寫個內核容易。:-P
============王聰先生的文章copy到此==============

2009年11月12日 星期四

ubuntu 9.10 on IBM R40e

The problem on the noise spark of LCD panel is the "Visual Effect".
Just turn off all the visual effect on "Preference - Apperence", the noise spark disappeared.

2009年6月29日 星期一

ubuntu memory larger than 4G

MB : ASUS P5B Plus 裝上 8G的RAM後,free顯示只有3.6G。 所以follow 這一篇說明,update server image,reboot 後,就可以看到 8G了 (奇怪,是 6.?G)
$ sudo sudo apt-get install linux-headers-server linux-image-server linux-server

2009年6月26日 星期五

build pilot-link-0.12.4

在這download..
解開後,看 README,照著作:
./configure --prefix=/home/charles/pilot
make結果出現 error:
contactsdb-test.c:28:18: 錯誤: popt.h:沒有此一檔案或目錄
contactsdb-test.c: In function 「main」:
contactsdb-test.c:348: 警告: 「pilot_connect」 is deprecated (declared at ../include/pi-header.h:31)
make[2]: *** [contactsdb-test.o] Error 1
make[2]: Leaving directory `/home/charles-chang/pilot-link-0.12.4/tests'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/charles-chang/pilot-link-0.12.4'
make: *** [all] Error 2
看一下,是有 popt 這個 folder,也有 popt.h 呀。 所以用 ./configure --help 看一下.. 有這個選項:
  --enable-conduits       Build the userland conduits
所以 重新 configure..
./configure --enable-conduits --prefix=/home/charles/pilot
這樣出現的config message 就有:
  Userland Tools
-------------------------.
Build userland tools.... : yes
Support for popt........ : yes (internal)
之後再make 就 OK 了!

2009年6月24日 星期三

rpmdb: Lock table is out of available locker entries

就是在 redhat 上 run yum command 出現的 error message:
$ sudo yum
rpmdb: Lock table is out of available locker entries
rpmdb: Unknown locker ID: bc0
error: db4 error(22) from db->close: 不適用的引數
error: cannot open Packages index using db3 - 無法配置記憶體 (12)
error: cannot open Packages database in /var/lib/rpm
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in ?
    yummain.main(sys.argv[1:])
  File "/usr/share/yum-cli/yummain.py", line 85, in main
    base.getOptionsConfig(args)
  File "/usr/share/yum-cli/cli.py", line 163, in getOptionsConfig
    disabled_plugins=self.optparser._splitArg(opts.disableplugins))
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 164, in _getConfig
    self._conf = config.readMainConfig(startupconf)
  File "/usr/lib/python2.4/site-packages/yum/config.py", line 685, in readMainConfig
    yumvars['releasever'] = _getsysver(startupconf.installroot, startupconf.distroverpkg)
  File "/usr/lib/python2.4/site-packages/yum/config.py", line 752, in _getsysver
    idx = ts.dbMatch('provides', distroverpkg)
TypeError: rpmdb open failed
這一篇 說,這是因為上次執行 yum 到一半被強制 kill,所以 lock file 沒有release。 解開的方法:
rm /var/lib/rpm/__db.00*
rpm --rebuilddb

2009年2月3日 星期二

Git behind proxy

在公司用 git,因為有 proxy,所以找了一下,大部分都是說加上 http_proxy 環境變數後,原來是 git:// 的,改為 http:// 就可以了。 但是 這個是 repo,所以不能這樣用。 找到一篇:repo behine proxy copy 一下內容:
Basically the steps are:
1 - sudo apt-get install socket
2 - in your home directory, put a shell script called "proxy-cmd.sh"
containing (replace YOUR_PROXY and YOUR_PROXY_PORT with your own proxy
parameters):
#! /bin/bash
(echo "CONNECT $1:$2 HTTP/1.0"; echo; cat ) | socket YOUR_PROXY
YOUR_PROXY_PORT | (read a; read a; cat )
3 - chmod +x proxy-cmd.sh
4 - export GIT_PROXY_COMMAND=<PATH TO YOUR SCRIPT>/proxy-cmd.sh

Enjoy,
Matthieu

PS: you can export GIT_PROXY_COMMAND in your ~/.bashrc file to make
this permanent 
還沒確認有沒有效...
這一篇有說明 socket command : git via a proxy server
From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Date: 2006-05-18 18:31:32

On Wed, 2006-05-17 20:44:28 -0700, Sam Song <samlinuxkernel@yahoo.com> wrote:
> Petr Vandrovec <petr@vmware.com> wrote:
> > Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> > > Well, install some package to have `socket'
> > > available? Debian calls
> > > the packet `socket', too, so I guess Fedora may
> > > have something similar.
> >
> > Surprisingly they do not...  You should be able to
> > replace 'socket' with
> > 'netcat' - and I believe that netcat/nc package is
> > available for Fedora.  For
> > this purpose they have same command line & behavior.
>
> Ummm, I am trying on that. nc is avaiable for Fedora.
> But what could be the replacement for CONNECT in
> Fedora? :-)

Erm, you haven't understood what you're doing there, have you?

With the GIT_PROXY_COMMAND helper, you're expected to create a clean
tunnel which in turn git can use to transfer its data.

You've only got some limited internet connectivity via a HTTP proxy
available, so you need to use this. This means:

 * The proxy administrator needs to allos outgoing connections for
   the CONNECT method with git's TCP port.
 * You need to have some minimalistic program to initially speak HTTP
   with the proxy and later on just stream the raw git protocol
   through the link.
 * You may or may not need to strip anything that came into the git
   stream by accident because you tunnled it through a HTTP proxy. A
   reply message from the proxy server is an example for this.

So this little script (using "CONNECT" and netcat or socket) does the
first part: it talks in the language HTTP with the proxy server. It
may be enough to just use CONNECT, but you may need to speak some more
lines, eg. for proxy authorization.

The first `cat' in there is just for pushing the git protocol though the
HTTP proxy connection later on (hopefully after the proxy was made to
accept the the CONNECT request.)  Once the proxy accepted it, it'll
send you a HTTP/200 message (or something like that) and an empty
line. This is what the two reads are for; the next `cat' simply again
transfers all the rest (the git protocol).

To draw the line, there's not _one_ solution to HTTP proxy tunneling,
there are many, and you'll need to design one that fits your network.
It should be quite simple, given that you've got nice tools like
`strace' and `tcpdump', which will help you to understand how the
proxy reacts and so on.

MfG, JBG

--
Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
für einen Freien Staat voll Freier Bürger"  | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


結果...
charles-chang@rbtlegacy:~/android-eee$ repo init -u git://android.git.kernel.org/platform/manifest.git
Getting repo ...
   from git://android.git.kernel.org/tools/repo.git
fatal: protocol error: bad line length character
所以是 Fail... 不知道是不是公司的squid proxy 不允許 CONNECT 這個 operation. 同樣的一篇有說:
Note: most HTTP proxy servers allow CONNECT method to a very limited
range of ports, and administrators will need to enable the git port
(9418) explicitly. 
所以要問 MIS 有沒有 允許 CONNECT method和開啟 git 要用的 9418 port。

2008年12月25日 星期四

自動 mount 拇指碟,要有 floppy 權限

插入拇指碟,出現 message 說權限不符。 只好手動 mount 進來,但是又不能任意修改,因為file owner 是 root (因為是用 sudo mount)。 是因為我沒有 存取 floppy 的權限,把自己加入 group : floppy 後,就會自動 mount 和跳出 檔案管理員。

2008年11月11日 星期二

TortoiseSVN : branch fail

這一版 TortoiseSVN 有點問題..
TortoiseSVN 1.5.5, Build 14361 - 32 Bit , 2008/10/24 18:06:34 Subversion 1.5.4, apr 1.2.12 apr-utils 1.2.12 berkeley db 4.4.20 neon 0.28.3 OpenSSL 0.9.8i 15 Sep 2008 zlib 1.2.3
不知道是因為我是從舊svn升級,還是什麼原因。不能 branch working copy. 會出現:
C:\WINCE500\PLATFORM\STMP37xx_BSP\SRC\BOOTLOADER\RBoot\ROmain.cpp
Commit failed (details follow):
File
'/svn/PND/RN1-RN2/branch/SW/Charles/tmp/081111_justtest/SRC/BOOTLOADER/RBoot/ROmain.cpp'
already exists
這樣的 Error。 奇怪的是我在另一台機器就不會有這樣的問題。 Google 的結果,雖然優有一些人有相同的問題,但是developer 的回答都是:他不會發生,所以沒辦法 debug... ...這大概是 local svn cache 的問題吧。 所以,使用大絕招:
  1. create patch
  2. delete entire source tree
  3. checkout
  4. apply patch
  5. brach ! .... OK
這樣就 OK 啦。

標籤

網誌存檔