12 USB相关

12.1 USB做device存储

USB can be used as a device storage function, that is, after the device is inserted into the PC, the U disk display can be seen on the PC, and files can be copied, etc.;。
1,Need to open menuconfig under the project, set as follows;:
Turn on usb device function;:

alt text

Open flash related support, enable flash file system;:
alt text

Open specific configuration related to USB;:
alt text

Perform detailed USB configuration, select Mass Storage device, and because flash1 has small space, and put code in at the same time, usually choose flash2 as U disk space;
alt text

After configuring the relevant definitions, compile the software, download it, then connect the device to the PC via the USB port, power on, and you need to enter commands in the PC serial port;:

mkfs -t elm flash2    ---Formatting;
mountfs -t elm flash2 /  ---Mounting;
ls /dev      ---You can check if there is a USB device;
mkdir abc    ---If you can see the USB device, create a folder via mkdir, you can see the U disk icon on the PC side, and you can click to enter and copy files;

PS:The SDK supports the device storage function, which requires relevant configuration, and customers also need to debug according to their own needs. Sometimes, it needs to be restarted and remounted before the U disk can be seen.。