itbrainpower.net
THE ALPHABET PROJECT - professional Arduino, BeagleBone & Raspberry PI shields



Order xyz-mIoT w. BG96 - product(s) of the week. Order itbrainpower.net u-GSM modems.
Read our last post: Modems and RaspberryPI 5. RaspberryPI OS [Debian 12 bookworm] notes..

BeagleBone Black w. u-GSM modem Debian10 notes

 

About this

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.

 

BeagleBone Black w. u-GSM modem Debian10 notes

 

Involved parts

* BC95G (do not be confused with BG95-M2 or BG95-M3) does not have ppp support included.

** first generation itbrainpower modular modems does not have P9 interface integrated, but still can be interfaced with BBB using wires.


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

 

 

Some BeagleBone Black and u-GSM hardware references

u-GSM BBB embedded P9 interface

u-GSM modem pinout and embedded BBB P9 interface

 

 

BeagleBone Black P8 and P9 interfaces

BeagleBone Black pinout

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, the 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

BeagleBone Black and u-GSM modem w. super-capacitor assembly

More BBB u-GSM hardware integration info.

 

 

BeagleBone Black with u-GSM modem + LiPO assembly

BeagleBone Black and u-GSM modem w. LiPO battery assembly

More BBB u-GSM 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.

 

 

Dedicated hardware information for modem interfacing via ITBPMM interface using wires

This may apply to u-GSM modem SMA version and first version of ITBP 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.

 

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 hints

Our 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:

 

 

Debian10 on BeagleBone Black

/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

 

/boot/uEnv.txt

1###U-Boot Overlays###
2###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
3###Master Enable
4enable_uboot_overlays=1
5###
6###Overide capes with eeprom
7#uboot_overlay_addr0=/lib/firmware/<file0>.dtbo
8#uboot_overlay_addr1=/lib/firmware/<file1>.dtbo
9#uboot_overlay_addr2=/lib/firmware/<file2>.dtbo
10#uboot_overlay_addr3=/lib/firmware/<file3>.dtbo
11###
12###Additional custom capes
13#uboot_overlay_addr4=/lib/firmware/<file4>.dtbo
14#uboot_overlay_addr5=/lib/firmware/<file5>.dtbo
15#uboot_overlay_addr6=/lib/firmware/<file6>.dtbo
16#uboot_overlay_addr7=/lib/firmware/<file7>.dtbo
17###
18###Custom Cape
19#dtb_overlay=/lib/firmware/<file8>.dtbo
20###
21###Disable auto loading of virtual capes (emmc/video/wireless/adc)
22#disable_uboot_overlay_emmc=1
23#disable_uboot_overlay_video=1
24#disable_uboot_overlay_audio=1
25#disable_uboot_overlay_wireless=1
26#disable_uboot_overlay_adc=1
27#disable_uboot_overlay_emmc=1
28disable_uboot_overlay_video=1
29disable_uboot_overlay_audio=1
30disable_uboot_overlay_wireless=1
31disable_uboot_overlay_adc=1
32###
33###PRUSS OPTIONS
34###pru_rproc (4.14.x-ti kernel)
35#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
36###pru_rproc (4.19.x-ti kernel)
37uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo
38###pru_uio (4.14.x-ti, 4.19.x-ti & mainline/bone kernel)
39#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
40###
41###Cape Universal Enable
42enable_uboot_cape_universal=1
43###
44###Debug: disable uboot autoload of Cape
45#disable_uboot_overlay_addr0=1
46#disable_uboot_overlay_addr1=1
47#disable_uboot_overlay_addr2=1
48#disable_uboot_overlay_addr3=1
49###
50###U-Boot fdt tweaks... (60000 = 384KB)
51#uboot_fdt_buffer=0x60000
52###U-Boot Overlays###
53
54cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet
55
56#In the event of edid real failures, uncomment this next line:
57#cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet video=HDMI-A-1:1024x768@60e
58
59##enable Generic eMMC Flasher:
60#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
61

 

HINTS:
- if your application require other cape / overlay(s) loaded, I recommend to you to start as 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]

/etc/rc.config-itbp-uGSM-modem

1#!/bin/sh -e
2#
3# rc.config-itbp-uGSM-modem v0.22
4#
5# This script configs the BBB ports for usage with the u-GSM modems [https://itbrainpower.net/u-GSM]  
6#
7# 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
8#
9# This SOFTWARE is distributed is provide "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 
10# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11#
12# itbrainpower.net invests significant time and resources providing those how to and in design phase of our IoT products.
13# Support us by purchasing itbrainpower.net modems from https://itbrainpower.net/order#u-GSM
14#
15# Dragos Iosub, Bucharest 2023.
16# http://itbrainpower.net
17#
18
19# next 3 lines, config P9_14, P9_16 and P9_12 as input pins WITHOUT pullings. 
20# Those pins will be used as CONTROL interface for the ITBP modular modems.
21sudo /usr/bin/config-pin P9_16 gpio_input #GPIO_51 ==> u-GSM pin STS
22sudo /usr/bin/config-pin P9_14 gpio #GPIO_50 ==> u-GSM pin ENA
23sudo /usr/bin/config-pin P9_12 gpio #GPIO_60 ==> u-GSM pin RST
24  
25#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]
26cd /sys/devices/platform/ocp/ocp:P9_11_pinmux*/
27echo uart > state
28cd /sys/devices/platform/ocp/ocp:P9_13_pinmux*/
29echo uart > state
30
31exit 0
32

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 /etc/rc.d.

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 BBB

