SimpleSerial `WARNING:root:Unexpected start to command:`

I also posted this issue on Github already, but figured I might also try here. Issue follows, any help appreciated!

I have a CWLite with an STM32F4 target. Using the chipwhisperer virtual machine (version 5.5.1) I get a WARNING:root:Unexpected start to command: None when I try out a the simpleserial-base example. How would I go about debugging this?

I executed the following commands in the jupyer notebook:

import chipwhisperer as cw
scope = cw.scope()
target = cw.target(scope, cw.targets.SimpleSerial)
scope.default_setup()
cw.program_target(scope, cw.programmers.STM32FProgrammer, "../hardware/victims/firmware/simpleserial-base/simpleserial-base-CW308_STM32F4.hex")

This seems to work:

Serial baud rate = 115200
Detected known STMF32: STM32F40xxx/41xxx
Extended erase (0x44), this can take ten seconds or more
Attempting to program 5315 bytes at 0x8000000
STM32F Programming flash...
STM32F Reading flash...
Verified flash OK, 5315 bytes
Serial baud rate = 38400

Now I build the simpleserial-base example and want to send a simple message:

%%bash
cd …/hardware/victims/firmware/simpleserial-base/
make PLATFORM=“CW308_STM32F4” CRYPTO_TARGET=NONE
msg = bytearray([1,2,3,4])
target.simpleserial_write(“p”,msg)
print(target.simpleserial_read(“r”, 1000, timeout=10000))

which returns the error:

WARNING:root:Unexpected start to command: 
None

Printing the variables scope and target:

print(scope)
cwlite Device
sn         = 50203220313038543230323239313037
fw_version = 
    major = 0
    minor = 30
    debug = 0
gain = 
    mode = low
    gain = 0
    db   = 5.5
adc = 
    state          = False
    basic_mode     = low
    timeout        = 2
    offset         = 0
    presamples     = 0
    samples        = 0
    decimate       = 1
    trig_count     = 6010355
    fifo_fill_mode = normal
clock = 
    adc_src       = clkgen_x1
    adc_phase     = 0
    adc_freq      = 0
    adc_rate      = 0.0
    adc_locked    = True
    freq_ctr      = 0
    freq_ctr_src  = extclk
    clkgen_src    = system
    extclk_freq   = 10000000
    clkgen_mul    = 2
    clkgen_div    = 1
    clkgen_freq   = 192000000.0
    clkgen_locked = True
trigger = 
    triggers = tio4
    module   = basic
io = 
    tio1         = serial_tx
    tio2         = serial_rx
    tio3         = high_z
    tio4         = high_z
    pdid         = high_z
    pdic         = high_z
    nrst         = high_z
    glitch_hp    = False
    glitch_lp    = False
    extclk_src   = hs1
    hs2          = None
    target_pwr   = True
    tio_states   = (1, 1, 0, 0)
    cdc_settings = array('B', [1, 1])
glitch = 
    clk_src     = target
    width       = 10.15625
    width_fine  = 0
    offset      = 10.15625
    offset_fine = 0
    trigger_src = manual
    arm_timing  = after_scope
    ext_offset  = 0
    repeat      = 1
    output      = clock_xor
   
print(target)
Serial baud rate = 38400
SimpleSerial Settings =
	output_len             = 16
	baud                   = 38400
	simpleserial_last_read = 
	simpleserial_last_sent = 
	

I’m guessing your issue is msg = bytearray([1,2,3,4]) and target.simpleserial_write(“p”,msg). The message length for 'p' is fixed at 16 bytes, so the target thinks your message isn’t valid and ignores it.

If you want to change the message length, you’ll need to update the firmware. I’d recommend using SimpleSerialV2, as it supports variable length messages.

Alex

1 Like