2009年12月16日 星期三

ARM的Flash啟動流程與機制(s3c2440)

Nand 與 Nor 不同處

Nor支援XIP(eXcute In Place)指令可以在Flash內執行,有點像是Memory的感覺。

Nand沒有Nor的特性,就嵌入式而言如果要執行Nand裡頭的指令必須載入Ram裡頭方可執行,Nand就好比一般個人電腦裡的硬碟。

另外Google到的參考文章解決我的困惑,bootloader有分網路啟動、Flash啟動,其中Flash的啟動中,Nand Flash有著很大的不同處。

NANDFlash需要与一个叫“Steppingstone”的内部SRAM配合工作(在所有的内存映射图上它叫BootSRAM),它是一个处理器内部自带的SRAM缓冲器,它把NANDFlash上4Kbyte启动代码加载,然后执行不信的话请看看英文原解S3C2440A boot code can be executed on an external NAND flash memory. In order to support NAND flash bootloader, the S3C2440A is equipped with an internal SRAM buffer called ‘Steppingstone’. When booting, the first 4KBytes of the NAND flash memory will be loaded into Steppingstone and the boot code loaded into Steppingstonewill be executed而这4K的SRAM buffer called ‘Steppingstone’会映射到0x00000000,在bootloader把主程序移到SDRAM以后他就可以被用到其他用途。

Steppingstone(SRAM, 並且映射至nGSC0)其實是內部就做好的,在開啟開發版(Reset)後會自動抓取nand前的4KB載入至Steppingstone(映射至nGSC0,0x00000000),CPU從0x00000000執行(其實是Steppingstone的SRAM),前4KB並不是指整個bootloader,而是只應射到steppingstone的內容必須小於4KB,之後,就是執行bootloader裡的內容,像是中斷、設置cpu速度與時鐘頻率、SDRAM初始化、LED初始化、複製bootloader‥等,然後是載入核心、檔案系統。


自启动模式的执行步骤如下:
(1)完成复位
(2)如果自动启动模式使能,NAND Flash存储器的前4KB自动复制到Steppingstone内部缓冲器;
(3)Steppingstone映射到nGCS0;
(4)CPU在Steppingstone的4KB内部缓冲器中开始执行启动代码。
注意:在自动启动模式下,不进行ECC检测。因此,应确保NAND Flash的前4KB不能有位错误(一般NAND Flash厂家都能确保)。


Steppingstone有點像是戰爭裡頭的第一槍,沒了這第一槍戰爭是打不起來的。

參考http://www.arm79.com/simple/?t347.html
      http://blog.sina.com.cn/s/blog_5128d4fc0100923l.html
      http://hi.baidu.com/zengzhaonong/blog/item/4b901ee9b5ef343cb90e2d16.html
      http://www.diybl.com/course/6_system/linux/Linuxjs/2008930/147032.html
      http://blog.ednchina.com/tengjingshu/245192/message.aspx

2009年12月8日 星期二

VirtualBox 分享資料夾使用步驟

(假設在Ubuntu裡頭透過Virtual Box跑一個XP)


1.先新增一個資料夾,並記住它的位置(Ubuntu裡頭)


2.在Virtual Box視窗裡點選你所要的作業系統(假設是XP)


3.按下設定值,然後點選分享資料夾並新增你要分享資料夾的路徑(1.裡所新增的路徑)


4.接著按啟動(接下來都在XP裡頭作業)


5.到了XP裡頭 開啟我的電腦


6.點選工具裡頭的連線網路磁碟機


7.選你喜歡的磁碟機代號,然後按瀏覽


8.會看到VirtualBox Shared Folders點進去就可以看到你在Ubuntu裡分享的資料夾


9.之後按確定與完成,就可以在我的電腦裡頭看見網路磁碟機,以後就可以透過這個資料夾在兩個系統間傳輸檔案

2009年11月30日 星期一

Bootloader的啟動方式


Bootloader的啟動


Linux系統是通過Bootloader引導啟動的。一上電,就要執行Bootloader來初始化系統。
系統加電或復位後(Reset),所有CPU都會從某個地址開始執行,這是由處理器設計決定的。比如,X86的復位向量在高地址端,ARM處理器在復位時從地址 0x00000000取第一條指令。嵌入式系統的開發板都要把板上ROMFlash映射到這個地址。因此,必須把Bootloader程序存儲在相應的 Flash位置。系統加電後,CPU將從這裡開始執行。


主機和目標機之間一般有串口(RS232或是RJ-45)可以連接,Bootloader軟件通常會通過串口來輸入輸出。例如:輸出出錯或者執行結果信息到串口終端,從串口終端讀取用戶控制命令等。


