CH32V307V-EVT-R1 Eth Sample

Hello all,

Would like to know if anyone got Ethernet working on CH32V307V-EVT-R1 board.

What I get today when building is “error: unknown type name ‘ETH_DMADESCTypeDef’”.

Maybe something to do with the static libwchnet.a and libwchnet_float.a libs? Can’t we have the source for those?

Thanks & Regards,

  • Cristiano
2 Likes

Hi @Montecri ,
I’m looking into your issue and will get back with a solution ASAP.

Kind regards,
Kristof

1 Like

Hi @Montecri ,
I just wanted to inform you that we released version 1.2.2 with improved support for the WCH chips. Now the sample projects for the WCH chips can do much more than just blinking an LED.

I’ll try to get the sample project for ethernet working tomorrow, for theCH32V307 chip. I’ll keep you updated.

Regards,
Kristof

Hi @Montecri ,
Please upgrade your Embeetle installation to version 1.2.2. Then create a new project for the ch32v307vct6-evt-r1 board. You will notice that this project has a lot of sample projects inside the <project>/source/Samples folder. All of them are deactivated by default - except for the GPIO sample project. That’s the “Blinky LED” project. It’s the active one, because it is an easy way to get something working on your board:

You expressed your interest in the Ethernet functionality. Therefore, I’ll guide you in this post how you can activate the ethernet functionality properly.


STEP 1: Deactivate current project

Right-click on the GPIO folder and select Force exclude:

Wait a few seconds for the Source Analyzer to complete the project analysis (a green progressbar in the bottom-right corner indicates that).


STEP 2: Activate the ethernet project

Navigate to the Ethernet sample project you want to activate. For example the ETH/UdpServer folder:

Right-click the folder and select Automatic in the menu. Embeetle will now figure out which files from this folder are needed for successful compilation:

image

Unfortunately, there are still a few project errors in the Diagnostics tab:

We’ll solve that in the next step.


STEP 3: Go hunting for 'missing symbols'

The errors you see in the Diagnostics tab are all ‘undefined global symbols’. In other words: you have activated a sample project, but not all source files are available to Embeetle yet. Some source files needed for a successful compilation are still missing.

So now we need to go hunting for these “missing symbols”. They turn out to be in the NetLib folder, located at <project>/source/Samples/ETH/NetLib. Put this folder also on Automatic mode:

image

Great, but now the Diagnostics tab shows hundreds of multiply defined globals! We have the opposite problem here: several symbols are defined in multiple places. That’s because the following two library files are fighting each other:

  • libwchnet.a
  • libwchnet_float.a

They can’t coexist. You have to choose one. Choose the libwchnet.a library (the other one has a few issues). Force exclude libwchnet_float.a (right-click and select ‘Force exclude’):

image

Great! Now the Diagnostics tab shows no more errors. Just a few warnings, but they are pretty harmless:

The build should work now:


STEP 4: Add some libraries

To be sure I didn’t miss anything, I ran the project in Mounriver Studio (the Eclipse-based IDE from WCH). I noticed they added the following libraries to the linker command:

-lm
-lwchnet
-lprintf

The linker is notified here that it can look for these libraries in the compiler toolchain:

  • -lm: mathematics library
  • -lwchnet: wchnet library
  • -lprintf: printf library

If you want to pass them in Embeetle IDE, you should open the file <project>/config/dashboard.mk and navigate to line 127:

image

Add them to the TOOLCHAIN_LDLIBS variable. Our makefile imports this dashboard.mk file and will use this variable to know which libraries to look for in the compiler toolchain when launching the linker.

However, The compiler toolchain in Mounriver Studio is slightly different from the one used in Embeetle IDE. It would lead us too far here to dive into all the details. Point is: the compiler used in Embeetle IDE has no built-in wchnet and printf libraries. So you should remove those. Keep only the maths library:

image

No worries though. The build works because the wchnet library is provided at this location:

image

As you can see, this library is automatically selected and fed to the linker. As for the printf library - there seems to be no compilation issue either.

1 Like

Hi Kristof!

Thank you for the detailed reply!

Just followed the steps and could compile the project. Will run some network tests and report back.

Regards,

  • Cristiano
2 Likes

Hi @Montecri ,
Wonderful.

Don’t hesitate to reach out if there’s anything else we can help you with.

Regards,
Kristof

1 Like

Hi Kristof,

Today I had some time to test and try running the DHCP demo.

The main call WCHNET_DHCPStart never returns control to the callback WCHNET_DHCPCallBack.

The ETH activity lights never blink and, since WCHNET_DHCPStart is inside libwchnet.a, it’s very difficult to understand what is going wrong.

Have you guys tested the DHCP example? can’t we have the source for the .a file to facilitate debugging?

Thanks & Regards,

  • Cristiano

Hi @Montecri ,
Thank you for sharing these technical issues with us. We’ll get in touch with WCH about the libwchnet.a library. Meanwhile, we also decided to set aside some time on Thursday to try the ETH project ourselves. Can you please give us a step-by-step procedure on what you tried? So we can reproduce the issue at hand.

Regards,
Kristof

1 Like

Hi Kristof,

I didn’t do much, just followed the steps above, but instead of selecting UDPServer I selected DHCP. Compiled and flashed. Plugged the board to my router and … nothing…

Wen’t to debug and noticed that the callback from DHCPStart is never invoked. Tried to put a breakpoint but saw myself inside a binary libwchnet.a instruction.

Unfortunately, I’m not knowledgeable enough to debug this .a file.

Thanks!

  • Cristiano
1 Like

Thank you @Montecri,
we’ll get back to you as soon as possible.

Regards,
Kristof

1 Like

Hi Cristiano,
The problem is indeed the compiler. Please follow the instructions described on this page:

https://embeetle.com/#supported-hardware/wch/compiler

Thank you for notifying us about the problem earlier.

Don’t hesitate to reach out again if there’s anything we can help you with.

Thank you! Will certainly test and report back.

Regards,

  • Cristiano
1 Like

Hi @kristof
I am getting same problem described by @Montecri in Mounriver software. Can you suggest me the solution? I am using CH32V307-VCT6-R1

Hi @Namrata ,
Please try the steps from this webpage:
https://embeetle.com/#supported-hardware/wch/compiler

Let me know if it worked for you.

Hi @kristof
I am using mounriver studio only i have not installed embeetle IDE. Is it necessary?

Hi @Namrata ,
If you install Embeetle IDE, it will be easier for us to help you.
you can download Embeetle from here:
https://embeetle.com/#embeetle-ide/download