Configure the USB driver to the device mode. After the computer is connected, the SD card is automatically recognized as a logical disk.
The kernel compilation configuration is shown in USB. txt.
Add the initialization statement to/etc/init. d/RCS.
Insmod musb_hdrc.ko
Insmod g_file_storage.ko file =/dev/mmcblk0p1
After USB is inserted, the hardware cannot be initialized because D + and D-are reversed on the USB board.
Problems:
1. when taking the photo, take 100 photos. The first time you plug the USB into the host, it will show that the size of the 100 photos is 0; however, if you input LS-Al/mnt/sdcard on the board, the size is 15.8 kb, which is correct. After the USB is inserted for the second time, some images may become correct, the size will change to 15.8k, and the images can be turned on. Some other images are broken.
2. later, I made a further research on this issue. I took 100 photos without loading the USB driver, and copied the data on the SD card to NFS on the serial terminal, copy the image from a Linux virtual machine to Windows. The image is correct. Input LS-Al/mnt/sdcard on the serial port to check that the image size is 15.8 kb. Board power-off, unplug the SD card, plug in to PC via card reader, browse under Windows, the results are also normal. However, if you do not want to write your work, only one photo set, m1.jpeg, is normal (random, but not all others are normal). The others are 0 kb. Insert the SD card back to the board, and then execute LS-Al/mnt/sdcardafter power-on. It is found that only m1.jpeg is normal, and all others are 0 kb. Solution: in Linux, data written to the disk is first cached in the memory, and the system writes the data from the memory to the disk when appropriate. Therefore, run the sync command before unplugging the SD card to ensure that the data in the memory is completely written to the disk.