Discussion:
serial tty name
Richard Zhao
2011-12-14 14:43:47 UTC
Permalink
How to map different uart port to ttymxc0 (take imx for example)?

In rootfs, it usually "getty ttymxc0" to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.

But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.

Is there a way to fix it?


Thanks
Richard
Igor Grinberg
2011-12-14 15:10:10 UTC
Permalink
Hi Richard,
Post by Richard Zhao
How to map different uart port to ttymxc0 (take imx for example)?
In rootfs, it usually "getty ttymxc0" to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.
But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.
Is there a way to fix it?
As for fix in userspace, you can spawn getty on every ttymxc*,
so you will get it always.

Another (userspace) fix would be:
Instead of getty, add a script (say getty.sh) which will do something like:
-----------
CONSOLE=`cat /proc/cmdline | tr " " "\n" | grep console= | tr "=" " " | tr "," " "`
TTY=`echo $CONSOLE | cut -d' ' -f 2`
SPEED=`echo $CONSOLE | cut -d' ' -f 3`

/sbin/getty -L $TTY $SPEED vt100
--------------

I use the above, because I have not just multiple boards,
but multiple platforms each with its own tty name...
--
Regards,
Igor.
Uwe Kleine-König
2011-12-14 18:33:41 UTC
Permalink
Post by Igor Grinberg
Hi Richard,
Post by Richard Zhao
How to map different uart port to ttymxc0 (take imx for example)?
In rootfs, it usually "getty ttymxc0" to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.
But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.
Is there a way to fix it?
As for fix in userspace, you can spawn getty on every ttymxc*,
so you will get it always.
-----------
CONSOLE=`cat /proc/cmdline | tr " " "\n" | grep console= | tr "=" " " | tr "," " "`
TTY=`echo $CONSOLE | cut -d' ' -f 2`
SPEED=`echo $CONSOLE | cut -d' ' -f 3`
/sbin/getty -L $TTY $SPEED vt100
--------------
what about:

eval "$(sed 's/.*console=\([^,]*\),\([0-9]*\).*/tty=\1; speed=\2/'" /proc/cmdline)"

this should prevent getting a "useless use of cat award".

Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Richard Zhao
2011-12-15 00:44:48 UTC
Permalink
Post by Uwe Kleine-König
Post by Igor Grinberg
Hi Richard,
Post by Richard Zhao
How to map different uart port to ttymxc0 (take imx for example)?
In rootfs, it usually "getty ttymxc0" to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.
But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.
Is there a way to fix it?
As for fix in userspace, you can spawn getty on every ttymxc*,
so you will get it always.
-----------
CONSOLE=`cat /proc/cmdline | tr " " "\n" | grep console= | tr "=" " " | tr "," " "`
TTY=`echo $CONSOLE | cut -d' ' -f 2`
SPEED=`echo $CONSOLE | cut -d' ' -f 3`
/sbin/getty -L $TTY $SPEED vt100
--------------
eval "$(sed 's/.*console=\([^,]*\),\([0-9]*\).*/tty=\1; speed=\2/'" /proc/cmdline)"
this should prevent getting a "useless use of cat award".
Thanks.
Richard
Post by Uwe Kleine-König
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
_______________________________________________
linux-arm-kernel mailing list
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Rob Herring
2011-12-14 15:31:59 UTC
Permalink
Richard,
Post by Richard Zhao
How to map different uart port to ttymxc0 (take imx for example)?
In rootfs, it usually "getty ttymxc0" to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.
But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.
Is there a way to fix it?
That's what the aliases are for.

Rob
Richard Zhao
2011-12-15 00:31:26 UTC
Permalink
Post by Igor Grinberg
Richard,
Post by Richard Zhao
How to map different uart port to ttymxc0 (take imx for example)?
In rootfs, it usually "getty ttymxc0" to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.
But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.
Is there a way to fix it?
That's what the aliases are for.
so, why do I see people define uart aliases in $SOC.dtsi, rather not in $BOARD.dts?

