串口调试 如果正在进行 U-Boot 或内核开发,USB串口适配器(USB 转串口TTL 适配器的 简称)对于检查系统启动日志非常有用,特别是在没有图形桌面显示的情况下。 配置串口调试 由于用于串口调试的UART2与蓝牙所使用的串口复用,所以官方发布的固件无法 使用串口调试。如果使用串口调试,蓝牙就无法正常使用,需要使用到串口调试 请进行如下修改: Linux配置串口调试 配置串口调试前,首先需要 《编译 Linux 固件》 ,然后请进行如下修改: 打开配置文件"kernel/arch/arm64/boot/dts/rockchip/rk3328-roc-pc.dts"。 串口调试的相关配置节点: fiq-debugger { status = "disabled"; }; ... &uart2 { dma-names = "tx", "rx"; status = "okay"; }; 修改为: fiq-debugger { status = "okay"; }; ... &uart2 { dma-names = "tx", "rx"; status = "disabled"; }; 编译内核,然后下载固件。 Android配置串口调试 Android7.1修改方式 配置串口调试前,首先需要 《编译 Android 固件》 ,然后请进行如下修改: 打开配置文件"kernel/arch/arm64/boot/dts/rk3328-roc-pc-port.dtsi"。 串口调试的相关配置节点: fiq-debugger { status = "disabled"; }; ... &uart_dbg { status = "okay"; dma-names = "tx","rx"; }; 修改为: fiq-debugger { status = "okay"; }; ... &uart_dbg { status = "disabled"; dma-names = "tx","rx"; }; 编译内核,然后下载固件。 Android10.0修改方式 uboot修改: diff --git a/u-boot/configs/rk3328_defconfig b/u-boot/configs/rk3328_defconfig index 9e9b7544c1..ae66c2b36d 100644 --- a/u-boot/configs/rk3328_defconfig +++ b/u-boot/configs/rk3328_defconfig @@ -19,7 +19,6 @@ CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_LOAD_FIT=y CONFIG_BOOTDELAY=0 -CONFIG_DISABLE_CONSOLE=y CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set CONFIG_ANDROID_BOOTLOADER=y cp rkbin/bin/rk33/rk3328_ddr_333MHz_v1.16_uart2_debug.bin rkbin/bin/rk33/rk3328_ddr_333MHz_v1.16.bin cd u-boot ./make.sh rk3328 kernel修改: diff --git a/kernel/arch/arm64/boot/dts/rockchip/roc-rk3328-pc.dtsi b/kernel/arch/arm64/boot/dts/rockchip/roc-rk3328-pc.dtsi index af29607..d5b9a86 100644 --- a/kernel/arch/arm64/boot/dts/rockchip/roc-rk3328-pc.dtsi +++ b/kernel/arch/arm64/boot/dts/rockchip/roc-rk3328-pc.dtsi @@ -176,7 +176,7 @@ #define UART2_BLUETOOTH 0 #define UART2_DEBUG 1 -#define UART2_FUNCTION UART2_BLUETOOTH +#define UART2_FUNCTION UART2_DEBUG cd kernel make ARCH=arm64 BOOT_IMG=../rockdev/Image-roc_rk3328_pc_32/boot.img roc-rk3328-pc.img -j24 最后烧录uboot目录下的 rk3328_loader_v1.16.250.bin , uboot.img , trust.img 与 kernel目录下的 boot.img 即可 另外当配置调试串口输出时,会有大量关于蓝牙的打印 [ 178.375793] init: Service 'vendor.bluetooth-1-0' (pid 5490) received signal 11 [ 178.375865] init: Sending signal 9 to service 'vendor.bluetooth-1-0' (pid 5490) process group... [ 178.376177] libprocessgroup: Successfully killed process cgroup uid 1002 pid 5490 in 0ms [ 178.376448] init: updatable process 'vendor.bluetooth-1-0' exited 4 times in 4 minutes [ 178.376699] init: Init cannot set 'ro.init.updatable_crashing_process_name' to 'vendor.bluetooth-1-0': Read-only property was already set [ 178.376839] init: Init cannot set 'ro.init.updatable_crashing' to '1': Read-only property was already set [ 178.377832] binder: release 5490:5490 transaction 55248 in, still active [ 178.377853] binder: send failed reply for transaction 55248 to 5573:5612 [ 178.950182] audit: audit_lost=511 audit_rate_limit=5 audit_backlog_limit=64 [ 178.950212] audit: rate limit exceeded [ 180.540002] binder: undelivered death notification, 00000000d4b533c0 [ 181.805281] audit: audit_lost=515 audit_rate_limit=5 audit_backlog_limit=64 [ 181.805305] audit: rate limit exceeded 如果觉得这些打印太繁琐可以直接关闭蓝牙功能,然后编译android上层 上层修 改: --- a/device/rockchip/common/BoardConfig.mk +++ b/device/rockchip/common/BoardConfig.mk @@ -402,8 +402,8 @@ BOARD_TEMPERATURE_SENSOR_SUPPORT ?= false BOARD_USB_HOST_SUPPORT ?= false BOARD_USB_ACCESSORY_SUPPORT ?= true BOARD_CAMERA_SUPPORT ?= false -BOARD_BLUETOOTH_SUPPORT ?= true -BOARD_BLUETOOTH_LE_SUPPORT ?= true +BOARD_BLUETOOTH_SUPPORT ?= false +BOARD_BLUETOOTH_LE_SUPPORT ?= false ./FFTools/make.sh -a -j8 最后烧写 super.img 即可 准备 USB 串口适配器 选择 USB 串口适配器 ROC-RK3328-PC 的 UART 调试口默认使用 1,500,000 波特率和 TTL 电平。 一些串口适配器不能支持如此高的波特率。因此在购买之前,请确保它符合要求 并有可用的驱动。参考 在线商城 上带 "CP2104" 芯片的 USB 转串口适配器 。 连接适配器和调试口 用三根线将 TX/RX/GND 引脚分别连接在一起: 如果在使用某些适配器时串口控制台没有输出,可以尝试将适配器的 TX 引脚连 接到开发板的 RX 引脚,适配器的 RX 引脚连接到开发板的 TX 引脚,即交换一 下 TX、RX 引脚。 串口参数配置 ROC-RK3328-PC 使用如下配置: 波特率:1,500,000 数据位:8 停止位:1 奇偶检查:无 流控:无 接下来,根据操作系统的不同,为你介绍详细的操作说明。 Windows 下的串口调试 安装驱动 安装卖家推荐的 USB 串口适配器驱动。如果没有,可以检查芯片组并尝试以下 驱动 CH340 PL2303 CP210X 提示:如果 PL2303 在 Win8 下无法工作,则可以尝试将驱动程序降级到版 本 3.3.5.122 或之前。 安装驱动后,将适配器连接到主机的 USB 端口。操作系统将提示检测到新硬件 。完成后,可以在设备管理器中找到新的COM端口: 安装工具 Windows 中有很多串口终端工具,例如 putty 和 SecureCRT。以下介绍Putty这 款流行的开源软件的使用。 Putty 下载地址 下载 "putty.zip",解压并运行 "PUTTY.exe": 选择 "Connection type" 为 "Serial"。 将 "Serial line" 修改为在设备管理器中找到的 COM 端口。 设置 "Speed" 为 1500000 。 点击 "Open" 按钮。 Linux 下的串口调试 如果 USB 串口适配器的芯片组受 Linux 内核支持,驱动程序将自动加载。 连接串口适配器,并通过如下命令检查相应的串口设备文件: $ ls -l /dev/ttyUSB* crw-rw---- 1 root uucp 188, 0 Apr 10 16:44 /dev/ttyUSB0 将你的 Linux 用户添加到 "uucp" 组中,以便获得访问此设备的权限(否则每 次需要在命令前加"sudo"来运行相应命令): sudo gpasswd -a $(whoami) uucp 用户组的更改将在注销并重新登录 Linux 后生效,或使用 "newgrp" 命令进入 带有新组的 shell: newgrp uucp 然后根据偏好,使用自己喜欢的串口控制台工具。以下介绍 picocom 和 minicom 。 picocom "picocom" 轻便小巧, 容易使用。 安装 "picocom" 命令: sudo apt-get install picocom 启动 "picocom": $ picocom -b 1500000 /dev/ttyUSB0 picocom v3.1 port is : /dev/ttyUSB0 flowcontrol : none baudrate is : 1500000 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no hangup is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs, logfile is : none initstring : none exit_after is : not set exit is : no Type [C-q] [C-h] to see available commands Terminal ready 上面的信息显示 "Ctrl-a" 是转义键。 按下 "Ctrl-a Ctrl-q" 将退出 "picocom" 并返回到 shell 。 minicom 安装 "minicom" 命令: sudo apt-get install minicom 启动 "minicom": $ minicom Welcome to minicom 2.7 OPTIONS: I18n Compiled on Jan 1 2014, 17:13:19. Port /dev/ttyUSB0, 15:57:00 Press CTRL-A Z for help on special keys 根据以上提示: 按 "Ctrl-a",然后按 "z"(而不是 "Ctrl-z" )调出帮助菜单 : +-------------------------------------------------------------------+ | Minicom Command Summary | | | | Commands can be called by CTRL-A | | | | 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. | +-------------------------------------------------------------------+ 按提示按 "O" 进入设置屏幕: +-----[configuration]------+ | Filenames and paths | | File transfer protocols | | Serial port setup | | Modem and dialing | | Screen and keyboard | | Save setup as dfl | | Save setup as.. | | Exit | +--------------------------+ 选择 "Serial port setup",然后按选项前面的大写字母并设置为如下所示的值 : +-----------------------------------------------------------------------+ | A - Serial Device : /dev/ttyUSB0 | | B - Lockfile Location : /var/lock | | C - Callin Program : | | D - Callout Program : | | E - Bps/Par/Bits : 1500000 8N1 | | F - Hardware Flow Control : No | | G - Software Flow Control : No | | | | Change which setting? | +-----------------------------------------------------------------------+ 注意 : Hardware Flow Control 和 Software Flow Control 应该设置为 No 。 结束设置之后, 按 ESC 键回到之前的菜单, 选择 Save setup as dfl 保存覆 盖掉默认配置。