a. Python ITBP modem and PPP support files was 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 [the IMEI can be found on the top of the modem, or you may find using AT+CIMI command] will be requested.

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 this case "uGSM2_02_hw_control.py"] is located. Alternate, you can download from here [right click & save as]: ITBP_gpioBBB.py

ITBP_gpioBBB.py : GPIO python helper file for ITBP u-GSM modems and modular modems - BBB[Debian 10] port

1###############################################################################################################################################################
2#ITBP_gpioBBB.py v022 - RPI.GPIO helper file for ITBP u-GSM modems and modular modems - [Debian 10] port 
3#COPYRIGHT (c) 2017-2023 Dragos Iosub / R&D Software Solutions srl
4#
5#You are legaly entitled to use this SOFTWARE ONLY IN CONJUNCTION WITH ITBP u-GSM modems or with ITBP MODULAR MODEMS DEVICES USAGE
6#[l-LTE, c-uGSM, h-nanoGSM and d-u3G shileds]. Modifications, derivates and redistribution of this software must include unmodified this COPYRIGHT NOTICE.
7#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
8#notice of Dragos Iosub / R&D Software Solutions srl.
9#
10#This SOFTWARE is distributed is provide "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 
11#warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12#
13#Dragos Iosub, Bucharest 2023.
14#http://itbrainpower.net
15###############################################################################################################################################################
16
17###############################################################################################################################################################
18#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]
19#or, u-GSM SMA version / ITBP MODULAR MODEMS conected via ITBPMM using wires [https://itbrainpower.net/a-gsm/BBB_u-GSM_Debian10_notes#wires]
20###############################################################################################################################################################
21# 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":
22# import RPi.GPIO as GPIO with:
23# import ITBP_gpioBBB as GPIO
24#
25# Edit the "globalParVar.py" file [mcedit globalParVar.py] and set the "CONTROL interface for the ITBP modems" as bellow:
26#   RESET = "P9_14"
27#   POWER = "P9_16"
28#   STATUS = "P9_12"
29#
30# Edit the "globalParVar.py" file [mcedit globalParVar.py] and replace the line
31#   SERIALPORT = "/dev/ttyAMA0" with
32#   SERIALPORT = "/dev/ttyO4"
33#
34# If previous line not found (for older version of python support files - mainly for ITBP MODULAR MODEMS, edit the "******GSM_Serial_Lib.py" file
35# [mcedit ******GSM_Serial_Lib.py] and replace the line":
36#   agsm = serial.Serial("/dev/ttyAMA0", serialSpeed, timeout=1) with:
37#   agsm = serial.Serial("/dev/ttyO4", serialSpeed, timeout=1)
38#
39###############################################################################################################################################################
40
41import subprocess
42ports   = ['P9_12','P9_14','P9_16','P9_18']
43mapping = {'P9_12':'gpio60','P9_14':'gpio50','P9_16':'gpio51','P9_18':'gpio4'}
44gpioPath = '/sys/class/gpio/'
45configPin = '/usr/bin/config-pin'
46
47#some definitions, do not change
48
49OUT     ='out'
50IN      ='in'
51HIGH    = 1
52LOW     = 0
53BOARD   = 1 #just 4 compatibility with RPi.GPIO
54dirmap = {'out':1,'in':0}
55
56def output(port, value):
57    p = subprocess.Popen('echo '+str(value)+' > '+gpioPath+mapping[port]+'/value', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
58    out, err = p.communicate()
59    #print str(out)
60    #print str(err)
61
62def setup(port, direction, initial=-100):
63    p = subprocess.Popen(configPin+' '+str(port)+' '+str(direction), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
64    out, err = p.communicate()
65    #print out
66    #print err
67    if (initial > -100):
68        output(port, initial) #write initial state
69        
70def input(port):
71    p = subprocess.Popen(['cat',gpioPath+mapping[port]+'/value'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
72    out, err = p.communicate()
73    #print out
74    #print err
75    try:
76        return int(out)
77    except:
78        return -100
79    #print str(out)
80    #print str(err)
81
82def cleanup():
83    global ports
84    for port in ports:
85        setup(port, 'in', -101)# input float
86
87
88#just 4 compatibility with RPi.GPIO
89def setmode(whatever):
90    return
91
92#just 4 compatibility with RPi.GPIO    
93def setwarnings(whatever):
94    return
95    
96

 

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 SETUP

You may run any ITBP modem python example file [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!!!!

 

 

Dragos Iosub & itbrainpower.net team original how to.

 

 

 

 

document version 1.0211 / 2023-03-27 © R&D Software Solutions srl