Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linux Driver SD Card 期末報告 Team4 : 694415016 曹啟訓 490415046 許弘達.

Similar presentations


Presentation on theme: "Linux Driver SD Card 期末報告 Team4 : 694415016 曹啟訓 490415046 許弘達."— Presentation transcript:

1 Linux Driver SD Card 期末報告 Team4 : 694415016 曹啟訓 490415046 許弘達

2 Architecture PC MI0101 SD card net UART Command line (SPI)

3 Program outline Use Block device driver architecture The SPI messages consist of command 、 response and data- block tokens The Card-Specific Data (CSD) register provides information on how to access the card contents Card detect uses GPIO interface to get the value from SD card pin, in order to judge whether SD card exist or not. Write Protect uses GPIO interface to get the value from SD card pin, in order to judge whether SD card write protect exist or not.

4 driver init module_init() sd_driver_init() Register_blkdev() blk_init_queue() Set timer Sd_exit() check media()Sd_init() yesno Program flowchart 註冊 major number 、 device name ,以及記錄 操作指令的資訊 連結 request 與 queue ,並且初始化 request queue 確認 sd card 是否偵測到 ? sd_card_init( ) : 初始化 sd card Sd_card_config( ) : 得到 sd card 特定資料 清除 sd_driver_init( ) 的設定

5 Program flowchart (cont.) request Sd_request() CMD READ CMD WRITE end_request() mmc_write_block mmc_read_block 得到 sd card 和 buffer 的位址; 再判斷 command 來做 read 和 write 的動作。 一次讀取 512 bytes 的資料 一次寫入 512 bytes 的資料 1 :成功 0 :失敗

6 Program flowchart (cont.) exit function module_exit() sd_driver_exit() blk_cleanup_queue() unregister_blkdev() delete timer 指定 major number 和 device name sd_exit() 釋放 request queue 清除 sd_driver_init( ) 的設定

7 實驗步驟 1 將 SD 驅動程式, sd.c 、 crc.h 以及 spi_reg.h 放置於 block 資料夾中。 # cp sd.c crc.h spi_reg.h /data/develop/uClinux/uClinux- dist.20020502/linux-2.4.x/drivers/block/ 註冊 device name, major number, minor number # vi /data/develop/uClinux/uClinux-dist.20020502/vendors/ Mcrolinks/ML-i0101/Makefile 加上這一行 mmca,b,121,0 mmca1,b,121,1 \ 定義三態,按鈕名稱,對應 Makefile 的名子 # vi /data/develop/uClinux/uClinux-dist.20020502/linux- 2.4.x/drivers/block/Config.in 加入這一行 tristate 'SD/MMC card support' CONFIG_BLK_DEV_SD 定義名子和對應的.o 檔 # vi /data/develop/uClinux/uClinux-dist.20020502/linux- 2.4.x/drivers/block/Makefile 加入這一行 obj-$ (CONFIG_BLK_DEV_SD)+= sd.o

8 實驗步驟 2 選取 kernel 支援的模組 [/uClinux-dist.20020502/]# make xconfig

9 實驗步驟 3 選取 Block devices -> SD/MMC Card Support ,勾選 ”m” ,將 SD/MMC 卡驅動程式編寫成模組 (modules) 的型態

10 實驗步驟 4 新增加的 SD card 選項 選取 module 的形式

11 實驗步驟 5 完成基本設定,開始編譯 image 檔 [/uClinux-dist.20020502/]# make dep ; make 等待 10 到 30 分鐘左右,新的 image 檔將會產生在 /data/devplop/uClinux/uClinux-dist.20020502/images 執行 minicom ,連到 I0101 後 , 再載入新的 image 檔 I0101 重新開機後,將模組化的 SD/MMC driver ,使用 insmod 指令安裝 於作業系統上,輸入指令如下: /> insmod sd.o

12

13 實驗步驟 6 將 SD device 掛載到系統 card A 點上,輸入指令如下: /> mount –t vfat /dev/mmca1 /card/A 查看 SD 卡裡面的檔案: /># ls /card/A /># cp /usr/10.mp3 /card/A /># ls /card/A 使用者若要移除 SD/MMC driver 可以在 minicom 終端機 執行以下指令: /># umount /card/A /># rmmod sd

14

15

16

17 END Thanks


Download ppt "Linux Driver SD Card 期末報告 Team4 : 694415016 曹啟訓 490415046 許弘達."

Similar presentations


Ads by Google