USB host driver for USB storage based on at91sam9

Source: Internet
Author: User

Some time ago, I was preparing to write the driver of a non-operating system USB host, streaking arm9-, and driving a USB flash drive. I 've been searching for it online for a long time, but I didn't find a good routine, so I decided to study USB specification, but that stuff was confusing! Later I saw OHCI specification, which is also a kind of protocol. To write a complete driver by myself is simply looking for guilt. If I don't write it for a year and a half, I guess it's just a problem!

Almost gave up streaking and went directly to the OS! Later, when reading the uboot and Linux code, I learned that there are also USB Host drivers below. So I decided to start with these two codes and work out a USB flash drive bare metal!

I have previously seen fudan_abc's "Linux things", Niu B's people. In order to see that a can read tens of thousands of lines of code from the Linux USB flash drive one night, if I had seen Zhou Gong! Haha

Back to the topic, many USB Host drivers in Linux are related to the kernel, so it is very troublesome to think of porting. It takes several days or even weeks to understand the content; the code in uboot is almost streaking, or is a single-task program that loads the kernel and can read and retrieve the kernel files from many memories, USB storage is also included, so it should be correct from here!

Uboot includes many underlying drivers and some commands. Run the commands for operating the USB flash drive in cmd_usb.c. link them step by step to see the whole uboot USB operation process. There is also the file pai_fat.c, which involves file operations on USB storage. By the way, I see u-boot-1.1.5.

I started root searching under the "Start" command under cmd_usb.c, and received the start command to start usb_init (). usb_init contains the initialization of the hardware register usb_lowlevel_init (), after the initialization is complete, start usb_scan_devices (). When it is executed to usb_new_device (), it is a process of executing the USB protocol. There are many functions in it, all about the USB underlying layer, I won't talk much about it. You can simply copy it and use it.

Due to my limited level, I Can't elaborate on this porting process very well. I just want to provide you with a feasible method.

The files I obtained from uboot to operate the USB flash disk include

Common/USB. C & usb_storage.c & cmd_usb.c & cmd_fat.c

FS/fat. C & file. c

CPU/arm926ejs/at91sam926x/usb_ohci.c & interrupts. c

Disk/part. C & part_dos.c

And Related. h header files. If you are interested, you can discuss them together!

 

 

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.