Skip to content

Instantly share code, notes, and snippets.

@TravMurav
Last active September 25, 2020 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TravMurav/45a705f210125858ce889b06f90656d9 to your computer and use it in GitHub Desktop.
Save TravMurav/45a705f210125858ce889b06f90656d9 to your computer and use it in GitHub Desktop.

Making dual-sim QMI modem work

Please see This wiki page for latest version of this document

(Examples are for wileyfox-crackling)

  1. Put a working SIM into the device.

  2. Get working libqmi:

cd ~/.local/var/pmbootstrap/cache_git/pmaports/temp
mkdir libqmi
cd libqmi
wget https://gist.githubusercontent.com/Minecrell/eddea99e7c7b17c2a723d8ea657d56ea/raw/cf7a7e1467c062fce459a94ec9d479bb8a22712c/APKBUILD
pmbootstrap build libqmi --arch aarch64
  1. You need to install all the necessary components: (Assuming that you have local repo and Internet connection configured)
sudo apk add modem-qcom-msm-mainline-common ofono firmware-wileyfox-crackling-modem py-dbus libqmi py3-gobject3
sudo pip3 install ofonoctl
git clone https://git.kernel.org/pub/scm/network/ofono/ofono.git
  1. Now you need to reboot into kernel that has hexagon enabled (You need to reboot in any case at this point)

  2. Check that your modem is working and detected SIM in slot:

wileyfox-crackling:~$ sudo qmicli -d /dev/modem --uim-get-card-status
[/dev/modem] Successfully got card status
Provisioning applications:
        Primary GW:   session doesn't exist
        Primary 1X:   session doesn't exist
        Secondary GW: session doesn't exist
        Secondary 1X: session doesn't exist
Slot [1]:
        Card state: 'present'
        UPIN state: 'not-initialized'
                UPIN retries: '0'
                UPUK retries: '0'
        Application [1]:
                Application type:  'usim (2)'
                Application state: 'detected'
                Application ID:
                        [ YOUR AID FOR THIS SIM ]
                Personalization state: 'unknown'
                UPIN replaces PIN1: 'no'
                PIN1 state: 'not-initialized'
                        PIN1 retries: '0'
                        PUK1 retries: '0'
                PIN2 state: 'not-initialized'
                        PIN2 retries: '0'
                        PUK2 retries: '0'
Slot [2]:
        Card state: 'error: no-atr-received (3)
        UPIN state: 'not-initialized'
                UPIN retries: '0'
                UPUK retries: '0'
  1. Now you can select this SIM with following command:
sudo qmicli -d /dev/modem --uim-change-provisioning-session="slot=1,activate=yes,session-type=primary-gw-provisioning,aid=$YOUR_AID"
[/dev/modem] Successfully changed provisioning session

You will have selected application at this point:

wileyfox-crackling:~$ sudo qmicli -d /dev/modem --uim-get-card-status
[/dev/modem] Successfully got card status
Provisioning applications:
        Primary GW:   slot '1', application '1'
        Primary 1X:   session doesn't exist
        Secondary GW: session doesn't exist
        Secondary 1X: session doesn't exist
Slot [1]:
        Card state: 'present'
        UPIN state: 'not-initialized'
                UPIN retries: '0'
                UPUK retries: '0'
        Application [1]:
                Application type:  'usim (2)'
                Application state: 'ready'
                Application ID:
                        [ AID ]
                Personalization state: 'ready'
                UPIN replaces PIN1: 'no'
                PIN1 state: 'disabled'
                        PIN1 retries: '3'
                        PUK1 retries: '10'
                PIN2 state: 'enabled-not-verified'
                        PIN2 retries: '2'
                        PUK2 retries: '10'
Slot [2]:
        Card state: 'error: no-atr-received (3)
        UPIN state: 'not-initialized'
                UPIN retries: '0'
                UPUK retries: '0'
  1. Only thing left is to start ofono:
wileyfox-crackling:~$ sudo service ofono start
 * Starting oFono ... 

