ESP32-C6 Serial / USB Jtag support

Hi everyone,

I’m working on implementing simpleFOC in my project. I designed some custom BLDC motor controller PCBs featuring an ESP32-C6, in hopes of utilizing simpleFOC for controlling BLDC motors for a CNC machine.

Thus far I’ve been to integrate Espresiffs port of simpleFOC successfully, and can take string inputs from a CAN bus, using sprintf and some logic to append various float values, to changing commander prefix (such as MLC, MLU, MLV, T, etc…

This is all great, but I’m now at a point of having to address the issue i’ve been having all along: No serial comms from simpleFOC. and as such - no motor info or debugging.

As I am using the ESP32-C6 I’ve had the joy of having to try and make sense of how the USB JTAG, and the serial communication through this interface.

On my custom board, I specifically chose to not have a dedicated UART bridge, and run the USB diff pair directly into the ESP, utilizing it’s usb jtag for flashing and monitoring.

Unfortunately, it seems to me, simpleFOC only supports UART (depite being named serial) communication for it’s commander interface?

I noticed that changing the sdkconfig to:

CONFIG_ESP_CONSOLE_UART_DEFAULT=y
CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y
CONFIG_ESP_CONSOLE_UART_NUM=0
CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0

Would get rid of my error message;

uart: uart_write_bytes(1454): uart_num error

Where as having the sdkconfig set as:

# CONFIG_ESP_CONSOLE_UART_DEFAULT is not set

CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y

CONFIG_ESP_CONSOLE_SECONDARY_NONE=y

CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y

CONFIG_ESP_CONSOLE_UART_NUM=-1

CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=3

Which makes sense.

But! I suppose the question then is; Is it possible to reconfigure simpleFOC to use the USB JTAG communication?
I would suspect that this also influences S3 and C3 users? (if native usb is used)

Any input is appreciated, cheers!
\n

Hi @thenicolaibulow , welcome to SimpleFOC!

Unfortunately I haven’t used the Espressif IDF component of SimpleFOC myself, though I’m aware of it.

I can confirm that both for C6 and S3 you can use the USB-JTAG in CDC mode and get Serial input/output using the normal Arduino Serial class. This also works with SimpleFOC commander, monitoring and debug output.

So there is no problem with C6/S3 JTAG serial support in principle.

I assume in combination with Espressif IDF you would also have to enable support for Arduino Serial library, and then make sure the “Serial” object is configured to use the JTAG CDC support. I’m not sure if and how this can be done though…

Hi @runger,

Thank you for the input - I should have probably mentioned that I had already verified this, with the original Arduino implementation.

Hm… according to the official documentation on the C6 CDC is allegedly supported.

However, trying to enable the CDC feature in ESP-IDF v5.3.1, I am faced with the following;

Name: ESP_CONSOLE_USB_CDC
Prompt: USB CDC
Type: bool
Value: n

Direct dependencies (=n):
     IDF_TARGET_ESP32S2(=n) || IDF_TARGET_ESP32S3(=n)  (=n)
  && !TINY_USB(undefined/n)  (=y)
  && <choice ESP_CONSOLE_UART>

So it would appear that the configuration in menuconfig/sdkconfig can only be enabled if the tinyusb stack is enabled, and if the core is a S2 or S3.

This makes me wonder if CDC just… ‘has yet to be implemented officially’ in the IDF? :thinking: Likewise, looking at the IDF examples, the only examples I found that used the CDC config, did, sure enough, not support the C6.

But… in any case, this does seem appropriate to try and bring up with the maintainers of the esp-idf port of simpleFOC.