linux编译用于启用uart2

时间:2016-09-29 21:12:06

标签: linux lua beagleboneblack uart openwrt

我正在使用openwrt,最初,在/ dev下,只有ttyO0用于控制台的串口。我用它来连接电路板(siamilar到beaglebone黑色)。

现在,我将gps连接到uart2。但我认为openwrt默认情况下不会启用它。

我检查了设备树,am335x-bone.dts(我正在使用骨头作为我的主板,因为我的主板不是BBB)。我没有太多的设置。大部分配置来自am33xx.dtst和am335x-bone-common.dtsi。

我检查了am33xx dtsi,在ocp {}

下有一些这样的代码
    uart0: serial@44e09000 {
        compatible = "ti,omap3-uart";
        ti,hwmods = "uart1";
        clock-frequency = <48000000>;
        reg = <0x44e09000 0x2000>;
        interrupts = <72>;
        status = "disabled";
    };

    uart1: serial@48022000 {
        compatible = "ti,omap3-uart";
        ti,hwmods = "uart2";
        clock-frequency = <48000000>;
        reg = <0x48022000 0x2000>;
        interrupts = <73>;
        status = "disabled";
    };

    uart2: serial@48024000 {
        compatible = "ti,omap3-uart";
        ti,hwmods = "uart3";
        clock-frequency = <48000000>;
        reg = <0x48024000 0x2000>;
        interrupts = <74>;
        status = "disabled";
    };

    uart3: serial@481a6000 {
        compatible = "ti,omap3-uart";
        ti,hwmods = "uart4";
        clock-frequency = <48000000>;
        reg = <0x481a6000 0x2000>;
        interrupts = <44>;
        status = "disabled";
    };

    uart4: serial@481a8000 {
        compatible = "ti,omap3-uart";
        ti,hwmods = "uart5";
        clock-frequency = <48000000>;
        reg = <0x481a8000 0x2000>;
        interrupts = <45>;
        status = "disabled";
    };

    uart5: serial@481aa000 {
        compatible = "ti,omap3-uart";
        ti,hwmods = "uart6";
        clock-frequency = <48000000>;
        reg = <0x481aa000 0x2000>;
        interrupts = <46>;
        status = "disabled";
    };

我确实将uart2从禁用状态更改为&#34;好的&#34;并且还更改了am335x-bone-common.dtsi中的代码&amp; am33xx_pinmux {}

uart0_pins: pinmux_uart0_pins {
    pinctrl-single,pins = <
        0x170 (PIN_INPUT_PULLUP | MUX_MODE0)    /* uart0_rxd.uart0_rxd */
        0x174 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* uart0_txd.uart0_txd */
    >;
};

uart2_pins: pinmux_uart2_pins {
    pinctrl-single,pins = <
        0x150 (PIN_INPUT_PULLUP | MUX_MODE0)    /* uart0_rxd.uart0_rxd */
        0x154 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* uart0_txd.uart0_txd */
    >;
};

uart0部分是默认的,我在它下面的uart2部分添加代码。

在am335x-bone.dts中,我添加此代码以启用uart2

  &uart2 {
    pinctrl-names = "default";
    pinctrl-0 = <&uart0_pins>;

    status = "okay";
};

编译之后,我可以看到/ dev / ttyO2出现在openwrt中。但是当我使用脚本写入此端口然后从中读取时。什么都没有出现。

这是我使用lua的脚本,因为它是内置的

local clock = os.clock

function wait(n)  -- seconds
  local t0 = clock()
  while clock() - t0 <= n do end
end


while true do
  print("Writing")
  wuar0 = io.open("/dev/ttyO0","w")
  wuar1 = io.open("/dev/ttyO1","w")
  wuar2 = io.open("/dev/ttyO2","w")
  wuar0:write("This is uart0 \n")
  wuar1:write("This is uart1 \n")
  wuar2:write("This is uart2 \n")
  wuar0:flush()
  wuar1:flush()
  wuar2:flush()
  wuar0 = io.close()
  wuar1 = io.close()
  wuar2 = io.close()
  wait(2)

  print("Reading")
  ruar0 = io.open("/dev/ttyO0","r")
  ruar1 = io.open("/dev/ttyO1","r")
  ruar2 = io.open("/dev/ttyO2","r")
  print(ruar0:read())
  print(ruar1:read())
  print(ruar2:read())
  ruar0:flush()
  ruar1:flush()
  ruar2:flush()
  ruar0 = io.close()
  ruar1 = io.close()
  ruar2 = io.close()
  wait(2)
end

我做得对吗?如果没有,我需要做什么来启用uart2。

我做了很多研究,但其中大部分都没有更新。在我的情况下不起作用。

或者是否有人可以告诉我启用此功能的步骤是什么,或者我如何检查它是否启用。

任何信息都会有所帮助。感谢。

0 个答案:

没有答案