原创 USB和SD/MMC移植V1.2

2009-12-20 14:01 2787 4 4 分类: 软件与OS

USBSD/MMC移植笔记<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />


 


一、USB移植


在移植好内核和跟文件系统的基础上,进行USB的移植。


S<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />3C2440集成了USB控制器支持USB1.1版本,支持USB主机和USB设备主机符合OHCI1.0版本,Linux2.6.29.1的内核支持USB控制器,只需在内核中配置即可。


在内核目录下,输入make menuconfig,进入配置菜单,如下:



Device Drivers-à


       SCSI device support-à


                     <*>SCSI device support


                    

  • legacy /proc/scsi/ support


    <*>SCSI disk support


    <*>SCSI CDROM support


          

  • HID Devices-à


                         <*> USB Human Interface Device(full HID)support


                        

  •    /dev/hiddev raw HID device support


          

  • USB support-à


                         <*> support for Host-side USB


                        

  • USB device filesystem


                        

  • USB device class-devices(DEPRECATED)


                         <*>OHCI HCD support


                         <*>USB Mass storage support


  • 先用make clean命令清除编译内核的垃圾文件,然后用命令make zImage编译内核。


    在移植的根文件系统系统目录dev下建立如下的设备文件:


    mknod sda1 b 8 1


    把编译好的内核和根文件系统映像文件下载到开发板,启动开发板后插入U盘,终端出现如下信息:



    [@MrFeng=W]#ls


    bin         etc         linuxrc     proc        sys         var


    boot        home        lost+found  root        tmp         www


    dev         lib         mnt         sbin        usr


    [@MrFeng=W]#usb 1-1: new full speed USB device using s3c2410-ohci and address 2


    usb 1-1: New USB device found, idVendor="0204", idProduct="6025"


    usb 1-1: New USB device strings: Mfr="0", Product="0", SerialNumber="0"


    usb 1-1: configuration #1 chosen from 1 choice


    scsi0 : SCSI emulation for USB Mass Storage devices


    scsi 0:0:0:0: Direct-Access     USB A    Flash Disk       2.00 PQ: 0 ANSI: 2


    sd 0:0:0:0: [sda] 506420 512-byte hardware sectors: (259 MB/247 MiB)


    sd 0:0:0:0: [sda] Write Protect is off


    sd 0:0:0:0: [sda] Assuming drive cache: write through


    sd 0:0:0:0: [sda] 506420 512-byte hardware sectors: (259 MB/247 MiB)


    sd 0:0:0:0: [sda] Write Protect is off


    sd 0:0:0:0: [sda] Assuming drive cache: write through


     sda: sda1


    sd 0:0:0:0: [sda] Attached SCSI removable disk


     


    [@MrFeng=W]#mount -t vfat /dev/sda1 /mnt/usb


    FAT: utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!


    使用命令mount挂载U盘:



    [@MrFeng=W]#mount -t vfat /dev/sda1 /mnt/usb 


    [@MrFeng=W]#ls /mnt/usb


    bootloader.tgz         logomaker.tgz          rootfs.img


    busybox-1.13.3.tar.gz  mdev.txt               server.c


    examples(1).tgz        mini2440_pwm.c         zImage


    getaddrinfo.c          mkyaffsimage.tgz


    led_driver.c           root_qtopia.img


     


    拔下U盘后出现:



    [@MrFeng=W]#usb 1-1: USB disconnect, address 2


     


    二、SD/MMC移植


    S3C2440集成了一个MMC/SD/SDIO主机控制器,用于访问外接的SDMMCSDIO卡,linux-2.6.29.1包含了MMC/SD驱动程序,只需在内核中配置即可。在内核里做如下配置:



    Device Drivers-?


           <*>MMC/SD/SDIO card support--->


                  <*>MMC block device driver


                 

  • Use bounce buffer for simple hosts


                  <*>Samsung S3C SD/MMC Card Interface support


  • 配置好后,把编译的内核下载到开发板后,插入SD卡终端没有任何提示。细细一看,友善之臂的SD卡的写保护不是直接接地的,二是接到GPH8引脚的,


    于是我在内核文件/arch/arm/mach-s3c2440/mach-smdk2440.c中做如下修改:



    static void __init smdk2440_machine_init(void)


    {


           s3c24xx_fb_set_platdata(&smdk2440_fb_info);


           s3c_i2c0_set_platdata(NULL);


           //开启LCD背光


           s3c2410_gpio_cfgpin(S3C2410_GPG4,S3C2410_GPG4_OUTP);


        s3c2410_gpio_setpin(S3C2410_GPG4,1);


           //关闭SD卡写保护


           s3c2410_gpio_cfgpin(S3C2410_GPH8,S3C2410_GPH8_OUTP);


           s3c2410_gpio_setpin(S3C2410_GPH8,0);


           platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));


           smdk_machine_init();


    }


    另外,将检测SD卡的引脚设为中断,用于检测SD卡,在内核文件在drivers/mmc/host/s3cmci.c1335行添加如下代码:




    host->irq_cd = IRQ_EINT16;


    s3c2410_gpio_cfgpin(S3C2410_GPG8,S3C2410_GPG8_EINT16);



    1357行注释掉如下代码:




    //ret = -EBUSY;


    //goto probe_free_irq_cd;



     


    重新编译内核,下载到开发板,并在跟文件系统的dev目录下通过命令“mknod mmcblk0 b 179 0”建立节点,烧写根文件系统。系统启动后将SD卡插入到卡座,在终端出现如下信息:



    [@MrFeng=W]#mmc0: card 0002 removed


    s3c2440-sdi s3c2440-sdi: powered down.


    s3c2440-sdi s3c2440-sdi: running at 0kHz (requested: 0kHz).


    s3c2440-sdi s3c2440-sdi: running at 198kHz (requested: 197kHz).


    s3c2440-sdi s3c2440-sdi: running at 198kHz (requested: 197kHz).


    s3c2440-sdi s3c2440-sdi: running at 198kHz (requested: 197kHz).


    s3c2440-sdi s3c2440-sdi: running at 198kHz (requested: 197kHz).


    s3c2440-sdi s3c2440-sdi: running at 198kHz (requested: 197kHz).


    s3c2440-sdi s3c2440-sdi: running at 198kHz (requested: 197kHz).


    s3c2440-sdi s3c2440-sdi: running at 198kHz (requested: 197kHz).


    s3c2440-sdi s3c2440-sdi: running at 16875kHz (requested: 25000kHz).


    s3c2440-sdi s3c2440-sdi: running at 16875kHz (requested: 25000kHz).


    mmc0: new SD card at address 0002


    mmcblk0: mmc0:0002 00000 1.90 GiB


     mmcblk0:<4>mmcblk0: retrying using single block read


     


    拔下SD卡出现:



    [@MrFeng=W]#mmc0: card 0002 removed


    s3c2440-sdi s3c2440-sdi: powered down.


     


    说明:V1.2是对V1.1SD卡移植部分进行修改,V1.1中移植SD卡是不完善的,只关闭了SD卡写保护,没有添加检测SD卡部分,这将导致使用不正常。


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


     


    ----------------------------取之于网络,还之于网络--------------------

    PARTNER CONTENT

    文章评论0条评论)

    登录后参与讨论
    EE直播间
    更多
    我要评论
    0
    4
    关闭 站长推荐上一条 /3 下一条