BLL
Posts: 203
Joined: Fri Jun 07, 2013 2:30 pm

Exar XR21B1411 driver

Thu Jan 12, 2017 4:07 pm

Hi, Can anyone help please. I have a USB to RS485 converter CC-USB-RS485-150U, which uses the Exar 21B1411.

On plugging it into my RPi 3 (Raspbian jesse) and doing lsusb, I see an entry that says 04e2:1411 Exar corporation and nothing else. However, the device is not assigned a ttyUSBx port. I presume that there is no driver on the RPi 3?
I went to Exar's site, but where it listed linux drivers, there was no download link! I saw something on github, but I couldn't make head or tail of what they were saying and how to proceed!!
Can anyone help me to get this working please?

Thanks

Brian

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7149
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Exar XR21B1411 driver

Thu Jan 12, 2017 4:35 pm

Seeing as https://github.com/raspberrypi/linux/is ... -241895241 is reporting that he is trying to build the driver, and I can't see anything applicable in the kernel tree, I think it is a fair assumption that the driver isn't supported upstream as yet, and the Pi kernel follows upstream for these sorts of devices.

https://github.com/shenki/exar-uart-driver claims to be a suitable driver against kernel 3.13 (Pi is now on 4.4, and will soon be on 4.9, so it may need some work).
Some history on https://bugs.debian.org/cgi-bin/bugrepo ... bug=804350
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

BLL
Posts: 203
Joined: Fri Jun 07, 2013 2:30 pm

Re: Exar XR21B1411 driver

Thu Jan 12, 2017 6:24 pm

Hi,

Thanks for the reply but it goes over my head!

"I think it is a fair assumption that the driver isn't supported upstream as yet, and the Pi kernel follows upstream for these sorts of devices."
Sorry for my ignorance, but what does this mean?
Thanks
Brian

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2076
Joined: Thu Jul 11, 2013 2:37 pm

Re: Exar XR21B1411 driver

Thu Jan 12, 2017 8:53 pm

tl;dr of our Linux kernel build process:

1. We operate a "downstream" kernel. This is one that has custom patches applied to the official releases from kernel.org.
2. We maintain a relatively small delta between the kernel.org releases and our downstream "base" branches. In other words, patches that appear in "upstream" are replicated in our "downstream" kernel after a relatively short period of time.
3. We are a "downstream" kernel maintainer because we have custom patches that aren't "upstreamed", i.e. we maintain and apply a set of changes by ourselves. This is typically limited to patches concerning pi-specific hardware. With certain exceptions, we also apply patches that short-circuit the upstream kernel release cycle (for example, obvious fixes or backported patches).
4. We don't have any drivers supported in our downstream kernel that are not exclusive to the Pi.

Thus with random vendor hardware, we won't incorporate their bespoke driver into our separate version of the Linux kernel. The optimal way to get the device supported on a Pi is to go through the kernel patch submission process that gets the driver incorporated into upstream Linux.
Rockets are loud.
https://astro-pi.org

exarinterface
Posts: 1
Joined: Fri Jan 13, 2017 7:01 pm

Re: Exar XR21B1411 driver

Fri Jan 13, 2017 7:16 pm

Hi Brian,

The XR21B1411 is compatible with the USB CDC-ACM driver that is included in the Linux kernel. The XR21B1411 would show up as a /dev/ttyACMxx device. This would work for an RS-232 serial port with a full-modem interface.

However, the CDC-ACM driver will probably not work since the OEM device that you are using is a USB to RS-485 converter. In this case, you would need to use the custom driver from Exar's website. You can download the latest custom drivers here: https://www.exar.com/design-tools/software-drivers

You would need to download, make any modifications if necessary, then compile the driver. See the "readme" file for details. You will most likely need to use a cross-compiler. Instructions do that can be found here: https://www.raspberrypi.org/documentati ... uilding.md

If you need further technical support, please feel free to contact us directly at [email protected].

Regards,
Patong

BLL
Posts: 203
Joined: Fri Jun 07, 2013 2:30 pm

Re: Exar XR21B1411 driver

