Gpio + uart (not the debug-port)

connected an arduino (with levelshifter) to GPIO Pin 8/10 (should be uart0=11002000=ttyS1)

set speed via stty -F /dev/ttyS1 9600 raw

cat /dev/ttyS1

nothing happens

now using minicom (9600 8n1,flow:off) with ttys2 and i’ve got the input from arduino (keepalives every 60 seconds), why ttyS2??

seems that i have an error in my notes…looked in schematics again.

summary:

pin 8/10 = uart1 (tx/rx) = 11003000 = ttyS2
pin 11/13 = uart0 (tx/rx) = 11002000 = ttyS1

read works, but i can not send via minicom/bash

#!/bin/bash
DEV=/dev/ttyS2
while read line; do
    echo "["$(date "+%Y-%m-%d %H:%M:%S")"] from Arduino: "$line
done < <(cat $DEV)

here i see my keepalives…if i try to send via

echo "AT" >/dev/ttyS2

i get no response (my arduino sends back “AT”-Strings)…arduino is connected also via usb to my workstation, if i send same string via ardiono-console, i see the response in the console and my script-output…so there is a problem with sending to the device (same construction works with raspi [script+send on another terminal via echo])

seems gpio (also uart) are not set to high-level…further debug here: https://github.com/BPI-SINOVOIP/BPI-R2-bsp/issues/17

got GPIO working, infos here

no idea currently about uart-tx, can anybody confirm, that is not working (maybe i doing something wrong)

is it enough to add the uart0/1 blocks to mt7623.dtsi and set the status to ok in bpi dts? anything needded for sending, because tx is not working?

tried this also with 4.14…also no TX (sending), and got uart1 not working (no device)

any idea?

Hello Gary,

can you please talk to the Hardware Engineers, where the position is of TP47,48 on the Board :-).

Thanks a lot, René

Hi Rene

QQ图片20171219163813

Above image shows the position of both TP48 and TP47

any idea about uart-tx? have the same problem in 4.14, too

what uart port does you use? i have tested uart0 and it works fine whose pinout from the 11,13 on the 40 pins out.

Tried both (8/10,11/13)

both are enabled, but Uart1 not found in 4.14

pin 8/10 = uart1 (tx/rx) = 11003000 = ttyS2
pin 11/13 = uart0 (tx/rx) = 11002000 = ttyS1

How did you test it? I use an arduino nano with level-shifter which sends keepalives (which i receive) and sends back what it receive (got no resonse if i send)

uart0, uart1, uart2 all work in my setup with kernel 4.15 rc1. for uart3, i will test it . but it seems having not pin out for it on the board. the way i test is using loopback.

loopback = wire rx to tx?

found out, that the problem seems to be the arduino…have my circuit placed on raspberry, where it works before…

if usb is connected to pc, serial is only receiving from it…if i power arduino via cellular-powersupply, it works with raspberry…

can you please look in my dts(i) why uart1 (11003000) not found in system? also tried to put uart2 in dts before others like i’ve done in dtsi, but without luck

@garywang

can you please help with the following error messages:

[    0.925251] mt6577-uart: probe of 11003000.serial failed with error -28
[ 9214.026213] mt6577-uart 11003000.serial: Unbalanced pm_runtime_enable!
[ 9214.026262] mt6577-uart: probe of 11003000.serial failed with error -28
[ 9497.466453] mt6577-uart 11003000.serial: Unbalanced pm_runtime_enable!

Thanks a lot, René

seems that in kernel 4.14 the fallback-driver mt6577 is used, which can only control 2 uarts

if i disable uart0 then uart1 is found

[14:37] root@bpi-r2:~# dmesg | grep tty
[    0.000000] Kernel command line: board=bpi-r2 console=earlyprintk fbcon=map:0 console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait service0
[    0.230738] console [ttyS0] disabled
[    0.250928] 11004000.serial: ttyS0 at MMIO 0x11004000 (irq = 195, base_baud = 1625000) is a ST16650V2
[    0.918903] console [ttyS0] enabled
[    0.943324] 11003000.serial: ttyS1 at MMIO 0x11003000 (irq = 196, base_baud = 1625000) is a ST16650V2

