QMI-RIL » History » Version 31
Kurtis Hanna, 08/25/2019 08:23 PM
added link to our issue page related to this and link to modem in mainline linux
1 | 29 | Denis 'GNUtoo' Carikli | h1. TODO |
---|---|---|---|
2 | |||
3 | See also the following links: |
||
4 | * https://github.com/scintill/android_frameworks_opt_telephony_ril_ofono |
||
5 | 31 | Kurtis Hanna | * https://redmine.replicant.us/issues/1813 |
6 | * https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/clk/qcom/gcc-mdm9615.c?h=v5.2.7 |
||
7 | 29 | Denis 'GNUtoo' Carikli | |
8 | 1 | Wolfgang Wiedmeyer | h1. QMI-RIL |
9 | |||
10 | This page covers development efforts to create a "Radio Interface Layer":https://en.wikipedia.org/wiki/Radio_Interface_Layer (RIL) for modems that use the Qualcomm MSM Interface (QMI) protocol. The work is currently carried out for the Galaxy S 3 4G (I9305) which has a Qualcomm MDM9615 modem. The Galaxy Note 2 4G (t0lte) uses the same modem and this device could be supported as well in Replicant when the QMI-RIL is ready. We will hopefully identify further candidates that have an isolated modem using the QMI protocol and for which Replicant support could be added. Among the non-Android devices, the iPhone 5 is one that "uses the MDM9615 modem":https://www.theiphonewiki.com/wiki/MDM9615 as well. |
||
11 | 2 | Wolfgang Wiedmeyer | |
12 | 6 | Wolfgang Wiedmeyer | "relevant thread on libqmi mailing list":https://lists.freedesktop.org/archives/libqmi-devel/2017-February/002089.html |
13 | |||
14 | 2 | Wolfgang Wiedmeyer | h2. Modem boot |
15 | |||
16 | 17 | Wolfgang Wiedmeyer | h3. Background |
17 | 3 | Wolfgang Wiedmeyer | |
18 | 17 | Wolfgang Wiedmeyer | When the MDM9615 modem is activated, it first boots into a Download mode. There, firmware, bootloaders and EFS files are uploaded to the modem via a serial interface. The used protocol is called SAHARA and it is a proprietary protocol developed by Qualcomm. The protocol covers various functionalities. We likely only need to implement a very small subset that is responsible for transferring firmware and other files to the modem and synchronising changes to EFS files with the filesystem. Being able to retrieve RAM dumps from the modem would also be helpful for debugging. In case of a fatal error, the Linux kernel already requests RAM dumps from the modem, so only the file transfer part needs to be implemented. |
19 | 2 | Wolfgang Wiedmeyer | |
20 | 17 | Wolfgang Wiedmeyer | Qualcomm provides the proprietary tool kickstart for uploading the files to the modem. It is run by the daemon qcks. After the modem is booted, qcks spawns efsks which is responsible for EFS sync. |
21 | |||
22 | 1 | Wolfgang Wiedmeyer | Logcat and dmesg output of the upload: attachment:ks_logcat, attachment:ks_dmesg |
23 | |||
24 | 30 | Joey Hewitt | "libopenpst":https://github.com/openpst/libopenpst, their "sahara":https://github.com/openpst/sahara tool, and "Linaro's QDL code":http://git.linaro.org/landing-teams/working/qualcomm/qdl.git/log/ can be used as a reference to implement the file upload and as documentation about the protocol. The "kernel":https://git.replicant.us/replicant/kernel_samsung_smdk4412 itself can be checked for the different boot modes. |
25 | 17 | Wolfgang Wiedmeyer | |
26 | h3. Implementation |
||
27 | |||
28 | 22 | Wolfgang Wiedmeyer | An initial version of the modem boot part is completed and a tool called @modem-boot@ is available as part of the qmi-ril repo: https://git.replicant.us/contrib/wiewo/qmi-ril/ |
29 | 19 | Wolfgang Wiedmeyer | It uploads the needed files in the Download mode and reboots the modem. The files are uploaded from a directory that @qcks@ uses to prepare the files. This preparation step (reading data from partitions and preparing them in a certain way before the upload) needs to be implemented. Otherwise, updates to the EFS partitions aren't used at the next boot of the modem. |
30 | 22 | Wolfgang Wiedmeyer | During regular operation of the modem, EFS data is received. The data is not yet written to the EFS partition. This step needs to be implemented as well. |
31 | 19 | Wolfgang Wiedmeyer | See the commit messages for more details. |
32 | 4 | Wolfgang Wiedmeyer | |
33 | h2. QMI protocol |
||
34 | 1 | Wolfgang Wiedmeyer | |
35 | 23 | Wolfgang Wiedmeyer | "libqmi":https://www.freedesktop.org/wiki/Software/libqmi/ is a library that implements the QMI protocol and it will be used for implementing the RIL. The source code for the command-line tool @qmicli@, which is part of libqmi, and "ModemManager's":https://cgit.freedesktop.org/ModemManager/ModemManager code is helpful for figuring out how to use libqmi. |
36 | 1 | Wolfgang Wiedmeyer | |
37 | 26 | Wolfgang Wiedmeyer | libqmi needs the cdc-wdm and qmi_wwan kernel drivers for communicating with the modem. These are backported to the smdk4412 kernel on the "qmi branch":https://code.fossencdi.org/kernel_samsung_smdk4412.git/log/?h=qmi. The qmi_wwan driver replaces the RMNET usb driver that the blobs use for a network interface to the modem. Some missing code in the backported qmi_wwan driver was ported from the RMNET driver. The commit messages offer more details. |
38 | 23 | Wolfgang Wiedmeyer | |
39 | 1 | Wolfgang Wiedmeyer | libqmi provides the command-line tool @qmicli@ to communicate with the modem. It was already successfully tested on the S 3 4G. Using the modem boot tool described above and the qmi branch of the kernel, @qmicli@ is usable with only free software. |
40 | 23 | Wolfgang Wiedmeyer | |
41 | The "RIL header":https://git.replicant.us/LineageOS-mirror/android_hardware_ril/tree/include/telephony/ril.h?h=cm-13.0 documents the Android side of the interface and the commands that need to be implemented. The [[Samsung-RIL]] page also offers some documentation in that regard. |
||
42 | |||
43 | h3. Status of QMI-RIL |
||
44 | |||
45 | 28 | Wolfgang Wiedmeyer | An initial version of QMI-RIL is available in the "qmi-ril repo":https://git.replicant.us/contrib/wiewo/qmi-ril/ See "this commit message":https://git.replicant.us/contrib/wiewo/qmi-ril/commit/?id=f35a9bbd1ebb52433f313c675fbe01bb1ca96d7d for the status details. |
46 | The device-specific repos for i9305 need to use these two branches to make the RIL work: |
||
47 | https://code.fossencdi.org/device_samsung_i9305.git/log/?h=qmi-wip |
||
48 | https://git.replicant.us/contrib/wiewo/device_samsung_smdk4412-qcom-common/log/?h=replicant-6.0 |
||
49 | |||
50 | 15 | Wolfgang Wiedmeyer | |
51 | 7 | Wolfgang Wiedmeyer | h2. Cross-compiling libqmi for Android on ARM |
52 | 1 | Wolfgang Wiedmeyer | |
53 | 20 | Wolfgang Wiedmeyer | These instructions can be used to build libqmi and include it in an image for the Galaxy S 3 4G. See the [[GalaxyS3I9305Build|build instructions for the Galaxy S 3 4G]] for building the image. |
54 | |||
55 | 27 | Wolfgang Wiedmeyer | Android.mk files need to be written to integrate libqmi and its dependencies into a regular device build. Some of the source code is auto-generated and some dependencies like GLib have a lot of source files, so writing the Android Makefiles will be some work. For GLib, these commits could be used for creating the Android.mk files: |
56 | 20 | Wolfgang Wiedmeyer | https://github.com/scintill/android_external_glib/commit/9bc8d813979140b8abdad77619aba20f08b19c6f |
57 | https://github.com/scintill/android_external_glib/commit/ae860f678520471da44823f500f302a1a27c1be9 |
||
58 | They are for GLib 2.32, but libqmi requires at least GLib 2.36, so they need to be ported to that version. It looks like that with these Makefiles, only libiconv is required as an additional dependency for GLib. For libiconv, the Makefiles from this commit could be helpful: |
||
59 | https://github.com/tguillem/android-libiconv/commit/8be7e8a7670abf251d6198606098a1908ec1033c |
||
60 | 7 | Wolfgang Wiedmeyer | |
61 | 13 | Wolfgang Wiedmeyer | Based on "these instructions":https://zwyuan.github.io/2016/07/17/cross-compile-glib-for-android/ |
62 | |||
63 | 8 | Wolfgang Wiedmeyer | h3. Dependencies |
64 | |||
65 | <pre> |
||
66 | 11 | Wolfgang Wiedmeyer | apt-get install groff libltdl-dev pkg-config gtk-doc-tools |
67 | 8 | Wolfgang Wiedmeyer | </pre> |
68 | |||
69 | 7 | Wolfgang Wiedmeyer | h3. Getting the source code |
70 | |||
71 | 1 | Wolfgang Wiedmeyer | <pre> |
72 | 13 | Wolfgang Wiedmeyer | git clone https://code.fossencdi.org/external_libqmi.git external/libqmi |
73 | 1 | Wolfgang Wiedmeyer | git clone https://git.savannah.gnu.org/git/libiconv.git external/libiconv -b v1.15 |
74 | 7 | Wolfgang Wiedmeyer | git clone https://github.com/libffi/libffi external/libffi -b v3.2.1 |
75 | 13 | Wolfgang Wiedmeyer | git clone https://code.fossencdi.org/external_gettext.git external/gettext |
76 | 1 | Wolfgang Wiedmeyer | git clone https://github.com/GNOME/glib external/glib -b 2.52.3 |
77 | 13 | Wolfgang Wiedmeyer | </pre> |
78 | |||
79 | h3. Configure and build |
||
80 | |||
81 | The attached script attachment:qmi_build_envsetup.sh makes it more convenient to configure the environment. You need to set the Replicant source tree root folder as the @REPLICANT_BASE@ variable at the top of the script. Then you can source it: |
||
82 | <pre> |
||
83 | . path/to/qmi_build_envsetup.sh |
||
84 | </pre> |
||
85 | |||
86 | 14 | Wolfgang Wiedmeyer | It's recommended to not run this and the following commands in the same shell you use for building a Replicant image as the environment variables break the Replicant build. Run the commands after you built an image for the I9305. |
87 | 13 | Wolfgang Wiedmeyer | |
88 | h4. libiconv |
||
89 | |||
90 | <pre> |
||
91 | ./autogen.sh |
||
92 | 1 | Wolfgang Wiedmeyer | ./configure --build=${BUILD_SYSTEM} --host=arm-eabi --prefix=${PREFIX} --disable-rpath |
93 | 14 | Wolfgang Wiedmeyer | make install -j8 |
94 | </pre> |
||
95 | |||
96 | If @autoconf-2.69@ and @autoheader-2.69@ are not found, remove the @-2.69@ suffix from the @AUTOCONF@ and @AUTOHEADER@ variables in @Makefile.devel@, @libcharset/Makefile.devel@ and @preload/Makefile.devel@. |
||
97 | |||
98 | h4. libffi |
||
99 | |||
100 | <pre> |
||
101 | ./autogen.sh |
||
102 | sed -e '/^includesdir/ s/$(libdir).*$/$(includedir)/' -i include/Makefile.in |
||
103 | sed -e '/^includedir/ s/=.*$/=@includedir@/' -e 's/^Cflags: -I${includedir}/Cflags:/' -i libffi.pc.in |
||
104 | ./configure --build=${BUILD_SYSTEM} --host=arm-eabi --prefix=${PREFIX} --enable-static |
||
105 | make install -j8 |
||
106 | </pre> |
||
107 | |||
108 | 21 | Wolfgang Wiedmeyer | h4. gettext (probably not needed) |
109 | 14 | Wolfgang Wiedmeyer | |
110 | <pre> |
||
111 | ./autogen.sh |
||
112 | ./configure --build=${BUILD_SYSTEM} --host=arm-eabi --prefix=${PREFIX} --disable-rpath --disable-libasprintf --disable-java --disable-native-java --disable-openmp --disable-curses |
||
113 | make install -j8 |
||
114 | </pre> |
||
115 | |||
116 | h4. glib |
||
117 | |||
118 | First, the file @android.cache@ with the following content needs to be created: |
||
119 | <pre> |
||
120 | glib_cv_long_long_format=ll |
||
121 | glib_cv_stack_grows=no |
||
122 | glib_cv_sane_realloc=yes |
||
123 | glib_cv_have_strlcpy=no |
||
124 | glib_cv_va_val_copy=yes |
||
125 | glib_cv_rtldglobal_broken=no |
||
126 | glib_cv_uscore=no |
||
127 | glib_cv_monotonic_clock=no |
||
128 | ac_cv_func_nonposix_getpwuid_r=no |
||
129 | ac_cv_func_posix_getpwuid_r=no |
||
130 | ac_cv_func_posix_getgrgid_r=no |
||
131 | glib_cv_use_pid_surrogate=yes |
||
132 | ac_cv_func_printf_unix98=no |
||
133 | ac_cv_func_vsnprintf_c99=yes |
||
134 | ac_cv_func_realloc_0_nonnull=yes |
||
135 | ac_cv_func_realloc_works=yes |
||
136 | </pre> |
||
137 | |||
138 | Make it read-only: |
||
139 | <pre> |
||
140 | chmod 444 android.cache |
||
141 | </pre> |
||
142 | |||
143 | Then configure and build: |
||
144 | <pre> |
||
145 | ./autogen.sh --build=${BUILD_SYSTEM} --host=${TOOLCHAIN_PREFIX} --prefix=${PREFIX} --disable-dependency-tracking --cache-file=android.cache --enable-included-printf --enable-static --with-pcre=no --enable-libmount=no |
||
146 | make install -j8 |
||
147 | </pre> |
||
148 | |||
149 | h4. libqmi |
||
150 | |||
151 | <pre> |
||
152 | 21 | Wolfgang Wiedmeyer | ./autogen.sh --build=${BUILD_SYSTEM} --host=${TOOLCHAIN_PREFIX} --prefix=${PREFIX} --enable-mbim-qmux=false --enable-firmware-update=false --enable-qmi-username=radio --without-udev --disable-mm-runtime-check --with-udev-base-dir=${PREFIX}/etc/udev |
153 | 13 | Wolfgang Wiedmeyer | make install -j8 |
154 | 7 | Wolfgang Wiedmeyer | </pre> |