Sat Jan 14, 2017 11:30 am

Hi both
Thanks for the replies.

Patong, the link you give for download doesn't allow the linux driver to be downloaded as there is nothing to click on, so I can't go any further! Do you have a link that works please?

My reading so far says that the CDC-ACM driver won't work with RS485..

I will look at making a request, but I have never done so and will need to find out how.

Thanks

Brian

pcmm
Posts: 24
Joined: Tue Feb 06, 2018 3:18 pm

Re: Exar XR21B1411 driver

Wed Feb 07, 2018 2:41 pm

Were you able to get this driver running? I've been working for days on this and can't get it to install.

jcalvarez
Posts: 6
Joined: Thu Oct 24, 2013 12:37 pm

Re: Exar XR21B1411 driver

Wed Feb 07, 2018 3:07 pm

Late to the party, but try to add your vendor and product id to the driver:

sudo echo "04e2 1411" > /sys/bus/usb/drivers/cdc_acm/new_id

pcmm
Posts: 24
Joined: Tue Feb 06, 2018 3:18 pm

Re: Exar XR21B1411 driver

Thu Feb 08, 2018 1:21 am

OK,

I've got the driver installed, but why do I have to re run the "make" and "insmod" commands after every boot to get the usb devices recognized. Isn't there a way to make these drivers permanent?

Jason_25
Posts: 120
Joined: Tue Oct 20, 2015 6:25 pm

Re: Exar XR21B1411 driver

Thu Feb 08, 2018 2:44 am

/etc/modules will let you load the driver automatically at boot time. You should not have to be running make more than once.

pcmm
Posts: 24
Joined: Tue Feb 06, 2018 3:18 pm

Re: Exar XR21B1411 driver

Thu Feb 08, 2018 1:32 pm

Jason_25 wrote:
Thu Feb 08, 2018 2:44 am
/etc/modules will let you load the driver automatically at boot time. You should not have to be running make more than once.
Thanks, but what do I put in that file to make it load the driver?

Jason_25
Posts: 120
Joined: Tue Oct 20, 2015 6:25 pm

Re: Exar XR21B1411 driver

Thu Feb 08, 2018 6:05 pm

It should just be the name of the module you load with insmod minus the path or the .ko part. The top part of /etc/modules, if it already exists, has a brief explanation also.

pcmm
Posts: 24
Joined: Tue Feb 06, 2018 3:18 pm

Re: Exar XR21B1411 driver

Thu Feb 22, 2018 2:30 pm

Jason_25 wrote:
Thu Feb 08, 2018 6:05 pm
It should just be the name of the module you load with insmod minus the path or the .ko part. The top part of /etc/modules, if it already exists, has a brief explanation also.
Sorry for the late reply. Thanks that works. How do I get the Kernal to load this driver instead of the cdc-acm driver without blacklisting the cdc-acm driver?

I need the cdc-acm driver for an Arduino Mega R3 that I want to connect.

ingbag
Posts: 1
Joined: Mon Apr 09, 2018 6:32 pm

Re: Exar XR21B1411 driver

Mon Apr 09, 2018 7:05 pm

