Implementation and problem solving of usb driver in linux2.6.22

Source: Internet
Author: User
Linux general technology-Linux programming and kernel information. For details, see the following section. 2007.11.16
1. The following problems occur during kernel startup:
Mount: mounting tmpfs on/dev failed
The solution is as follows,
File systems --->
Pseudo filesystems --->
  • Virtual memory file system support (former shm fs)

    2. The vivi startup parameter is attached. nfs has been used recently. It is difficult to switch. Remember cp first.
    Set to start from flash:
    Param set linux_cmd_line "noinitrd init =/linuxrc console = ttySAC0 root =/dev/mtdblock3"
    Set to start from nfs:
    Param set linux_cmd_line "noinitrd init =/linuxrc console = ttySAC0 root =/dev/nfs nfsroot = kernel:/srv/nfs/rootfs ip = 192.192.192.200: 192.192.192.xx: kernel: 255.255.255.0 :: eth0: off"
    Set to start from ramdisk:
    Param set linux_cmd_line "console = ttySAC0 initrd = 0x30800000,0x400000 root =/dev/ram ".

    3. after the usb device test is passed, you can attach modules to the usb device from the device as follows. the ko file is a module File driven by usb, which must be loaded before use)
    $ Insmod s3c2410_udc.ko
    $ Insmod g_file_storage.ko file =/dev/mtdblock5 stall = 0 removable = 1

    4. Add content from usb:
    4.1.usb is configured when it is initialized as a slave device:
    + + Linux-2.6.22/arch/arm/mach-s3c2410/mach-f2410.c 2007-11-15
    & Amp; initi_device_i2c,
    & Amp; cloud_device_iis,
    & Amp; cloud_device_nand,
    +/* Add by feng */
    + & Amp; cloud_device_usbgadget,
    };
    /* USB */
    Initi_device_usb.dev.platform_data = & usb_s3c2410_info;
    S3c2410_modify_miscr (S3C2410_MISCCR_USBSUSPND0 |
    -S3C2410_MISCCR_USBSUSPND1, 0x8 );
    + S3C2410_MISCCR_USBSUSPND1 |
    + S3C2410_MISCCR_USBHOST, 0x0 );

    . Add the udc DRIVER:
    + + Linux-2.6.22/drivers/usb/gadget/s3c2410-udc.c 17:38:17. 000000000 + 0800
    + + Linux-2.6.22/drivers/usb/gadget/s3c2410-udc.h 17:38:31. 000000000 + 0800
    + + Linux-2.6.22/include/asm/arch-s3c2410/regs-udc.h 01:22:25. 000000000 + 0800

    4. 3. added the udc option in kconfig to support:
    ++ Linux-2.6.22/drivers/usb/gadget/Kconfig 2007-11-15
    Select this only if your OMAP board has a Mini-AB connector.
    + # Add by feng
    + Config USB_GADGET_S3C2410
    + Boolean "S3C2410"
    + Depends on ARCH_S3C2410
    + Help
    + Samsung's S3C2410 is an ARM-4 processor with an integrated
    + Full speed USB 1.1 device controller.
    + It has 4 retriable endpoints, as well as endpoint
    + Zero (for control transfers ).
    +
    + Config USB_S3C2410
    + Tristate
    + Depends on USB_GADGET_S3C2410
    + Default USB_GADGET
    + Select USB_GADGET_SELECTED
    +
    + Config USB_S3C2410_DEBUG
    + Boolean "S3C2410 udc debug messages"
    + Depends on USB_GADGET_S3C2410
    + # End add
    +
    Config USB_GADGET_AT91
    Boolean "AT91 USB Device Port"
    4. added the udc option in makefile to support:
    ++ Linux-2.6.22/drivers/usb/gadget/Makefile 17:01:04. 000000000 + 0800
    Obj-$ (CONFIG_USB_FSL_USB2) + = fsl_usb2_udc.o
    + # Add by feng
    + Obj-$ (CONFIG_USB_S3C2410) + = s3c2410-udc.o

    2007.11.15
    I. Learn how to use ctags to find the source code, which is super convenient
    Steps:
    1. run commands in the source code directory.
    $ Ctags? R * ($ is a Linux Shell prompt)
    2. Use vi to enter the editing environment,
    Ctrl +] Query
    Ctrl + T return to the previous step
    : Ta XX find file XX
    Ii. usb slave part (to be added later)
    1. Add the udc DRIVER:

    Add udc support in kconfig:

    Add udc support to makefile:

    2. Configuration
    Device Drivers --->
    USB Gadget Support --->
    Support for USB Gadgets
    USB Peripheral Controller (S3C2410) --->
    (X) S3C2410
    File-backed Storage Gadget
    2007.11.14
    Refer to luofuchong's post, modify the file, and modify the mach-f2410.c file so that it supports usb Initialization
    Add the following in the mach-f2410.c:

    # Include
    # Include
    # Include
    # Include
    # Include

    /* USB */
    Static struct s3c2410_hcd_info usb_s3c2410_info = {
    . Port [0] = {
    . Flags = maid
    },
    . Port [1] = {
    . Flags = maid
    }
    };

    Int _ init s3c2410_init_usb (void)
    {
    Unsigned long upllvalue;
    Printk ("USB Control, (c) 2006 pc104 \ n ");
    Initi_device_usb.dev.platform_data = & usb_s3c2410_info;

    S3c2410_modify_miscr (S3C2410_MISCCR_USBSUSPND0 |
    S3C2410_MISCCR_USBSUSPND1, 0x8 );

    Upllvalue = (0x78 <12) | (0x02 <4) | (0x03 );
    While (upllvalue! ==Raw_readl (S3C2410_UPLLCON ))
    {
    _ Raw_writel (upllvalue, S3C2410_UPLLCON );
    Mdelay (1 );
    }
    Return 0;
    }

    Static void _ init f2410_init_machine (void)
    {
    Initi_device_nand.dev.platform_data = & sbc2410x_nand_info;
    Platform_add_devices (f2410_devices, ARRAY_SIZE (f2410_devices ));
    S3c2410_init_usb ();
    }

    The configuration is as follows:

    The following copy luofuchong linux-2.6.14 USB driver porting experience, mainly according to 2.6.22 core changed a bit, so that it can support U disk.
    /*************************************** ** From luofuchong **********************************/
    1. Enable the kernel to support hot swapping
    │ General setup --->
  • Configure standard kernel features (for small systems) --->
  • Support for hot-pluggable devices (NEW)
    2. USB driver settings
    Device Drivers --->
    Generic Driver Options --->
    <*> Userspace firmware loading support
    Block devices --->
    <*> Low Performance USB Block driver
    SCSI device support --->
    <*> SCSI generic support
  • Probe all LUNs on each SCSI device
    USB support --->
    <*> Support for Host-side USB
  • USB device filesystem
    <*> Ohci hcd support
    <*> USB Mass Storage support
  • USB Monitor
    3. Added support for MSDOS fs and VFAT fs.

    File systems --->
    DOS/FAT/NT Filesystems --->
    <*> MSDOS fs support
    <*> VFAT (Windows-95) fs support
    (936) Default codepage for FAT
    (Cp936) Default iocharset for FAT

    File systems --->
    Partition Types --->
  • Pc bios (MSDOS partition tables) support

    4. added the Chinese font library (unfortunately, the Chinese font still fails to be displayed on my board ~ _~, If you know something, please let me know. Let's discuss it together)
    Native Language Support --->
    <*> Simplified Chinese charset (CP936, GB2312)
    <*> NLS UTF8

    5. In addition, if you want the kernel to treat it as a SCSI device, you just need to take the above:
    Device Drivers --->
    Block devices --->
    <*> Low Performance USB Block driver
    The Low Performance USB Block driver option is removed, and then:
    Device Drivers --->
    SCSI device support --->
    <*> SCSI disk support
    Select the SCSI disk support option, and recompile the kernel.
    /*************************************** End from ************************************** *******/
    2007.11.13
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.