No success using CDC serial port on CW-Lite

Hello,
I’m currently trying to use the cdc serial port on my cw-lite to communicate with a custom target through pyserial.
I already tried using SimpleSerial2 for the communication. With SimpleSerial2 I couldn’t send data to the device and could only receive 199 bytes of ~600 bytes that are send on startup.
I could only find a way to change the baudrate of SimpleSerial2 (which I did) but my device also uses a different parity and I couldn’t find a way to change that.

So right now I’m trying to use cdc serial port with pyserial.

scope.io.cdc_settings = 1
port_info = scope.get_serial_ports()
port_info[0]["port"]

ser = serial.Serial()
ser.port = port_info[0]["port"]
ser.baudrate = 115200
ser.parity = serial.PARITY_EVEN
ser.stopbits = 1
ser.bytesize = 8
ser.timeout = 5

ser.open()
ser.write(b"help\n")
hello = ser.read(10)

The target should answers if it receives “help\n”, however it doesn’t.
The error is not generated by the custom target. Communication with the target via another device that also has a cdc serial port, like the CW-Lite, does work.

I connected my target with +3.3V, TX, RX and GND of the 20-Pin Connector. This is also the setup I used for simpleserial2.

Are there settings I have forgotten?

The CW-Lite uses Firmware Version {‘major’: 0, ‘minor’: 64, ‘debug’: 0} under Windows.

Update 1:
I noticed that the description for the 20-Pin Connector says thas FPGA-TARG1 and 2 are mostly TX or RX (CW1173 ChipWhisperer-Lite - NewAE Hardware Product Documentation).
The 20-Pin to Jumper Adapter Cable that came came with the CWLite has TX printed on TARG1 and RX on the TARG2 cable.
However the default_setup() sets TARG1 to RX and TARG2 to TX.
But the “real default”, if you don’t use the default_setup, is TARG1 = TX and TARG2 = RX…
Either way I wasn’t using the default_setup(), so my connection with TX and RX was correct.
I also checked for any broken cable but everything seems to be fine.

Update 2:
SimpleSerial2_CDC also doesn’t work. While reading with normal SimpleSerial2 does work until the buffer is full.
Code for both:

import chipwhisperer as cw
scope = cw.scope(scope_type=cw.scopes.OpenADC)
scope.io.cdc_settings = 1
scope.io.tio1 = "serial_tx"
scope.io.tio2 = "serial_rx"

# SimpleSerial2_CDC
target = cw.target(scope, cw.targets.SimpleSerial2_CDC)
target.baud = 115200
# device is rebooted before this to catch startup message
print(target.read(num_char=200, timeout=5000)) # returns b''
target.dis()

# SimpleSerial2
target = cw.target(scope, cw.targets.SimpleSerial2)
target.baud = 115200
# device reboot
print(target.read(num_char=200, timeout=5000)) # returns the first 199 byte of the startup message
target.dis()

So these questions remain:

  • How to successfully setup CRC?
  • Is there a kind of interrupt once the read buffer for SimpleSerial is full to get it’s content and to clear it?

Hi,

There’s a limited size serial buffer on the Lite, so if you send too much data, some ends up getting lost. There’s not really much you can do to work around this, unfortunately.

We don’t really have a great interface for setting the parity at the moment, but you can do it via target.ser.cwlite_usart.init(baud=115200, parity="even").

Regarding your CDC issues, what operating system are you using? Note that you’ll also have to make sure scope.io.cdc_settings = [1, 0, 0, 0] to change settings via the CDC interface. This interface isn’t as well tested, since we don’t really use it much ourselves, so there may be issues in that firmware version.

Unfortunately, UART can be ambiguous with RX and TX, since there’s no “master” of the bus like there is with something like SPI or USB. For the first ChipWhisperer targets, the TX and RX pins were swapped from how they are on targets now, which is why they’re swapped when the ChipWhisperer first boots up.

Unfortunately, USB transactions are always initiated by the host, so doing this isn’t really possible.

Alex

Thanks for your answer.

I’m currently using windows.

I will do that. Could you explain what different values mean (e.g [1,1,1,1])? I thought setting scope.io.cdc_settings = 1 will be enought, because the docs state:

Can set either via an integer (which sets both ports) or an array of length 4 (which sets each port)

Regarding this statement

Is there a way to downgrade the firmware? Ever post I saw that addressed firmware only flashed the latest firmware again (e.g after a reset). But I would like to try older firmware versions in order to check if CDC works on them.

Hello again,
sadly I wasn’t able to get CDC running but I can now send data via SimpleSerial1 and SimpleSerial2 thanks to target.ser.cwlite_usart.init(baud=115200, parity="even").
There should really be a better interface for setting this or at least an official documentation.

However I will keep this post open for now, because the main issue with CDC isn’t resolved yet.

These are now being tracked via Rebuild Firmware with CDC fixes · Issue #488 · newaetech/chipwhisperer · GitHub and Better interface for setting serial settings · Issue #487 · newaetech/chipwhisperer · GitHub. I can get 487 done pretty quick, 488 will require some more testing on each of the firmware targets, so that’ll be a bit longer.

That’s great to hear. Thank you for your efforts :smile: