Hello,
I would like to use UART on ROCKPro64 for bi-directional communication with Arduino Pro Mini.
According to documentation, UART4 TX, RX are connected to Pi-2 connector pins 19 and 21.
But there is no relevant device file - /dev/ttyS4. I can see only /dev/ttyS0 and /dev/ttyS2. I do not want to use these two, because they are already intended for Bluetooth and console.
How could I enable /dev/ttyS4 in my Linux system?
I am using rockpro64-debian-desktop-mrfixit-191226. ‘uname -a’ shows:
Linux Debian-Desktop 4.4.207 #1 SMP Fri Dec 27 11:35:59 EST 2019 aarch64 GNU/Linux
Thanks in advance!
Hi!
Finally, I have figured out, how to obtain the device file /dev/ttyS4. Guys, you could have told me that it is so easy!
Here the instruction, for the case somebody is so new to this area, as I am.
The Linux of Mrfixit2001 has already the necessary driver, because UART2 is active. It is just necessary to inform
it to activate this device. This is done in the Device Tree. Stored in the file /boot/rk3399-rockpro64.dtb.
UART4 uses the same pins as SPI1, so it is probably good idea to disable SPI1, while enabling UART4.
Step-by-step procedure (all executed as root):
1. Make backup of the current definitions:
cp /boot/rk3399-rockpro64.dtb /<somwhere>/rk3399-rockpro64.dtb.backup
2. Install dtc, to create readable version of Device Tree definitions:
apt-get install device-tree-compiler
3. Convert .dtb file to .dts one:
dtc -I dtb -O dts -f /boot/rk3399-rockpro64.dtb -o /<somwhere>/rk3399-rockpro64.dts
4. Disable SPI1 in the .dts file:
a. Search for line, which defines which section really deals with SPI1. The line is like this:
spi1 = "/spi@ff1d0000" by the way, ff1d0000 corresponds to SPI1 address in memory (can be found in the TRM document)
b. Search for the section spi@ff1d0000 { ... }
In this section change line:
status = "okay";
to:
status = "disabled";
5. Enable UART4:
a. Similarly, like for SPI1, find which section defines UART4. It is serial@ff370000 { ... }
b. In the section serial@ff370000 { ... } change line:
status = "disabled";
to:
status = "okay";
6. Convert the edited .dts file to .dtb:
dtc -I dts -O dtb -f /<somwhere>/rk3399-rockpro64.dts -o /<somwhere>/rk3399-rockpro64.dtb.UART4
7. Re-mount /boot to make it writable:
mount | grep boot -> /dev/mmcblk0p1 on /boot type vfat (ro, .......
umount /boot
mount /dev/mmcblk0p1 /boot
8. Put the new .dtb file in place of the old one:
cp /<somwhere>/rk3399-rockpro64.dtb.UART4 /boot/rk3399-rockpro64.dtb
After next reboot, the file /dev/ttyS4 is there, and can be used to communicate through pins 19 and 20.
Regarding /dev/ttyS2: I did a lot of testing and gymnastics to use it for two-way communication with Arduino.
Whatever I did, latest after few hours, the complete ROCPro64 was hanging. I think, using this UART requires
complete disabling console on it. Disabling of serial-getty is not enough.
Best regards,
Gienek.