nice now here is 11003000 aka uart1

here the /sys-tree if all uart are enabled in dts:

[14:30] root@bpi-r2:~# find /sys -name '*serial*'
/sys/devices/platform/11003000.serial
/sys/devices/platform/11230000.mmc/mmc_host/mmc1/mmc1:0001/serial
/sys/devices/platform/11240000.mmc/mmc_host/mmc0/mmc0:0007/serial
/sys/devices/platform/1a240000.usb/usb3/serial
/sys/devices/platform/1a240000.usb/usb4/serial
/sys/devices/platform/11004000.serial
/sys/devices/platform/1a1c0000.usb/usb1/serial
/sys/devices/platform/1a1c0000.usb/usb2/serial
/sys/devices/platform/11002000.serial
/sys/devices/platform/serial8250
/sys/devices/platform/11005000.serial
/sys/firmware/devicetree/base/serial@11004000
/sys/firmware/devicetree/base/aliases/serial2
/sys/firmware/devicetree/base/serial@11003000
/sys/firmware/devicetree/base/serial@11005000
/sys/firmware/devicetree/base/serial@11002000
/sys/fs/cgroup/systemd/system.slice/setserial.service
/sys/fs/cgroup/systemd/system.slice/system-serial\x2dgetty.slice
/sys/fs/cgroup/systemd/system.slice/system-serial\x2dgetty.slice/[email protected]
/sys/fs/cgroup/systemd/system.slice/etc-setserial.service
/sys/bus/platform/devices/11003000.serial
/sys/bus/platform/devices/11004000.serial
/sys/bus/platform/devices/11002000.serial
/sys/bus/platform/devices/serial8250
/sys/bus/platform/devices/11005000.serial
/sys/bus/platform/drivers/mt6577-uart/11004000.serial
/sys/bus/platform/drivers/mt6577-uart/11002000.serial
/sys/bus/platform/drivers/serial8250
/sys/bus/platform/drivers/serial8250/serial8250
/sys/bus/pci/drivers/exar_serial
/sys/bus/pci/drivers/serial

4.4.x seems to use mt2712

Linux bpi-r2 4.4.107-BPI-R2-Kernel #13 SMP Thu Dec 21 13:36:53 CET 2017 armv7l
[14:53] root@bpi-r2:~# find /sys -name '*serial*'
/sys/fs/cgroup/systemd/system.slice/etc-setserial.service
/sys/fs/cgroup/systemd/system.slice/setserial.service
/sys/fs/cgroup/systemd/system.slice/system-serial\x2dgetty.slice
/sys/fs/cgroup/systemd/system.slice/system-serial\x2dgetty.slice/[email protected]
/sys/bus/pci/drivers/serial
/sys/bus/platform/devices/11004000.serial
/sys/bus/platform/devices/11003000.serial
/sys/bus/platform/devices/serial8250
/sys/bus/platform/devices/11002000.serial
/sys/bus/platform/drivers/serial8250
/sys/bus/platform/drivers/serial8250/serial8250
/sys/bus/platform/drivers/mt2712-uart/11004000.serial
/sys/bus/platform/drivers/mt2712-uart/11003000.serial
/sys/bus/platform/drivers/mt2712-uart/11002000.serial
/sys/devices/platform/11230000.mmc/mmc_host/mmc1/mmc1:0001/serial
/sys/devices/platform/11004000.serial
/sys/devices/platform/11003000.serial
/sys/devices/platform/1a1c0000.usb/usb1/serial
/sys/devices/platform/1a1c0000.usb/usb2/serial
/sys/devices/platform/serial8250
/sys/devices/platform/1a240000.usb/usb3/serial
/sys/devices/platform/1a240000.usb/usb4/serial
/sys/devices/platform/11002000.serial
/sys/devices/platform/11240000.mmc/mmc_host/mmc0/mmc0:0007/serial
/sys/firmware/devicetree/base/serial@11002000
/sys/firmware/devicetree/base/serial@11003000
/sys/firmware/devicetree/base/serial@11004000

@garywang can you explain, where mt2712 is loaded for uart?

maybe here