Bootloader啟動過程通常是多階段的(Vivi分成兩階段head.S(組合語言寫成)init/main.c(C語言寫成)),這樣既能提供復雜的功能,又有很好的可移植性。例如:從Flash啟動的Bootloader多數是兩階段的啟動過程。


大多數Bootloader都包含2種不同的操作模式:本地加載模式和遠程下載模式。這2種操作模式的區別僅對於開發人員才有意義,也就是不同啟動方式的使用。從最終用戶的角度看,Bootloader的作用就是用來加載操作系統,而並不存在所謂的本地加載模式與遠程下載模式的區別。
因為Bootloader的主要功能是引導操作系統啟動,所以我們詳細討論一下各種啟動方式的特點。


1.網路啟動方式
這種方式開發板不需要配置較大的存儲介質,跟無硬碟的工作站有點類似。但是使用這種啟動方式之前,需要把Bootloader安裝到板上的EPROM或者 Flash中。Bootloader通過以太網接口遠程下載Linux內核映像或者文件系統。
使用這種方式也有前提條件,就是目標板有串口、以太網接口或者其他連接方式。串口一般可以作為控制台,同時可以用來下載內核影像和RAMDISK文件系統。串口通信(RS232)傳輸速率過低,不適合用來掛接NFS文件系統。所以以太網接口成為通用的互連設備,一般的開發板都 可以配置10M乙太網接口(RJ-45)
對於PDA等手持設備來說,以太網的RJ-45接口顯得大了些,而USB接口,特別是USB的迷你接口,尺寸非常小。對於開發的嵌入式系統,可以把USB接口虛擬成以太網接口來通訊。這種方式在開發主機和開發板兩端都需要驅動程序。
另外,還要在服務器上配置啟動相關網路服務。Bootloader下載文件一般都使用TFTP網路協議,還可以通過DHCP的方式動態配置IP地址。


2.硬碟啟動方式
傳統的Linux系統運行在桌機或者伺服器上,這些電腦一般都使用BIOS引導,並且使用硬碟作為存儲介質。如果進入BIOS設置菜單,可以探測處理器、內存、硬碟等設備,可以設置BIOS從軟碟片、光碟機或者某顆硬碟啟動。也就是說,BIOS並不直接引導操作系統。那麼在硬碟的主引導區,還需要一個 Bootloader。這個Bootloader可以從硬碟文件系統中把操作系統引導起來。
Linux傳統上是通過LILOLInux LOader)引導的,後來又出現了GNU的軟件GRUBGRand Unified Bootloader)。這2Bootloader廣泛應用在X86Linux系統上。你的開發主機可能就使用了其中一種,熟悉它們有助於配置多種系統引導功能。


LILO軟件工程是由Werner Almesberger創建,專門為引導Linux開發的。現在LILO的維護者是John Coffman,最新版本下載站點:http://lilo.go.dyndns.orgLILO有詳細的文檔,例如LILO套件中附帶使用手冊和參考手冊。此外,還可以在LDP的“LILO mini-HOWTO”中找到LILO的使用指南。
GRUB GNU計劃的主要bootloaderGRUB最初是由Erich BoleynGNU Mach操作系統撰寫的引導程序。後來有Gordon MatzigkeitOkuji Yoshinori接替Erich的工作,繼續維護和開發GRUBGRUB的網站http://www.gnu.org/software/grub/上有對套件使用的說明文件,叫作《GRUB manual》。GRUB能夠使用TFTPBOOTP或者DHCP通過網路啟動,這種功能對於系統開發過程很有用。
除了傳統的Linux系統上的引導程序以外,還有其他一些引導程序,也可以支持硬碟引導啟動。例如:LoadLin可以從DOS下啟動Linux;還有ROLOLinuxBIOSU-Boot也支持這種功能。


3Flash啟動方式
大多數嵌入式系統上都使用Flash存儲介質。Flash有很多類型,包括NOR FlashNAND Flash和其他半導體盤。其中,NOR Flash使用最為普遍。
NOR Flash可以支持隨機訪問,所以程式是可以直接在Flash上執行的。Bootloader一般是存儲在Flash芯片上的。
Bootloader一般放在Flash的底端或者頂端,這要根據處理器的復位向量(Reset)設置。要使Bootloader的入口位於處理器上電執行第一條指令的位置。
接下來分配參數區,這裡可以作為Bootloader的參數保存區域。
再下來內核映像區。Bootloader引導Linux內核,就是要從這個地方把內核映像解壓到RAM中去,然後跳轉到內核映像入口執行。
然後是文件系統區。如果使用Ramdisk文件系統,則需要Bootloader把它解壓到RAM中。
最後還可以分出一些數據區,這要根據實際需要和Flash大小來考慮了。
這些分區是開發者定義的,Bootloader一般直接讀寫對應的偏移地址。到了Linux內核空間,可以配置成MTD設備來訪問Flash分區。
除了NOR Flash,還有NAND FlashCompact FlashDiskOnChip等。這些Flash具有芯片價格低,存儲容量大的特點。但是這些芯片一般通過專用控制器的I/O方式來訪問,不能隨機訪問,因此引導方式跟NOR Flash也不同。在這些芯片上,需要配置專用的引導程序。通常,這種引導程序起始的一段程式就把整個引導程序複製到RAM中運行,從而實現自行啟動,這跟從硬碟上啟動相似。

