Baud rate is not getting set for more than 1500000 (1.5Mbps)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Baud rate is not getting set for more than 1500000 (1.5Mbps)

Jump to solution
4,558 Views
jadhav_lokesh
Contributor I

Hello there,

I’m working on a project on Humming Board IMX8MP, in that I’m working with UART for Video stream out. We are able to transmit video stream with 1.5Mbps i.e. with baud rate 1500000. For video streaming, we are using gstreamer pipeline.

As per the data sheet, UART can support up to 4Mbps and we would like to use it to the fullest.
Could anyone help me with this. ???

We are using following commands to set Baud Rate :

 

stty -F /dev/ttymxc2 1500000          // set baudrate
stty -F /dev/ttymxc2 -crtscts         // disable cts-rts

 

0 Kudos
Reply
1 Solution
4,438 Views
kef2
Senior Contributor V

Ok. 

In imx8mp RM see available settings

kef2_0-1682581212138.png

Determine in device how are they called in Linux jargon. dtsi's point to include/dt-bindings/clock/imx8mp-clock.h. You won't find there something like PLL1_DIV10, but somewhat equivalent with divider output frequency. In imx8mp-ab2.dts I found ready made example for you:

&uart1 { /* BT */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart1>;
	assigned-clocks = <&clk IMX8MP_CLK_UART1>;
	assigned-clock-parents = <&clk IMX8MP_SYS_PLL1_80M>;
	fsl,uart-has-rtscts;
	status = "okay";
};

You need those two assigned-xx lines with UARTn matching your UART instance. It could be SYS_PLL1_80M or something else from the list above "translated" to defines from imx8mp-clock.h.

View solution in original post

16 Replies
4,543 Views
kef2
Senior Contributor V

Isn't 24MHz (1.5*16) oscillator selected as your UART module clock? 

From imx7 manual:

  • Due to the 16x oversampling of the incoming characters, module_clock frequency
    must always be greater or equal to 16x the maximum baud rate. For example, if max baud rate is 4 Mbit/s, module_clock must be greater or equal to 4 M x 16 = 64 MHz.

 

0 Kudos
Reply
4,540 Views
jadhav_lokesh
Contributor I

Dear @kef2 ,

Thanks for your reply.

I'm attaching imx8mp SOM schematic, and Highlighted an oscillator section.

Were you taking about this.?? 

If Yes, then by changing it to 64Mhz, UART should start working with 4Mbps. Right.?? 

Plz refer the below image. Looking forward to your quick response.

imx8mp_som_Schematic.jpg

0 Kudos
Reply
4,533 Views
kef2
Senior Contributor V

I meant that your UART module clock is perhaps too low for >1.5MBps. You shouldn't change oscillator crystal, but instead modify your kernel device tree to switch your UART to faster clock.

0 Kudos
Reply
4,529 Views
jadhav_lokesh
Contributor I

Dear @kef2 ,

Understood. But could you please help me with few more details, like -

Which device tree files exactly I should be looking into..??

I'm working with Solidrun's Humming Board.

Thanks,

Lokesh 

0 Kudos
Reply
4,464 Views
jadhav_lokesh
Contributor I

Dear @kef2 ,

Could you please guide me, which specific kernel file I should be touching in order to change UART Module clock.??

0 Kudos
Reply
4,444 Views
kef2
Senior Contributor V
  • which specific kernel file I should be touching

It depends on board you are using.

Looks like you are not in touch with kernel device tree. Sadly I don't have time to create detail instructions for You. 

0 Kudos
Reply
4,441 Views
jadhav_lokesh
Contributor I

Dear @kef2 ,

I'm using IMX8MP Humming Board from Solidrun. I've gone through all the dts and dtsi files, where UART modules are declared and clks also defined in there. But if I look deeper, I didn't found the place where I can change the clock frequency.

You can give me a generalize hint, a little more detailed. So, I can find it by myself.

Thanks for your response. 

Lokesh 

0 Kudos
Reply
3,338 Views
lukaschmela
Contributor I

Hello @jadhav_lokesh,

I am wondering if you were able to find a solution to setting the desired baud rate with your DTS. I am trying to reach 3 Mbaud/s but was not lucky enough to get there with the solution proposed by @kef2. The interface work perfectly in U-Boot when 115200 bauds/s is set, but as soon as I boot to Linux kernel with command line option console=ttyS5,3000000, the output gets lost somewhere between our UART2USB adapter and my serial console client. The adapter's LED does indicate there is some data transmission from the kernel, but gives no output either with 115200 baud/s or with 3 Mbauds/s. I am able to reconnect to another ARM64 CPU from a different manufacturer with 3Mbauds/s using the same HW and procedure, though.

Thanks!
Lukáš

