Since 2016-2017 when I wrote my first post regarding itbrainpower.net modem(s) integration with the BeagleBone Black, a lot of changes happen in Debian implementation. Most significant was the ones related to cape(s)/overlays manipulation and in config-pin behavior.
Also, the u-GSM modem family [~22 modem types having BBB P9 interface embedded] become commercially available.
Any of the itbrainpower.net u-GSM modems, uFL version (excepting the BC95G* version) may be used as described in this how to.
* BC95G (do not be confused with BG95-M2 or BG95-M3) does not have the ppp support included.
I stress you again! LiPo/LiION battery OR super-capacitor are REQUIRED for proper u-GSM functionality! **
** for low power LTE u-GSM modems used in LTE-CATM or NBIoT mode only [BG95-M2 and BG96/BG95-M3 having 2G mode restricted], the LiPO battery or the super-capacitor can be safely replaced with 1000-1500uF/6.3V LOW ESR capacitor.
Knowledge and skills required- BeagleBone Black previous experience
- Python, shell scripting and Linux knowledge
u-GSM BBB embedded P9 interface
BeagleBone Black P8 and P9 interfaces
BBB pins functionality is controlled via PinMUX [mode0 ==> mode7], check: BBB P9 pins table [pdf] and BBB P8 pins table [pdf]In this how to, BBB pins UART4_RX[P2.5] and UART4_TX[P2.7] are used for Serial communication and GPIO52[P2.10], GPIO60[P2.8] and GPIO57[P2.6] are used as modem control interface.
BeagleBone Black with u-GSM modem + super-capacitor assembly
More BBB u-GSM w. super-capacitor hardware integration info.
BeagleBone Black with u-GSM modem + LiPO assembly
More BBB u-GSM w. LiPO/LiION hardware integration info.
HINT: for low power LTE modems used in LTE-CATM or NBIoT mode only [BG95-M2 and BG96/BG95-M3 having 2G mode restricted], the LiPO battery or the super-capacitor can be safely replaced with 1000-1500uF/6.3V LOW ESR capacitor.
(Alternate) hardware information for modem interfacing via ITBPMM* interface using wiresThis mayapply to u-GSM modem SMA versionor for previous itbrainpower.net modular modems (c-uGSM, h-nanoGSM, d-u3G or l-LTE). You may ignore this if the u-GSM integration it's performed as described above.
* ITBPMM see the "u-GSM BBB embedded P9 interface" picture above
Simply connect the wires as shown bellow:
BBB P9.16 [GPIO51]<====> ITBPMM STS
BBB P9.14 [GPIO50]<====> ITBPMM ENA / ITBPMM POW
BBB P9.12 [GPIO60]<====> ITBPMM RST* / ITBPMM RST
BBB P9.13 [GPIO31]<====> ITBPMM TX
BBB P9.11 [GPIO30] <====> ITBPMM RX
BBB P9.01 [GND] <====> ITBPMM GND
BBB P9.05 [5V] <====> ITBPMM Vin
That's all for wire interfacing.
Linux Debian 10 for BeagleBone information and hintsOur tests was made over BeagleBoard.org Debian Buster IoT Image 2020-04-06 (kernel version 4.19.94-ti-r42) - as default image shipped on new BBB boards
HINTS:
- download and install Debian 10 IoT distribution on SD
- default users and passwords: root : root and debian : temppwd. Also, you may like to make sudo no password required
- connect the BBB to the USB. use ssh to connect to BBB (target address 192.168.6.2 or 192.168.7.2)
- BeagleBone overlays and BeagleBone overlays
- BeagleBone capes and config-pin
- and, last but no least: getting started
/boot/uEnv.txt
In order to have access to modem control pins (GPIO52[P2.10], GPIO60[P2.8] and GPIO57[P2.6]) and to serial (later, available as /dev/ttyO4) connection (UART4_RX[P2.5] and UART4_TX[P2.7]), I've done small changes to default /boot/uEnv.txt script. [add/enable following lines:]
disable_uboot_overlay_video=1
disable_uboot_overlay_audio=1
disable_uboot_overlay_wireless=1
disable_uboot_overlay_adc=1
You may like to see my /boot/uEnv.txt
HINTS:
- if your application require other cape / overlay(s) loaded, I stronglyrecommend to you to start as described above. Later, after the modem is integrated, you may play with overlays and caps as you like to.
- overlays sources are located in /opt/source/bb.org-overlays/src/arm/.
DEBIAN SETUP [MAINLY BBB PORTS CONFIGURATION, BUT GATHERING SOME PACKAGES TOO]a. Connect the the BBB Ethernet to your lan. Check the connectivity to the internet. Update Debian
sudo apt-get update
then install additional packages as: ppp, mc, python, python-serial, other
sudo apt-get install ppp python-serial mc mtr
b. add following lines in /etc/rc.local at the bottom of the file, but before exit 0 line
sudo /etc/rc.config-itbp-uGSM-modem > /dev/null 2>&1
#next 3 lines .. to start the modem at boot
#sleep 10 #increase this with ~90-110sec if super-capacitor is used
#sudo /home/debian/poweronGSM.sh
#sudo /home/debian/startPPP.sh
/etc/rc.d related hint: by default, Debian 10 Buster does not execute the /etc/rc.local [the /etc/rc.local file is missing]. To solve this, just execute following commands:
echo > /etc/rc.local
chmod +x /etc/rc.local
systemctl daemon-reload
systemctl start rc-local
systemctl status rc-local
or,
b'. feel free to use crond or systemd to start and manage the processes above (...define services, systemctl edit.service....)
c. Make/Copy the following file as /etc/rc.config-itbp-uGSM-modem [right click & save as]
#!/bin/sh -e
#
# rc.config-itbp-uGSM-modem v0.22
#
# This script configs the BBB ports for usage with the u-GSM modems [https://itbrainpower.net/u-GSM]
#
# Tested on BeagleBoard.org Debian Buster IoT Image 2020-04-06, kernel version 4.19.94-ti-r42 - the default image found shipped on new BBB
#
# This SOFTWARE is distributed is provide "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# itbrainpower.net invests significant time and resources providing those how to and in design phase of our IoT products.
# Support us by purchasing itbrainpower.net modems from https://itbrainpower.net/order#u-GSM
#
# Dragos Iosub, Bucharest 2023.
# http://itbrainpower.net
#
# next 3 lines, config P9_14, P9_16 and P9_12 as input pins WITHOUT pullings.
# Those pins will be used as CONTROL interface for the ITBP modular modems.
sudo /usr/bin/config-pin P9_16 gpio_input #GPIO_51 ==> u-GSM pin STS
sudo /usr/bin/config-pin P9_14 gpio #GPIO_50 ==> u-GSM pin ENA
sudo /usr/bin/config-pin P9_12 gpio #GPIO_60 ==> u-GSM pin RST
#next four lines, config the P9_11 and P9_13 ports to be internally connected to UART4 [will be available under linux as /dev/ttyO4]
cd /sys/devices/platform/ocp/ocp:P9_11_pinmux*/
echo uart > state
cd /sys/devices/platform/ocp/ocp:P9_13_pinmux*/
echo uart > state
exit 0
Make /etc/rc.config-itbp-uGSM-modem executable.
c'. alternate and easier, just copy the relevant contents of the above rc.config-itbp-uGSM-modem file in the /etc/rc.local file.
We are almost there... Just reboot your BeagleBone Black.
Download u-GSM shield BeagleBone Black [Debian10] UTILITIES [u-GSM control scripts and PPP peers files for BeagleBone Black Debian10] from the download page.
This package contains both files above. Expand the archive and copy poweronGSM.sh, poweroffGSM.sh, startPPP.sh and stopPPP.sh into the /home/debian folder. Make them executable and check the ownership.
You may start the tests, but not before read the readmefirst.txt! First, run the scripts manually in order to identify and fix any bug. Later, you may link the scripts in order to start the modem and ppp at the boot time.
ppp0 default route and routing issue related hint: - if you intend to "share" the modem (ppp0) Internet connection with local lan (eth0), you should fix the auto "default route supervisor". To do this, you may like to investigate first the "connmand" daemon behavior and change the configuration.
PYTHON SCRIPTS and ITBP_gpioBBB.py - python GPIO handler for BBBa. Python ITBP modem and PPP support files was originally written for RaspberryPI [Debian distribution]. Some patches should be applied in order to run those scripts in BeagleBone Black [Debian]:- a1. Serial port names. /dev/ttyAMA0 [RPI] ==> /dev/ttyO4 [BBB].- a2. The RPI.GPIO python class does not exist in BBB python.- a3. The BBB port addressing it is different from the RPI port addressing under python. b. Download the u-GSM python and PPP support files from the u-GSM download section (for other modems from download page and select your modem first). Your name, email address and with the IMEI of your modem will be requested [the IMEI can be found on the top of the modem, or you may find using AT+CIMI command].c. Decompress the archives. This archive contains, along with other files, the following files: "uGSM2_02_hw_control.py", "uGSM_Serial_Lib.py" and "globalParVar.py", related to python modem control and serial communication.d. Copy the code bellow and make a file called "ITBP_gpioBBB.py" in the very same folder where the "MyMODEMver_hw_control.py" [in u-GSM case "uGSM2_02_hw_control.py"] is located. Alternate, you may download it from here [right click & save as]: ITBP_gpioBBB.py
###############################################################################################################################################################
#ITBP_gpioBBB.py v022 - RPI.GPIO helper file for ITBP u-GSM modems and modular modems - [Debian 10] port
#COPYRIGHT (c) 2017-2023 Dragos Iosub / R&D Software Solutions srl
#
#You are legaly entitled to use this SOFTWARE ONLY IN CONJUNCTION WITH ITBP u-GSM modems or with ITBP MODULAR MODEMS DEVICES USAGE
#[l-LTE, c-uGSM, h-nanoGSM and d-u3G shileds]. Modifications, derivates and redistribution of this software must include unmodified this COPYRIGHT NOTICE.
#You can redistribute this SOFTWARE and/or modify it under the terms of this COPYRIGHT NOTICE. Any other usage may be permited only after written
#notice of Dragos Iosub / R&D Software Solutions srl.
#
#This SOFTWARE is distributed is provide "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
#warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
#Dragos Iosub, Bucharest 2023.
#http://itbrainpower.net
###############################################################################################################################################################
###############################################################################################################################################################
#next, configs required for u-GSM modems (uFL) connected via u-GSM BBB interface [https://itbrainpower.net/images/u-GSM-top-03-pinout_1200px.jpg]
#or, u-GSM SMA version / ITBP MODULAR MODEMS conected via ITBPMM using wires [https://itbrainpower.net/a-gsm/BBB_u-GSM_Debian10_notes#wires]
###############################################################################################################################################################
# Edit the "uGSM2_19_hw_control.py" - "*********_hw_control.py" for other modems - file [mcedit uGSM2_19_hw_control.py] and replace the line 17":
# import RPi.GPIO as GPIO with:
# import ITBP_gpioBBB as GPIO
#
# Edit the "globalParVar.py" file [mcedit globalParVar.py] and set the "CONTROL interface for the ITBP modems" as bellow:
# RESET = "P9_14"
# POWER = "P9_16"
# STATUS = "P9_12"
#
# Edit the "globalParVar.py" file [mcedit globalParVar.py] and replace the line
# SERIALPORT = "/dev/ttyAMA0" with
# SERIALPORT = "/dev/ttyO4"
#
# If previous line not found (for older version of python support files - mainly for ITBP MODULAR MODEMS, edit the "******GSM_Serial_Lib.py" file
# [mcedit ******GSM_Serial_Lib.py] and replace the line":
# agsm = serial.Serial("/dev/ttyAMA0", serialSpeed, timeout=1) with:
# agsm = serial.Serial("/dev/ttyO4", serialSpeed, timeout=1)
#
###############################################################################################################################################################
import subprocess
ports = ['P9_12','P9_14','P9_16','P9_18']
mapping = {'P9_12':'gpio60','P9_14':'gpio50','P9_16':'gpio51','P9_18':'gpio4'}
gpioPath = '/sys/class/gpio/'
configPin = '/usr/bin/config-pin'
#some definitions, do not change
OUT ='out'
IN ='in'
HIGH = 1
LOW = 0
BOARD = 1 #just 4 compatibility with RPi.GPIO
dirmap = {'out':1,'in':0}
def output(port, value):
p = subprocess.Popen('echo '+str(value)+' > '+gpioPath+mapping[port]+'/value', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
#print str(out)
#print str(err)
def setup(port, direction, initial=-100):
p = subprocess.Popen(configPin+' '+str(port)+' '+str(direction), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
#print out
#print err
if (initial > -100):
output(port, initial) #write initial state
def input(port):
p = subprocess.Popen(['cat',gpioPath+mapping[port]+'/value'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
#print out
#print err
try:
return int(out)
except:
return -100
#print str(out)
#print str(err)
def cleanup():
global ports
for port in ports:
setup(port, 'in', -101)# input float
#just 4 compatibility with RPi.GPIO
def setmode(whatever):
return
#just 4 compatibility with RPi.GPIO
def setwarnings(whatever):
return
e. Fixing a1, a2 and a3 differences e1. Edit the "uGSM2_19_hw_control.py" file ["*********_hw_control.py" for other modems] and replace the line 17:
import RPi.GPIO as GPIO
with:
import ITBP_gpioBBB as GPIO
e2. Edit the "globalParVar.py" file and set the "CONTROL interface for the ITBP modems" as bellow:
RESET = "P9_14"
POWER = "P9_16"
STATUS = "P9_18"
e3. Edit the "globalParVar.py" file [mcedit globalParVar.py] and replace the line:
SERIALPORT = "/dev/ttyAMA0"
with
SERIALPORT = "/dev/ttyO4"
If SERIALPORT variable is missing in "globalParVar.py" (for older version of python support files - mainly for ITBP MODULAR MODEMS, edit the "******GSM_Serial_Lib.py" file and replace the line 40":
agsm = serial.Serial("/dev/ttyAMA0", serialSpeed, timeout=1)
with:
agsm = serial.Serial("/dev/ttyO4", serialSpeed, timeout=1)
TEST THE SETUPYou may run any ITBP modem python example files [Eg. python sendSMS.py].
Ready. Enjoy!
Additional BeagleBone Black references.- https://github.com/cdsteinkuehler/beaglebone-universal-io- http://www.armhf.com/using-beaglebone-black-gpios/- http://derekmolloy.ie/gpios-on-the-beaglebone-black-using-device-tree-overlays/- CAPE, what's about: http://elinux.org/Capemgr- BBB pins definition: https://github.com/jadonk/bonescript/blob/master/src/bone.js- and last, but not least http://www.ti.com/product/am3359
Keep calm, understand what's under the BBB blanket, follow the principles presented above and maybe write your own overlay!?
TUTORIAL & SOFTWARE ARE PROVIDED WITHOUT ANY WARRANTY!!! USE IT AT YOUR OWN RISK!!!!
Comments