1 / 17

Linux Driver

Linux Driver. SD Card 期末報告. Team4 : 694415016 曹啟訓 490415046 許弘達. Architecture. PC. SD card. net. UART. Command line (SPI). MI0101. Program outline. Use Block device driver architecture The SPI messages consist of command 、 response and data-block tokens

anja
Download Presentation

Linux Driver

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

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

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

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

  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. 實驗步驟 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

  13. END Thanks

More Related