Hi,
I'm using an imx6qsabresd board with demo yocto images and I'm running a uart test,
The usb cable is connected to PC on /dev/ttymxc0.
I aim to open this as a file in C and write a string to it and then read back the data.
When I write the string I see it appear on the console as so.
root@imx6dlsabresd:/run/media/sdb1/test_cases# ./asyn
press 0 for gpio test and 1 for async test
1
enter word length
12
012345678901
however there is no string being read, perror prints success for read even though it has read 0 bytes (verified with prints) .
Is it because of incorrect termios settings?
this is my setting:
struct termios tty;
if (tcgetattr (fd, &tty) != 0)
{
printf ("error %d from tcgetattr", errno);
return -4;
}
cfsetospeed (&tty, speed);
cfsetispeed (&tty, speed);
tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; // 8-bit chars
// disable IGNBRK for mismatched speed tests; otherwise receive break as \000 chars
tty.c_iflag &= ~IGNBRK; // disable break processing
tty.c_lflag = 0; // no signaling chars, no echo,
// no canonical processing
tty.c_oflag = 0; // no remapping, no delays
tty.c_cc[VMIN] = 0; // read doesn't block
tty.c_cc[VTIME] = 5; // 0.5 seconds read timeout
tty.c_iflag &= ~(IXON | IXOFF | IXANY); // shut off xon/xoff ctrl
tty.c_cflag |= (CLOCAL | CREAD);// ignore modem controls,
// enable reading
tty.c_cflag &= ~(PARENB | PARODD); // shut off parity
tty.c_cflag |= parity;
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CRTSCTS;
if (tcsetattr (fd, TCSANOW, &tty) != 0)
{
printf ("error %d from tcsetattr", errno);
return -5;
}
Thanks.
Solved! Go to Solution.
Hi Sujay,
On i.MX6Q-SabreSDB board, UART1 is used for debugging port:
So it means that system is using UART1, you can't use it on application.
If you want to test UART, you can wire UART3 and test it, see below, please!
Hope above information is helpful to you.
Hava a nice day!
B.R,
Weidong
Hi Sujay,
On i.MX6Q-SabreSDB board, UART1 is used for debugging port:
So it means that system is using UART1, you can't use it on application.
If you want to test UART, you can wire UART3 and test it, see below, please!
Hope above information is helpful to you.
Hava a nice day!
B.R,
Weidong
Hi weidong.sun
Thank you for the input,
I got the dts file from the dtb in mfg tools following this link cross compiling - How to compile dts Linux device tree source files to dtb? - Stack Overflow
I then set node :serial@021ec000 status as okay and compiled dts and flashed the generated dtb, now I can see the serial port on the board as /dev/ttymxc2 however I'm unable to read from this port, is there any other change I need to make in the dts file?
this is the node:
serial@021ec000 {
compatible = "fsl,imx6q-uart", "fsl,imx21-uart";
reg = <0x21ec000 0x4000>;
interrupts = <0x0 0x1c 0x4>;
clocks = <0x2 0xa0 0x2 0xa1>;
clock-names = "ipg", "per";
dmas = <0xe 0x1d 0x4 0x0 0xe 0x1e 0x4 0x0>;
dma-names = "rx", "tx";
status = "okay";
};
Thanks
Hi Sujay,
UART3 is not supported in device tree, you should add the port to device tree.
It's usage in device tree should be like this:
Open imx6qdl-sabresd.dtsi in arch/arm/boot/dts directory.
------------------------------------------------------------------------
1.Adding iomux pins of UART3 TXD/RXD
&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hog>;
imx6qdl-sabresd {
......
pinctrl_uart3: uart3grp {
fsl,pins = <
MX6QDL_PAD_EIM_D24__UART3_TX_DATA 0x1b0b1
MX6QDL_PAD_EIM_D25__UART3_RX_DATA 0x1b0b1
>;
};
......
}
2. Adding UART3 node(enabling UART3 driver)
&uart3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart3>;
status = "okay";
};
---------------------------------------------------------
Try it , please!
Have a nice day!
B.R,
Weidong
Hi weidong.sun
I did as you've suggested and I can now see a port /dev/ttymxc2.
however when I do:
cat /dev/ttymxc2 &
echo hi > /dev/ttymxc2
there is no output.
Also to check pinctrl I ran
cat /sys/kernel/debug/pinctrl/pinctrl-handles|grep uart3
and output was
type: MUX_GROUP controller 20e0000.iomuxc group: uart3grp (0) function: imx6qdl-sabresd (0)
is this the right output? as I'm seeing uart3grp(0)
but for
cat /sys/kernel/debug/pinctrl/pinctrl-handles|grep uart1 I get
type: MUX_GROUP controller 20e0000.iomuxc group: uart1grp (20) function: imx6qdl-sabresd (0)
Thanks
Sujay
try this test:
Have a nice day!
B.R,
Weidong
Hi weidong.sun
There was a continuity error in the RX line because of which the test was failing.
The issue is resolved.
Thank you for all the support.