USB Flash and FAT32 on the K70 SOM Using uClinux |
This application note explains how to use USB Flash disks and FAT32 on the K70 SOM running uClinux.
Set up your system with the K70 SOM as follows:
Please note that the USB power supplied to the K70 SOM over the mini-USB cable is limited to 500mA. As long as you stick to the use scenarios that involve only USB Flash as described below, this should be enough. However, if you access the USB Flash simultaneously with performing some other I/O operations, the 500mA power supplied by the USB link may be not sufficient. Should this happen to you, you could set up the K70 SOM and the Freescale Tower System with an external 5V power supply as described below:
The following kernel options are necessary to get the USB High Speed interface configured for the host-mode operation: CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_ROOT_HUB_TT=y CONFIG_USB_EHCI_MXC=y Additional kernel configuration options are required to enable support for the USB Flash and the FAT32 file system. Also, appropriate device node files must be created in the target root filesystem. The usbflash.tgz tarball contains a uClinux sample configuration (a uClinux project) that configures the kernel, busybox and root filesystems for operations with the USB Flash disk over the USB High-Speed interface of the K70. Contact Emcraft to obtain the bootable image and project source files. This project can be installed and built within the uClinux K70 software development environment using the following step-wise procedure:
tar xvfz usbflash.tgz cd projects/usbflash/ This will produce a uClinux bootable image for the newly installed project (usbflash.uImage). That image can booted on the K70 SOM from either a TFTP host or the on-module NAND Flash.
The most typical use of a USB Flash disk in embedded applications is storing data in a FAT32 file system. This allows easy transfer of data collected on the embedded system to a PC host. Linux supports many file systems, including FAT32 with support for long file names (VFAT). As soon as a USB Flash disk formatted as FAT32 has been connected to the K70, it can be immediately mounted and accessed using standard Linux tools and interfaces. For example: ~ # mount /dev/sda1 /mnt/ The newly created file (file.txt in the folder directory) can now be opened on this USB Flash disk on a PC in almost any operating system, including Windows, Mac OS X and Linux.
On some USB storage devices, a FAT32 file system may have been created in a partition, not on the whole disk. Linux supports the MBR partitioning, allowing access to specific partitions on a disk. The disk partitioning support is seamless - all you need to do is change the pathname to the storage volume, sda being the whole disk, sda1 - the first partition, etc. For example, this command will mount a first partition of the USB Flash disk, rather than the entire disk. ~ # mount /dev/sda1 /mnt/ Note further that the MBR partition table can be created or modified directly on the K70 target. This is done using the fdisk utility implemented as part of the busybox multi-entry tool. The sample session below shows how fdisk can be used to create a primary partition on the USB Flash disk: ~ # fdisk /dev/sda
Although typically a USB Flash disk would be formatted as FAT32 on a PC host, it is possible to do the formatting on the K70 target as well. The following command shows how format the entire USB Flash disk: ~ # mkfs.vfat /dev/sda -v -n "MYDISK" The newly formatted FAT32 file system is now ready for mounting. |