6

I was compiling the OpenWrt (A wireless router based on Linux), i added a board to the OpenWrt source, my board has two uart ports, i can declare and enable the two uart ports, the two uart ports are named 'uartfull' and 'uartlite'.

The 'uartlite' is registered to '/dev/ttyS1', and the 'uartfull' is registered to '/dev/ttyS0'. But i want uartlite to '/dev/ttyS0' and 'uartfull' to '/dev/ttyS1'.

    uartlite@c00 {
        compatible = "ralink,rt5350-uart", "ralink,rt2880-uart", "ns16550a";
        reg = <0xc00 0x100>;

        resets = <&rstctrl 19>;
        reset-names = "uartl";

        interrupt-parent = <&intc>;
        interrupts = <12>;

        reg-shift = <2>;
    };

    uart@500 {
        compatible = "ralink,rt5350-uart", "ralink,rt2880-uart", "ns16550a";
        reg = <0x500 0x100>;

        resets = <&rstctrl 12>;
        reset-names = "uart";

        interrupt-parent = <&intc>;
        interrupts = <5>;

        reg-shift = <2>;

        status = "okay";
    };

This is the 'uartfull'(name uart) and the 'uartlite' node in my dts file. I was guessing what determines the device name(/dev/ttyS0 /dev/ttyS1 and so on), can i force a device name for this two uart nodes.

VividD
  • 10,456
  • 6
  • 64
  • 111
Jiapeng
  • 126
  • 1
  • 5

2 Answers2

4

Use the aliases field in the top of the devicetree file:

aliases {
serial0 = &uart0; // becomes /dev/ttyS0
serial1 = &uart2; // becomes /dev/ttyS1
serial2 = &uart5; // becomes /dev/ttyS2 (not /dev/ttyS3)
serial3 = &uart4; // becomes /dev/ttyS3 (not /dev/ttyS2)

};

dashxdr
  • 61
  • 3
0

Hrm, I'm going to call this a bug. The /aliases/serial0 assignment should work as dashxdr describes in her/his answer but it is not. I am also using an mt7620a-based device with OpenWRT 18.06.1 (Linux 4.14.64).

Daniel Santos
  • 3,098
  • 26
  • 25