Skip to contentSkip to conversation

serial tty name

DISCUSSION Richard Zhao 7 participants 12 messages Dec 14, 2011 – Dec 19, 2011

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

Hi Richard,

Quoted 10 lines · 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...

Signature · 2 lines
Regards,
Igor.
#4 lore raw
In reply to Richard Zhao

Richard,

Quoted 10 lines · 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

#2 lore raw
In reply to Igor Grinberg
Quoted 24 lines · Igor Grinberg

Hi Richard,

Quoted 10 lines · 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

Quoted 2 lines

/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

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#5 lore raw
In reply to Rob Herring
Quoted 9 lines · Rob Herring

Richard,

Quoted 6 lines · 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.

Quoted 6 lines
Quoted 4 lines

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

Quoted 8 lines

Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
In reply to Uwe Kleine-König
Quoted 25 lines · Uwe Kleine-K?nig
Quoted 24 lines · Igor Grinberg

Hi Richard,

Quoted 10 lines · 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

Quoted 8 lines
Quoted 2 lines

/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".

Thanks.
Richard

Quoted 13 lines

Best regards
Uwe

Signature · 7 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#9 lore raw
In reply to Richard Zhao
Quoted 11 lines · 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.

Signature · 2 lines
Regards,
Shawn
#6 lore raw
In reply to Rob Herring
Quoted 9 lines · Rob Herring

Richard,

Quoted 6 lines · 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.

Quoted 7 lines
Quoted 4 lines

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.

Signature · 2 lines
Regards,
Shawn
#7 lore raw

2011/12/19 Shawn Guo <[email protected]>:

Quoted 15 lines · Rob Herring
Quoted 14 lines

Richard,

Quoted 10 lines · 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?

Quoted 7 lines
Quoted 2 lines

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.

Quoted 10 lines

--
Regards,
Shawn

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#10 lore raw
In reply to Shawn Guo
Quoted 7 lines · Shawn Guo
Quoted 6 lines · 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.

Quoted 7 lines
Quoted 5 lines

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

Quoted 11 lines
Signature · 9 lines
-- 
Regards,
Shawn


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#8 lore raw
In reply to Jason Liu
Quoted 18 lines · Jason Liu

2011/12/19 Shawn Guo <[email protected]>:

Quoted 17 lines · Rob Herring
Quoted 16 lines

Richard,

Quoted 10 lines · 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.

Quoted 8 lines
Quoted 5 lines

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

Quoted 17 lines
Quoted 11 lines

--
Regards,
Shawn

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#11 lore raw
In reply to Richard Zhao
Quoted 8 lines · Richard Zhao
Quoted 7 lines · Shawn Guo
Quoted 6 lines · 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.

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

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?

Signature · 2 lines
Regards,
Shawn