diff --git a/docs/hardware/en/lichee/RV_Nano/5_peripheral.md b/docs/hardware/en/lichee/RV_Nano/5_peripheral.md index 8551ad8f47..b2416af139 100644 --- a/docs/hardware/en/lichee/RV_Nano/5_peripheral.md +++ b/docs/hardware/en/lichee/RV_Nano/5_peripheral.md @@ -13,12 +13,64 @@ keywords: riscv, licheerv,nano ### UART0 -Connect the UART port to the board at: - -A17 A16 GND +Connect the UART serial port to the GND, `A16 (TX)`, and `A17 (RX)` of the board Then use terminal software to connect to the serial port, with a baud rate of 115200. +UART0 is also brought out on SBU1/2 on the USB interface. You can use the USB TypeC adapter to bring out RX0 and TX0. + +#### Disable UART0 output log + +First, transfer the output of the user space to another tty device: + +``` +#include +#include +#include +#include + +int main(int argc, char *argv[]) { + int fd; + if (argc < 2) { + fprintf(stderr, "usage: %s /dev/ttyX\n", argv[0]); + exit(EXIT_FAILURE); + } + fd = open(argv[1], O_RDWR); + if (fd < 0) { + perror("open"); + exit(EXIT_FAILURE); + } + ioctl(fd, TIOCCONS); + close(fd); + exit(EXIT_SUCCESS); +} +``` + +``` +riscv64-unknown-linux-gcc tioccons.c -o tioccons +./tioccons /dev/tty2 # Transfer /dev/console to tty2 +``` + +Then set the kernel log level: + +``` +echo 0 > /proc/sys/kernel/printk +``` + +Test method: + +``` +echo userspace > /dev/console +echo kernel > /dev/kmsg +``` + +Another way is to add the following content to /boot/uEnv.txt to switch the console to another tty: + +``` +consoledev=/dev/ttyX +``` + + ### USB CDC ACM Serial Port When the board's USB Type-C port is connected to a computer, it will provide a USB CDC ACM serial port device (provided by Linux gadget).