轉貼 http://ethanjob.blogspot.com/2007/02/volatile.html
volatile宣告 在C裡面有volatile這個宣告,通常是說這個變數會被外在routine改變, 在kernel裡面通常是指會被interrupt handler(有時就是硬體中斷的routine) 改變值,也就是被非同步的改變的變數。例如 unsigned long vloatile jiffies; jiffies在kernel是時間每次hardware的中斷會來改這個值 在asm裡面是說這個東西compiler時,gcc不要雞婆作optimized,因為 最佳化的結果,compiler會把code按照他想的方法放到記憶體裡, 但是有的code我們需要特定指定他一定要在某個記憶體上, 在kernel裡常有這樣情形發生,我們可以用 __asm__ __volatile__宣告一段assembly的code是不要做最佳化的。 例如cli sti #define disable() __asm__ __volatile__ ("cli"); #define enable() __asm__ __volatile__ ("sti");
[ 例1 ]
Volatile這玩意兒用在單晶片的C語言較多
例如:
Volatile char wait;
void xxx(void)
{
wait=1;
while (wait!=0);
.....
.....
}
void timer0(void) interrupt 1
{
wait=0;
.......
}
xxx()中就是等一個timer中斷才執底下工作.
如果不寫Volatile會被編譯器省略掉.
因為wait=1;何來wait會等於0
[ 例2 ]
volatile sig_atomic_t read_flag = 1;
volatile是一個關鍵字(keyword),用來修飾詞資料型態,與const有對應的關係。
是語言關鍵字的話,就不會出現在標頭檔內的定義。
volatile sig_atomic_t read_flag = 1;
read_flag是一個為sig_atomic_t的資料型態,透過volatile的修飾,說明sig_atomic_t在程式中,可以在任何的時間下被修改 ,
也就是說,你的程式可能同一時間不止一個程序在使用。
可能主程式main在使用的同時,I/O Device或另一個thread也在利用或指定這個read_flag
來透過溝通的作用。
[ 例3 ]
http://www.programmersheaven.com/articles/pathak/article1.htm
[ 參考 ]
http://www.programmersheaven.com/articles/pathak/article1.htm
http://www.blueshop.com.tw/board/show.asp?subcde=BRD20060329085552QSX&fumcde=FUM20050124191259IGD&rplcnt=5
2012年1月16日 星期一
2011年9月2日 星期五
SD card有發現容量變小, 找不到,無法格式化
1.在ubuntu 11.04下的桌面,按右鍵,選擇format,會找到Disk Utility
2.進去後,找到Format Drive==>Format ****** 如果不能Format,請找一下mount Volume把它給unmount,就可以format
3.如果在中間的Volumes 下面的bar沒有看到new volume ,就要再去執行Format Volume
4.再去執行mount volume
5,如果以上是在桌面上看不到磁碟機的話,請到請到請到system==>administration==>Disk Utility,在左邊可以看到SD card, 一樣可以
2.進去後,找到Format Drive==>Format ****** 如果不能Format,請找一下mount Volume把它給unmount,就可以format
3.如果在中間的Volumes 下面的bar沒有看到new volume ,就要再去執行Format Volume
4.再去執行mount volume
5,如果以上是在桌面上看不到磁碟機的話,請到請到請到system==>administration==>Disk Utility,在左邊可以看到SD card, 一樣可以
使用SD card的partition啟動NAND
有測試過的,搞了好久,
1.在ubuntu 11.04 linux下,要先知道SD card掛在哪,請在桌面下按右鍵,選擇format,最上面那行就會跟你說是哪一個,測試看到的是 /dev/sdb1
2.打開終端機,sudo fdisk /dev/sdb <===sdb 要注意這點,不是sdb1
3.不知道指令請按 "m", "d"是刪除partition
Command (m for help): d
Selected partition 1
"n",是新增一個partition
Command (m for help): n
Command action
e extended
p primary partition (1-4)
"p"建立主要的partition
p
Partition number (1-4): 1 <===要幾個partition
First cylinder (1-1017, default 1): 50 <=====輸入要劃多大的容量
Last cylinder, +cylinders or +size{K,M,G} (50-1017, default 1017):
Using default value 1017
4.在將SD card 設定成FAT格式,
sudo mkfs -t vfat /dev/sdb1 <====注意,這次是有sdb1
5. 在windows xp下測試一下SD card是否能打開,有問題的話,會秀需要格式化
=============================================
6.再到windows xp,打開winhex 程式,把剛剛設定好的SD card 透過USB轉卡放去windows下, 再到winhex下的==>tools==>Open Disk==>在physical media選擇剛剛的SD card===>OK
7.再按2下,Unpartitioned <===這是剛剛在linux 下設定的空間,就是上面的50
8.在0x00~0x1C0,這段空間就是要把u-boot放進去的地方
9.將0x1C0這一行給記錄下來,這一行是在跟PC說它的容量大小,所以必須要記下來
10.去tools==>Disk Tools==>Clone Disk==>Source,選擇右邊像文件的icon,把要寫到partition的u-boot打開,如果看不到,請打*, Destination,選擇右邊像磁碟機的icon,指到Physical Media下面的SUB( 就是指SD card),右邊的Copy entire raw image file選項要打勾,start sector要輸入0(零),剩下的不管,就是不打勾==>ok
11.會出現很多的訊息,這些全部都按"確定"
12.在將剛剛所備份的0x1C0那行,回存到當前的0x1C0
13.File==>save 大功靠成
14.將要燒得檔案放入SD card中
15.以上就可以測試燒錄了
1.在ubuntu 11.04 linux下,要先知道SD card掛在哪,請在桌面下按右鍵,選擇format,最上面那行就會跟你說是哪一個,測試看到的是 /dev/sdb1
2.打開終端機,sudo fdisk /dev/sdb <===sdb 要注意這點,不是sdb1
3.不知道指令請按 "m", "d"是刪除partition
Command (m for help): d
Selected partition 1
"n",是新增一個partition
Command (m for help): n
Command action
e extended
p primary partition (1-4)
"p"建立主要的partition
p
Partition number (1-4): 1 <===要幾個partition
First cylinder (1-1017, default 1): 50 <=====輸入要劃多大的容量
Last cylinder, +cylinders or +size{K,M,G} (50-1017, default 1017):
Using default value 1017
4.在將SD card 設定成FAT格式,
sudo mkfs -t vfat /dev/sdb1 <====注意,這次是有sdb1
5. 在windows xp下測試一下SD card是否能打開,有問題的話,會秀需要格式化
=============================================
6.再到windows xp,打開winhex 程式,把剛剛設定好的SD card 透過USB轉卡放去windows下, 再到winhex下的==>tools==>Open Disk==>在physical media選擇剛剛的SD card===>OK
7.再按2下,Unpartitioned <===這是剛剛在linux 下設定的空間,就是上面的50
8.在0x00~0x1C0,這段空間就是要把u-boot放進去的地方
9.將0x1C0這一行給記錄下來,這一行是在跟PC說它的容量大小,所以必須要記下來
10.去tools==>Disk Tools==>Clone Disk==>Source,選擇右邊像文件的icon,把要寫到partition的u-boot打開,如果看不到,請打*, Destination,選擇右邊像磁碟機的icon,指到Physical Media下面的SUB( 就是指SD card),右邊的Copy entire raw image file選項要打勾,start sector要輸入0(零),剩下的不管,就是不打勾==>ok
11.會出現很多的訊息,這些全部都按"確定"
12.在將剛剛所備份的0x1C0那行,回存到當前的0x1C0
13.File==>save 大功靠成
14.將要燒得檔案放入SD card中
15.以上就可以測試燒錄了
2011年7月28日 星期四
將bin檔案放置SD card
1.要先用linux ubuntu format SD card
sudo fdisk /dev/sdc =>sdc 這是要看插入sd card是在哪裝置
輸入後,顯示如下:
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help):
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): d
Partition number (1-4): 1
Command (m for help): n
Command action寫最後面的數字
p primary partition (1-4)
p
Selected partition 1
First cylinder (1-1015, default 1): 50 <== 50 是要寫入檔案的大小
Last cylinder, +cylinders or +size{K,M,G} (50-1015, default 1015): 1015 <= 50-1015 寫最後面的數字
Command (m for help): w
The partition table has been altered!
上面是我操作的指令
sudo mkfs -t vfat /dev/sdd <==更改為fat format
最後到windows xp上格式化就好了
完成 !!!!!
sudo fdisk /dev/sdc =>sdc 這是要看插入sd card是在哪裝置
輸入後,顯示如下:
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help):
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): d
Partition number (1-4): 1
Command (m for help): n
Command action寫最後面的數字
p primary partition (1-4)
p
Selected partition 1
First cylinder (1-1015, default 1): 50 <== 50 是要寫入檔案的大小
Last cylinder, +cylinders or +size{K,M,G} (50-1015, default 1015): 1015 <= 50-1015 寫最後面的數字
Command (m for help): w
The partition table has been altered!
上面是我操作的指令
sudo mkfs -t vfat /dev/sdd <==更改為fat format
最後到windows xp上格式化就好了
完成 !!!!!
2011年6月28日 星期二
Android Compile error debug
1.android-2.2.1,直接make或make sdk
2.出錯及解决如下:
(1)/bin/bash: bison: command not found
解决:sudo apt-get install bison
2.出錯及解决如下:
(1)/bin/bash: bison: command not found
解决:sudo apt-get install bison
(2)make: *** No rule to make target `Please-install-JDK-5.0,-update-12-or-higher,-which-you-can-download-from-java.sun.com',
needed by `out/target/common/docs/api-stubs-timestamp'. Stop.
解决:安装JDK 5.0
1):根據官方文件有說,source code 的編譯必須使用JDK5才能編譯的了,所以這裡我們使用jdk5
2): 需要先更新來源,在終端機,先備份原來的檔案,之後還要還原
needed by `out/target/common/docs/api-stubs-timestamp'. Stop.
解决:安装JDK 5.0
1):根據官方文件有說,source code 的編譯必須使用JDK5才能編譯的了,所以這裡我們使用jdk5
2): 需要先更新來源,在終端機,先備份原來的檔案,之後還要還原
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup, 再執行 sudo vim /etc/apt/sources.list
3): 在source.list把以下2行拷貝到文件最後面:
deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse
保存退出。
4): 執行 sudo apt-get update 更新
5): 配置編譯環境並下載JDK5:sudo apt-get install sun-java5-jdk
3): 在source.list把以下2行拷貝到文件最後面:
deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse
保存退出。
4): 執行 sudo apt-get update 更新
5): 配置編譯環境並下載JDK5:sudo apt-get install sun-java5-jdk
(3)/bin/bash: g++: command not found
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/pseudolocalize.o] Error 127
sudo apt-get install build-essential
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/pseudolocalize.o] Error 127
sudo apt-get install build-essential
(4)external/clearsilver/cgi/cgi.c:22:18: error: zlib.h: No such file or directory
external/clearsilver/cgi/cgi.c: In function ‘cgi_compress’:
external/clearsilver/cgi/cgi.c:885: error: ‘z_stream’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:885: error: (Each undeclared identifier is reported only once
external/clearsilver/cgi/cgi.c:885: error: for each function it appears in.)
external/clearsilver/cgi/cgi.c:885: error: expected ‘;’ before ‘stream’
external/clearsilver/cgi/cgi.c:888: error: ‘stream’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:888: error: ‘Bytef’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:888: error: expected expression before ‘)’ token
external/clearsilver/cgi/cgi.c:889: error: ‘uInt’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:889: error: expected ‘;’ before ‘str’
external/clearsilver/cgi/cgi.c:890: error: expected expression before ‘)’ token
external/clearsilver/cgi/cgi.c:892: error: ‘uLong’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:892: error: expected ‘)’ before ‘stream’
external/clearsilver/cgi/cgi.c:895: error: ‘alloc_func’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:895: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:896: error: ‘free_func’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:896: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:897: error: ‘voidpf’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:897: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFAULT_COMPRESSION’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFLATED’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘MAX_WBITS’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFAULT_STRATEGY’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:901: error: ‘Z_OK’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:904: error: ‘Z_FINISH’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:905: error: ‘Z_STREAM_END’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c: In function ‘cgi_output’:
external/clearsilver/cgi/cgi.c:1200: error: ‘Z_NULL’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:1201: error: expected ‘)’ before ‘Bytef’
external/clearsilver/cgi/cgi.c:1218: error: ‘Z_DEFLATED’ undeclared (first use in this function)
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o] Error 1
sudo apt-get install zlib1g-dev
external/clearsilver/cgi/cgi.c: In function ‘cgi_compress’:
external/clearsilver/cgi/cgi.c:885: error: ‘z_stream’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:885: error: (Each undeclared identifier is reported only once
external/clearsilver/cgi/cgi.c:885: error: for each function it appears in.)
external/clearsilver/cgi/cgi.c:885: error: expected ‘;’ before ‘stream’
external/clearsilver/cgi/cgi.c:888: error: ‘stream’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:888: error: ‘Bytef’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:888: error: expected expression before ‘)’ token
external/clearsilver/cgi/cgi.c:889: error: ‘uInt’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:889: error: expected ‘;’ before ‘str’
external/clearsilver/cgi/cgi.c:890: error: expected expression before ‘)’ token
external/clearsilver/cgi/cgi.c:892: error: ‘uLong’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:892: error: expected ‘)’ before ‘stream’
external/clearsilver/cgi/cgi.c:895: error: ‘alloc_func’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:895: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:896: error: ‘free_func’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:896: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:897: error: ‘voidpf’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:897: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFAULT_COMPRESSION’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFLATED’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘MAX_WBITS’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFAULT_STRATEGY’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:901: error: ‘Z_OK’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:904: error: ‘Z_FINISH’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:905: error: ‘Z_STREAM_END’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c: In function ‘cgi_output’:
external/clearsilver/cgi/cgi.c:1200: error: ‘Z_NULL’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:1201: error: expected ‘)’ before ‘Bytef’
external/clearsilver/cgi/cgi.c:1218: error: ‘Z_DEFLATED’ undeclared (first use in this function)
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o] Error 1
sudo apt-get install zlib1g-dev
(5)/bin/bash: flex: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
sudo apt-get install flex
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
sudo apt-get install flex
(6)/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
sudo apt-get install libncurses-dev
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
sudo apt-get install libncurses-dev
(7)prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:55:22: error: X11/Xlib.h: No such file or directory
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:56:23: error: X11/Xatom.h: No such file or directory
In file included from external/qemu/android/skin/window.c:19:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:73: error: expected specifier-qualifier-list before ‘XEvent’
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:86: error: expected specifier-qualifier-list before ‘Display’
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/skin/window.o] Error 1
sudo apt-get install libx11-dev
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:56:23: error: X11/Xatom.h: No such file or directory
In file included from external/qemu/android/skin/window.c:19:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:73: error: expected specifier-qualifier-list before ‘XEvent’
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:86: error: expected specifier-qualifier-list before ‘Display’
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/skin/window.o] Error 1
sudo apt-get install libx11-dev
(8)sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 96.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h'
sudo apt-get install gperf
calling gperf failed: 32512 at ./makeprop.pl line 96.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h'
sudo apt-get install gperf
Android SDK
Android 官方網站,有寫到基本的需求,把他給記錄下來.
http://developer.android.com/sdk/requirements.html
Note that the disk-space requirements above are in addition to those of the Eclipse IDE, JDK, or other prerequisite tools that you may need to install on your development computer.
http://developer.android.com/sdk/requirements.html
Supported Operating Systems
- Windows XP (32-bit), Vista (32- or 64-bit), or Windows 7 (32- or 64-bit)
- Mac OS X 10.5.8 or later (x86 only)
- Linux (tested on Ubuntu Linux, Lucid Lynx)
- GNU C Library (glibc) 2.7 or later is required.
- On Ubuntu Linux, version 8.04 or later is required.
- 64-bit distributions must be capable of running 32-bit applications. For information about how to add support for 32-bit applications, see the Ubuntu Linux installation notes.
Supported Development Environments
Eclipse IDE
- Eclipse 3.5 (Galileo) or greater Note: Eclipse 3.4 (Ganymede) is no longer supported with the latest version of ADT.
- Eclipse JDT plugin (included in most Eclipse IDE packages)
- If you need to install or update Eclipse, you can download it from http://www.eclipse.org/downloads/. Several types of Eclipse packages are available for each platform. For developing Android applications, we recommend that you install one of these packages:
- Eclipse IDE for Java Developers
- Eclipse Classic (versions 3.5.1 and higher)
- Eclipse IDE for Java EE Developers
- JDK 5 or JDK 6 (JRE alone is not sufficient)
- Android Development Tools plugin (recommended)
- Not compatible with Gnu Compiler for Java (gcj)
Note: If JDK is already installed on your development computer, please take a moment to make sure that it meets the version requirements listed above. In particular, note that some Linux distributions may include JDK 1.4 or Gnu Compiler for Java, both of which are not supported for Android development.
Hardware requirements
The Android SDK requires disk storage for all of the components that you choose to install. The table below provides a rough idea of the disk-space requirements to expect, based on the components that you plan to use.| Component type | Approximate size | Comments |
|---|---|---|
| SDK Tools | 35 MB | Required. |
| SDK Platform-tools | 6 MB | Required. |
| Android platform (each) | 150 MB | At least one platform is required. |
| SDK Add-on (each) | 100 MB | Optional. |
| USB Driver for Windows | 10 MB | Optional. For Windows only. |
| Samples (per platform) | 10M | Optional. |
| Offline documentation | 250 MB | Optional. |
訂閱:
文章 (Atom)