This area is my sharing area. Include some technical/believing/life experiences. Hope you can enjoy with me. God bless you. :)
2009年11月30日 星期一
Linux Development - gcc
# /usr/bin/gcc34 --version <== use "yum install compat-gcc-34.i386" to install gcc 3.4
version gcc34 (GCC) 3.4.6 20060404 (Red Hat 3.4.6-8) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# /usr/bin/gcc-4.1.2 --version
gcc-4.1.2 (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Two different version series of gcc * gcc 3.4.X * gcc 4.1.X gcc 4.1.X provides stdc++ library. So we can use -lstdc++ as compiling parameter to compile program e.g. LFLAGS = -lstdc++ -lpthread But in gcc 3.4.X, the "stdc++" library is not yet support. So can not link the library while using gcc 3.4.X version. While compile the binutils of arm toolchain, it will generate error
[root@localhost binutils-build]# make all Configuring in libiberty configure: loading cache .././config.cache checking whether to enable maintainer-specific portions of Makefiles... no checking for makeinfo... makeinfo checking for perl... perl checking build system type... i386-pc-linux-gnu checking host system type... i386-pc-linux-gnu checking for i386-pc-linux-gnu-ar... (cached) arm-linux-uclibc-ar checking for i386-pc-linux-gnu-ranlib... (cached) arm-linux-uclibc-ranlib checking whether ln -s works... yes checking for i386-pc-linux-gnu-gcc... arm-linux-uclibc-gcc checking for C compiler default output... a.out checking whether the C compiler works... configure: error: cannot run C compiled programs.==> After the help of "google", I found that this is because I don't setup the proper g++ (version 3.4) compiler
If you meant to cross compile, use `--host'.
See `config.log' for more details.
make: *** [configure-libiberty] Error 1
Original g++ version
# /usr/bin/g++ --version
g++ (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
install g++ version 3.4
# yum install compat-gcc-34-c++.i386
Before compile the program, make sure the default cc is correct
Use either one of the following two methods
1. readlink -f $(which gcc)
2. echo $CC
Linux Command - e2fsck
指令:e2fsck
使用權限 : 超級使用者
使用方式 : e2fsck [-pacnydfvFV] [-b superblock] [-B blocksize] [-l|-L bad_blocks_file] [-C fd] device
說明 : 檢查使用 Linux ext2 檔案系統的 partition 是否正常工作
參數 :
device : 預備檢查的硬盤 partition,例如:/dev/sda1
-a : 對 partition 做檢查,若有問題便自動修復,等同 -p 的功能
-b : 設定存放 superblock 的位置
-B : 設定單位 block 的大小
-c : 檢查該partition 是否有壞軌
-C file : 將檢查的結果存到 file 中以便查看
-d : 列印 e2fsck 的 debug 結果
-f : 強制檢查
-F : 在開始檢查前,將device 的 buffer cache 清空,避免有錯誤發生
-l bad_blocks_file : 將有壞軌的block資料加到 bad_blocks_file 裡面
-L bad_blocks_file : 設定壞軌的block資料存到 bad_blocks_file 裡面,若無該檔則自動產生
-n : 將檔案系統以[唯讀]方式開啟
-p : 對 partition 做檢查,若有問題便自動修復
-v : 詳細顯示模式
-V : 顯示出目前 e2fsck 的版本
-y : 預先設定所有檢查時的問題均回答[是]
例子 :
檢查 /dev/hda5 是否正常,如果有異常便自動修復,並且設定若有問答,均回答[是] :
# e2fsck -a -y /dev/hda5
# e2fsck -c -y /dev/sda1
Notice: here the device name must have the full string, not only /dev/sda (this type of string will result fail)
注意 :
大部份使用 e2fsck 來檢查硬盤 partition 的情況時,通常都是情形特殊,因此最好先將該 partition umount,然再執行 e2fsck 來做檢查,若是要非要檢查 / 時,則請進入 single user mode 再執行。
Linux Command - useradd/userdel/groupadd/groupdel
# useradd -m -G groupname newUsername
// Delete the specified user and the data of his/her home directory
# userdel -r userName
// Add the specified group, and make it as a system group (usually group id lower than 500, often 470 by default)
# groupadd -r groupName
# cat /etc/group | grep groupName
groupName:x:470:
# modify userABC as a mail/ftp user without login ability
/usr/sbin/usermod -s /sbin/nologin userABC
userABC:x:508:508::/home/userABC:/sbin/nologin
The command to change the permission flags is "chmod". Only the owner of a file can change its permissions.
The command to change the group of a file is "chgrp". Only the owner of a file can change its group, and can only change it to a group of which he is a memberSo we need to set the user into multiple groups if we wish the user is a member of the specified group.
2009年11月29日 星期日
Linux Command - dd
This utility is ``useful for making an image copy of any media. An image copy is an exact byte-for-byte copy" [8, p. 80,].
dd [if=input-file] [of=output-file] [option]
where both input-file and output-file are optional. If omitted, input-file will default to the standard input, whereas output-file will default to the standard output.
option can be one or more of:
bs (block size): default is 512 bytes.
conv=arg... where arg is one or more of the following, separated by commas:
ascii: convert EBCDIC to ASCII.
ebcdic: convert ASCII to EBCDIC.
swab: swap every pair of bytes.
noerror: do not stop processing on detecting an error.
sync: pad every input record to (default) 512 bytes.
see your system manual for more details.
To read an older Silicon Graphics tape on a Sun, the dd command is:
dd if=/dev/tape conv=swab,noerror,sync | tar xf -
The input of dd is the file on the cartridge tape. dd converts that file by swapping every pair of bytes, and padding every record to 512 bytes (while not stopping if an error occurs). The resulting output file is fed (through the pipe) to tar, which then reads the file.
When a hyphen (-) is used instead of a file name on the tar command, the input is taken from the standard input on the extract and put to the standard ouput on the create function.
我的經驗
dd -if
My experience
複製Target image 到 target machine 的memory 中,然後利用dd 寫到 compact flash上的方法
首先第一步先將compact flash unmount下來
# umount /flash/
再來建立一個子目錄
# mkdir /tmp2
並且把/tmp2 device mount 到 /tmp2
# mount -t tmpfs /tmp2 /tmp2/
將target image 檔案下載放到新建的目錄/tmp2目錄下
# cd /tmp2
# ftp 192.168.XX.XX
get image file myImage.img
檢查系統資訊
# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/root.old 1766 684 1082 39% /initrd
/dev/ram1 58093 35785 22308 62% /
/mnt 32768 212 32556 1% /mnt
/tmp2 254248 62788 191460 25% /tmp2
# mount
/dev/root.old on /initrd type ext2 (rw)
/dev/ram1 on / type ext2 (rw)
/proc on /proc type proc (rw)
/mnt on /mnt type tmpfs (rw)
/tmp2 on /tmp2 type tmpfs (rw)
再來檢查要將compact flash 是掛在系統的哪一個device file上,這裡是XXX-5000, compact flash 是屬於/dev/hdc這一個file
# dmesg | grep hdc
hdc: SanDisk SDCFB-64, CFA DISK drive
hdc: attached ide-disk driver.
hdc: task_no_data_intr: status=0x51 { DriveReady SeekComplete Error }
hdc: task_no_data_intr: error=0x04 { DriveStatusError }
hdc: 125440 sectors (64 MB) w/1KiB Cache, CHS=490/8/32
hdc: hdc1
hdc: hdc1
hdc: hdc1
hdc: hdc1
hdc: hdc1
hdc: hdc1
hdc: hdc1
最後實際執行dd command bs (block size)為 512k
# dd if=myImage.img of=/dev/hdc bs=512k
122+1 records in
122+1 records out
sync 將記憶體的資料寫到flash中
# sync
# sync
# sync
Suggestions & Advices for Christians
Suggestions & Advices for Christians
1.下次如果覺得自己了不起時,試試行在水上。
2.當魔鬼提起你的過去時,請提醒牠的未來。
3.你不是幸運,是蒙福。
4.若想要真正活著,得先徹底死去。
5.機會也許只敲一次門,但試探與誘惑卻總是在按門鈴。
6.我們常在強壯時,忘了 神。
7.那些只在星期天呼喚"天父"的人,在一星期餘下的日子中活得像孤兒。
8.不要以自我為中心,要以基督為中心。
9..沒有基督,沒有平安;認識基督,得到平安。
10.為什麼我們不常向朋友提起神?因為我們不常向 神提起我們的朋友。
11.當把你的一切獻給基督,因為他把他的一切都給了你。
12.你現在所追求的,值得基督為它死嗎?
13.使你向 神靠近的人,是你真正的朋友。
14.神愛我們,不是因為我們是怎樣一個人,而是因為他是怎樣一位神。
15.神的應許像夜空中的星星。夜越深,星星的光芒越亮。
16.沒有基督的生命,是無望的盡頭。有基督的生命,是無盡的盼望。
17.我雖不知道未來掌管著什麼,但我知道誰掌管著未來。
18.把你的重擔交給主,讓它留在主那裡。
19.不要畏懼明天,因為神已在那裡。
20.當你除了 神,一無所有時,你將知道神就是你全部的需要。
21.放手交給神,別再向神講述你的風暴有多大,當向風暴講述你的神有多大。
22.能夠滿足人心的,是造人心的那一位。
23.請常常保持著你心中的光,因為你不知道,誰會藉著這光走出黑暗。
24.當我們只顧工作的時候,我們獨自工作;當我們祈禱的時候,神工作。
25.神無所不在,所以我們可以隨處禱告。
26.一個沒有需要的人永遠見不到神蹟。
27.敬拜提醒我們生命的價值,但世界卻使我們忘記它。
28.步履艱難的時候,別一味的禱告,卻不邁向神要你走的路。
29.禱告會為我們作很多事,憂慮同樣可以。
30.神祝福你,是要你成為別人的祝福。
2009年11月19日 星期四
TCP segmentation offload (TSO)
This is a technology that shift the data segmentation effort from CPU to NIC-CPU. So the checksum will also generated by the NIC-CPU.
In Linux OS, we can disable this function by issue the following command:
# ethtool -K eth0 tso off
show all the offload information for a specified interface
# ethtool -k eth0
Large segment offload
http://en.wikipedia.org/wiki/TCP_segmentation_offloading
In computer networking, large segment offload (LSO) is a technique for increasing outbound throughput of high-bandwidth network connections by reducing CPU overhead. It works by queuing up large buffers and letting the NIC split them into separate packets. The technique is also called TCP segmentation offload (TSO) when applied to TCP, or generic segmentation offload (GSO).
When large chunks of data are to be sent over a computer network, they need to be first broken down to smaller segments that can pass through all the network elements like routers and switches between the source and destination computers. This process is referred to as segmentation. Segmentation is often done by the TCP protocol in the host computer. Offloading this work to the network card is called TCP segmentation offload (TSO).
For example, a unit of 64KB (65,536 bytes) of data is usually segmented to 46 segments of 1448 bytes each before it is sent over the network through the network interface controller (NIC). With some intelligence in the NIC, the host CPU can hand over the 64 KB of data to the NIC in a single transmit request, the NIC can break that data down into smaller segments of 1448 bytes, add the TCP, IP, and data link layer protocol headers -- according to a template provided by the host's TCP/IP stack -- to each segment, and send the resulting frames over the network. This significantly reduces the work done by the CPU. Many new NICs on the market today support TSO.
Some network cards implement TSO generically enough that it can be used for offloading fragmentation of other transport layer protocols, or by doing IP fragmentation for protocols that don't support fragmentation by themselves, such as UDP. This is not as useful, though, as other protocols aren't commonly used for transmitting large amounts of data.
TCP checksum offload (
2009年11月5日 星期四
static variable
Difference Between Static & Global Variable
6/10/2002 By ITtoolbox Popular Q&A Team for ITtoolbox as adapted from CPP-L discussion group
What is the difference between static & global variable in C++?
1) Adapted from response by Smit on Fri, 7 Jun 2002
http://Groups.ITtoolbox.com/archives/archives.asp?l=cpp-l&i=101470
Variables defined local to a function disappear at the end of the function scope. So when we call the function again, storage for variables is created and
values are reinitialized. So if we want the value to be extent throughout the life of a program, we can define the local variable as "static." Initialization is performed only at the first call and data is retained between func calls.
Had it been gloal variable, it would have been available outside the scope of the function, but static variable is not available outside the scope of a function (helpful in localizing errors - as it can't be changed outside the func
scope).
2) Adapted from response by Meraj on Fri, 7 Jun 2002
http://Groups.ITtoolbox.com/archives/archives.asp?l=cpp-l&i=101471
Static and global variable differ a lot in their behaviour to life and scope. First, let me distinguish between life and scope. Life of an object determines whether the object is still in the memory (of the process) whereas scope of the object is whether can I know the variable by its name at this position. It is possible that object is live, but not visible (not in scope) but not that object is not alive but in scope (except for dynamically allocated objects where you refer object through pointers).
Static variables are local in scope to their module in which they are defined, but life is throughout the program. Say for a static variable inside a function cannot be called from outside the function (because it's not in scope) but is alive and exists in memory. The next time this function is entered (within the same program) the same chunk of memory would be accessed now retaining the variables old value and no new memory is allocated this time for this variable like other variables in the function (automatic variables). So basically the variable persists throughout the program. Similarly if a static variable is defined in a global space (say at beginning of file) then this variable will be
accessible only in this file (file scope).
On the other hand global variables have to be defined globally, persists (life is) throughout the program, scope is also throughout the program. This means such variables can be accessed from any function, any file of the program.
So if you have a global variable and u r distributing ur files as a library and you want others to not access your global variable, you may make it static by just prefixing keyword static (of course if same variable is not required in other files of yours).
2009年11月1日 星期日
Linux Command - file
"programA": ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
# file programB
"programB": ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
32 bits program can be run on the 64 bits platform.
But 64 bits program can not run on the 32 bits platform
Add -m 32 in the CFLAG to compile a 32 bits program in the 64 bits platform for backward compatbility.
# The following target was ARM-chipset device
$ file core
core: ELF 32-bit MSB core file, ARM, version 1 (SYSV), SVR4-style, from 'programARM'
$ file programARM
programARM: ELF 32-bit MSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
# The following target was X86 PC
# file programX86
programX86: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
How to completely remove ActiveX from WindowsXP
2. Remove all the already downloaded ActiveX from the "C:\Windows\Downloaded Program Files" folder
(include strange number objects)
3. Re-Enable the selected ActiveX