Hi guys,
anyone made it to make the adapter mentioned in the beginning running on a RPi? (By the way: It's a cable for data-transfer from a Tracer 2210A Solar charge controller.)

I've upgraded my RPi3 to latest Kernel 4.14.32 and compiled the driver "1B" from EXAR-Website: https://www.exar.com/design-tools/software-drivers. After

Code: Select all

insmod xr_usb_serial_common.ko 

everything looks fine: i got a /dev/ttyXRUSB0 and my python-Script which I've adapted from this example: http://www.solarpoweredhome.co.uk/ seems to speak to it. At least the Debug-output of Python shows the outgoing modbus-messages ... but without answer.

Anyway, a look at /dev/ttyXRUSB0 with jpnevulator after starting the Script

Code: Select all

 jpnevulator --tty /dev/ttyXRUSB0 --read 
or

Code: Select all

 jpnevulator --tty /dev/ttyXRUSB0 --write 
doesn't show any traffic on the interface.

Anyone?
Thanks in advance!
Andreas

P.S.: On Windows i got the setup running, so there aren't hardware issues. Me and my friend, who is a full-time software-developer (not raspberry but embedded-linux) are about to set the white flag after three days working on my RPi3

mkomar
Posts: 1
Joined: Sat Sep 22, 2018 12:44 am

Re: Exar XR21B1411 driver

Sat Sep 22, 2018 12:46 am

Has anybody actually gotten this totally working? Sounds like a number of people have gotten close.

jamief
Posts: 3
Joined: Fri Mar 08, 2019 5:09 am

Re: Exar XR21B1411 driver

Fri Mar 08, 2019 5:23 am

I'm fighting with this as well. I had to build the driver for my mint PC and managed to get it working just fine there. When I do the same thing on my pi zero W it doesn't work I noticed there is a difference in dmsg
on the PC I get

Code: Select all

2586804.503482] usb 3-4: new full-speed USB device number 46 using xhci_hcd
[2586804.649880] usb 3-4: New USB device found, idVendor=04e2, idProduct=1411
[2586804.649882] usb 3-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[2586804.649883] usb 3-4: Product: XR21B1411
[2586804.649884] usb 3-4: Manufacturer: Exar Corp.
[2586804.649884] usb 3-4: SerialNumber: Q7155832051
[2586804.650484] cdc_xr_usb_serial 3-4:1.0: This device cannot do calls on its own. It is not a modem.
[2586804.650502] cdc_xr_usb_serial 3-4:1.0: ttyXR_USB_SERIAL0: USB XR_USB_SERIAL device
on the Pi zero WI get

Code: Select all

90.962936] usb 1-1: new full-speed USB device number 3 using dwc_otg
[   90.963251] Indeed it is in host mode hprt0 = 00021501
[  91.204592 usb 1-1: New USB device found, idVendor=04e2, idProduct=1411
[   91.204609] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   91.204616] usb 1-1: Product: XR21B1411
[   91.204623] usb 1-1: Manufacturer: Exar Corp.
[   91.204630] usb 1-1: SerialNumber: Q7155832051
[   91.223610] cdc_xr_usb_serial 1-1:1.0: This device cannot do calls on its own. It is not a modem.
[   91.223706] cdc_xr_usb_serial 1-1:1.0: ttyXR_USB_SERIAL0: USB XR_USB_SERIAL device
Notice that one is using xhci_hcd and the other is using dwc-otg.
I'm guessing this is because the zero W is usb 2.0? Is there any chance this is what's causing the driver not to work? I'm at a loss on where to go from here with this.

jamief
Posts: 3
Joined: Fri Mar 08, 2019 5:09 am

Re: Exar XR21B1411 driver

Mon Mar 25, 2019 11:32 pm

I got this working today. I was missing one thing...

sudo chmod 777 /dev/ttyXRUSB0

I don't know why that was needed on the pi but not on my mint PC but that was all that it took

I was using the driver found at https://github.com/kasbert/epsolar-trac ... master.zip as it has the rs-485 handling activate. I basically followed the instructions in the readme to get the driver installed and the cdc-acm driver blacklisted. After that the /dev/ttyXRUSB0 was showing up correctly but I couldn't make my program read correctly

Code: Select all

from pymodbus.client.sync import ModbusSerialClient as ModbusClient
import serial
from pymodbus.pdu import ModbusRequest
from pymodbus.transaction import ModbusRtuFramer
client = ModbusClient(method = 'rtu', port = '/dev/ttyXRUSB0', baudrate = 115200, timeout=10, parity ='N')
client.connect()


result = client.read_input_registers(0x3100,1,unit=1) # Request the range of registers that hold the solar/battery realtime data (3100 - 3105)
sV = float(result.registers[0] / 100.0) # Solar voltage is register 3100, divide by 100
print sV
client.close()
The parity='N' also matters. A lot of the code that I based this off of uses parity='E'. 'N' or don't specify parity at all works.

hopefully this helps someone else out

miroslavzeleznik1986
Posts: 1
Joined: Sat May 04, 2019 2:58 pm

