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 GPRS connection all at the same time.
When enabling the multiplexer protocol on the Raspberry Pi and SARA-R5 module, you can access 4 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
- Channel 3 – Control
To be able to use this protocol, we will need to update the Raspberry Pi with a new kernel module and install the GSM CMUX driver.
1. Open raspi-config and disable the serial console
The serial console needs to be disabled and then the serial port enabled.
Select interfacing options -> Serial -> No -> Yes
And then Yes
to reboot
2. Install N_GSM kernel module
Change to root and install dependencies;
apt update
apt install bc bison git build-essential flex libssl-dev -y
3. Download kernel source
Download kernel sources which will be used to make the new kernel module;
chmod +x /usr/bin/rpi-source
python2.7 /usr/bin/rpi-source -q –tag-update
python2.7 /usr/bin/rpi-source
4. Build the N_GSM kernel module
Build the module and and update module dependencies;
make -C /lib/modules/$(uname -r)/build M=$(pwd) -e CONFIG_N_GSM=m modules
cp /root/linux/drivers/tty/n_gsm.ko /lib/modules/`uname -r`/kernel/drivers/tty/
depmod
5. Download and compile the CMUX driver
Compile the driver can copy it to the bin directory. Finally, exit root.
git clone https://github.com/ozzmaker/cmux.git
cd cmux
make
cp cmux /usr/bin/cmux
exit
6. Load module and run CMUX
To enable MUX communication, you first need to load the module and then you need to run the CMUX driver;
pi@raspberrypi ~ $ sudo cmux
SERIAL_PORT = /dev/ttyS0
AT+IFC=2: AT+IFC=2,2 OK
AT+GMM : AT+GMM SARA-R510M8S OK
AT : AT OK
AT+IPR=1: AT+IPR=115200 OK
AT+CMUX=: AT+CMUX=0,0,5,512,10,3,30,10,2 OK
Line dicipline set
Created /dev/ttyGSM1
Created /dev/ttyGSM2
Created /dev/ttyGSM3
Created /dev/ttyGSM4
Going to background
pi@raspberrypi ~ $
Above you can see that 4 virtual channels created by the CMUX driver;
- /dev/ttyGSM1 – AT Commands and Data
- /dev/ttyGSM2 – AT Commands and Data
- /dev/ttyGSM3 – GNSS Streaming
- /dev/ttyGSM4 – Control Channel
When needing to configure the cellular module using at commands, you can use minicom and you would need to connect to either ttyGSM1 or ttyGSM2.
You can install minicom with;
Then connect to either ttyGSM1 or ttyGSM2.
If using ttyGSM1 to configure the module, you would then use ttyGSM2 to create a data connection with your provider.
ttyGSM3 would be used to receive GNSS data from the module. You would point GPSD to this interface
Autoload Kernel module and CMUX driver at boot.
Below is how you can configure you Raspberry Pi to load the module at boot and to run the CMUX driver automatically .
Kernel Module
Add n_gsm in new line at the bottom of /etc/modules. This will force the module to load at boot.
For the CMUX driver, we will first need to create a script which will then be used to start the CMUX driver after some delay.
Copy in the text below, then save and exit
#!/bin/bash sleep 15 /usr/bin/cmux >> /tmp/log 2>&1 &
Make the script executable;
You can use the startup script /etc/rc.local to start the above script at boot.
Just before the exit 0 at the bottom, insert this line