Virtual serial com port ?

Hi,

Is their a way to use the USB port to change it to a serial port via a virtual serial port ?

It’s really nice to interact with the board without any USB-serial module (FTDI, CH340 etc.). On the host side you just need to have a virtual serial com port, included in all modern OS, Linux or even Windows.
I use it with STM32 for debug or interact on little projects, it’s really convenient.

I’ve only found an example with USBFS stuff, but nothing related to a serial port.

Cheers,

Phil

Hum, seems from this repo there is something interesting: https://github.com/riscv-mcu/GD32VF103_Firmware_Library/tree/master/Examples/USBFS/USB_Device/CDC_ACM

Now I need to figure out how to use this sample code.

Nice, what is the progress ?

Hi Zepan,

For the moment I’ve forget the idea of using the USB driver. Let me explain a little.

I’ve spent 4 or 5 days to try to compile this one. After having setup everything on Windows or Linux I always got this error:

_Other\usb-ser/src/cdc_acm_core.c:388: undefined reference to usbd_ep_recev' c:/users/migou/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld.exe: .pio\build\sipeed-longan-nano\src\cdc_acm_core.o: in functioncdc_acm_data_send’:
c:_Other\usb-ser/src/cdc_acm_core.c:402: undefined reference to usbd_ep_send' c:/users/migou/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld.exe: .pio\build\sipeed-longan-nano\src\app.o: in functionmain’:
c:_Other\usb-ser/src/app.c:70: undefined reference to `usbd_init’

etc…

It means all the source code was OK, it failed during the link.
While searching the error I’ve notice that during the compilation stage it even forgot to generate the .o file for the USB driver, despite all the includes referencing the .h file of the driver.
I’ve spent time on tuning the lib discover in PlatformIO, but again no result (http://docs.platformio.org/en/latest/librarymanager/ldf.html).
I was thinking founding a bug in Platformio or in the framework, so I’ve load the source code of the target GD32V to check how a new target is added in Platformio.
And after reading and understanding the build process I went on the file “fimware_libray.py” and this awful piece of code:

> #
> # Target: Build Core Library
> #
> 
> libs = [
>     env.BuildLibrary(
>         join("$BUILD_DIR", "standard_peripheral"),
>         join(FRAMEWORK_DIR, "GD32VF103_standard_peripheral")),
> 
> #    env.BuildLibrary(
> #        join("$BUILD_DIR", "usbfs_driver"),
> #        join(FRAMEWORK_DIR, "GD32VF103_usbfs_driver")),
>     
>     env.BuildLibrary(
>         join("$BUILD_DIR", "RISCV"),
>         join(FRAMEWORK_DIR, "RISCV")),
> 
> ]
> 
> env.Prepend(LIBS=libs)

I was a little upset of this one :frowning: It tells to the Platformio to NOT build the USB lib !!!

I’ve tried to uncomment it and it failed to compile. Then I understood why it was commented: nothing is building with this libs. And I didn’t found a tricks to achieve it by correcting the source code of the USB lib.

So I’ve drop it. And now I use the USART0, a shame regarding the ability of the module. But I need to achieve something with this board and not loose more time on a BETA framework (I know it’s a bad spirit of only complain, but I don’t have the knowledge in development to correct the driver, I’m not a developer).

So maybe on the next release of the framework or with the help of someone it could be usable. With the problem clearly spotted it’s now possible to go further.

Cheers,

Phil

1 Like

Interesting finding Phil. The missing function usbd_init exists in the source code tree. Have a look here
So we need to understand why this file is not included in the build. I have no clue how this build system works unfortunately. But if I have time I will take a look at compiling the examples. Can you perhaps attach the log from your build?

Yes the function is in the source code, but have a look at the upper commented code I’ve spotted : it ask to ignore the compiling of the USB files.
So with this bug the SDK does not add all the USB functions to the lib & bin generated and it failed during the link stage. You have the error in the post upper.

As I said I’ve drop the idea for the moment to use the USB- port for other things than a power supply :slight_smile:

Cheers,

Phil