UART Configuration

Configure Kernel Menu for UART Controller

  1. Under the root directory of frrlight-u-sdk, run the following command to enter the kernel menu configuration GUI.
    make linux-menuconfig
  2. Enter the Device Drivers menu.

  3. Enter the Character devices > Serial drivers menu.

  4. Select the Support for Synopsys Designware 8250 quirks option.

  5. Save your change and exit the kernel configuration dialog.

Board-level Configuration

See Board-level Configuration.

Set a UART Port as Print Console

To set a specific UART port as the print console:
  1. Find the target UART port in the board.dts file and make sure the port has been enabled. For example:
    &uart3 {
            pinctrl-names = "default"; 
            pinctrl-0 = <&uart3_pins>; 
            status = "okay";
    };
  2. Modify the kernel command line parameter passed by the bootloader to enable the target UART port as the print console. For example, the following command sets UART3 as the print console.
    arlyprintk console=ttyS3,115200 debug rootwait earlycon=sbi
    Note: 
    ttyS0 <=====> uart0 
    ttySl <=====> uartl 
    ttyS2 <=====> uart2 
    ttyS3 <=====> uart3

Configure Serial Port

You can enable or disable a serial port and use the standard Linux interface to configure the serial port attributes.

To turn a UART serial port on or off in Linux:
  1. Include 4 standard header files at the top of your code.
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <unistd.h>
  2. Use the standard Linux functions to control the port:
    • open(): turns on the serial port
    • close(): Turns off the serial port
    For example:
    int open(const char *pathname, int flags);
    int close (int fd)
To configure serial port attributes:
  1. Make sure you have included the following header file before setting attributes.
    #include <termios.h>
  2. Use the following standard Linux interfaces to configure the attributes of a serial port.

    Commonly, a serial port include the following attributes:
    • Baud rate
    • Data bit
    • Stop bit
    • Verification bit
    • Traffic control
    Table 1. Linux Interfaces to Set Attributes
    Interface Description
    tcgetattr Gets parameters from the terminal.
    tcsetattr Sets parameters to the terminal.
    cfgetispeed Gets input baud rate.
    cfgetospeed Gets output baud rate.
    cfsetispeed Sets input baud rate.
    cfsetospeed Sets output baud rate.
    cfsetspeed Sets input and output speed.
    tcflush Discards data written to the object .