Cannot read from serial port on Raspberry Pi

I've got the current 10.0 image running on the Pi. Actually, it boots about 50% of the time, but that's not my main problem.

I'm trying to read serial data from the RX pin. The remote end's TX bit is sending the letter X repeatedly. The ground of both devices is common. Here it is on my scope.

DSCN4433.JPG


If you look carefully, you will see:
Code:
START 0 0 0 1 1 0 1 0 STOP
As you can see there is 1 stop bit, no parity, 8 bits of data, and if you do the math, a bit width of 833us works out to 1200 baud.

I think I set up the device correctly:
Code:
root@raspberry-pi:~ # ./ttys
speed 1200 baud; 0 rows; 0 columns;
lflags: -icanon -isig -iexten -echo -echoe -echok echoke -echonl echoctl
  -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
  -extproc
iflags: -istrip -icrnl -inlcr -igncr -ixon -ixoff ixany -imaxbel ignbrk
  -brkint -inpck ignpar -parmrk
oflags: -opost onlcr -ocrnl tab0 -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl clocal -cstopb -crtscts -dsrflow
  -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
  eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;
  lnext = ^V; min = 1; quit = ^\; reprint = ^R; start = ^Q;
  status = ^T; stop = ^S; susp = ^Z; time = 0; werase = ^W;

However reading from the port yields nothing:
[EMAIL]root@raspberry-pi[/EMAIL]:~ # cat /dev/ttyu0

I did remove the port from ttys.

Help appreciated.
 
So it turns out the problem is in the driver itself. ttys do not work in FreeBSD 10.0 on the Raspberry Pi. Specifically, it appears to change baud rates to 1200, but keeps using 115200. It works correctly in FreeBSD 11.0.
 
So it turns out the problem is in the driver itself. ttys do not work in FreeBSD 10.0 on the Raspberry Pi. Specifically, it appears to change baud rates to 1200, but keeps using 115200. It works correctly in FreeBSD 11.0.
I'm not sure whether this means you already figured it out, but in case you didn't, I've been struggling with the same issue last night, in an attempt to get the serial console speed down to 9600 baud.

The problem is that the pl011-specific part of the uart driver, when ioctl'ed to obtain the baud rate, unconditionally reports 115200 baud/s. This makes sense since it seems to be pl011's default baud rate, but breaks when the boot loader already established a different baud rate.

While not being a proper solution, the rate can be changed at line 323 in sys/dev/uart/uart_dev_pl011.c. The offending code:
Code:
case UART_IOCTL_BAUD:
        *(int*)data = 115200;
        break;
 
Back
Top