UART: Configure Custom Speed?

580 views
Skip to first unread message

bruce bushby

unread,
Jan 31, 2015, 6:25:16 PM1/31/15
to linux...@googlegroups.com
Hi

I'm hoping a list member could offer some advice setting a UART with a custom speed.

I was hoping to calculate the required divisor and use setserial to set my speed (100000), however both Python's pySerial and the "setserial" command cause the following error:

[root@A20-SOM ~]# setserial /dev/ttyS1 spd_cust
[  697.027655] dw-apb-uart 1c29800.serial: setserial sets custom speed on ttyS1. This is deprecated.
[root@A20-SOM ~]#


Deprecated in favor of?


I had a look in the dts:

    uart6: serial@01c29800 {
                        compatible = "snps,dw-apb-uart";
                        reg = <0x01c29800 0x400>;
                        interrupts = <0 19 4>;
                        reg-shift = <2>;
                        reg-io-width = <4>;
                        clocks = <&apb1_gates 22>;
                        status = "disabled";
                };


...however I don't understand the relationship between "22"  and  "&apb1_gates" 


How do I set the divisor and/or configure my custom speed of 100000 for my UART6?



Thanks
Bruce





Emilio López

unread,
Jan 31, 2015, 6:54:03 PM1/31/15
to linux...@googlegroups.com, bruce....@gmail.com
Hi,

El 31/01/15 a las 20:25, bruce bushby escibió:
> Hi
>
> I'm hoping a list member could offer some advice setting a UART with a
> custom speed.
>
> I was hoping to calculate the required divisor and use setserial to set
> my speed (100000), however both Python's pySerial and the "setserial"
> command cause the following error:
>
> [root@A20-SOM ~]# setserial /dev/ttyS1 spd_cust
> [ 697.027655] dw-apb-uart 1c29800.serial: setserial sets custom speed
> on ttyS1. This is deprecated.
> [root@A20-SOM ~]#
>
>
> Deprecated in favor of?

It seems this has been deprecated for a couple of years now judging by
Google results. Have you tried using stty?

On a 115200 terminal, the following makes it stop working

stty -F /dev/ttyS0 9600

And reattaching with 9600 makes it work again

> I had a look in the dts:
>
> uart6: serial@01c29800 {
> compatible = "snps,dw-apb-uart";
> reg = <0x01c29800 0x400>;
> interrupts = <0 19 4>;
> reg-shift = <2>;
> reg-io-width = <4>;
> clocks = <&apb1_gates 22>;
> status = "disabled";
> };
>
>
> ...however I don't understand the relationship between "22" and
> "&apb1_gates"

It means that the gate feeding the UART hardware is the 22nd bit on the
register where the gates are.

> How do I set the divisor and/or configure my custom speed of 100000 for
> my UART6?

I've never heard of anyone using 100000, are you sure you can't use
115200 or one of the other standard speeds?

Cheers,

Emilio

bruce bushby

unread,
Jan 31, 2015, 8:07:51 PM1/31/15
to Emilio López, linux...@googlegroups.com
Hi Emilio 



[root@A20-SOM ~]# 
[root@A20-SOM ~]# stty -F /dev/ttyS1 9600
[root@A20-SOM ~]# stty -F /dev/ttyS1 115200
[root@A20-SOM ~]# 
[root@A20-SOM ~]# stty -F /dev/ttyS1 100000
stty: invalid argument '100000'
[root@A20-SOM ~]# 
[root@A20-SOM ~]# setserial -ag /dev/ttyS1
/dev/ttyS1, Line 1, UART: U6_16550A, Port: 0x0000, IRQ: 51
        Baud_base: 1500000, close_delay: 50, divisor: 0
        closing_wait: 3000
        Flags: spd_normal

[root@A20-SOM ~]# setserial  /dev/ttyS1 spd_cust
[   81.049490] dw-apb-uart 1c29800.serial: setserial sets custom speed on ttyS1. This is deprecated.
[root@A20-SOM ~]# 
[root@A20-SOM ~]# setserial  --help             
BusyBox v1.22.1 (2015-01-22 20:55:37 GMT) multi-call binary.

Usage: setserial [-gabGvzV] DEVICE [PARAMETER [ARG]]...