wileyfox-crackling:~$ cd ofono/test/

wileyfox-crackling:~/ofono/test$ ./enable-modem
Connecting modem /gobi_0...

wileyfox-crackling:~/ofono/test$ ./list-modems 
[ /gobi_0 ]
    Online = 0
    Powered = 1
    Lockdown = 0
    Emergency = 0
    Manufacturer = QUALCOMM INCORPORATED
    Model = 0
    Revision = MPSS.DPM.2.0.2.c1.4-00015-M8936FAAAANUZM-1  1  [Apr 29 2015 05:00:00]
    Serial = XXXXXXXXXXXXXXX
    SystemPath = /sys/devices/platform/soc/4080000.hexagon/remoteproc/remoteproc0/remoteproc0:smd-edge/remoteproc0:smd-edge.rpmsg_chrdev.0.0/rpmsg/rpmsg_ctrl1/rpmsg0
    Interfaces = org.ofono.SmartMessaging org.ofono.PushNotification org.ofono.MessageManager org.ofono.LongTermEvolution org.ofono.RadioSettings org.ofono.MessageWaiting org.ofono.AllowedAccessPoints org.ofono.SimManager org.ofono.VoiceCallManager 
    Features = sms rat sim 
    Type = hardware
    [ org.ofono.SmartMessaging ]
    [ org.ofono.PushNotification ]
    [ org.ofono.MessageManager ]
        ServiceCenterAddress = +XXXXXXXXXXX
        UseDeliveryReports = 0
        Bearer = cs-preferred
        Alphabet = default
    [ org.ofono.LongTermEvolution ]
        DefaultAccessPointName = 
        Protocol = ip
        AuthenticationMethod = none
        Username = 
        Password = 
    [ org.ofono.RadioSettings ]
        TechnologyPreference = any
        AvailableTechnologies = gsm umts lte 
    [ org.ofono.MessageWaiting ]
        VoicemailWaiting = 0
        VoicemailMessageCount = 0
        VoicemailMailboxNumber = 
    [ org.ofono.AllowedAccessPoints ]
    [ org.ofono.SimManager ]
        Present = 1
        CardIdentifier = XXXXXXXXXXXXXXXXXXXX
        SubscriberIdentity = XXXXXXXXXXXXXXX
        FixedDialing = 0
        BarredDialing = 0
        MobileCountryCode = XXX
        MobileNetworkCode = XX
        SubscriberNumbers = +XXXXXXXXXXX 
        LockedPins = 
        PinRequired = none
        Retries = [pin = 3] [pin2 = 2] [puk = 10] [puk2 = 10] 
        CardSlotCount = 1
        ActiveCardSlot = 1
    [ org.ofono.VoiceCallManager ]
        EmergencyNumbers = 911 112 

wileyfox-crackling:~/ofono/test$ ./online-modem 
Setting modem /gobi_0 online...
  1. Now you can send an SMS!
wileyfox-crackling:~/ofono/test$ ./send-sms "+XXXXXXXXXXX" "Hello from pmOS!" 0
Send message using modem /gobi_0 ...
/gobi_0/message_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Notes: "valid" session-type values are:

session-type Description
primary-gw-provisioning Primary GSM/WCDMA provisioning.
primary-1x-provisioning Primary CDMA1x provisioning.
secondary-gw-provisioning Secondary GSM/WCDMA provisioning.
secondary-1x-provisioning Secondary CDMA1x provisioning.
nonprovisioning-slot-1 Nonprovisioning on slot 1.
nonprovisioning-slot-2 Nonprovisioning on slot 2.
type-card-slot-1 Card on slot 1.
type-card-slot-2 Card on slot 2.
logical-channel-slot-1 Logical channel on slot 1.
logical-channel-slot-2 Logical channel on slot 2.

See: https://gitlab.freedesktop.org/mobile-broadband/libqmi/blob/qmi-1-24/src/libqmi-glib/qmi-enums-uim.h#L84

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment