Debugging Serial Output with Minicom - GaloisInc/betaflight GitHub Wiki

This document explains how to debug a small embedded device with no interface via its serial terminal using Minicom. This allows one to insert print statements and view the output.

First install minicom if its not already in your system with:

sudo apt install minicom

Then confirm which ports you are going to use. For the Kendryte board since all its inputs/outputs are through the USB-C port it will be the same port used to flash the board. So type the following to find that port.

tree /dev/serial

You should see output like this:

tree /dev/serial

The same port used to flash the board will be used for the monitor. In this case USB0.

Next configure minicom by typing:

sudo minicom -s

Which turns your terminal view into this:

Using the arrow keys and the enter key to confirm your selections select “Serial port setup” this will bring up a window that lets you set the port used and the baudrate. Make sure you set the port to the one your device is connected to and that the baudrate is 115200 (for the Kendryte K210 at least). Press “A” to begin editing the line for Serial Device, when done press enter.

Next configure the “Screen and keyboard” settings. I recommend turning on “Line Wrap” and “Add carriage return” to get clearer text output. Pushing “T” here for example toggles it on/off. Then push ENTER/ESC to exit.

Save your settings by selecting the “Save setup as dfl” so you don’t have to reconfigure it every time you run minicom.

“Exit” will exit the settings and allow you to see minicoms monitor. Exit from minicom will exit the whole program.

Do note that because there is only 1 serial port if you are running minicom WHILE trying to flash the board with kflash, then kflash will fail. So exit minicom before flashing the board.

If all went well you will see whatever output is sent out serially, for example the output from the printf() function like so.

Some helpful minicom commands to know: First push CTRL-A simultaneously followed by key

X = To exit minicom
O = To bring up the settings menu from within minicom (restart mincom to take effect)
minicom = From the linux terminal to immediately enter the serial view

Here is some example code to show the corresponding output from the example output above

Additional help and info can be found here:

https://maixpy.sipeed.com/en/get_started/serial_tools.html