Trouble with reading serial on CW308_FE310

Hello!

I’m working on a project with the FE310 UFO, and I’m having trouble using the serial connection through SimpleSerial and the Python library (from a Jupyter notebook) on this target. I have tried to use the simpleserial-base firmware as provided in the tutorials, which provides me with the following results:

>>> target.get_simpleserial_commands()
(ChipWhisperer Target WARNING|File SimpleSerial.py:414) Unexpected start to command: 
{
	"name": "TypeError",
	"message": "'NoneType' object is not subscriptable",
	"stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[12], line 1
----> 1 target.get_simpleserial_commands()

File ~/cw/chipwhisperer/software/chipwhisperer/capture/targets/SimpleSerial.py:232, in SimpleSerial.get_simpleserial_commands(self, timeout, ack)
    229 num_commands = self.simpleserial_read('r', 1, timeout=timeout, ack=ack)
    230 self.simpleserial_write('w', bytearray())
--> 232 cmd_packet = self.simpleserial_read('r', num_commands[0]*3, timeout=timeout, ack=ack)
    233 command_list = []
    234 for i in range(num_commands[0]):

TypeError: 'NoneType' object is not subscriptable"
}

Reading any other command results in the same “Unexpected start to command” error, and the target does not ack either.

I have also tried to run my own firmware that just prints “Hello World!” to the serial connection and turns a GPIO pin high and low every second. Using a logic analyzer, I have confirmed that the FE310 is actually flashed, as this seems to work as intended. Even here, though, I am not able to read the serial monitor using “target.read()” as it just returns an empty string.

Does anyone have any idea what could be going on here, or am I missing something very obvious?

Also, a partly unrelated question, but am I correct in understanding that “/dev/ttyACM0” (or whatever else I receive from “scope.get_serial_ports()”) should pass through the serial connection of the target device?

In order for target.get_simpleserial_commands() to work, the target firmware needs to respond to the “y” command. Most of our example firmware does not implement this, except for this one.

You can find simpleserial documentation here.

It could be that scope.io isn’t set up properly. For historical reasons and to not break anything, the io1/io2 pins come up as tx/rx, which is the inverse of what our current firmware uses.
When you run scope.default_setup(), io1/io2 are then set to rx/tx. So just make sure you have the proper pin assignment. Also check that target.baud is correct.

I’m not exactly sure what you mean by pass through but yes, you can e.g. run screen /dev/ttyACM0 <baud rate>.

Ah, thank you, I did not catch that and mistakenly assumed it was a built-in command.

I have tried again with running “scope.default_setup()” and that does report that RX and TX are modified, but I still cannot seem to get any commands to return anything other than “Unexpected start to command”. I have confirmed that the baud rate is correct as well.

The thing is, I (and others) have had luck with sending commands and recording traces in the past, but now when I repeat the exact same steps from the “chipwhisperer-jupyter/1 - Connecting to Hardware.ipynb” notebook, I can’t seem to be able to get it to work.

Some possibilities:

  • Is target.baud set to what you observe on your logic analyzer?
  • Was the firmware compiled with the same SS_VER that Python is using to communicate?
  • If you’re not on the CW develop branch, you may have run into this issue, which was fixed here.

Thank you very much for your pointers! It indeed turned out that the baud rate was not set correctly on the FE310, and now we’re able to read serial data.

1 Like