Hobbyist Toolkit

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I use more Uart on Raspberry Pi CM4

Solved!
Go to solution

All,

    I am using raspi Cm4, as the documents stated out Cm4 exist 5 uart and i enable and dtoverlay uart2,uart3. however, in labview linx device not able to use them. how can i fix it?  

uart error.PNG

0 Kudos
Message 1 of 8
(2,478 Views)
Solution
Accepted by topic author Billy.Deng

The number of UARTs that Linx supports are hardcoded in the liblinxdevice.so library. But you are trying to use VISA instead and that should support additional serial ports IF they are properly installed in Linux. There is a potential issue with VISA recognizing those UART channels though. Traditionally Linux installs serial ports as ttyXXXYY in the /dev tree. XXX depends on the serial port driver that is used to access them and YY is an increasing number. Linux also likes to install many pseudo ttySomething devices that are not real serial ports, so VISA can't just go and try to detect every device starting with tty in its name. You would end up with several dozen VISA serial ports that can not be used for communicating with anything useful.

 

So you need to do some work on your Raspi.

 

First complication is that the environment the LabVIEW executable runs in is not directly the Raspbian host OS but a sort virtual machine running inside your host OS. This uses the Linux chroot system.

 

So you need to open a command line shell on your Raspi and then change into that chroot subsystem:

sudo schroot -r -c lv

This will change the prompt to indicate that you are now operating inside the LabVIEW chroot environment. 

 

Once you are in there you need to verify a few things about VISA.

 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019Ky8SAE

 

Points 1 to 3 should not be relevant. If that was not correctly setup you could not even connect to the ASRL1 port.

 

Rolf Kalbermatter
My Blog
Message 2 of 8
(2,413 Views)

Hi Billy
Did you solve it? I have same problem but I wanna use UART3 in CM4.

0 Kudos
Message 3 of 8
(927 Views)

yes, i did. please go back to see the solution.

0 Kudos
Message 4 of 8
(900 Views)

I read Rolfk's solution but it seems that in LINX just first serial (Serial0) is defined (Maybe because LINX is written for Raspberry 2 & 3). 

I activate UART3 and use it with python so my hardware works fine but in LabVIEW(LINX) I can't make it.

(UART1 works fine & charm.)

Did you change Raspbian parameters (like config.txt or cmdline.txt or...) ? Could you send for me your steps in Raspbian & your VI? ‌‌‌‌

0 Kudos
Message 5 of 8
(883 Views)

i just follow that and you need config overlay pins. then everything goes well

0 Kudos
Message 6 of 8
(878 Views)
Thank you for your time.. Is this correct? dtoverlay=uart3,txd3_pin=4,rxd3_pin=5
0 Kudos
Message 7 of 8
(854 Views)

Finally, I get my desired goal with these steps:
1- The kernel use of the serial port must be disabled in /boot/cmdline.txt file by removing this flag:

         console=serial0,115200

So, it should be something like this:

         console=tty1 root=PARTUUID=295be2ff-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
2- Add these flags in the /boot/config.txt file (if you want to use UART3):

         enable_uart=1

         dtoverlay=uart3,txd3_pin=4,rxd3_pin=5

Or these “dtoverlay” if want to use UART4 or UART5:

        dtoverlay=uart4,txd4_pin=8,rxd4_pin=9

        dtoverlay=uart5,txd5_pin=12,rxd5_pin=13
3- In your VI, when configure VISA port, use this syntax:

       ASRL3::INSTR
4- Use “VISA Find Resource” before read or write on VISA.

Untitled.png

 

 

 

0 Kudos
Message 8 of 8
(381 Views)