ttS1 & SIM800L

Started by igrinon, December 03, 2016, 11:59:44 AM

Previous topic - Next topic

igrinon

Hello all,

I'm trying to access RT's serial port to be able to connect to SIM800L

echo "asdasdad" > /dev/ttyS1
ash: write error: Input/output error

Can anybody tell me how to enable ttS1?

THANKS IN ADVANCE @ ALL


I used a level translator between RT 3.3V and SIM 3.9V.
I'm using standard ttyS0 to talk to RT.
I can talk to SIM800 from FTDI.
Only need to enable ttyS1.

JohnS

#1
Does stty help / give clues?

Make sure no unwanted handshaking is enabled.

You tried as root?

BTW I get the same kind of error on my desktop Linux - because ttyS1 does not actually have any physical device (i.e. the fs entry exists but nothing handles it).  You may want to look at the fs details (ls -l) for /dev/ttyS1 and then track what driver is supposed to handle the major dev #

John

igrinon

Thanks JohnS,

Let me take a look to it...

zgyarmati

Hi,

which OpewWrt are you using? It's possible you don't have the ttyS1 enabled in your device tree, hence actually there is no ttyS1 port.If this is the case you have to recompile the device tree.
--<br />Zoltan Gyarmati

igrinon

Thanks guys,

I've in front of me and I didn't see it:

  x x                  < > kmod-regmap................................. Generic register map support            x x
  x x                  < > kmod-rotary-gpio-custom.......... Custom GPIO-based rotary encoder device            x x
  x x                  < > kmod-sdhci.............. Secure Digital Host Controller Interface support            x x
  x x                  <*> kmod-serial-8250.............................................. 8250 UARTs            x x
  x x                  < > kmod-softdog.................................... Software watchdog driver            x x
  x x                  < > kmod-zram........................................................... ZRAM            x x

From here I can't see it on kernel boot...

[    0.440000] gpio-export gpio_export: 3 gpio(s) exported
[    0.450000] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    0.470000] console [ttyS0] disabled
[    0.480000] 10000c00.uartlite: ttyS0 at MMIO 0x10000c00 (irq = 20, base_baud = 2500000) is a 16550A
[    0.490000] console [ttyS0] enabled
[    0.490000] console [ttyS0] enabled
[    0.510000] bootconsole [early0] disabled

and...

root@OpenWrt:/sys/module/8250/parameters# ls
nr_uarts        share_irqs      skip_txen_test
root@OpenWrt:/sys/module/8250/parameters# cat nr_uarts
2

but if I type on serial console...

root@OpenWrt:/dev# echo "PLEASE HELP ME JUST A LITTLE" > ttyS1
ash: write error: Input/output error

and if I do it by Wifi:

root@OpenWrt:~# echo "PLEASE HELP ME JUST A LITTLE" > ttyS1
root@OpenWrt:~# echo "PLEASE HELP ME JUST A LITTLE" > ttyS0

no errors was given.

But the problem is that on the second case (echo redirected to ttyS0/1), I can't see any flash on FTDI led.

Deeping more...

Thanks again guys

igrinon

I need something like this:

*[    0.360000] serial8250: ttyS0 at MMIO 0x10000500 (irq = 13) is a 16550A*
*[    0.370000] serial8250: ttyS1 at MMIO 0x10000c00 (irq = 20) is a 16550A*

More googling and deeping into...

vim ./build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_rt305x/linux-3.18.19/drivers/tty/serial/8250/8250_core.c

zgyarmati

Dear igrinon,

yes, it seems you need to enable the serial port in the device tree, and you will be able to see its appearance in the bootlog and it might actually work as well ;)
Check out this thread:
https://lists.openwrt.org/pipermail/openwrt-devel/2013-July/020825.html
I'll try to look into this and attach a patch when i come around...
--<br />Zoltan Gyarmati

igrinon

Big Thanks zgyarmati, but if I look at RT5350.DTSI cannot find any "uartmux" string, ops!

Now I changed the position of uartlite@c00 and uart@500 and my boot doesn't change between one serial port and the other (it was the first choice before changing the tty on the kernel parameters and it worked).

Now I've boot and kernel on the same serial!!! Walking forward...

Enabling some help!!!

       x x     
  • Image configuration  --->   x x
    ---->  x x          Base system  --->           x x
           x x          Boot Loaders  ----          x x

           x x   < > block-mount........................... Block device mounting and checking         x x
    ---->  x x   <*> busybox................................ Core utilities for embedded Linux  --->   x x
           x x   < > ca-certificates................................... System CA certificates         x x

           x x   Linux System Utilities  --->   x x
    ---->  x x   Miscellaneous Utilities  --->  x x
           x x   Networking Utilities  ---> 

           x x  [ ] rfkill      x x
    ---->  x x 
  • setserial   x x
           x x  [ ] taskset     x x                         

    root@OpenWrt:/# setserial -a /dev/ttyS0
    /dev/ttyS0, Line 0, UART: 16550A, Port: 0x0000, IRQ: 20
            Baud_base: 2500000, close_delay: 50, divisor: 0
            closing_wait: 3000
            Flags: spd_normal

    root@OpenWrt:/# setserial -a /dev/ttyS1
    /dev/ttyS1, Line 1, UART: 16550A, Port: 0x0000, IRQ: 13
            Baud_base: 2500000, close_delay: 50, divisor: 0
            closing_wait: 3000
            Flags: spd_normal

    Ole!!! It seems it is working.

    More progress later!

    zgyarmati, talk later to see where I can do your change, please.

zgyarmati

Dear igrinon,

I submitted some patches to the OpenWrt devel mailing list, also the one which enables the ttyS1 serial port, it might help to you. You can find them here, if you are (still) interested:
https://lists.openwrt.org/pipermail/openwrt-devel/2017-January/thread.html#42692
or here:
https://patchwork.ozlabs.org/project/openwrt/list/?submitter=18211&state=&q=&archive=&delegate=
--<br />Zoltan Gyarmati

ciarez

Dear zgyarmati,
I enabled ttyS1 on my EVB board by your patch but I lost gpio for relays. How can I enable only rx/tx keeping gpio for ralays?

ciarez

Hi,
I think I have solved my problem. My patch for u-boot:

diff --git a/board/rt2880/serial.h b/board/rt2880/serial.h
index f089ffd..a8cf3b8 100644
--- a/board/rt2880/serial.h
+++ b/board/rt2880/serial.h
@@ -20,7 +20,8 @@
#define RT2880_UART1   0x0500
#define RT2880_UART2   0x0C00  /* UART Lite */

-#define CFG_RT2880_CONSOLE     RT2880_UART2   /* we use UART Lite for console */
+//#define CFG_RT2880_CONSOLE   RT2880_UART2   /* we use UART Lite for console */
+#define CFG_RT2880_CONSOLE     RT2880_UART1

#define RT2880_UART_CFG_BASE (RT2880_CHIP_REG_CFG_BASE)




And about kernel:
target/linux/ramips/dts/OLINUXINO-RT5350F-EVB.dts

pinctrl {
         state_default: pinctrl0 {
                 gpio {
                    ralink,group = "jtag", "rgmii", "mdio", "uartf";
                    ralink,function = "gpio";
                 };
        };
};


to


pinctrl {
     state_default: pinctrl0 {
             gpio {
                ralink,group = "jtag", "rgmii", "mdio";
                ralink,function = "gpio";
             };
            uartf {
               ralink,group = "uartf";
               ralink,function = "gpio uartf";
            };
};


target/linux/ramips/dts/rt5350.dtsi

diff --git a/target/linux/ramips/dts/rt5350.dtsi b/target/linux/ramips/dts/rt5350.dtsi
index 456a937..78a849d 100644
--- a/target/linux/ramips/dts/rt5350.dtsi
+++ b/target/linux/ramips/dts/rt5350.dtsi
@@ -92,7 +92,7 @@
                        pinctrl-names = "default";
                        pinctrl-0 = <&uartf_pins>;

-                       status = "disabled";
+                       status = "okay";
                };

                gpio0: gpio@600 {


so I get uboot and kernel serial console on full uart keeping relays gpio. The only issue which remains is a bit of bytes that come out at the beginning of the kernel boot  :(