Welcome, Guest

Author Topic: ttS1 & SIM800L  (Read 3413 times)

igrinon

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
ttS1 & SIM800L
« 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.
« Last Edit: December 03, 2016, 12:01:42 PM by igrinon »

JohnS

  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +33/-45
Re: ttS1 & SIM800L
« Reply #1 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
« Last Edit: December 03, 2016, 02:52:17 PM by JohnS »

igrinon

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: ttS1 & SIM800L
« Reply #2 on: December 04, 2016, 12:57:17 AM »
Thanks JohnS,

Let me take a look to it...

zgyarmati

  • Newbie
  • *
  • Posts: 32
  • Karma: +1/-0
    • https://zgyarmati.de
Re: ttS1 & SIM800L
« Reply #3 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.
--
Zoltan Gyarmati
https://zgyarmati.de

igrinon

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: ttS1 & SIM800L
« Reply #4 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

igrinon

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: ttS1 & SIM800L
« Reply #5 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

zgyarmati

  • Newbie
  • *
  • Posts: 32
  • Karma: +1/-0
    • https://zgyarmati.de
Re: ttS1 & SIM800L
« Reply #6 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...
--
Zoltan Gyarmati
https://zgyarmati.de

igrinon

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: ttS1 & SIM800L
« Reply #7 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     
  • 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

  • Newbie
  • *
  • Posts: 32
  • Karma: +1/-0
    • https://zgyarmati.de
Re: ttS1 & SIM800L
« Reply #8 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=
--
Zoltan Gyarmati
https://zgyarmati.de

ciarez

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: ttS1 & SIM800L
« Reply #9 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?

ciarez

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: ttS1 & SIM800L
« Reply #10 on: February 08, 2017, 07:22:03 PM »
Hi,
I think I have solved my problem. My patch for u-boot:
Code: [Select]
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
Code: [Select]
pinctrl {
         state_default: pinctrl0 {
                 gpio {
                    ralink,group = "jtag", "rgmii", "mdio", "uartf";
                    ralink,function = "gpio";
                 };
        };
};

to

Code: [Select]
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
Code: [Select]
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  :(