Skip to content

[QUESTION] How to debug and enable a new CDC device? #6

Open
@shreeve

Description

@shreeve

Summary

I have a CDC device that uses the very common FTDI-232 serial-to-USB chip. Part of the device descriptor shows:

*** Device descriptor ***

  bLength         18
  bDescriptorType 1
  bcdUSB          2.00
  bDeviceClass    0x00  <== this is a 0x00, ugh
  bDeviceSubClass 0x00  <== this is a 0x00, ugh
  bDeviceProtocol 0x00
  bMaxPacketSize0 8
  idVendor        0x0403  <== this is "FTDI" (the vendor)
  idProduct       0xcd18  <== this is "Abaxis Piccolo xpress" (the product)

Notice that the Class and SubClass are listed here both as 0x00, instead of what they should be for a normal CDC device. As a result, when the USB Host tries to enumerate this device, it's not quite sure what to do, so I think it just skips it. I would like for the USB Host to consider this device to be a CDC class device (which I think it is actually), even though it doesn't claim to be here. This capability was recently added to TinyUSB. Basically, I think TinyUSB is aware of this type of device and considers it to be a CDC class.

In addition, there are some USB control commands that need to be sent to the device to set it up properly. These are sent as a USB control transfer with the following:

# these are sent as: bmRequestType, bRequest, and wValue
cmd(0x40,  0,  0)      # resets device, purges RX/TX, clears DTR/RTS, data is 8N1, leaves baud
cmd(0x40,  1, 0x0303)  # enables DTR/RTS
cmd(0x40,  3, 0x4138)  # sets 9600 baud (3MHz/312.5)

Question

First, when trying to debug this, it would be nice to be able to do a little "printf() debugging". I am using the PicoPad/USB/USBUART example (appropriately adjusted for just the Pico). I've configured it so that I can upload code and connect to the Pico through the UART, while being able to use the on-board physical microUSB port to connect to the Piccolo (CDC device). From the main code, I can use Print("I'm here...\n"); statements, but I can't use them from sdk_usb_host.c, where I'm trying to debug to try to get this working for me. So my first question is, how can I use a Print() style message from withing sdk_usb_host.c to help me debug this?

Second, is there a way to send an arbitrary USB control transfer to the device to reset it and configure it's flow control, data bits, and baud as shown above? I think each of those cmd() calls (that code is actually in Ruby) just generate an 8-byte USB control packet that configures the device. My second question is, how can I send these packets to configure the device?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions