Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => RT5350F => Topic started by: igrinon on December 03, 2016, 11:59:44 AM

Title: ttS1 & SIM800L
Post by: igrinon on December 03, 2016, 11:59:44 AM
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.
Title: Re: ttS1 & SIM800L
Post by: JohnS on December 03, 2016, 01:38:14 PM
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
Title: Re: ttS1 & SIM800L
Post by: igrinon on December 04, 2016, 12:57:17 AM
Thanks JohnS,

Let me take a look to it...
Title: Re: ttS1 & SIM800L
Post by: zgyarmati on December 04, 2016, 05:54:16 PM
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.
Title: Re: ttS1 & SIM800L
Post by: igrinon on December 05, 2016, 12:30:08 AM
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
Title: Re: ttS1 & SIM800L
Post by: igrinon on December 05, 2016, 01:00:29 AM
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
Title: Re: ttS1 & SIM800L
Post by: zgyarmati on December 06, 2016, 02:18:48 AM
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...
Title: Re: ttS1 & SIM800L
Post by: igrinon on December 06, 2016, 10:59:59 AM
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     
Title: Re: ttS1 & SIM800L
Post by: zgyarmati on January 31, 2017, 07:29:38 PM
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=
Title: Re: ttS1 & SIM800L
Post by: ciarez on February 08, 2017, 02:07:12 PM
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?
Title: Re: ttS1 & SIM800L
Post by: ciarez on February 08, 2017, 07:22:03 PM
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  :(