2013年9月3日 星期二

change svn file access mode

svn propset svn:executable '*' 

2013年8月22日 星期四

用 ARP proxy 去模擬單一 MAC 多 ip answering 的實驗

實作步驟
1. 先打開 arp proxy
echo 1 > /proc/sys/net/ipv4/conf/__you_device__/proxy_arp
2. 設定 device ip
ifconfig __you_device__ 192.168.60.200 up
原本以為,這樣設定了之後,arp proxy 就可以通了,但是不行

3. 胡亂自己湊了一些網路上的指令
arp -i br0 -Ds 192.168.60.2 br0 pub
還是不通

4. 最後,鬼使神差的,把 route 移走,突然就通了
第一步 ... 還是沒有作用
ip r d 192.168.60.0/24 dev __your_device__  proto kernel  scope link  src 192.168.60.1
第二步 ...
ip r a 192.168.60.0/24 dev __other_device__  proto kernel  scope link  src 192.168.60.1
突然就通了,見鬼,難道是七月到了嗎!!


2013年8月3日 星期六

Remote Debug with GDB

今天在追 code 的時候,突然想把遺忘多年的 GDB 再 build 出來,遠端 debug 一下 embedded system 上的 code。廢話少說,進入步驟
1. 和 local debug 當然不一樣,我原本以為要 build 一個再 target device 上的 gdb 命令,NO !!! 教學上說,要 build 一個 gdbserver

2. gdb server 在哪裡呢?在 toolchain 裡面,所以需要重新把 toolchain 編譯出來,同時啟用 toolchain 的 gdb 選項

3. Build 出來 toolchain 以後,多了一個 gdb 目錄,裡面有 build 出來的 gdb(提供給 PC 上使用),還有一個 gdbserver 目錄,裡面有裡面有 gdbserver 命令,是要放在 remote target 上面的 ---- 也就是說,如果沒有 vender 的 toolchain source build,只有 build 好的 toolchain 的話,還是不能用

4. 把gdbserver 放到 target device 上,參考教程,執行
gdbserver :51234 command_to_be_debug

5. 用剛剛build 的,toolchain 裡面的 gdb,執行以後,出現gdb的 prompt
 gdb)

6. 執行 target remote target_device_ip:51234

7. 用 load-symbol command_to_be_debug ,這樣就可以把 symbol load 進來

8. 可以設 break point 了,萬歲

2013年5月2日 星期四

Add subversion 1.7 client

sudo apt-get install subversion
sudo apt-add-repository ppa:dominik-stadler/subversion-1.7
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade 
    

Android project including with errors --- fixed

今天在處理一個 Android sample code 的時候,突然愈到了一些問題,解完了之後,深深覺得,這樣的系統性問題,應該更加用心去了解
遇到的問題
1. @override 會出現 error
2. 就算把 @override 都拿掉,還是會出現其他莫名奇妙的 error
這兩個 error,實際上是Eclipse 選到了 JDK5 的語法
可是 ***
絕對不是我們安裝來的 JDK 是 JDK5,我們可能已經裝過 JDK6/JDK7 了,那到底是怎樣呢?
a. 如果你的 javac -version 顯示的是 1.5.xx,麻煩請到 sun oracle 的網站上抓 jdk6 / jdk7
b. 如果你已經裝過 jdk6/idk7,那就到 project -> properties -> Java Compiler -> Compiler Compliance Level,調到 1.6 以上,這樣就可以去掉 1,2 的 error 了

3. 突然間,R 有找不到了有找不到了
R 就是 android resource 自動產生的 class,所以 R 找不到,試試看以下的步驟
a. clean project
--> 沒用,下一步
b. close Eclipse, delete gen / bin directories in the folder, restart Eclipse
--> 沒用,下一步
c. go into resource directory, change "All" upper case file name to lower case, change the name in code too.
--> 沒用,下一步.............
d. Look at compile console, if there is a "resource generating failed" message, check the fail item and do related work.
 *example* if you have a.gif and a.png, the Java will complain : a is multiple defined.
delete one of the image and restart eclipse.

2013年4月29日 星期一

Add exfat support for ubuntu

sudo apt-add-repository ppa:relan/exfat
sudo apt-get update
sudo apt-get install fuse-exfat

2013年4月18日 星期四

vlan setting

For  Ralink SoC switch, we needs

VLAN port group setting (0x70)
VLAN ID setting (0x50)
VLAN port untag setting (0x98) 
VLAN port pvid setting       (0x40)
VLAN accept/reject policy (0x14)

For Atheros switch

We can set additional
Port forwarding group
Ingress/egress setting

2013年4月15日 星期一

Bit bucket usage

cd /path/to/my/repo git remote add origin https://MYNAME@bitbucket.org/MYNAME/MYPROJECT.git git push -u origin --all # to push changes for the first time

2013年3月16日 星期六

Build vim environment

