This chapter introduces the working mode, flow control, use as a console, ttl to usb, ttl to rs232, ttl to rs485 of the YY3588 development board serial port (taking serial port 1 as an example)
Experimental environment: a windows PC computer; a YY3588 development board debian12 system.
The serial port has two working modes, namely interrupt mode and DMA mode.
The kernel configures the serial port to interrupt mode by default. The transmission rate is fast in interrupt mode, but it is easy to lose packets or errors when transmitting large amounts of data. Therefore, please do not use interrupt mode when the amount of data is large. You can consider the following DMA mode.
There is a similar print log
failed to request DMA, use interrupt mode
DMA mode is mainly used when transmitting large amounts of data. The kernel will provide a buffer space for the serial port to receive data to minimize the packet loss rate of serial port transmission. The default size of the buffer space is 8K. If a transmission exceeds the buffer size, the packet will be lost. Therefore, if DMA mode is used, the sender needs to send in packets. UART uses DMA transmission mode to significantly reduce the CPU load only when the amount of data is large. Generally speaking, compared with the interrupt transmission mode, UART does not necessarily increase the data transmission speed when using DMA transmission mode.
DTS configuration (taking serial port 1 as an example)
&uart1 {
+++ status = "okay";
+++ dma-names = "tx", "rx";
};
When using hardware automatic flow control for UART, you need to ensure that the UART driver enables the hardware automatic flow control function and that the iomux of the cts and rts flow control pins have been switched in dts. It is recommended to use hardware automatic flow control in scenarios with high baud rates (1.5M baud rate and above) and large amounts of data, that is, to use four-wire UART.
Hardware flow control requires hardware support. Please confirm whether your device supports it.
&uart1 {
+++ pinctrl-0 = <&uart1m0_xfer &uart1m1_ctsn &uart1m1_rtsn>;
};
The application layer also needs to enable flow control settings. Here is how to enable flow control in stty.
# stty -F /dev/ttyS1 crtscts
# stty -F /dev/ttyS1 -a | grep crtscts
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal crtscts
The default uart2 of the YY3588 development board is configured as the ttyFIQ0 device, which is what we call the debug port. Generally, no modification is required.
If the customer needs to configure the ordinary serial port as a console serial port, the corresponding ordinary serial port uart node needs to be disabled, and then the fiq_debugger node needs to be enabled.
Device Drivers --->
[*] Staging drivers --->
Android --->
chosen: chosen {
bootargs = "earlycon=uart8250,mmio32,0xfeb40000 console=ttyFIQ0";
};
fiq-debugger {
compatible = "rockchip,fiq-debugger";
rockchip,serial-id = <1>;
rockchip,wake-irq = <0>;
/* If enable uart uses irq instead of fiq */
rockchip,irq-mode-enable = <1>;
rockchip,baudrate = <1500000>; /* Only 115200 and 1500000 */
interrupts = <GIC_SPI 252 IRQ_TYPE_LEVEL_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&uart1m0_xfer>;
status = "okay";
};
&uart2 {
status = "disabled";
};
Description:
Here we demonstrate the free version of the
mobaxterm
software, and the animated picture is as follows
Port | Board end | TTL to RS232 module end |
---|---|---|
Corresponding | TX | TX |
Corresponding | RX | RX |
Corresponding | VCC | VCC |
Corresponding | GND | GND |

Here is a demonstration with the free version of
mobaxterm
software, the animated picture is as follows
// TO DO