../BPI-R2-4.4/linux-mt/drivers/tty/serial/8250/8250_mtk.c:796:	{ .compatible = "mediatek,mt2712-uart" },
../BPI-R2-4.4/linux-mt/drivers/tty/serial/8250/8250_mtk.c:804:		.name		= "mt2712-uart",

but i’ve not found 8250 in the related dts(i) for bpi-r2

The cause for you guys only can let 2 uarts enabled is I guessed you only allow 2 ports for 8250 driver. You have to configure again with menuconfig.

1 Like
  │ Symbol: SERIAL_8250_NR_UARTS [=2]                                                                             │  
  │ Type  : integer                                                                                               │  
  │ Prompt: Maximum number of 8250/16550 serial ports                                                             │  
  │   Location:                                                                                                   │  
  │     -> Device Drivers                                                                                         │  
  │       -> Character devices                                                                                    │  
  │         -> Serial drivers                                                                                     │  
  │ (6)       -> 8250/16550 and compatible serial support (SERIAL_8250 [=y])                                      │  
  │   Defined at drivers/tty/serial/8250/Kconfig:169                                                              │  
  │   Depends on: TTY [=y] && HAS_IOMEM [=y] && SERIAL_8250 [=y]                                                  │  

:wink: good to know its configurable…

-CONFIG_SERIAL_8250_NR_UARTS=2
-CONFIG_SERIAL_8250_RUNTIME_UARTS=2
+CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4


Linux bpi-r2 4.14.8-00022-gb3e6160-dirty #47 SMP Thu Dec 21 15:53:13 CET 2017 armv7l
[15:56] root@bpi-r2:~# find /sys -name '*serial*'
[15:56] root@bpi-r2:~# dmesg | grep tty
[    0.000000] Kernel command line: board=bpi-r2 console=earlyprintk fbcon=map:0 console=ttyS0,115200 root=/dev/mmcbl0
[    0.231181] console [ttyS0] disabled
[    0.251356] 11004000.serial: ttyS0 at MMIO 0x11004000 (irq = 195, base_baud = 1625000) is a ST16650V2
[    0.919335] console [ttyS0] enabled
[    0.943721] 11002000.serial: ttyS1 at MMIO 0x11002000 (irq = 196, base_baud = 1625000) is a ST16650V2
[    0.973765] 11003000.serial: ttyS2 at MMIO 0x11003000 (irq = 197, base_baud = 1625000) is a ST16650V2
[    4.306955] systemd[1]: Expecting device dev-ttyS0.device...

kernel 4.14.8 with uarts enabled: https://drive.google.com/drive/folders/1EGN1TvqCpDHdOAS-mjRg9ipi0kahnOUV?usp=sharing

Yes, you got the points.

@linkerosa can you explain how in 4.14 gpio-read and pwm works?

tried uart again:

running that on one terminal:

#!/bin/bash
DEV=/dev/ttyS2
stty -F ${DEV} 9600 cs8 -cstopb -parenb
while read line; do
    echo "["$(date "+%Y-%m-%d %H:%M:%S")"] Arduino: "$line
done < <(cat $DEV)

and on the other

[17:20] root@bpi-r2:~# stty -F /dev/ttyS2 sane
[17:20] root@bpi-r2:~# stty -F /dev/ttyS2 9600 cs8 -cstopb -parenb
[17:20] root@bpi-r2:~# echo "blahblubb">/dev/ttyS2

and got some weired chars…same config (9600b 8N1) on raspberry works, also tried with minicom, seems also work…but not with the cat-loop

i think i have got it working:

stty -F ${DEV} 9600 cs8 -cstopb -parenb raw -echo 

should be the right setting. full config, if anyone have problems:

root@bpi-r2:~# stty -F /dev/ttyS2 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

Gpio read is described here: GPIO Python or shell and of. Course in my wiki http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:gpio

Hello,

Is there a way to get serial working from the box (in compiled image)? I understand everyone here is a linux engineer but how people without this kind of background can get it working?

Thanks in advance,

You can use debian/ubuntu-images and installing one my compiled kernels (4.4 or 4.14). I have activated the uart-nodes.

The configuration of the serial-port itself depends on your device. Basicly you can use raw-mode with 8n1 and desired speed (documentation of your device)

1 Like