4160 views|2 replies

7

Posts

0

Resources
The OP
 

[GD32E503 Evaluation] Realizing USB disk function based on uCOSIII project 1 [Copy link]

 

Preface:

When driving the LCD screen, we need to use fonts, pictures and other data. For example, if we want to display Chinese characters, the process is as follows: Make a font library to generate a .bin file, for example, generate a gb2312.bin file through the font library, and write the gb2312.bin file to the flash. The MCU parses the Chinese characters, obtains the gb2312 index value, and calculates the flash location based on the size of the font library. Read the corresponding data. The MCU sends the read data to the LCD screen for display.

When implementing the above process, I encountered a problem, that is, how to transfer the gb2312.bin file to the flash? I have the following methods:

  1. Write to flash via the serial port using the Ymodem protocol.
  2. Through the flash burning tool (but you need to take down the flash, burn it and then solder it back)
  3. Write to flash via usb-hid using the Ymodem protocol.
  4. Write files to flash in the form of a virtual USB disk.

Well...if you have any good ideas, please give me some advice. I can think of the above methods.

So, to sum up, I think it is most convenient to simulate a USB flash drive through gd32e503v and write the bin file to the USB flash drive on the PC side.

So I checked the schematic diagram and found out the solution for the USB port:

Also looked at the USB example code:

The official website only provides two examples, one for keyboard and one for CDC. As for USB flash disk, it belongs to MSC, but unfortunately it is not provided by the official website.

However, if we look carefully at the official information, we can find that the official still provides some necessary library files, as shown in the figure below, usbd stands for usb device, usbh stands for usbhost. These necessary driver codes are all there, and further checking the file usbd_library, we can find that the official actually provides a sample demo of msc.

Okay, everything is ready, except for freezing your hands.

Based on the current situation, we have already created the framework of uCOSIII, so we plan to add to it.

  1. First, transplant the official 23_USBD_Keyboard to the uCosIII framework and test whether it is normal.
  2. According to the official usb msc file, modify the 23_USBD_Keyboard project to realize the USB disk function.

Open the 23_USBD_Keyboard project, and you can see that the project structure is as follows. Application is where users modify the files. The three files USBD_Drivers, USBD_Devices, and USBD_Class are all officially provided. Generally, there is no special requirement and no need to modify them. You just need to add them.

We follow the same pattern, create corresponding files in our own project, and import

Then during compilation, there will be many header files that cannot be found. We can look in the demo project, find the corresponding header file path, and import them together. After that, you will find that some function interfaces cannot be found, so I also added a USBD_User folder for easy modification.

It should be noted that the file gd32e_50x_it.c is the entry of the interrupt function. Therefore, we need to copy some contents in the Demo to our project, including the following interface functions:

During this period, there will be some compilation errors, header files cannot be found, functions cannot be found, etc. I will not go into details about these basic skills.

Further, write the main function code

Two threads were created previously, so we add the following code to task2: (In fact, it is just copying the main function of the official routine)

Then compile and pass it, and then debug to see the effect.

But there was a problem:

And the development board can no longer debug or burn. . This scared me, I don't know why. However, fortunately, the gd32e503v development board brings out boot0 and boot1, which can easily modify the startup method of the mcu. (From flash, from ram... You can find the specific details on Baidu, stm32's Boot0 Boot1) Why stm32? ? ? Because gd is almost perfectly compatible with stm32~! The best domestic IC. I think it's awesome.

Pull boot0 and boot1 high, select erase all for flash programming, and then power on again to start flash programming.

Because the chip cannot be burned due to our code, we need to modify the code:

Then, set boot0 and boot1 low again, and you can debug. The chip is finally normal.

The above is just the beginning of realizing the USB disk function.

It took me quite a while, unfinished, to be continued...

This post is from Domestic Chip Exchange

Latest reply

Interesting, solving problems is improving   Details Published on 2021-1-27 22:22
 
 

144

Posts

0

Resources
2
 

Develop new skills, looking forward to it!

This post is from Domestic Chip Exchange
 
 
 

7462

Posts

2

Resources
3
 

Interesting, solving problems is improving

This post is from Domestic Chip Exchange
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list