2009年11月22日 星期日

如何讓Ubuntu下可以解壓縮RAR檔?

下載rarlinux-3.9.0.tar.gz (版本可能不同)

開啟終端機然後到該資料夾的目錄輸入
tar zxvf rarlinux-3.9.0.tar.gz

會出現下列訊息
rar/
rar/readme.txt
rar/default.sfx
rar/whatsnew.txt
rar/license.txt
rar/order.htm
rar/rar
rar/unrar
rar/rar_static
rar/technote.txt
rar/rarfiles.lst
rar/makefile
rar/rar.txt

然後在輸入
cd rar => 進入rar資料夾

接著在輸入
make

2009年11月21日 星期六

如何在Ubuntu下安裝FTP(以Vsftpd為例)

1.首先先在終端機下輸入

sudo apt-get install vsftpd => 安裝Vsftpd套件

2.接著開啟

sudo gedit /etc/vsftpd.conf => 設定相關參數(可自行Google各參數定義)

****************以下是指令(你也可以複製貼上然後存檔)********************

# Example config file /etc/vsftpd.conf


#


# The default compiled in settings are fairly paranoid. This sample file


# loosens things up a bit, to make the ftp daemon more usable.


# Please see vsftpd.conf.5 for all compiled in defaults.


#


# READ THIS: This example file is NOT an exhaustive list of vsftpd options.


# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's


# capabilities.


#


#


# Run standalone? vsftpd can run either from an inetd or as a standalone


# daemon started from an initscript.


listen=YES


#


# Run standalone with IPv6?


# Like the listen parameter, except vsftpd will listen on an IPv6 socket


# instead of an IPv4 one. This parameter and the listen parameter are mutually


# exclusive.


#listen_ipv6=YES


#


# Allow anonymous FTP? (Beware - allowed by default if you comment this out).


anonymous_enable=NO


#


# Uncomment this to allow local users to log in.


local_enable=YES


#


# Uncomment this to enable any form of FTP write command.


write_enable=YES


#


# Default umask for local users is 077. You may wish to change this to 022,


# if your users expect that (022 is used by most other ftpd's)


local_umask=022


#


# Uncomment this to allow the anonymous FTP user to upload files. This only


# has an effect if the above global write enable is activated. Also, you will


# obviously need to create a directory writable by the FTP user.


#anon_upload_enable=YES


#


# Uncomment this if you want the anonymous FTP user to be able to create


# new directories.


#anon_mkdir_write_enable=YES


#


# Activate directory messages - messages given to remote users when they


# go into a certain directory.


dirmessage_enable=YES


#


# Activate logging of uploads/downloads.


xferlog_enable=YES


#


# Make sure PORT transfer connections originate from port 20 (ftp-data).


connect_from_port_20=YES


#


# If you want, you can arrange for uploaded anonymous files to be owned by


# a different user. Note! Using "root" for uploaded files is not


# recommended!


#chown_uploads=YES


#chown_username=whoever


#


# You may override where the log file goes if you like. The default is shown


# below.


xferlog_file=/var/log/vsftpd.log


#


# If you want, you can have your log file in standard ftpd xferlog format


xferlog_std_format=YES


#


# You may change the default value for timing out an idle session.


idle_session_timeout=600


#


# You may change the default value for timing out a data connection.


#data_connection_timeout=120


#


# It is recommended that you define on your system a unique user which the


# ftp server can use as a totally isolated and unprivileged user.


#nopriv_user=ftpsecure


#


# Enable this and the server will recognise asynchronous ABOR requests. Not


# recommended for security (the code is non-trivial). Not enabling it,


# however, may confuse older FTP clients.


#async_abor_enable=YES


#


# By default the server will pretend to allow ASCII mode but in fact ignore


# the request. Turn on the below options to have the server actually do ASCII


# mangling on files when in ASCII mode.


# Beware that on some FTP servers, ASCII support allows a denial of service


# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd


# predicted this attack and has always been safe, reporting the size of the


# raw file.


# ASCII mangling is a horrible feature of the protocol.


