Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:common:applications:gpio:uart

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
products:sbc:common:applications:gpio:uart [2023/08/13 21:22]
jacobe
products:sbc:common:applications:gpio:uart [2023/11/07 05:09]
nick [Enable UART]
Line 7: Line 7:
 ===== UART Information ===== ===== UART Information =====
  
-|            UART       ^ PIN      ^ GPIO Name  ^ GPIO Number   DT Overlays Node  ^  Device Node  ^ +|            UART       ^ PIN      ^ GPIO Name  ^  DT Overlays Node  ^  Device Node  ^ 
-^  VIM1/   UART_AO_B  |  15(RX)  |  GPIOAO_5  |  506         |  uart4              /dev/ttyS4   | +^  VIM1/   UART_AO_B  |  15(RX)  |  GPIOAO_5  |  uart4              /dev/ttyS4   | 
-| :::       | :::          16(TX)  |  GPIOAO_4  |  505         | :::                | :::           | +| :::       | :::          16(TX)  |  GPIOAO_4  | :::                | :::           | 
-^  VIM3/3L  |  UART_C      15(RX)  |  GPIOH_6   |  433         |  uart3              /dev/ttyS3   | +^  VIM3/3L  |  UART_C      15(RX)  |  GPIOH_6    uart3              /dev/ttyS3   | 
-| :::       | :::          16(TX)  |  GPIOH_7   |  434         | :::                | :::           | +| :::       | :::          16(TX)  |  GPIOH_7   | :::                | :::           | 
-^  VIM4      UART_E      15(RX)  |  GPIOY_7   |  491         |  uart_e            |  /dev/ttyS4   | +^  VIM4      UART_E      15(RX)  |  GPIOY_7    uart_e            |  /dev/ttyS4   | 
-| :::       | :::          16(TX)  |  GPIOY_6   |  490         | :::                | :::           | +| :::       | :::          16(TX)  |  GPIOY_6   | :::                | :::           | 
-^  VIM1S    |  UART_C      15(RX)  |  GPIOD_3   |  457         |  uart_c            |  /dev/ttyS2   | +^  VIM1S    |  UART_C      15(RX)  |  GPIOD_3    uart_c            |  /dev/ttyS2   | 
-| :::       | :::          16(TX)  |  GPIOD_2   |  456         | :::                | :::           |+| :::       | :::          16(TX)  |  GPIOD_2   | :::                | :::           |
 ===== Enable UART ===== ===== Enable UART =====
  
Line 35: Line 35:
 $ ls /dev/ttyS3 $ ls /dev/ttyS3
 /dev/ttyS3 /dev/ttyS3
 +```
 +
 +<tabbox VIM3 with 5.15 kernel>
 +
 +Edit ''/boot/dtb/amlogic/kvim3.dtb.overlay.env'' to add uart node to ''fdt_overlays'' node if it doesn't exist.
 +
 +
 +e.g. Enable ''UART_E'', you need to add ''uart_e'' to node ''fdt_overlays'' if it doesn't exist.
 +
 +```shell
 +fdt_overlays=uart_e
 +
 +```
 +
 +After reboot, you will see the UART device node.
 +
 +```shell
 +$ ls /dev/ttyS4
 +/dev/ttyS4
 +```
 +
 +<tabbox VIM3L with 5.15 kernel>
 +
 +Edit ''/boot/dtb/amlogic/kvim3l.dtb.overlay.env'' to add uart node to ''fdt_overlays'' node if it doesn't exist.
 +
 +
 +e.g. Enable ''UART_E'', you need to add ''uart_e'' to node ''fdt_overlays'' if it doesn't exist.
 +
 +```shell
 +fdt_overlays=uart_e
 +
 +```
 +
 +After reboot, you will see the UART device node.
 +
 +```shell
 +$ ls /dev/ttyS4
 +/dev/ttyS4
 ``` ```
  
Line 87: Line 125:
  
 // set correct serial path // set correct serial path
-#define SERIAL_PORT "/dev/ttyS4"+#define SERIAL_PORT "/dev/ttyS2"
  
 int main() { int main() {
Line 108: Line 146:
     }     }
          
-    cfsetospeed(&tty, B1500000); // set correct baud rate +    cfsetospeed(&tty, B921600); // set correct baud rate 
-    cfsetispeed(&tty, B1500000);+    cfsetispeed(&tty, B921600);
          
     tty.c_cflag |= (CLOCAL | CREAD);     tty.c_cflag |= (CLOCAL | CREAD);
Line 150: Line 188:
 Compile test code: Compile test code:
  
-''$ gcc uart.c -o uart''+``` 
 +$ gcc uart.c -o uart 
 +```
  
 ===== Test demonstration ===== ===== Test demonstration =====
Line 160: Line 200:
 ``` ```
  
-Open ttyUSBX on PC and input hello+After connecting PIN15, PIN16 and GND to PC, open ttyUSBX and input hello
  
 ``` ```
Last modified: 2023/11/07 05:09 by nick