| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | [=#notes] |
| 420 | == Specific Product / Model Notes |
| 421 | |
| 422 | |
| 423 | [=#venice] |
| 424 | === Venice |
| 425 | Most Venice products have a flexible [http://dev.gateworks.com/datasheets/sp335e.pdf MaxLinear SP335E] RS-232/RS-485/RS-422 transceiver which is software configurable. For these boards a device-tree fragment is used to configure the kernel appropriately for the mode you desire: |
| 426 | * 2x RS232 TX/RX (default configuration requiring no dt overlay) |
| 427 | * 1x RS232 TX/RX/RTS/CTS (uses rs232-rts dt overlay) |
| 428 | * 1x RS485 (half duplex) (uses rs485 dt overlay) |
| 429 | * 1x RS422 (full duplex) (uses rs422 dt overlay) |
| 430 | |
| 431 | ''' WARNING ''' Some Venice models such as the GW73xx have the default Linux serial console being output to the same UART that a RS485 might be using. Thus, it is critical to disable the Linux serial console with the console variable in u-boot. Please note that when doing this, it is critical to first enable something like ssh to access the board over the network. |
| 432 | * Enable ssh first [wiki:ubuntu#SSHServer Instructions for Ubuntu] |
| 433 | * Disable serial console in uboot prompt or move to a different port: |
| 434 | * |
| 435 | {{{ |
| 436 | setenv console 'console=/dev/null' |
| 437 | saveenv |
| 438 | }}} |
| 439 | * Also see [wiki:silenceconsole silenceconsole] for details on silencing or changing the serial console for boot firmware, Linux kernel, and OS. |
| 440 | |
| 441 | To use dt overlays you specify the appropriate overlay(s) in the U-Boot {{{fdt_overlays}}} environment variable in the U-Boot bootloader. This instructs U-Boot to load and apply those dt overlay fragments to the board dt before booting Linux. Note that you can have more than one dt overlay specified in the {{{fdt_overlays}}} separated by a space: |
| 442 | * imx8mm-venice-gw730x-0x RS485: |
| 443 | {{{#!bash |
| 444 | setenv fdt_overlays "$fdt_overlays imx8mm-venice-gw73xx-0x-rs485.dtbo" |
| 445 | saveenv |
| 446 | }}} |
| 447 | * imx8mm-venice-gw730x-0x RS422: |
| 448 | {{{#!bash |
| 449 | setenv fdt_overlays "imx8mm-venice-gw73xx-0x-rs422.dtbo" |
| 450 | saveenv |
| 451 | }}} |
| 452 | * imx8mm-venice-gw730x-0x RS232-CTSRTS flow control: |
| 453 | {{{#!bash |
| 454 | setenv fdt_overlays "imx8mm-venice-gw73xx-0x-rs232-rts.dtbo" |
| 455 | saveenv |
| 456 | }}} |
| 457 | * imx8mm-venice-gw730x-0x default 2x RS232 TX/RX: |
| 458 | {{{#!bash |
| 459 | setenv fdt_overlays |
| 460 | saveenv |
| 461 | }}} |
| 462 | |
| 463 | For Venice when configured for RS485 or RS422 you do not need to use the TIOCSRS485 as the dt fragments will enable this on bootup as well as configure the UARTs transmit enable pin. |
| 464 | |
| 465 | If you wish to enable the SP335E on-board RS485 termination (which is disabled by default) you can set the GPIO manually: |
| 466 | * GW730x/GW720x: |
| 467 | - U-Boot: |
| 468 | {{{#!bash |
| 469 | u-boot=> gpio status GPIO1_0 |
| 470 | Bank GPIO1_: |
| 471 | GPIO1_0: output: 0 [x] rs485_term.gpio-hog |
| 472 | u-boot=> gpio set GPIO1_0 |
| 473 | gpio: pin GPIO1_0 (gpio 0) value is 1 |
| 474 | }}} |
| 475 | - Linux (sysfs) (deprecated API) |
| 476 | {{{#!bash |
| 477 | root@focal-venice:~# grep rs485_term /sys/kernel/debug/gpio |
| 478 | gpio-0 (rs485_term ) |
| 479 | root@focal-venice:~# echo 0 > /sys/class/gpio/export |
| 480 | root@focal-venice:~# echo out > /sys/class/gpio/gpio0/direction |
| 481 | root@focal-venice:~# echo 1 > /sys/class/gpio/gpio0/value |
| 482 | }}} |
| 483 | - Linux (gpiolib) |
| 484 | {{{#!bash |
| 485 | root@focal-venice:~# gpiofind "rs485_term" |
| 486 | gpiochip0 0 |
| 487 | root@focal-venice:~# gpioset --mode=signal --background gpiochip0 0=1 |
| 488 | }}} |
| 489 | * Note we have to tell {{{gpioset}}} to remaining running until it receives a signal in order to keep the GPIO line from reverting back to its original state when the process exits. If you use the deprecated {{{sysfs}}} API or set it in U-Boot it may be easier |
| 490 | |
| 491 | Note that if you want to be able to change the UART mode at runtime instead of at boot time you can use the 'rs232-rts' overlay which adds the RTS signal capability to the UART, configure the various gpios manually at runtime via sysfs or gpiod, and use the TIOCSRS485 ioctl to invoke RS485 mode with the polarity of the RTS pin handled by setting rs485conf.flags SER_RS485_RTS_AFTER_SEND |
| 492 | |
| 493 | [=#newport] |
| 494 | === Newport |
| 495 | Most Newport products have a flexible [http://dev.gateworks.com/datasheets/sp335e.pdf MaxLinear SP335E] RS-232/RS-485/RS-422 transceiver which is software configurable. For these boards the Bootloader {{{hwconfig}}} environment variable can be used to configure the functionality of the serial ports at power-up between dual RS232 without flow control (default), single RS232 with hardware flow control, and RS485 (full/half duplex and optional termination). See [wiki:/newport/bootloader#hwconfig:serialConfiguration Newport bootloader hwconfig] for more details. |
| 496 | |
| 497 | If you wish to configure the SP335E transceiver yourself you can control it at runtime through the following GPIO's (which is what the Boot firmware will do for you via the {{{hwconfig}}} variable): |
| 498 | * GPIO21: UART_HALF - selects full (low) or half (high) duplex (RS485 mode only) |
| 499 | * GPIO22: UART_TERM - disables (low) or enables (high) on-chip termination (RS485 mode only) |
| 500 | * GPIO23: UART_RS485 - selects between RS232 (low) and RS245 (high) modes |
| 501 | |
| 502 | See [wiki:gpio gpio] for details on using GPIO from Linux userspace or use the U-Boot bootloader {{{gpio}}} command. |
| 503 | |
| 504 | The CN80XX / CN81XX has 4 TTL level UARTs with the following mapping: |
| 505 | ||= UART =||= device-tree alias =||= Linux device =|| |
| 506 | || UART0 || serial0 || /dev/ttyAMA0 || |
| 507 | || UART1 || serial1 || /dev/ttyAMA1 || |
| 508 | || UART2 || serial2 || /dev/ttyAMA2 || |
| 509 | || UART3 || serial3 || /dev/ttyAMA3 || |
| 510 | |
| 511 | The Linux kernel uses the {{{console}}} parameter from the Kernel cmdline to specify the serial console. You can usually modify the 'console' U-boot env variable if you want to change the default console UART as it typically gets passed on to the kernel: |
| 512 | {{{ |
| 513 | Newport > setenv console '/dev/ttyAMA2,115200n8'; saveenv |
| 514 | }}} |
| 515 | * Specify that Linux and userspace use UART2 |
| 516 | |
| 517 | The U-Boot Bootloader (as well as kernel if the {{{console}}} cmdline is not specified) uses the device-tree 'chosen' node 'stdout-path' property to specify serial console. For example the default is specified in the cn81xx-linux.dtsi: |
| 518 | {{{ |
| 519 | chosen { |
| 520 | stdout-path = "serial0:115200n8"; |
| 521 | }; |
| 522 | }}} |
| 523 | |
| 524 | If you wish to change the serial console in the BDK or ATF, you will need to modify the source code which will take some digging. |
596 | | |
597 | | |
598 | | [=#notes] |
599 | | == Specific Product / Model Notes |
600 | | |
601 | | |
602 | | [=#venice] |
603 | | === Venice |
604 | | Most Venice products have a flexible [http://dev.gateworks.com/datasheets/sp335e.pdf MaxLinear SP335E] RS-232/RS-485/RS-422 transceiver which is software configurable. For these boards a device-tree frament is used to configure the kernel appropriately for the mode you desire: |
605 | | * 2x RS232 TX/RX (default configuration requiring no dt overlay) |
606 | | * 1x RS232 TX/RX/RTS/CTS (uses rs232-rts dt overlay) |
607 | | * 1x RS485 (half duplex) (uses rs485 dt overlay) |
608 | | * 1x RS422 (full duplex) (uses rs422 dt overlay) |
609 | | |
610 | | To use dt overlays you specify the appropriate overlay(s) in the U-Boot {{{fdt_overlays}}} environment variable in the U-Boot bootloader. This instructs U-Boot to load and apply those dt overlay fragments to the board dt before booting Linux. Note that you can have more than one dt overlay specified in the {{{fdt_overlays}}} separated by a space: |
611 | | * imx8mm-venice-gw730x-0x RS485: |
612 | | {{{#!bash |
613 | | setenv fdt_overlays "$fdt_overlays imx8mm-venice-gw73xx-0x-rs485.dtbo" |
614 | | saveenv |
615 | | }}} |
616 | | * imx8mm-venice-gw730x-0x RS422: |
617 | | {{{#!bash |
618 | | setenv fdt_overlays "imx8mm-venice-gw73xx-0x-rs422.dtbo" |
619 | | saveenv |
620 | | }}} |
621 | | * imx8mm-venice-gw730x-0x RS232-CTSRTS flow control: |
622 | | {{{#!bash |
623 | | setenv fdt_overlays "imx8mm-venice-gw73xx-0x-rs232-rts.dtbo" |
624 | | saveenv |
625 | | }}} |
626 | | * imx8mm-venice-gw730x-0x default 2x RS232 TX/RX: |
627 | | {{{#!bash |
628 | | setenv fdt_overlays |
629 | | saveenv |
630 | | }}} |
631 | | |
632 | | For Venice when configured for RS485 or RS422 you do not need to use the TIOCSRS485 as the dt fragments will enable this on bootup as well as configure the UARTs transmit enable pin. |
633 | | |
634 | | If you wish to enable the SP335E on-board RS485 termination (which is disabled by default) you can set the GPIO manually: |
635 | | * GW730x/GW720x: |
636 | | - U-Boot: |
637 | | {{{#!bash |
638 | | u-boot=> gpio status GPIO1_0 |
639 | | Bank GPIO1_: |
640 | | GPIO1_0: output: 0 [x] rs485_term.gpio-hog |
641 | | u-boot=> gpio set GPIO1_0 |
642 | | gpio: pin GPIO1_0 (gpio 0) value is 1 |
643 | | }}} |
644 | | - Linux (sysfs) (deprecated API) |
645 | | {{{#!bash |
646 | | root@focal-venice:~# grep rs485_term /sys/kernel/debug/gpio |
647 | | gpio-0 (rs485_term ) |
648 | | root@focal-venice:~# echo 0 > /sys/class/gpio/export |
649 | | root@focal-venice:~# echo out > /sys/class/gpio/gpio0/direction |
650 | | root@focal-venice:~# echo 1 > /sys/class/gpio/gpio0/value |
651 | | }}} |
652 | | - Linux (gpiolib) |
653 | | {{{#!bash |
654 | | root@focal-venice:~# gpiofind "rs485_term" |
655 | | gpiochip0 0 |
656 | | root@focal-venice:~# gpioset --mode=signal --background gpiochip0 0=1 |
657 | | }}} |
658 | | * Note we have to tell {{{gpioset}}} to remaining running until it receives a signal in order to keep the GPIO line from reverting back to its original state when the process exits. If you use the deprecated {{{sysfs}}} API or set it in U-Boot it may be easier |
659 | | |
660 | | Note that if you want to be able to change the UART mode at runtime instead of at boot time you can use the 'rs232-rts' overlay which adds the RTS signal capability to the UART, configure the various gpios manually at runtime via sysfs or gpiod, and use the TIOCSRS485 ioctl to invoke RS485 mode with the polarity of the RTS pin handled by setting rs485conf.flags SER_RS485_RTS_AFTER_SEND |
661 | | |
662 | | [=#newport] |
663 | | === Newport |
664 | | Most Newport products have a flexible [http://dev.gateworks.com/datasheets/sp335e.pdf MaxLinear SP335E] RS-232/RS-485/RS-422 transceiver which is software configurable. For these boards the Bootloader {{{hwconfig}}} environment variable can be used to configure the functionality of the serial ports at power-up between dual RS232 without flow control (default), single RS232 with hardware flow control, and RS485 (full/half duplex and optional termination). See [wiki:/newport/bootloader#hwconfig:serialConfiguration Newport bootloader hwconfig] for more details. |
665 | | |
666 | | If you wish to configure the SP335E transceiver yourself you can control it at runtime through the following GPIO's (which is what the Boot firmware will do for you via the {{{hwconfig}}} variable): |
667 | | * GPIO21: UART_HALF - selects full (low) or half (high) duplex (RS485 mode only) |
668 | | * GPIO22: UART_TERM - disables (low) or enables (high) on-chip termination (RS485 mode only) |
669 | | * GPIO23: UART_RS485 - selects between RS232 (low) and RS245 (high) modes |
670 | | |
671 | | See [wiki:gpio gpio] for details on using GPIO from Linux userspace or use the U-Boot bootloader {{{gpio}}} command. |
672 | | |
673 | | The CN80XX / CN81XX has 4 TTL level UARTs with the following mapping: |
674 | | ||= UART =||= device-tree alias =||= Linux device =|| |
675 | | || UART0 || serial0 || /dev/ttyAMA0 || |
676 | | || UART1 || serial1 || /dev/ttyAMA1 || |
677 | | || UART2 || serial2 || /dev/ttyAMA2 || |
678 | | || UART3 || serial3 || /dev/ttyAMA3 || |
679 | | |
680 | | The Linux kernel uses the {{{console}}} parameter from the Kernel cmdline to specify the serial console. You can usually modify the 'console' U-boot env variable if you want to change the default console UART as it typically gets passed on to the kernel: |
681 | | {{{ |
682 | | Newport > setenv console '/dev/ttyAMA2,115200n8'; saveenv |
683 | | }}} |
684 | | * Specify that Linux and userspace use UART2 |
685 | | |
686 | | The U-Boot Bootloader (as well as kernel if the {{{console}}} cmdline is not specified) uses the device-tree 'chosen' node 'stdout-path' property to specify serial console. For example the default is specified in the cn81xx-linux.dtsi: |
687 | | {{{ |
688 | | chosen { |
689 | | stdout-path = "serial0:115200n8"; |
690 | | }; |
691 | | }}} |
692 | | |
693 | | If you wish to change the serial console in the BDK or ATF, you will need to modify the source code which will take some digging. |
694 | | |
695 | | |
696 | | |
697 | | |