#ascii_upload_enable=YES


#ascii_download_enable=YES


#


# You may fully customise the login banner string:


#ftpd_banner=Welcome to OIpingo FTP service.


#


# You may specify a file of disallowed anonymous e-mail addresses. Apparently


# useful for combatting certain DoS attacks.


#deny_email_enable=YES


# (default follows)


#banned_email_file=/etc/vsftpd.banned_emails


#


# You may restrict local users to their home directories. See the FAQ for


# the possible risks in this before using chroot_local_user or


# chroot_list_enable below.


#chroot_local_user=YES


#


# You may specify an explicit list of local users to chroot() to their home


# directory. If chroot_local_user is YES, then this list becomes a list of


# users to NOT chroot().


chroot_list_enable=YES


# (default follows)


chroot_list_file=/etc/vsftpd.chroot_list


#


# You may activate the "-R" option to the builtin ls. This is disabled by


# default to avoid remote users being able to cause excessive I/O on large


# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume


# the presence of the "-R" option, so there is a strong case for enabling it.


#ls_recurse_enable=YES


#


#


# Debian customization


#


# Some of vsftpd's settings don't fit the Debian filesystem layout by


# default. These settings are more Debian-friendly.


#


# This option should be the name of a directory which is empty. Also, the


# directory should not be writable by the ftp user. This directory is used


# as a secure chroot() jail at times vsftpd does not require filesystem


# access.


secure_chroot_dir=/var/run/vsftpd


#


# This string is the name of the PAM service vsftpd will use.


pam_service_name=vsftpd


#


# This option specifies the location of the RSA certificate to use for SSL


# encrypted connections.


rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem


# This option specifies the location of the RSA key to use for SSL


# encrypted connections.


rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key


#可以接受的最大clinet可連線的數目


max_clients=20


#每個ip的最大連線數目


max_per_ip=15

*************以上是程式碼(去掉前面的井號該參數就會enable)****************



3.如果要新增另一個使用者步驟如下:
在終端機下輸入(先切換成Root權限 => sudo su)
adduser 您要的帳號
接著會要你輸入兩次密碼
然後開啟ftp軟體 輸入IP 帳號 密碼 就可以進入了
(如果你只有一個人使用,輸入IP然後帳號密碼用你登入Ubuntu的帳號與密碼就可以了 )

或者是在終端機下輸入
ftp 你的IP
(如果你的IP非固定IP請參考這篇NO-IP)


4.更改步驟後都要在終端機執行


sudo /etc/init.d/vsftpd stop 關閉 FTP服務
sudo /etc/init.d/vsftpd start 開啟 FTP服務
或者是你也可以用
sudo /etc/init.d/vsftpd restart 重開FTP服務

5.限制使用者

當在/etc/vsftpd.conf裡的chroot_local_user=YES(代表所有人都不可以跳出家目錄)
這時如果在sudo gedit /etc/vsftpd.chroot_list有該使用者的名稱則該使用者可以跳出

反之當chroot_local_user=NO(代表所有人都可以跳出家目錄)
這時如果在sudo gedit /etc/vsftpd.chroot_list有該使用者的名稱則該使用者無法跳出

6.讓你的FTP在登入時出現歡迎訊息方法如下:

開啟筆記本將你想要的歡迎訊息輸入,並將檔案儲存為『.message』並存放於跟目錄下『/home/你的帳號』

2009年11月20日 星期五

想開保時捷又沒錢買嗎?







 Link
想開保時捷又沒錢買嗎?
這裡有不錯的方案
xbox的方向盤
希望他可以出法拉利或是賓士、藍寶堅尼
個人是比較想開法拉利的

2009年11月13日 星期五

Ubuntu能夠執行.rpm檔的方法

如果在 Ubuntu 想要安裝的軟件只提供 RPM 檔案,而沒有提供 debian 的 .deb 檔案,可以使用 Alien Package 來解決。

執行下列指令安裝alien
sudo apt-get install alien

將.rpm轉.deb
sudo alien -k 檔名.rpm  這個步驟就需要一點時間了

完成後直接點就可以安裝了

Nero的Linux版

網址連結
http://www.nero.com/eng/downloads-linux4-trial.php

點選你要的版本安裝後就可以使用了

電路板的Nike球鞋






engadget看到的這雙Nike  這樣穿起來舒服嗎?

2009年11月12日 星期四

全世界最小的直昇機

全世界最小的直昇機Gen H-4 看了很久還是很有意思



該公司網站 http://www.gen-corp.jp/

販売価格 日幣 ¥6,000,000円(税別)能夠飛上天,這價錢算便宜吧!


另外一台 Mosquito XE

Mosquito XE : $30,000 (美金)including engine/instruments