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?