remap is an option that makes mappings work recursively. By default it is on and I'd recommend you leave it that way. The rest are mapping commands, described below:
:map and :noremap are recursive and non-recursive versions of the various mapping commands. What that means is that if you do:
:map j gg
:map Q j
:noremap W j
j will be mapped to gg. Q will also be mapped to gg, because j will be expanded for the recursive mapping. W will be mapped to j (and not to gg) because j will not be expanded for the non-recursive mapping.
Now remember that Vim is a modal editor. It has a normal mode, visual mode and other modes.
For each of these sets of mappings, there is a mapping that works in all modes (:map and :noremap), one that works in normal mode (:nmap and :nnoremap), one in visual mode (:vmap and :vnoremap) and so on.
For more guidance on this, see:
:help :map
:help :noremap
:help recursive_mapping
:help :map-modes 
 
This command will triggle "mouse highlight to yy" function
set mouse=a 

2013年3月15日 星期五

IPSec as a default gateway

IPSec will maintain a table as a routing matching policies as Left -- Right pairs.
Assume 192.168.A.0/24 - 192.168.B.0/24 subnets are ipsec as a secured LAN, and
A wish to use gateway B as a default gateway, it must be set :
1.
A sets left = 192.168.A.0/24 right = 0.0.0.0/0
B sets left = 0.0.0.0/0 right = 192.168.A.0/24
2.
A removes "MASQUERADE" chain from NAT table
B adds 192.168.A.0/24 to MASQUERADE rule into NAT table

Then it is done.


2013年3月3日 星期日

USB packet sniffer

1. command / on device board
Make sure build with "CONFIG_DEBUG_FS" ( which generates /sys/kernel/debug ) "CONFIG_USB_MON" and "CONFIG_USB_DEBUG" (which generates /sys/kernel/debug/usbmon)
1.a
mount -t debugfs none_debugs /sys/kernel/debug
modprobe usbmon / insmod usbmon
1.b
cat /sys/kernel/debug/usbmon/1u
1u ==> by the bus number
 
2. With wireshark on PC
3. With USB sniffer tool
4. Test unit ready
sdparm --command=ready /dev/sda1 

2013年2月19日 星期二

調整網路傳輸數據

upload
  cat /proc/sys/net/core/wmem_max
  cat /proc/sys/net/ipv4/tcp_wmem

download
  cat /proc/sys/net/core/rmem_max
  cat /proc/sys/net/ipv4/tcp_rmem

2013年2月17日 星期日

vic stream 和 transcode 的一些命令



vlc -I dummy ~/音樂/audio_clips/MayDayDNA.mp4
--sout '#transcode{vcodec=h264,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=http,mux=ogg,dst=172.20.10.5:9999}'
用着個mux的話,只有聲音輸出

vlc -I dummy ~/音樂/audio_clips/MayDayDNA.mp4
--sout '#transcode{vcodec=h264,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=http,mux=ts,dst=172.20.10.5:9999}'
用着個mux的話,會用 mpeg2 ts 的方式輸出影像和聲音

vlc -I dummy ~/音樂/audio_clips/MayDayDNA.mp4
--sout '#transcode{vcodec=h264,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=http,mux=asf,dst=172.20.10.5:9999}'
用着個mux的話,會用 asf 的方式輸出影像和聲音

vlc -I dummy ~/音樂/audio_clips/MayDayDNA.mp4
--sout '#transcode{vcodec=h264,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=mmsh,mux=ts,ttl=128,dst=172.20.10.5:9999}'
用着個mux的話,會用 mms 的方式輸出影像和聲音


RTSP H264 over RTP setting

vlc -I dummy ~/音樂/audio_clips/MayDayDNA.mp4 --sout '#transcode{vcodec=h264,acodec=mp3,ab=128,channels=2,samplerate=44100}:rtp{sdp=rtsp://172.20.10.5:9999/mysdp,name="test",ttl=127}'

Transcode to file
vlc -I dummy ./tender_Mayday.aac ":sout=#transcode{acodec=mp3,ab=128,channels=2,samplerate=44100}:duplicate{dst=std{access=file,mux=raw,dst=./song.mp3}}"
這個命令如果是作 aac -> mp3 ,用起來 ok,可是做 mp4/flv 轉 mp3 的話, 就有問題了

2013年2月11日 星期一

在 SPI flash UBOOT 上使用 serial kermit modem 傳輸linux kernel and boot up

1. 安裝 ckermit
2. 設定 .kermrc
set line /dev/ttyUSB0
set speed 57600
set carrier-watch off
set handshake none
set flow-control none
robust
3. 啓動kermit, 執行 connect
4. 開啓 uboot 的命令模式, 執行 loadb 0x81000000, uboot 會進入 kermit 模式, 等待console 端傳檔案, 目的地是 memory address 0x81000000
5. 用 Ctrl + \ , c , 回到 kermit command mode, 輸入 send /tftpboot/kernel_image.bix
開始傳輸 kernel image, 可能會要10~30分鐘
6. 傳完之後, 輸入bootm 0x81000000, 就可以用該 linux kernel 開機

補充,使用 tftp 來 boot
有時候,因爲 bootloader size checking 的緣故,我們會發生無法燒錄的狀況
那樣,我們可以
1. tftp 81000000 image_name
這樣可以把 image_name tftp 到 81000000 這個地方
2. bootm 81000000
用新的 image boot
3. 執行更新韌體的動作