Request or set Linux serial port information

        -g      Interpret parameters as list of devices for reporting
        -a      Print all available information
        -b      Print summary information
        -G      Print in form which can be fed back
                to setserial as command line parameters
        -z      Zero out serial flags before setting
        -v      Verbose

Parameters: (* = takes an argument, ^ = can be turned off by preceding ^)
        *port, *irq, *divisor, *uart, *baud_base, *close_delay, *closing_wait,
        ^fourport, ^auto_irq, ^skip_test, ^sak, ^session_lockout, ^pgrp_lockout,
        ^callout_nohup, ^split_termios, ^hup_notify, ^low_latency, autoconfig,
        spd_normal, spd_hi, spd_vhi, spd_shi, spd_warp, spd_cust

UART types:
        unknown, 8250, 16450, 16550, 16550A, Cirrus, 16650, 16650V2, 16750,
        16950, 16954, 16654, 16850, RSA, NS16550A, XSCALE, RM9000, OCTEON, AR7,
        U6_16550A

[root@A20-SOM ~]#


bruce bushby

unread,
Jan 31, 2015, 8:14:29 PM1/31/15
to Emilio López, linux...@googlegroups.com
Hi Emilio 

Apologies, previous email sent by mistake.

 >> And reattaching with 9600 makes it work again.
Ahh...thank you, that appears to work in that I don't get any error messages 

[root@A20-SOM ~]# 
[root@A20-SOM ~]# setserial -v /dev/ttyS1 spd_cust
/dev/ttyS1, UART: U6_16550A, Port: 0x0000, IRQ: 51, Flags: spd_cust
[root@A20-SOM ~]# setserial -v /dev/ttyS1 divisor 15
/dev/ttyS1, UART: U6_16550A, Port: 0x0000, IRQ: 51, Flags: spd_cust
[root@A20-SOM ~]# setserial -ag /dev/ttyS1 
/dev/ttyS1, Line 1, UART: U6_16550A, Port: 0x0000, IRQ: 51
        Baud_base: 1500000, close_delay: 50, divisor: 15
        closing_wait: 3000
        Flags: spd_cust

[root@A20-SOM ~]#



I was following this url:


Apparently I then issue a:
[root@A20-SOM ~]# stty -F /dev/ttyS1 38400
[root@A20-SOM ~]#


>> I've never heard of anyone using 100000, are you sure you can't use 115200 or one of the other standard speeds?
Yes, 100000 is correct for Futaba s.bus digital servo control. I'm trying to read/write s.bus servo control via a UART + inverter (s.bus has inverted signal)

Thanks again, guess I'll need a scope to confirm if the above actually sets the baud to 100Khz 


Bruce


Olliver Schinagl

unread,
Oct 1, 2015, 2:34:09 PM10/1/15
to linux...@googlegroups.com, Emilio López
Hey Bruce,


On 01-02-15 02:14, bruce bushby wrote:
Hi Emilio 

Apologies, previous email sent by mistake.

 >> And reattaching with 9600 makes it work again.
Ahh...thank you, that appears to work in that I don't get any error messages 

[root@A20-SOM ~]# 
[root@A20-SOM ~]# setserial -v /dev/ttyS1 spd_cust
/dev/ttyS1, UART: U6_16550A, Port: 0x0000, IRQ: 51, Flags: spd_cust
[root@A20-SOM ~]# setserial -v /dev/ttyS1 divisor 15
/dev/ttyS1, UART: U6_16550A, Port: 0x0000, IRQ: 51, Flags: spd_cust
[root@A20-SOM ~]# setserial -ag /dev/ttyS1 
/dev/ttyS1, Line 1, UART: U6_16550A, Port: 0x0000, IRQ: 51
        Baud_base: 1500000, close_delay: 50, divisor: 15
        closing_wait: 3000
        Flags: spd_cust

[root@A20-SOM ~]#
I can't see from your paste if it worked or not. I'm curious about this too, because Ideally I want the non-standaard baudrate of 250000 (roughly twice 115200). This as 250000 is an 'ideal' baudrate to talk to atmega's (arduino's) at 16 MHz.

Olliver
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages