Accessing internet with SIM7600 4G Modem using MBIM interface in Pocketbeagle/Beaglebone (linux)
This post is intended to show how to set up a data connection over the MBIM interface using libmbim and driver cdc_mbim in Linux(Beaglebone/Pocketbeagle). There is a open source Linux in-kernel driver supporting MBIM interface and it is called cdc_mbim. The library libmbim can be used to communicate with the cellular devices over the interface and do necessary configurations to trigger the data connection over the cellular network.
Test Setup
The instructions are tested with PocketBeagle running Debian 9.8 with kernel version 4.14.
Hardware used is SIM7600E from ElementzOnline. The modem is connected to PocketBeagle using the USB port exposed on PocketBeagle pinheader.
Switching the SIM7600 to MBIM driver mode
By default the SIM7600 PID is 9001 and the PID configuration is 9001:Diag, NMEA, At, Modem, Audio, Rmnet. To setup data connection over the MBIM interface we need to change the PID to 9003(9003:Diag, NMEA, At, Modem, Audio, MBIM). The AT commands can be send to the GSM modem using the AT command port using the following commands
screen /dev/ttyUSB2 // Assuming ttyUSB2 corresponds to AT command port
AT+CUSBPIDSWITCH=9003,1,1
OK
SIM7600 supports Wan mode and LAN mode. Customer can use AT command to change the mode. For sharing the net to PC, the Wan mode has to be used. SIM7600E Module works in wan mode in default. You can check the current mode using
AT+CLANMODE?
Module
should respond with
OK, 1
If the module is not in Wan mode then the mode can be switched using the following command.
AT+CLANMODE=1
Atfter run this command, module will restart automatically, then the module will work in wan mode.
Important Note: Make sure that you are connecting the modem in WAN mode(AT+CLANMODE=1) to get internet in PC.
LAN9730 is not opened in default, if want to open the LAN9730, you can run
AT+CENABLELAN=1 Afterrun this command, the module will restart automatically, then the LAN9730 will be opened.
Preparing PocketBeagle for MBIM connectivity
First install the libmbim Linux library using your system package manager like apt etc.
The mbim functionality can be used by installing the libmbim-utils with the following command.
sudo
apt install
libmbim
-utils
Verify that you have the Linux in-kernel cdc_mbim driver installed for the cellular modules exposed MBIM interface endpoint over USB:
lsusb -t
The libmbim tool: mbim-network can be used to establish a simple data connection.
First create a config file containing your network operators APN details. Save it in the default location where mbim-network searches for the file: /etc/mbim-network.conf . The parameter --profile=[PATH] can be used to alter this path when executing mbim-network.
Save the APN details, (and username, password and authentication type if necessary) into the configuration file /etc/mbim-network.conf:
cat /etc/mbim-network.conf
APN=internet
APN_USER=
APN_PASS=
APN_AUTH=
PROXY=yes
Starting the network using MBIM connection
Start the mbim data connection with command bellow, if successful it will print "Network started successfully"
sudo mbim-network /dev/cdc-wdm0 start
You can now execute the mbim-set-ip script(download link at bottom) with sufficient system privileges:
sudo ./mbim-set-ip /dev/cdc-wdm0 wwan0
This script will collect the network interface IP configurations from the cellular module over MBIM interfaceusing
mbimcli, parse them and apply them to the network interface in Linux, this because DHCP requests are generally not supported over MBIM interfaces.
Verify the internet access
Once you have started the data connection and set the details with the mbim-set-ip script you should be able to ping the data connection:
ping -4 -I wwan0 8.8.8.8
ping -4 -I wwan0 google.com
ping -6 -I wwan0 2001:4860:4860::8888
ping -6 -I wwan0 google.com
Incase network not accessible then type the following in BBB terminal
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
The cellular data connection can be disconnected by commands:
Stop
mbim data connection:
sudo mbim-network /dev/cdc-wdm0 stop
Set network interface down:
ip link set wwan0 down
Important Links:
Scripts Download: https://github.com/elementzonline/GSMModem/tree/master/SIM7600/mbim-set-ip
SIM7600 Modem purchase link: https://www.elementzonline.com/sim7600e-4g-gsm-ttl-usb-modem-with-sma-antenna
PocketBeagle/BeagleBone Black purchase link: https://www.elementzonline.com/index.php?route=product/search&search=beagle&description=true