How to enable multiplexing on the Raspberry Pi Serial interface

The SARA-R5  cellular module on the OzzMaker SARA-R5 LTE-M GPS + 10DOF supports the 3GPP TS 27.010 multiplexer protocol. With this protocol , it is possible to emulate several virtual connection channels on a single physical serial interface between a Raspberry Pi and the SARA-R5 module. This allows for the streaming of GNSS data, the action of performing AT commands and  having an active 5G connection all at the same time.

When enabling the multiplexer protocol on the Raspberry Pi and SARA-R5 module, you can access 3 UART channels which would be able to perform these functions;

  • Channel 0 – AT Commands and Data
  • Channel 1 – AT Commands and Data
  • Channel 2 – GNSS Streaming

To be able to use this protocol, we will need to install the gsmMuxd  driver.

 1. Open raspi-config and disable the serial console

The serial console needs to be disabled and then the serial port enabled.

pi@raspberrypi ~ $ sudo raspi-config

Select interfacing options -> Serial -> No -> Yes
And then Yes to reboot

2. Download and compile gsmMuxd

Download and compile the multiplexer driver and copy it to the bin directory. Finally, exit root.

pi@raspberrypi ~ $ sudo -i
cd /usr/local/src/
git clone https://github.com/ozzmaker/gsmmux
cd gsmmux
make
cp gsmMuxd /usr/bin/gsmMuxd
exit

 

3. Add Pi user to TTY group

Now add ‘pi’ user to the tty group;

pi@raspberrypi ~ $ sudo adduser pi tty

Log out and then back in again for the new group assignment to take effect.

 

4. Run gsmMuxd

Run gsmMux driver to enable multiplexing;

pi@raspberrypi ~ $ sudo gsmMuxd
/dev/ttyGSM0 Command Channel
/dev/ttyGSM1 Command Channel
/dev/ttyGSM2 GNSS Tunneling
MUX started
pi@raspberrypi ~ $

Above you can see that 3 virtual channels created by the gsmMuxd driver;

  • /dev/ttyGSM0 – AT Commands and Data
  • /dev/ttyGSM1 – AT Commands and Data
  • /dev/ttyGSM2 – GNSS Streaming

 

When needing to configure the cellular module using AT commands, you can use minicom and you would need to connect to either ttyGSM0 or ttyGSM1.
You can install minicom with;

pi@raspberrypi ~ $ sudo apt-get install minicom

Then connect to either ttyGSM0 or ttyGSM1.

pi@raspberrypi ~ $ minicom 115200 -D /dev/ttyGSM0

If using ttyGSM0 to configure the modem, you would then use ttyGSM1 to create a data connection with your provider.

ttyGSM2 would be used to receive GNSS data from the module. You would point GPSD to this interface

 

Reset SARA-R5 when rebooting

For some Raspberry Pis, when rebooting the Pi, the MUX no longer works. (We are still working out why)
To fix this, we can do a quick reset on booting, as well as load the mux driver.

If you dont have this issue when rebooting, you can skip this step.

We will need to connect the PWR pin on the SARA-R5 module to GPIO4 on the Raspberry Pi, this can be done by placing a solder “blob” on the bottom two pads on Jumper JP1. (pads shown below)

SARA-R5 PWR pin

Now create a script which will be used to bounce the PWR pin and load the mux driver

pi@raspberrypi ~ $ nano ~/SARA-R5-init.sh

Copy in the text below, then save and exit

#!/bin/bash
raspi-gpio set 4 op pn dl
sleep 30
raspi-gpio set 4  dh
sleep 3
raspi-gpio set 4 op pn dl
sleep 3
raspi-gpio set 4  dh
sleep 3
gsmMuxd

Make the script executable;

pi@raspberrypi ~ $ chmod +x ~/SARA-R5-init.sh

You add the startup script to /etc/rc.local to make it load on boot.

pi@raspberrypi ~ $ sudo nano /etc/rc.local

Just before the exit 0 at the bottom, insert this line

/home/pi/SARA-R5-init.sh & >> /tmp/log 2>&1 &

 

Other Information and Guides

Blip, blop, bloop…