RT-Thread USB Protocol Stack — CherryUSB Reference Guide
CherryUSB is a small yet powerful and highly portable USB host and device protocol stack. Developed by domestic developers, it has garnered favor among developers due to its excellent performance and efficiency, particularly excelling in high-speed USB peripherals. Notably, CherryUSB has become the standard USB protocol stack implementation for RT-Thread. This means that within the RT-Thread system, developers can conveniently use CherryUSB to implement USB-related functionalities, providing more options and convenience for project development.
Preparation
● Hardware Platform: NXP MCX N947
● Keil MDK5 (firmware development/compilation requires installing version 5.38 or above of Keil MDK5), along with the chip support package: NXP.MCXN947_DFP.17.0.0
● MCUXpresso IDE (development/compilation requires installing version 11.9.0 or above of MCUXpresso IDE)
● RT-Thread env Tool (requires installing version 2.0.0 or above of RT-Thread env)
This implementation will enable the CherryUSB component in RT-Thread and create a USB RAM disk.
Firmwareirm
Based on the experimental environment one, insert another USB cable into J11 (HS-USB), as shown in the diagram below.
Software
Unzip handson4_cherryUSB_integration.7z and open the project.uvprojx file. Compile and download it (as done in the previous steps) to the board. Once the firmware is loaded, open “My Computer,” and a prompt will appear for an unformatted USB drive (size: 512K):
This indicates that the USB is functioning successfully, and a RAM Disk has been created. The 512KB USB drive actually uses 512KB of the MCXN947’s internal SRAM as storage space. Therefore, any files saved to the USB drive will be lost after a reset, and powering the device again will also invalidate the previously formatted file system. As a result, an unformatted USB drive will appear after every reset. If you’re up for the challenge, you can modify the source code to change the storage from RAM to Flash (either internal or external SPI flash, or an SD card).
The CherryUSB protocol stack comes with a wealth of examples. After integrating CherryUSB, you can freely use all the examples, supporting functionalities such as USB storage drives, USB keyboards and mice, USB virtual serial ports, and more.