Driver:
Moschip download
(need to register)
Patch for 2.6.28:
starex_2.6.28.patch.gz
(source:http://forums.linuxmint.com/viewtopic.php?f=49&t=29576/MCS9901_Linux/version1.6)
Usage:
@Drivers/MCS9901_Linux/version1.6 $ gzip -d starex_2.6.28.patch.gz
@Drivers/MCS9901_Linux/version1.6 $ ls
MCS9901_Linux_UM_Ver0.4.pdf starex starex_2.6.28.patch starex.tar.gz
@Drivers/MCS9901_Linux/version1.6 $ patch -p0 <>make
->sudo make install
->ls /dev/ttyD*
->lspci -v (After install)
03:00.0 Serial controller: NetMos Technology PCIe 9901 Multi-I/O Controller (prog-if 02)
Subsystem: Device a000:1000
Flags: bus master, fast devsel, latency 0, IRQ 17
I/O ports at ec00 [size=8]
Memory at febff000 (32-bit, non-prefetchable) [size=4K]
Memory at febfe000 (32-bit, non-prefetchable) [size=4K]
Capabilities: [80] Power Management version 3
Capabilities: [88] Message Signalled Interrupts: Mask- 64bit+ Queue=0/5 Enable-
Capabilities: [c0] Express Legacy Endpoint, MSI 00
Capabilities: [100] Power Budgeting
Capabilities: [200] Device Serial Number aa-bb-cc-dd-ee-ff-99-88
Kernel driver in use: starex-serial
Kernel modules: 9900-isa
You may need to modify Makefile before calling "make install":
(My OS is Ubuntu 9.04)
#ln -s /etc/init.d/mcs9900 /etc/rc.d/rc3.d/Smcs9900 || true
#ln -s /etc/init.d/mcs9900 /etc/rc.d/rc5.d/Smcs9900 || true
ln -s /etc/init.d/mcs9900 /etc/rc2.d/Smcs9900 || true
ln -s /etc/init.d/mcs9900 /etc/rc3.d/Smcs9900 || true
ln -s /etc/init.d/mcs9900 /etc/rc5.d/Smcs9900 || true
so that the driver is loaded when OS starts.
2009年11月23日 星期一
2009年11月17日 星期二
使用 od 觀察(dump) binary file
od -x -j 5 -N 10 file
->0000005 5478 1245 4eae 0842 4082
->0000017
-x: 以16進位印出, 兩個bytes為單位 (因此此例由小位址起dump值為 78 54 45 12 ae 4e ... 82 40)
-j: 跳過幾個bytes
-N: 輸出幾個bytes
file: 檔名
->0000005 5478 1245 4eae 0842 4082
->0000017
-x: 以16進位印出, 兩個bytes為單位 (因此此例由小位址起dump值為 78 54 45 12 ae 4e ... 82 40)
-j: 跳過幾個bytes
-N: 輸出幾個bytes
file: 檔名
2009年11月10日 星期二
file nodes in /proc (relevant to driver)
看Major number
robert@robert-desktop ~/Test $ cat /proc/devices
Character devices:
1 mem
4 /dev/vc/0
4 tty
4 ttyS
...
看device node, Major number, minor number range
robert@robert-desktop ~/Test $ cat /proc/tty/drivers
/dev/tty /dev/tty 5 0 system:/dev/tty
/dev/console /dev/console 5 1 system:console
/dev/ptmx /dev/ptmx 5 2 system
/dev/vc/0 /dev/vc/0 4 0 system:vtmaster
rfcomm /dev/rfcomm 216 0-255 serial
serial /dev/ttyS 4 64-111 serial
...
看IO port
robert@robert-desktop ~/Test $ cat /proc/ioports
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
0060-0060 : keyboard
0064-0064 : keyboard
...
看Memory Map IO
robert@robert-desktop ~/Test $ cat /proc/iomem
00000000-0000ffff : reserved
00010000-0009fbff : System RAM
0009fc00-0009ffff : reserved
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000cc800-000cd7ff : Adapter ROM
...
看serial port tty* 的 IO port 和 IRQ
robert@robert-desktop ~/Test $ setserial -g /dev/tty*
/dev/ttyD0, UART: 16550A, Port: 0xec00, IRQ: 17
/dev/ttyS0, UART: unknown, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: unknown, Port: 0x02f8, IRQ: 3
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
看 IRQ 次數
robert@robert-desktop ~/Test $ cat /proc/interrupts
CPU0 CPU1 CPU2 CPU3
0: 3855694 3885186 3836114 3824345 IO-APIC-edge timer
1: 0 1 0 1 IO-APIC-edge i8042
...
robert@robert-desktop ~/Test $ cat /proc/devices
Character devices:
1 mem
4 /dev/vc/0
4 tty
4 ttyS
...
看device node, Major number, minor number range
robert@robert-desktop ~/Test $ cat /proc/tty/drivers
/dev/tty /dev/tty 5 0 system:/dev/tty
/dev/console /dev/console 5 1 system:console
/dev/ptmx /dev/ptmx 5 2 system
/dev/vc/0 /dev/vc/0 4 0 system:vtmaster
rfcomm /dev/rfcomm 216 0-255 serial
serial /dev/ttyS 4 64-111 serial
...
看IO port
robert@robert-desktop ~/Test $ cat /proc/ioports
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
0060-0060 : keyboard
0064-0064 : keyboard
...
看Memory Map IO
robert@robert-desktop ~/Test $ cat /proc/iomem
00000000-0000ffff : reserved
00010000-0009fbff : System RAM
0009fc00-0009ffff : reserved
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000cc800-000cd7ff : Adapter ROM
...
看serial port tty* 的 IO port 和 IRQ
robert@robert-desktop ~/Test $ setserial -g /dev/tty*
/dev/ttyD0, UART: 16550A, Port: 0xec00, IRQ: 17
/dev/ttyS0, UART: unknown, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: unknown, Port: 0x02f8, IRQ: 3
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
看 IRQ 次數
robert@robert-desktop ~/Test $ cat /proc/interrupts
CPU0 CPU1 CPU2 CPU3
0: 3855694 3885186 3836114 3824345 IO-APIC-edge timer
1: 0 1 0 1 IO-APIC-edge i8042
...
2009年10月26日 星期一
Use ntfs-clone to backup to / restore from an image
==== save image ======
robert@robert-desktop ~/Test $ sudo ntfsclone --save-image --output clonentfs.img /dev/sdb2
ntfsclone v2.0.0 (libntfs 10:0:0)
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 8044322816 bytes (8045 MB)
Current device size: 8044323840 bytes (8045 MB)
Scanning volume ...
100.00 percent completed
Accounting clusters ...
Space in use : 864 MB (10.7%)
Saving NTFS to image ...
100.00 percent completed
Syncing ...
====== restore =========
robert@robert-desktop ~/Test $ sudo ntfsclone --restore-image --overwrite /dev/sdb2 clonentfs.img
ntfsclone v2.0.0 (libntfs 10:0:0)
Ntfsclone image version: 10.0
Cluster size : 4096 bytes
Image volume size : 8044322816 bytes (8045 MB)
Image device size : 8044323840 bytes
Space in use : 864 MB (10.7%)
Offset to image data : 56 (0x38) bytes
Restoring NTFS from image ...
100.00 percent completed
Syncing ...
==== Error if you restore a smaller partition =====
robert@robert-desktop ~/Test $ sudo ntfsclone --restore-image --overwrite /dev/sdb2 clonentfs.img
ntfsclone v2.0.0 (libntfs 10:0:0)
ERROR: Output device is too small (3708230144) to fit the NTFS image (8044323328).
robert@robert-desktop ~/Test $ sudo ntfsclone --save-image --output clonentfs.img /dev/sdb2
ntfsclone v2.0.0 (libntfs 10:0:0)
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 8044322816 bytes (8045 MB)
Current device size: 8044323840 bytes (8045 MB)
Scanning volume ...
100.00 percent completed
Accounting clusters ...
Space in use : 864 MB (10.7%)
Saving NTFS to image ...
100.00 percent completed
Syncing ...
====== restore =========
robert@robert-desktop ~/Test $ sudo ntfsclone --restore-image --overwrite /dev/sdb2 clonentfs.img
ntfsclone v2.0.0 (libntfs 10:0:0)
Ntfsclone image version: 10.0
Cluster size : 4096 bytes
Image volume size : 8044322816 bytes (8045 MB)
Image device size : 8044323840 bytes
Space in use : 864 MB (10.7%)
Offset to image data : 56 (0x38) bytes
Restoring NTFS from image ...
100.00 percent completed
Syncing ...
==== Error if you restore a smaller partition =====
robert@robert-desktop ~/Test $ sudo ntfsclone --restore-image --overwrite /dev/sdb2 clonentfs.img
ntfsclone v2.0.0 (libntfs 10:0:0)
ERROR: Output device is too small (3708230144) to fit the NTFS image (8044323328).
2009年10月20日 星期二
安裝與設定 apache 2.2 with WebDAV and AuthType=Digest
如果你要設定把Apache的AuthType設為Digest,要注意:
1. 你的Apache 版本,不同版本設定很不一樣: http://httpd.apache.org/docs/ 查mod_auth_digest
2. 非常tricky的地方(文件沒提到):
=====
安裝:
sudo apt-get update
sudo apt-get install apache2 php5 libapache2-mod-php5 apache2-utils
設定
1) 啟用WebDAV
sudo a2enmod dav_fs
sudo a2enmod dav
sudo a2enmod dav_lock
sudo a2enmod auth_digest
2) 建立 WebDAV 使用者 (舉例:使用者 robertDAV)
sudo htdigest -c /etc/apache2/.digestpwd.dav /davshared/ robertdav
(Basic認證才用 htpasswd )
1. 你的Apache 版本,不同版本設定很不一樣: http://httpd.apache.org/docs/ 查mod_auth_digest
2. 非常tricky的地方(文件沒提到):
AuthName 要設得跟 realm 一樣,不然會總是認證失敗!=====
安裝:
sudo apt-get update
sudo apt-get install apache2 php5 libapache2-mod-php5 apache2-utils
設定
1) 啟用WebDAV
sudo a2enmod dav_fs
sudo a2enmod dav
sudo a2enmod dav_lock
sudo a2enmod auth_digest
2) 建立 WebDAV 使用者 (舉例:使用者 robertDAV)
sudo htdigest -c /etc/apache2/.digestpwd.dav /davshared/ robertdav
(Basic認證才用 htpasswd )
(如果有兩組以上user要設定,可能要手動填第二行喔!不然第二次使用htdigest會把第一組的資料"切掉")
3) 建立共享的 WebDAV 目錄
sudo mkdir /var/www/davshared/
sudo chown www-data:www-data /var/www/davshared/
4) 設定apache config 關於 WebDAV 目錄位置、權限等
vim /etc/apache2/sites-available/default
插入:
(請自動把以下的( )換成< >,因打< >在此秀不出來)
5) 重啟 apache
sudo /etc/init.d/apache2 restart
========================
Reference:
Setting up a WebDAV server
http://www.linuxquestions.org/questions/linux-server-73/digest-authentication-not-working-on-default-apache-installation-on-slackware-12.1-730785/
http://httpd.apache.org/docs/2.2/mod/mod_auth_digest.html
http://samiux.wordpress.com/2009/06/27/howto-webdav-on-ubuntu-9-04-server/
3) 建立共享的 WebDAV 目錄
sudo mkdir /var/www/davshared/
sudo chown www-data:www-data /var/www/davshared/
4) 設定apache config 關於 WebDAV 目錄位置、權限等
vim /etc/apache2/sites-available/default
插入:
(請自動把以下的( )換成< >,因打< >在此秀不出來)
Alias /davshared/ "/var/www/davshared/"
(Directory "/var/www/davshared/")
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
#Allow from 192.168.0.0/255.0.0.0 ::1/128
(/Directory)
(Location /davshared/)
DAV On
AuthName "/davshared/"
#AuthType Basic
#AuthUserFile /etc/apache2/.passwd.dav
AuthType Digest
AuthDigestProvider file
AuthDigestDomain /davshared/
AuthUserFile /etc/apache2/.digestpwd.dav
DavMinTimeout 600
#(LimitExcept GET PUT HEAD OPTIONS POST)
(LimitExcept GET HEAD OPTIONS)
Require valid-user
(/LimitExcept)
(/Location)
5) 重啟 apache
sudo /etc/init.d/apache2 restart
========================
Reference:
Setting up a WebDAV server
http://www.linuxquestions.org/questions/linux-server-73/digest-authentication-not-working-on-default-apache-installation-on-slackware-12.1-730785/
http://httpd.apache.org/docs/2.2/mod/mod_auth_digest.html
http://samiux.wordpress.com/2009/06/27/howto-webdav-on-ubuntu-9-04-server/
2009年10月18日 星期日
認識 initrd 與 initramfs
查wiki的initrd有很好的說明
這裡提供最簡易的認知
Linux系統開機時,除了載入kernel,還需掛載根檔案系統(rootfs),
由於根檔案系統並不一定能很容易的被掛載,(例如rootfs不位在本機硬碟,需要使用其它工具才能從遠端掛載它;又例如你的rootfs在特殊的儲存裝置,需要先載入它的driver才能正常使用)。
為了提供足夠掛載真正 rootfs 能力,所以設計成兩階段掛載rootfs,先掛載容易取得的 initrd檔為rootfs,有了足夠的能力,再掛載真正的rootfs,這樣的設計就很有彈性。
當然initrd檔要放在系統很容易就能存取到的地方,例如kernel有支援的硬碟中的一個檔案。
initrd檔案有兩種:
1. (old) Ram disk image : (optionally gzip-compressed) file system image (例如一個 ext2 file system 的壓縮檔)
2. (new) Initramfs image: gzip-compressed cpio archive (直接將開機所需檔丟給 cpio,再經 gzip 壓縮)
kernel能自行判斷是哪一種 initrd 檔,成功解壓縮形成在 ram 中的 rootfs。如果是 Ram disk image,就會把原本的 file system (如ext2) 還原成 ram disk;如果是 initramfs image,則會使用它cpio中包含的檔案形成 tmpfs file system(或是較舊的 ramfs file system)
雖然也是在 ram 中運作,但 tmpfs 並不是 ram disk,ram disk 指的是把一般的 disk file system 放到 ram 中運作,而 tmpfs就是設計在ram中運作,並不是 disk file system,也比它有效率。
My note on creating initramfs:
To extract initramfs:
gunzip < /boot/initrd.img-2.6.28-11-generic | cpio -i -d -H newc --no-absolute-filenames
To create initramfs:
cd myinitrd/
find . | cpio -o -H newc | gzip > ../myinitrd.gz
Note 1: Makesure all files in myinitrd/ are belong to root (chown -R 0:0 *). Otherwise, init script may fail to mount proc and show you "permission denied (are you root )" errors.
Note 2: use gzip -9 ... may lead to kernel panic "invalid compressed format" when booting !! Guess it's because some vmlinuz doesn't support that compression level.
Reference:
深入理解 Linux 2.6 的 initramfs 機制 (上)
Introducing initramfs, a new model for initial RAM disks
how to create an initramfs image
https://www.kernel.org/doc/Documentation/initrd.txt
https://www.kernel.org/doc/Documentation/initrd.txt
2009年10月1日 星期四
Sed : remove empty lines, remove beginning spaces, tabs
Remove empty lines:
cat file|sed /^$/d
Remove beginning spaces:
cat file|sed s/^\ *//g
Remove beginning tabs:
cat file|sed s/^\\t*/d
(Remove=Replace with nothing)
cat file|sed /^$/d
Remove beginning spaces:
cat file|sed s/^\ *//g
Remove beginning tabs:
cat file|sed s/^\\t*/d
(Remove=Replace with nothing)
訂閱:
文章 (Atom)