QMI-RIL » History » Version 18
Wolfgang Wiedmeyer, 07/16/2017 08:45 PM
explain the current status
1 | 1 | Wolfgang Wiedmeyer | h1. QMI-RIL |
---|---|---|---|
2 | |||
3 | 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. |
||
4 | 2 | Wolfgang Wiedmeyer | |
5 | 6 | Wolfgang Wiedmeyer | "relevant thread on libqmi mailing list":https://lists.freedesktop.org/archives/libqmi-devel/2017-February/002089.html |
6 | |||
7 | 2 | Wolfgang Wiedmeyer | h2. Modem boot |
8 | |||
9 | 17 | Wolfgang Wiedmeyer | h3. Background |
10 | 3 | Wolfgang Wiedmeyer | |
11 | 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. |
12 | 2 | Wolfgang Wiedmeyer | |
13 | 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. |
14 | |||
15 | 1 | Wolfgang Wiedmeyer | Logcat and dmesg output of the upload: attachment:ks_logcat, attachment:ks_dmesg |
16 | |||
17 | "libopenpst":https://github.com/openpst/libopenpst 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. |
||
18 | 17 | Wolfgang Wiedmeyer | |
19 | h3. Implementation |
||
20 | |||
21 | 18 | Wolfgang Wiedmeyer | An initial version of the modem boot part is completed and a tool to boot the modem is available here: https://code.fossencdi.org/i9305_modem.git |
22 | 17 | Wolfgang Wiedmeyer | It uploads the needed files in the Download mode and reboots the modem. |
23 | 4 | Wolfgang Wiedmeyer | |
24 | h2. QMI protocol |
||
25 | |||
26 | 1 | 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. 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 branch is not yet merged into the replicant-6.0 branch because one commit sets SELinux to permissive. This is more convenient for development. The qmi_wwan driver replaces the RMNET usb driver that the blobs use for a network interface to the modem. |
27 | 7 | Wolfgang Wiedmeyer | |
28 | 18 | 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. But after sending a few commands, the modem sends an errfatal interrupt and becomes unusable. A possible reason could be that the modem expects EFS sync to be working on the serial interface when QMI commands are sent. Implementing the EFS sync part with the SAHARA protocol and reading the data the modem sends on the serial interface may help solving this issue. |
29 | 15 | Wolfgang Wiedmeyer | |
30 | 7 | Wolfgang Wiedmeyer | h2. Cross-compiling libqmi for Android on ARM |
31 | |||
32 | 12 | 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. 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. |
33 | 7 | Wolfgang Wiedmeyer | |
34 | 13 | Wolfgang Wiedmeyer | Based on "these instructions":https://zwyuan.github.io/2016/07/17/cross-compile-glib-for-android/ |
35 | |||
36 | 8 | Wolfgang Wiedmeyer | h3. Dependencies |
37 | |||
38 | <pre> |
||
39 | 11 | Wolfgang Wiedmeyer | apt-get install groff libltdl-dev pkg-config gtk-doc-tools |
40 | 8 | Wolfgang Wiedmeyer | </pre> |
41 | |||
42 | 7 | Wolfgang Wiedmeyer | h3. Getting the source code |
43 | |||
44 | 1 | Wolfgang Wiedmeyer | <pre> |
45 | 13 | Wolfgang Wiedmeyer | git clone https://code.fossencdi.org/external_libqmi.git external/libqmi |
46 | 1 | Wolfgang Wiedmeyer | git clone https://git.savannah.gnu.org/git/libiconv.git external/libiconv -b v1.15 |
47 | 7 | Wolfgang Wiedmeyer | git clone https://github.com/libffi/libffi external/libffi -b v3.2.1 |
48 | 13 | Wolfgang Wiedmeyer | git clone https://code.fossencdi.org/external_gettext.git external/gettext |
49 | 1 | Wolfgang Wiedmeyer | git clone https://github.com/GNOME/glib external/glib -b 2.52.3 |
50 | 13 | Wolfgang Wiedmeyer | </pre> |
51 | |||
52 | h3. Configure and build |
||
53 | |||
54 | 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: |
||
55 | <pre> |
||
56 | . path/to/qmi_build_envsetup.sh |
||
57 | </pre> |
||
58 | |||
59 | 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. |
60 | 13 | Wolfgang Wiedmeyer | |
61 | h4. libiconv |
||
62 | |||
63 | <pre> |
||
64 | ./autogen.sh |
||
65 | 1 | Wolfgang Wiedmeyer | ./configure --build=${BUILD_SYSTEM} --host=arm-eabi --prefix=${PREFIX} --disable-rpath |
66 | 14 | Wolfgang Wiedmeyer | make install -j8 |
67 | </pre> |
||
68 | |||
69 | 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@. |
||
70 | |||
71 | h4. libffi |
||
72 | |||
73 | <pre> |
||
74 | ./autogen.sh |
||
75 | sed -e '/^includesdir/ s/$(libdir).*$/$(includedir)/' -i include/Makefile.in |
||
76 | sed -e '/^includedir/ s/=.*$/=@includedir@/' -e 's/^Cflags: -I${includedir}/Cflags:/' -i libffi.pc.in |
||
77 | ./configure --build=${BUILD_SYSTEM} --host=arm-eabi --prefix=${PREFIX} --enable-static |
||
78 | make install -j8 |
||
79 | </pre> |
||
80 | |||
81 | h4. gettext |
||
82 | |||
83 | <pre> |
||
84 | ./autogen.sh |
||
85 | ./configure --build=${BUILD_SYSTEM} --host=arm-eabi --prefix=${PREFIX} --disable-rpath --disable-libasprintf --disable-java --disable-native-java --disable-openmp --disable-curses |
||
86 | make install -j8 |
||
87 | </pre> |
||
88 | |||
89 | h4. glib |
||
90 | |||
91 | First, the file @android.cache@ with the following content needs to be created: |
||
92 | <pre> |
||
93 | glib_cv_long_long_format=ll |
||
94 | glib_cv_stack_grows=no |
||
95 | glib_cv_sane_realloc=yes |
||
96 | glib_cv_have_strlcpy=no |
||
97 | glib_cv_va_val_copy=yes |
||
98 | glib_cv_rtldglobal_broken=no |
||
99 | glib_cv_uscore=no |
||
100 | glib_cv_monotonic_clock=no |
||
101 | ac_cv_func_nonposix_getpwuid_r=no |
||
102 | ac_cv_func_posix_getpwuid_r=no |
||
103 | ac_cv_func_posix_getgrgid_r=no |
||
104 | glib_cv_use_pid_surrogate=yes |
||
105 | ac_cv_func_printf_unix98=no |
||
106 | ac_cv_func_vsnprintf_c99=yes |
||
107 | ac_cv_func_realloc_0_nonnull=yes |
||
108 | ac_cv_func_realloc_works=yes |
||
109 | </pre> |
||
110 | |||
111 | Make it read-only: |
||
112 | <pre> |
||
113 | chmod 444 android.cache |
||
114 | </pre> |
||
115 | |||
116 | Then configure and build: |
||
117 | <pre> |
||
118 | ./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 |
||
119 | make install -j8 |
||
120 | </pre> |
||
121 | |||
122 | h4. libqmi |
||
123 | |||
124 | <pre> |
||
125 | ./autogen.sh --build=${BUILD_SYSTEM} --host=${TOOLCHAIN_PREFIX} --prefix=${PREFIX} --without-udev |
||
126 | 13 | Wolfgang Wiedmeyer | make install -j8 |
127 | 7 | Wolfgang Wiedmeyer | </pre> |