Android 串口调试

A33 RK3288

Posted by LXG on June 1, 2021

Firefly-RK3288串口调试

串口调试利器–minicom-简书

串口调试

如果正在进行 U-Boot 或内核开发,USB 串口适配器( USB 转串口 TTL 适配器的简称)对于检查系统启动日志非常有用,特别是在没有图形桌面显示的情况下。

适配器

网店上有许多 USB 转串口的适配器,按芯片来分,有以下几种:

  • CP2104
  • PL2303
  • CH340

一般来说,采用 CH340 芯片的适配器,性能比较稳定,价格上贵一些。

硬件连接

串口转 USB 适配器,有四个引脚:

  • 3.3V 电源(NC),不需要连接
  • GND,串口的地线,接开发板串口的 GND 针
  • TXD,串口的输出线,接开发板串口的 TX 针
  • RXD,串口的输入线,接开发板串口的 RX 针

注意: 如使用其它串口适配器遇到 TX 和 RX 不能输入和输出的问题,可以尝试对调 TX 和 RX 的连接。

Firefly-RK3288 串口连接图:

debug_connection

串口参数设置

Firefly-RK3288 使用以下串口参数:

  • 波特率:115200
  • 数据位:8
  • 停止位:1
  • 奇偶校验:无
  • 流控:无

Ubuntu minicom

sudo apt-get install minicom

lsusb


$ lsusb

Bus 003 Device 013: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light

ttyUSB

查看USB转串口权限


$ ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 6月   1 16:26 /dev/ttyUSB0

sudo minicom -s

选择Serial port setup 设置串口名称/dev/ttyUSB0 和 波特率 115200, 然后回车退出


            +-----[configuration]------+
            | Filenames and paths      |
            | File transfer protocols  |
            | Serial port setup        |
            | Modem and dialing        |
            | Screen and keyboard      |
            | Save setup as dfl        |
            | Save setup as..          |
            | Exit                     |
            | Exit from Minicom        |
            +--------------------------+


Serial port setup


    +-----------------------------------------------------------------------+
    | A -    Serial Device      : /dev/ttyUSB0                                 |
    | B - Lockfile Location     : /var/lock                                 |
    | C -   Callin Program      :                                           |
    | D -  Callout Program      :                                           |
    | E -    Bps/Par/Bits       : 115200 8N1                                |
    | F - Hardware Flow Control : Yes                                       |
    | G - Software Flow Control : No                                        |
    |                                                                       |
    |    Change which setting?                                              |
    +-----------------------------------------------------------------------+


串口日志路径配置


Welcome to minicom 2.7

OPTIONS: I18n
Compiled on Nov 15 2018, 20:18:47.
Port /dev/ttyUSB0, 16:41:53
                                                                             
Press CTRL-A Z for help on special keys



Ctrl + A –> L


                               +-----------------------------------------+            
                               |Capture to which file?                   |            
                               |> /home/lxg/code/code/log.txt            |            
                               +-----------------------------------------+ 

minicom help

Ctrl + A –> Z


                      +-------------------------------------------------------------------+
                      |                      Minicom Command Summary                      |
                      |                                                                   |
                      |              Commands can be called by CTRL-A <key>               |
                      |                                                                   |
                      |               Main Functions                  Other Functions     |
                      |                                                                   |
                      | Dialing directory..D  run script (Go)....G | Clear Screen.......C |
                      | Send files.........S  Receive files......R | cOnfigure Minicom..O |
                      | comm Parameters....P  Add linefeed.......A | Suspend minicom....J |
                      | Capture on/off.....L  Hangup.............H | eXit and reset.....X |
                      | send break.........F  initialize Modem...M | Quit with no reset.Q |
                      | Terminal settings..T  run Kermit.........K | Cursor key mode....I |
                      | lineWrap on/off....W  local Echo on/off..E | Help screen........Z |
                      | Paste file.........Y  Timestamp toggle...N | scroll Back........B |
                      | Add Carriage Ret...U                                              |
                      |                                                                   |
                      |             Select function or press Enter for none.              |
                      +-------------------------------------------------------------------+


MobaXterm

mobaxterm-download

  1. 选择 session 为 Serial。
  2. 将 Serial port 修改为在设备管理器中找到的 COM 端口。
  3. 设置 Speed (bsp) 为 115200。
  4. 点击 OK 按钮。

注意笔记本电脑一定要接地线

debug_set_MobaXterm1

串口日志打印级别

echo 8 > /proc/sys/kernel/printk

system/core/include/curtils/klog.h


#define KLOG_DEFAULT_LEVEL  7  /* messages <= this level are logged */

内核日志

adb shell dmesg