Re: Exar XR21B1411 driver

Mon May 06, 2019 7:00 am

I got this working as well on my Raspberry 3B+ with Node-Red.

I would like to thank to Jamief for the permission tip (sudo chmod 777 /dev/ttyXRUSB0) because without that Node-Red didn't want to interact with the converter.

I couldn't get it to work with original driver from Exar site so I used driver from GitHub mentioned in Jamiefs post. I basically followed the readme. I compiled the driver, unloaded the original driver (cdc-acm) from the system and I blacklisted it. Then I loaded the newly compiled driver and the controller started to show up correctly as /dev/ttyXRUSB0.

I configured Modbus-client-node in Node-Red. I used RTU-buffered and baud rate of 115200 to match with my Modbus device (Epever Solar charge controller)

Everything seems to be working so far ;)

jamief
Posts: 3
Joined: Fri Mar 08, 2019 5:09 am

Re: Exar XR21B1411 driver

Mon May 06, 2019 11:26 pm

I found an issue with the chmod fix. Every time the machine reboots or the device gets unplugged from the USB you'll need to run chmod again. Instead add the user that is running to the dialout group.

sudo adduser "username" dialout

That group automatically gets read/write to tty

Zanderama
Posts: 3
Joined: Sat May 25, 2019 6:10 am

Re: Exar XR21B1411 driver

Sat Jun 22, 2019 1:50 pm

Hi all - thanks very much for this thread, I will try the suggestions out too.

I've been pulling my hair out most of the day, as the EPsolar / EPever cable for my LS1024B seemed to work and be detected, but was getting no data, despite it working on Windows 10 with some cajoling. It sounds like, as with Windows10, the Pi needs an extra driver on top of the serial port to actually be able to talk to the Exar controller. A little surprising its so involved for what's claimed to be such a simple protocol :)

My Pi seemed to detect

Code: Select all

/dev/ttyACM0
which I thought might be communicable for MODBUS RS-485, and

Code: Select all

python -m serial.tools.list_ports -v
found the 'port'

Code: Select all

/dev/ttyACM0
    desc: XR21B1411
    hwid: USB VID:PID=04E2:1411 SER=R2724608251 LOCATION=1-1.2:1.0
After installing lots of MODBUS tools to try and get 'something' I found https://minimalmodbus.readthedocs.io/en ... eadme.html was very user-friendly and low-level enough to debug. Also, some of the most helpful documentation on MODBUS too!

I look forward to trying it out on some working data soon hopefully.

Edited to add - just got it all working, thanks! Though currently 'losing' /dev/ttyXRUSB0 on reboot, I'll look into. Suggestions welcome, currently I just 'insmod' again. I've got the 'blacklist' setup as per driver README.

Also, first program to extract good data from LS1024B goes to this one-file C project - https://github.com/pconroy328/epsolar-landstar-LS1024B though the Python Epsolar Tracer worked well too - https://github.com/kasbert/epsolar-tracer/
Last edited by Zanderama on Sun Jun 23, 2019 10:25 am, edited 2 times in total.

Zanderama
Posts: 3
Joined: Sat May 25, 2019 6:10 am

Re: Exar XR21B1411 driver

Sat Jun 22, 2019 11:33 pm

I seem to have got the module loaded automatically at boot with :-

as root :-

Code: Select all

XRMODPATH=/lib/modules/`uname -r`/kernel/drivers/xr_usb_serial_common
mkdir $XRMODPATH
cp xr_usb_serial_common.ko $XRMODPATH/
depmod
It was also interesting to note that the default 'pi' user is already part of the 'dialout' group so didn't need to add that group or chmod 777 /dev/ttyXRUSB0

Awesome :)

alexpatcas
Posts: 1
Joined: Thu Aug 22, 2019 4:12 pm

Re: Exar XR21B1411 driver

Thu Aug 22, 2019 4:15 pm

Hi all,

Is there any way you can post a step by step on how to get this working? I've been looking everywhere for a way to make this work.

Thanks in advance

Return to “General discussion”