0 Kudos
Reply
3,331 Views
kef2
Senior Contributor V

There is a list of "standard" baud rates, Linux supports. If your baudrate is not on that list, then the only practical way to get custom baudrate is to use TCSETS2 IOCTL. 

 

#include <stdlib.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <asm/termbits.h>
#include <sys/ioctl.h>
#include <unistd.h>

void main(void)
{
struct termios2 newtio;

int	fd = open( "/dev/ttymxc1", O_RDWR | O_NOCTTY);
	
	ioctl(fd, TCGETS2, &newtio);	
	newtio.c_cflag &= ~CBAUD;    //Remove current baud rate
	newtio.c_cflag |= CBAUDEX;    //Allow custom baud rate using int input
	newtio.c_ispeed = 1250000;    //Set the input baud rate
	newtio.c_ospeed = 1250000;    //Set the output baud rate
	ioctl(fd, TCSETS2, &newtio);

 

 

0 Kudos
Reply
3,071 Views
lukaschmela
Contributor I

Hello @kef2, thank you for quick reply. What do you mean by "standard" baud rates? Is it a limitation of NXP's serial driver? If so, is there a list of baud rates which are actually allowed by the driver for the iMX8MP processor? The Linux kernel supports baud rates up to 4 Mbaud/s incl. 3 Mbaud/s, as documented in the manual: https://man7.org/linux/man-pages/man3/termios.3.html. The UART2USB adapter we are using works correctly at 3 Mbaud/s with ARM64 processors from Marvell. Our use case requires early-boot access to the serial console with baud rate set at boot time.

0 Kudos
Reply
3,038 Views
kef2
Senior Contributor V
  • What do you mean by "standard" baud rates?

I meant baud rates, which Linux finds OK. Other not listed in Linux sources are not OK.

drivers/tty/tty_baudrates.c lists only these baud rates. Others like 1250000 can be activated with TCSETS2 ioctl. 

 

static const speed_t baud_table[] = {
0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800,
#ifdef __sparc__
76800, 153600, 307200, 614400, 921600, 500000, 576000,
1000000, 1152000, 1500000, 2000000
#else
500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000,
2500000, 3000000, 3500000, 4000000
#endif
};
 
static const tcflag_t baud_bits[] = {
B0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400,
B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800,
#ifdef __sparc__
B76800, B153600, B307200, B614400, B921600, B500000, B576000,
B1000000, B1152000, B1500000, B2000000
#else
B500000, B576000, B921600, B1000000, B1152000, B1500000, B2000000,
B2500000, B3000000, B3500000, B4000000
#endif
};

 

0 Kudos
Reply
3,032 Views
lukaschmela
Contributor I

Hello @kef2,

right, but this is precisely the resource I am referring to. Both tables list 3000000 baud/s as well. After all, the iMX8MP processor is not a SPARC platform.

Yet, the baud rate does not seem to work. What I don't know is if that is a limitation of the serial driver from NXP. And, if there are further limits imposed by the driver, which baud rates are actually supported?

0 Kudos
Reply
3,027 Views
kef2
Senior Contributor V

Low serial module clock question was touched already. Check your module clock. From imx8mp RM;

  • Due to the 16x oversampling of the incoming characters, module_clock frequency
    must always be greater or equal to 16x the maximum baud rate. For example, if max
    baud rate is 4 Mbit/s, module_clock must be greater or equal to 4 M x 16 = 64 MHz.
0 Kudos
Reply
4,439 Views
kef2
Senior Contributor V

Ok. 

In imx8mp RM see available settings

kef2_0-1682581212138.png

Determine in device how are they called in Linux jargon. dtsi's point to include/dt-bindings/clock/imx8mp-clock.h. You won't find there something like PLL1_DIV10, but somewhat equivalent with divider output frequency. In imx8mp-ab2.dts I found ready made example for you:

&uart1 { /* BT */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart1>;
	assigned-clocks = <&clk IMX8MP_CLK_UART1>;
	assigned-clock-parents = <&clk IMX8MP_SYS_PLL1_80M>;
	fsl,uart-has-rtscts;
	status = "okay";
};

You need those two assigned-xx lines with UARTn matching your UART instance. It could be SYS_PLL1_80M or something else from the list above "translated" to defines from imx8mp-clock.h.

3,438 Views
mengfei
Contributor III

hi,

Thanks for your reply!

0 Kudos
Reply
4,547 Views
joanxie
NXP TechSupport
NXP TechSupport

I just wonder how you set gstreamer pipeline with uart to transmit video stream? for how to set uart, maybe you can refer to the link as below:

"https://community.nxp.com/t5/i-MX-Processors/iMX6-UART-refuse-to-set-baud-rate-to-1-Mbps/m-p/704653"

0 Kudos
Reply