05-19-2020, 02:47 AM
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.
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.