FX30S RS485 port - cannot set termination resistor (GPIO 63)


I’m trying to get a FX30S to communicate with an rs485 device, but for some reason it is not possible to set the GPIO for rs485 termination resistor. rs485 mode can be set using the python script from the manual, but setting termination fails, as GPIO63 is not exported under /sys/class (and consequently no rs_term under /sys/devices/platform/msm_serial_hsl.0)

The UARTs are configured as follows:


!MAPUART: 17,16

/dev/ttyHSL0 exists, and seems to work

I’m fairly new to yocto/Legato/

  1. How do I get GPIO63 to be exported for usage?

  2. The serial interface always reverts to rs232 mode on reboot

    Can this be set from Legato app, or do I need to change the startup scripts for this?

    • Is it possible to verify basic communication from linux console, or is a Legato app necessary to talk to the serial port? I would like to use something like the below shell script to verify that the communication is working and that the rs485 device responds as it has been verified to do with rs485->usb converver.


disable rs232 mode

#echo 0 > /sys/class/gpio/gpio59/value

set 9600 8n1 mode

stty -F /dev/ttyHSL0 9600 cs8 -cstopb -parenb raw -echo

enable rs485 transmitter

echo 1 > /sys/class/gpio/gpio60/value

send command

echo -ne “\x3a\x04\x01\x02\x07” > /dev/ttyHSL0

disable rs485 transmitter

echo 0 > /sys/class/gpio/gpio60/value

#enable rs485 receiver

echo 0 > /sys/class/gpio/gpio61/value

show command reply in Hex format

hexdump -C < /dev/ttyHSL0

  1. Are there any sample app’s available that use the FX30S serial port? I would greatly appreciate examples of how to use transmit/receive, but haven’t been able to find anything at all online.

Thank you


Hey, I’m also using the FX30s.

I don’t have a solution to the termination resistor, but I can share some RS-485 code in case it saves you some time. Please post an update if you figure something out with GPIO63.


version: 2.0
sandboxed: false // can't modify rs485 mode if sandboxed
start: auto

        // Configuration object for RS-232/485 mode
        '/sys/devices/platform/msm_serial_hsl.0/rs_mode' '/sys/devices/platform/msm_serial_hsl.0/'
        // RS-485
        [rw] /dev/ttyHSL0 /dev/ttyHSL0



#define SSENSOR_TTY      "/dev/ttyHSL0"
#define SENSOR_TTY_MODE    "/sys/devices/platform/msm_serial_hsl.0/rs_mode"
#define SENSOR_TTY_MODE_STR   "1"

// Open and lock serial port
SensorFd = le_tty_Open(SENSOR_TTY, O_RDWR | O_NOCTTY | O_NDELAY);
le_tty_SetBaudRate(SensorFd, SENSOR_TTY_BAUD_RATE);
le_tty_SetFraming(SensorFd, 'N', 8, 1);
le_tty_SetRaw(SensorFd, 0, 0);

// Configure serial port to be RS-485
int rsModeFd;
LE_DEBUG("rs_mode open: %s", strerror(errno));
LE_DEBUG("rs_mode write: %s", strerror(errno));

// io
write(SensorFd, "hello!", strlen("hello!"));
rxBufferLen = read(SensorFd, rxBuffer, sizeof(rxBuffer));



Thank you very much for your reply and the example code.

Question: Are you not supposed to set the rs485 transmit/recieve mode manually from c in order to write/read from it halfduplex?


Oh, that’s a good question. No, it’s not necessary to manually set the RS485 RX/TX mode.

I’d guess that what’s happening is that hardware flow control is force-enabled somewhere under the hood and RTS/CTS are routed onto the transmit/receive enable pins of the SN65HVD72 transceiver, so the RS-485 interface is in listen mode whenever it’s not actively transmitting.

Since it isn’t necessary, I’ve edited the example code to remove the call to le_tty_SetFlowControl


Thank you very much

May I impose on you again to ask what firmware version you are running on your FX30S, and whether you can see gpio63 from the filesystem? I’m running the newest downloadable version from source.sierrawireless.com

root@fx30s:~# cm info firmware
SWI9X15Y_07.11.22.00 r33729 CARMD-EV-FRMWR1 2017/01/11 18:04:06

After new factory reset, I’m now able to get my commands echoed back from the serial port in the Legato App, which happens only when the rs485 device is connected and turned on, so it seems I’m on the right track, but still not reading the expected reply. However, by accident, I found out that getting 0x11 (XON) echoed back will silence the rest of the command sequence, so it seems that ttyHSL0 on my FX30S is running Software Flow Control by default, if no mode has been set with le_tty_SetFlowControl.

I also found out from stopping/starting the gpioService app running on the device, that GPIO63 is actually advertised there,

Aug 17 23:37:02 fx30s user.info Legato: INFO | gpioService[28950]/sysfsGpio T=main | gpioSysfs.c _sysfsGpio_COMPONENT_INIT() 9658 | Starting GPIO Service for Pin 63

…so I guess I just need to learn to use the GPIO api to enable termination resistor in the app.
Would really have liked to be able to use simple command line to verify the communications before adding further complexity, but I guess it just isn’t possible…


I’m using the version downloaded from:


root@fx30s:~# legato version; fwupdate query
Connecting to service ...
Firmware Version: SWI9X15Y_07.11.22.00 r33729 CARMD-EV-FRMWR1 2017/01/11 18:04:06
Bootloader Version: SWI9X15Y_07.11.22.00 r33729 CARMD-EV-FRMWR1 2017/01/11 18:04:06
Linux Version: 3.14.29ltsi-a00e464379_3f15cd39ad #2 PREEMPT Mon Feb 20 11:11:17 PST 2017
FX30 Version: R13.1.2.004