Thanks
Richard
Post by Igor Grinberg
Rob
_______________________________________________
linux-arm-kernel mailing list
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Shawn Guo
2011-12-19 04:08:05 UTC
Permalink
Post by Igor Grinberg
Richard,
Post by Richard Zhao
How to map different uart port to ttymxc0 (take imx for example)?
In rootfs, it usually "getty ttymxc0" to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.
But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.
Is there a way to fix it?
That's what the aliases are for.
I understand it differently. The aliases was introduced to help
tty/serial driver identify the correct hardware port for given serial
node from device tree. (Ab)using it to fool 'console' setting may
eventually confuse users, saying they will think the uart port on his
board is UART0.
--
Regards,
Shawn
Jason Liu
2011-12-19 04:49:11 UTC
Permalink
Post by Igor Grinberg
Richard,
Post by Richard Zhao
How to map different uart port to ttymxc0 (take imx for example)?
In rootfs, it usually "getty ttymxc0"  to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.
But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.
Is there a way to fix it?
That's what the aliases are for.
I understand it differently.  The aliases was introduced to help
tty/serial driver identify the correct hardware port for given serial
node from device tree.  (Ab)using it to fool 'console' setting may
eventually confuse users, saying they will think the uart port on his
board is UART0.
We absolutely need document this in detail to avoid confusion. Otherwise,
the ARM DT support will also mess up in the end.
--
Regards,
Shawn
_______________________________________________
linux-arm-kernel mailing list
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Richard Zhao
2011-12-19 05:41:38 UTC
Permalink
Post by Jason Liu
Post by Igor Grinberg
Richard,
Post by Richard Zhao
How to map different uart port to ttymxc0 (take imx for example)?
In rootfs, it usually "getty ttymxc0"  to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.
But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.
Is there a way to fix it?
That's what the aliases are for.
I understand it differently.  The aliases was introduced to help
tty/serial driver identify the correct hardware port for given serial
node from device tree.  (Ab)using it to fool 'console' setting may
eventually confuse users, saying they will think the uart port on his
board is UART0.
We absolutely need document this in detail to avoid confusion. Otherwise,
the ARM DT support will also mess up in the end.
Yes, why not come a patch to doc it?

THanks
Richard
Post by Jason Liu
--
Regards,
Shawn
_______________________________________________
linux-arm-kernel mailing list
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Shawn Guo
2011-12-19 03:56:37 UTC
Permalink
Post by Richard Zhao
How to map different uart port to ttymxc0 (take imx for example)?
In rootfs, it usually "getty ttymxc0" to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.
But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.
Is there a way to fix it?
I'm using Linaro rootfs and do not see this problem at all. So as
people have suggested, you need to fix it in your user space.
--
Regards,
Shawn
Richard Zhao
2011-12-19 05:40:13 UTC
Permalink
Post by Shawn Guo
Post by Richard Zhao
How to map different uart port to ttymxc0 (take imx for example)?
In rootfs, it usually "getty ttymxc0" to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.
But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.
Is there a way to fix it?
I'm using Linaro rootfs and do not see this problem at all. So as
people have suggested, you need to fix it in your user space.
Why not past your linaro rootfs solution?

Thanks
Richard
Post by Shawn Guo
--
Regards,
Shawn
_______________________________________________
linux-arm-kernel mailing list
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Shawn Guo
2011-12-19 06:05:48 UTC
Permalink
Post by Richard Zhao
Post by Shawn Guo
Post by Richard Zhao
How to map different uart port to ttymxc0 (take imx for example)?
In rootfs, it usually "getty ttymxc0" to get
serial console. And the rootfs may be shared by different boards.
Traditionaly way is to set right platform device ID.
But with DT, UART2 always generate ttymxc1, UART3 for ttymxc2. You
always needs to modify the getty command when your change another board.
Is there a way to fix it?
I'm using Linaro rootfs and do not see this problem at all. So as
people have suggested, you need to fix it in your user space.
Why not past your linaro rootfs solution?
You do have Linaro rootfs, don't you?
--
Regards,
Shawn
Continue reading on narkive:
Loading...