PINE64
Change Baudrate for Built-On Serial - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: ROCKPRO64 (https://forum.pine64.org/forumdisplay.php?fid=98)
+--- Forum: General Discussion on ROCKPRO64 (https://forum.pine64.org/forumdisplay.php?fid=99)
+--- Thread: Change Baudrate for Built-On Serial (/showthread.php?tid=11609)



Change Baudrate for Built-On Serial - R0b0t1 - 09-23-2020

The serial port on the RPi header has a baud of 1,500,000. This is fine for most tools, but some are capped at the values present in the baud tables in various places in the Linux kernel and other utilities.

How do I change the baud to 460800? I've found the uarts in rk3399.dtsi in the kernel tree, but am unsure how their clocks are actually generated.

As expected software seems unable to change the speed of the serial port.


RE: Change Baudrate for Built-On Serial - Gienek - 10-04-2020

Hello R0b0t1,
  I do not know, what software you are using to operate the UART. I usually use C-programs for this purpose. So my experience is limited to Linux and C.
  Before any further consideration, I would like to strongly discourage from using UART2 on ROCKPro64. It is used by system console in Linux, any my attempts to connect two-way communication to this port ended with the board hanging completely after some time. I tried Armbian, Mrfixit2001 and Ayufan images. It is better to activate one of unused UARTs and use it.
  The C-interface for UART speed in Linux (cfsetispeed() ) is limited to only some baud-rates up to 230400. This might be the reason, why many software tools offer only limited UART-speed settings.
Once, I needed to overcome this issue on another ARM board. My solution was not very elegant, but I do not know any other:
  1. Open the device-file and set it for communication, by using the standard functions (fcntl(), tcsetattr(), ioctl()...)
  2. Map the memory part, which contains the UART control registers.
  3. Set the speed of UART directly in the control registers.
  4. Continue with communication in the program.
I do not want to post the coding here, because it is for a different chip.
Description of the control registers, and their settings can be found in the TRM document of RK3399 (http://opensource.rock-chips.com/images/e/ee/Rockchip_RK3399TRM_V1.4_Part1-20170408.pdf).
Maybe you could apply similar procedure?
Please, be aware that those boards cannot generate any UART frequency. Sometimes approximations must be used.
  Best regards,
  Gienek.