I don’t have gpio63 in my /sys/

root@fx30s:~# ls /sys/class/gpio/
export       gpio21       gpio24       gpio32       gpio38       gpio44       gpio46       gpio48       gpio50       gpio52       gpio54       gpio57       gpio60       gpio62       gpiochip1    gpiochip200  gpiochip94
gpio2        gpio22       gpio25       gpio36       gpio43       gpio45       gpio47       gpio49       gpio51       gpio53       gpio56       gpio58       gpio61       gpio7        gpiochip100  gpiochip88   unexport

Are you up and running with the development environment? I kept notes on the setup process:

Follow instructions here:

Use legato-spm -i to install the WP85xx toolchain

Build the GPIO demo app:
find ~ -name gpioCf3*
instapp *.update


Yes, I have a working Developer studio env. running and is able to deploy apps.
I’m also now able to read the port from the Legato App, and getting my command seqences looped back when, and only when, the rs485 device in question is connected, so it seems to be on the edge of working, I just need to figure out why I’m not getting the expected response…

It looks like we have identical setups, the reason I’m so concerned about gpio63, is that the manual for the FX30S clearly states that it should be possible to set RS485 termination with the python script supplied in the FX30S manual, which for me fails with an error that appears to be related to the “missing” sysfs gpio. That makes me worry if something fundemental isn’t working as it is supposed to, which could lead to lots of wasted time with the app.
I guess lack of termination wouldn’t necessarily be a big issue with a short cable length and 9600 baud between 2 devices only, so its mostly about an error executing a command that is listed in the manual.

Are you also getting the same error ,due to missing rs_term when running


Yeah, it sounds like our setups are really similar. Like you said, termination shouldn’t matter at 9600 baud. I’m running unterminated at 9600 baud, and I’ve done firmware updates at 115200 with 20m cables.

Do you have anything like a Saleae analyzer around? If not, you should buy one. My Logic 8 has saved many days debugging exactly this sort of thing

As far as wasting time on the app… Legato is a really nice platform, but I do question how committed they are to the FX30. The official forum is not very active. My intention is to use the FX30 as a development and demonstration platform until the Mangoh Red ships at the end of August.


Unfortunately I don’t have a logic analyzer around.

It sounds like you have been communicating successfully with various rs485 devices, are you able to confirm that?

The reason I’m asking, is that when I use Legato to set the rs_mode, based on your unsandboxed example code, I’m not able to observe the change from the file system (also after removing the .adef file requirement, which seem to be for sandboxed mode). The rs_mode file still read “RS232” after the app confirms that it has written 1 to it.

If, on the other hand, I set RS485 mode from a shell script uploaded as unsandboxed Legato app, rs_mode does read “RS485” after the script has run.

Furthermore, if I set rs485 mode like this, or manually, the Legato C app stops being able to read my commands back - it only works if rs_mode is set to RS232 mode initially.

This leads me towards the conclusion, that my C Legato App is actually communicating in RS232 mode despite having tried to set the rs_mode to RS485. And that, for whatever reason, the serial port is still silent when in rs485 mode.

Thanks for all your help.


This leads me towards the conclusion, that my C Legato App is actually communicating in RS232 mode despite having tried to set the rs_mode to RS485. And that, for whatever reason, the serial port is still silent when in rs485 mode.

I feel like I’m on the edge of overstepping some bounds, but if you can buy, borrow, or hack an Arduino to be a logic analyzer, it’s the difference between spending a week discovering that you’re actually in RS232 mode, or having it fixed within minutes. If you get one with an analog input it can also be useful for power profiling. They really are that useful. The Saleae ones are are really nice.

It sounds like you have been communicating successfully with various rs485 devices, are you able to confirm that?

I’ve only tried a single sensor so far. The port is definitely switching into RS-485 mode. I’m going to add a second device in the next few weeks, I’ll post here if I run into any trouble with it.


I’m trying to get support from Sierra Wireless regarding my issues (will post if I get an explanation for the missing GPIO 59/63.

Perhaps you can help me with a last thing, so I don’t have to doublecheck on each change - do you connect A->pin3 and B->pin1 on the DB9 port, or the other way around?
I’m betting on the first, as it works with my FTDI rs485-USB cable, but have read that TI is one of the companies that use the opposite AB spec…


Reg. the terminal resistance setting, there is typo in the FX30S user guide.
There are 3 references to:

These need to be changed to:

The file rs_term does not exist, and returns an error when used.

This will be corrected in the next user guide release.

Note also that you mandatorily need to run the R13.1.3.001 FW. If not the commands will not work (even the proper commands).


Hey, I just noticed in my notes, there’s another typo in the User’s Guide:

The User’s Guide incorrectly indicates that RS-485+ is on pin 3.
In fact, the RS-485+ signal is on pin 2 of the DB-9 connector.


Thank you!!!

That just solved all my problems communicating with the device. It seems like a rather glaring error in the manual, which I think SW needs to fix in the next revision…

Thank you again.


To round off the topic, anyone using fkorans example code above as a startoff template for setting RS485 mode should probably hold off opening the tty filehandle until after RS485 mode has been set, as my trials (on R13.1.2.004) indicated that it would keep using the RS232 driver if the TTY is opened in that mode.