From 6276ce90fbb9ccd0eff7a5c6d706ef6810588932 Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Thu, 25 Jul 2019 00:51:47 +0200 Subject: July 2019 Replicant meeting: Add presentations on modems. Signed-off-by: Denis 'GNUtoo' Carikli --- .../modems/.gitignore | 4 + .../modems/COPYING | 428 +++++++++++ .../modems/Makefile | 40 + .../modems/Replicant_and_modems_Introduction.tex | 522 +++++++++++++ .../modems/Replicant_and_modems_Samsung-ipc.tex | 805 +++++++++++++++++++++ .../modems/dot/.gitignore | 1 + .../modems/dot/example_modem.dot | 38 + .../modems/dot/serial_modem_hardware.dot | 38 + .../modems/dot/serial_modem_software.dot | 39 + .../modems/dot/xmm626_hsic.dot | 30 + 10 files changed, 1945 insertions(+) create mode 100644 Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/.gitignore create mode 100644 Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/COPYING create mode 100644 Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Makefile create mode 100644 Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Replicant_and_modems_Introduction.tex create mode 100644 Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Replicant_and_modems_Samsung-ipc.tex create mode 100644 Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/.gitignore create mode 100644 Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/example_modem.dot create mode 100644 Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/serial_modem_hardware.dot create mode 100644 Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/serial_modem_software.dot create mode 100644 Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/xmm626_hsic.dot diff --git a/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/.gitignore b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/.gitignore new file mode 100644 index 0000000..7556a77 --- /dev/null +++ b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/.gitignore @@ -0,0 +1,4 @@ +.* +*~ +\#*# +output/** diff --git a/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/COPYING b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/COPYING new file mode 100644 index 0000000..fd662a7 --- /dev/null +++ b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/COPYING @@ -0,0 +1,428 @@ +Attribution-ShareAlike 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More_considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution-ShareAlike 4.0 International Public +License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-ShareAlike 4.0 International Public License ("Public +License"). To the extent this Public License may be interpreted as a +contract, You are granted the Licensed Rights in consideration of Your +acceptance of these terms and conditions, and the Licensor grants You +such rights in consideration of benefits the Licensor receives from +making the Licensed Material available under these terms and +conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. BY-SA Compatible License means a license listed at + creativecommons.org/compatiblelicenses, approved by Creative + Commons as essentially the equivalent of this Public License. + + d. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + e. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + f. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + g. License Elements means the license attributes listed in the name + of a Creative Commons Public License. The License Elements of this + Public License are Attribution and ShareAlike. + + h. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + i. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + j. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + k. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + l. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + m. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. Additional offer from the Licensor -- Adapted Material. + Every recipient of Adapted Material from You + automatically receives an offer from the Licensor to + exercise the Licensed Rights in the Adapted Material + under the conditions of the Adapter's License You apply. + + c. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + b. ShareAlike. + + In addition to the conditions in Section 3(a), if You Share + Adapted Material You produce, the following conditions also apply. + + 1. The Adapter's License You apply must be a Creative Commons + license with the same License Elements, this version or + later, or a BY-SA Compatible License. + + 2. You must include the text of, or the URI or hyperlink to, the + Adapter's License You apply. You may satisfy this condition + in any reasonable manner based on the medium, means, and + context in which You Share Adapted Material. + + 3. You may not offer or impose any additional or different terms + or conditions on, or apply any Effective Technological + Measures to, Adapted Material that restrict exercise of the + rights granted under the Adapter's License You apply. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material, + + including for purposes of Section 3(b); and + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. + diff --git a/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Makefile b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Makefile new file mode 100644 index 0000000..1414bc7 --- /dev/null +++ b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Makefile @@ -0,0 +1,40 @@ +TEXFLAGS ?= -halt-on-error -output-format pdf -output-directory output + +.PHONY: \ + all \ + clean \ + test \ + medias \ + test-Replicant_and_modems_Introduction.pdf \ + test-Replicant_and_modems_Samsung-ipc.pdf \ + +all: output/Replicant_and_modems_Introduction.pdf output/Replicant_and_modems_Samsung-ipc.pdf + xdg-open output/Replicant_and_modems_Introduction.pdf + xdg-open output/Replicant_and_modems_Samsung-ipc.pdf + +output: + mkdir output + +output/Replicant_and_modems_Introduction.pdf: \ + Replicant_and_modems_Introduction.tex \ + output/example_modem.png \ + output/example_modem.png \ + output/serial_modem_hardware.png \ + output/serial_modem_software.png \ + output/xmm626_hsic.png \ + output + pdflatex $(TEXFLAGS) '\providecommand\locale{en}\input{Replicant_and_modems_Introduction.tex}' + #pdflatex $(TEXFLAGS) '\providecommand\locale{en}\input{Replicant_and_modems_Introduction.tex}' + +output/Replicant_and_modems_Samsung-ipc.pdf: \ + Replicant_and_modems_Samsung-ipc.tex \ + output/xmm626_hsic.png \ + output + pdflatex $(TEXFLAGS) '\providecommand\locale{en}\input{Replicant_and_modems_Samsung-ipc.tex}' + #pdflatex $(TEXFLAGS) '\providecommand\locale{en}\input{Replicant_and_modems_Samsung-ipc.tex}' + +output/%.png: dot/%.dot output + dot -T png $< > $@ + +clean: + rm -rf output diff --git a/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Replicant_and_modems_Introduction.tex b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Replicant_and_modems_Introduction.tex new file mode 100644 index 0000000..17463d4 --- /dev/null +++ b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Replicant_and_modems_Introduction.tex @@ -0,0 +1,522 @@ +\documentclass{beamer} +\usepackage[english]{babel} +\usepackage{color} +\usepackage{graphicx} +\usepackage{ifthen} +\usepackage[utf8]{inputenc} +\usepackage{listings} +\usepackage{pdfpages} + +\lstdefinestyle{terminal}{ + backgroundcolor=\color{black}, + basicstyle=\scriptsize\color{green}, +} + +%% Based on: +%% https://tex.stackexchange.com/questions/136900/insert-a-full-page-image +\newcommand{\pictureframe}[1] { + { + \begin{frame} + \noindent + \resizebox{\textwidth}{\textheight} + {\includegraphics{#1}} + \hspace*{-\textwidth} + \end{frame} + } +} + +\usetheme{Singapore} + +\title{Modems support in Replicant} +\author{Denis 'GNUtoo' Carikli} +\date{\today} + +\begin{document} + +\maketitle + +%% TODO: Using \itemize{} fails to compile +%% TODO: convert \center frames to chapter title + +\begin{frame} + \center{In this presentation:} + \begin{itemize} + \item The hardware + \item Android Reference implementation (More simple) + \item Questions and/or Pause + \item Replicant's Samsung IPC implementation (More complex) + \end{itemize} +\end{frame} + +\begin{frame} + \center{The hardware} +\end{frame} + +\pictureframe{../../external_resources/replicant_website/images/freedom-privacy-security-issues/hardware.png} +\pictureframe{../../external_resources/replicant_website/images/freedom-privacy-security-issues/good-modem-isolation.png} + +\pictureframe{output/example_modem.png} + +\begin{frame} + \center{Why do we look at android reference implementation first?} + \begin{itemize} + \item The hardware is more simple + \item The protocol is way easier to understand + \item Has good enough documentation (standard, reference implentation) + \item It also explains why we got protocols like samsung-ipc + \item Relevant for devices with free software bootloaders + \end{itemize} +\end{frame} + +\begin{frame} + \center{Example: Openmoko} + \begin{itemize} + \item Simple + \item But very strongly outdated + \end{itemize} +\end{frame} + +\pictureframe{output/serial_modem_hardware.png} + +\begin{frame} + \center{AT commands} + \begin{itemize} + \item The good parts: + \begin{itemize} + \item Standard (ETSI GSM 07.07 / 3GPP TS 27.007) + \item Publically available, no registration + \item pdf versions: git://git.osmocom.org/3gpp-etsi-pdf-links.git + \end{itemize} + \item The bad parts: More on that later... + \end{itemize} +\end{frame} + +\begin{frame} + \center{Examples based on the specification (07.07)} +\end{frame} + +\begin{lstlisting}[style=terminal] + # use verbose error values, report registration + > AT+CMEE=2;+CREG=1 + < OK + > AT + < OK + > AT+CFUN=1 + < OK +\end{lstlisting} + +\begin{lstlisting}[style=terminal] + # use verbose error values, report registration + > AT+CMEE=2;+CREG=1 + < OK + > AT+CFUN=1 + < +CME ERROR: SIM PIN required + > AT+CPIN="1234" + < +CME ERROR: incorrect password (user entered wrong PIN) + > AT+CPIN="4321" + < OK + > AT+COPS=0,0 + < OK + < +CREG: 1 + > AT+COPS? + < +COPS: 0,0,"SFR" + > OK +\end{lstlisting} + +\begin{frame} + \center{AT commands: The bad parts:} + \begin{itemize} + \item Syncronous + \item difficult to write parsers (need to keep state) + \item Slow + \item Vendors extensions + \end{itemize} +\end{frame} + +\begin{frame} + \center{More realistic example} +\end{frame} + +\begin{lstlisting}[style=terminal] + # 0707: +CSQ: , + # MDM6200/6600: +CSQ: + # 0707: 31 = -51dbm + # MDM6200/6600: 31 = -75dbm + > +CSQ: 31 + < +CRING: VOICE/06050403002 +\end{lstlisting} + +\begin{lstlisting}[style=terminal] + # Enable noise cancelation on the OpenMoko + > AT%N0105 + < OK +\end{lstlisting} + +\begin{frame} + \center{Example of issues} + \begin{itemize} + \item What if the answer doesn't come back? + \item What if there is some noise on the serial port? + \item What if I need to run another commands while waiting for the answer of the previous one? + \item More modern modems with AT protocol (Example: GTA04): + \begin{itemize} + \item Modem connected over USB + \item Serveral "virtual serial" interfaces + \end{itemize} + \end{itemize} +\end{frame} + +\begin{frame} + \center{The bad parts:} + \begin{itemize} + \item $\rightarrow$This lead vendor to make their own protocol. + \item $\rightarrow$Very similar issues with GPS (NMEA not meant for GPS). + \end{itemize} +\end{frame} + +\begin{frame} + \center{AT commands are still in use:} + \begin{itemize} + \item GTA04 + \item Optimus black + \item Usually (also) available on modems available at low quantity orders. + \item $\rightarrow$Often in use on devices made for the free software community . + \item Sometimes vendor documentation is even publically available for specific modems. + \end{itemize} +\end{frame} + +\begin{frame} + \center{Handling AT command set in Android} +\end{frame} + +\pictureframe{output/serial_modem_software.png} + +\begin{frame} + \center{rild} +\end{frame} + +\begin{frame} + \center{finding libril implementation} + + \raggedright + finding libril implementation: + \begin{verse} + vendor ril lib path either passed in as -l parameter, or read from rild.libpath property + \end{verse} + \begin{verse} + ril arguments either passed in as - - parameter, or read from rild.libargs property + \end{verse} +\end{frame} + +\begin{frame} +\center{finding libril implementation} +\end{frame} + +\begin{lstlisting}[style=terminal] + $ cd device/samsung/i9300 + $ git grep rild + system.prop:rild.libpath=/system/lib/hw/libsamsung-ril.so + system.prop:rild.libargs=-d /dev/ttyS0 +\end{lstlisting} + +\begin{frame} + \center{In the code: hardware/ril/rild/rild.c} +\end{frame} + +\lstset{language=C} +\begin{lstlisting} +int main(int argc, char **argv) { + // [...] + const RIL_RadioFunctions *(*rilInit)( + const struct RIL_Env *, int, char **); + // [...] + dlHandle = dlopen(rilLibPath, RTLD_NOW); + // [...] + RIL_startEventLoop(); + // [...] + rilInit = (const RIL_RadioFunctions *(*)( + const struct RIL_Env *, int, char **)) + dlsym(dlHandle, "RIL_Init"); + funcs = rilInit(&s_rilEnv, argc, rilArgv); + // [...] + RIL_register(funcs); + // [...] +} +\end{lstlisting} + +\begin{frame} + \center{reference-ril} + \begin{itemize} + \item Implements libril, like libsamsung-ril + \item Same git repository than rild + \item AT commands, very basic (only one channel) + \item Beware of CaMeL Case Code and \_ mix (RIL\_Init, not RIL\_init) + \end{itemize} +\end{frame} + +\lstset{language=C} +\begin{lstlisting} +const RIL_RadioFunctions *RIL_Init( + const struct RIL_Env *env, + int argc, char **argv) { + while ( -1 != (opt = getopt(argc, argv, + "p:d:s:c:"))) { + // [...] + switch (opt) { + // [...] + case 'd': + s_device_path = optarg; + RLOGI("Opening tty device %s\n", + s_device_path); + break; + // [...] + } + } // [...] +} +\end{lstlisting} + +\lstset{language=C} +\begin{lstlisting} + static const RIL_RadioFunctions s_callbacks = { + RIL_VERSION, + onRequest, + currentState, + onSupports, + onCancel, + getVersion + }; + // [...] + + const RIL_RadioFunctions *RIL_Init( + const struct RIL_Env *env, + int argc, char **argv) { + // [...] + return &s_callbacks; + } +\end{lstlisting} + +\begin{frame} + \center{Calling} +\end{frame} + +\lstset{language=C} +\begin{lstlisting} + static void onRequest (int request, void *data, + size_t datalen, RIL_Token t) { + // [...] + switch (request) { + // [...] + case RIL_REQUEST_DIAL: + requestDial(data, datalen, t); + break; + // case [...] + } +\end{lstlisting} + +\begin{frame} + \center{requestDial} +\end{frame} + +\lstset{language=C} +\begin{lstlisting} + static void requestDial(void *data, + size_t datalen __unused, RIL_Token t) { + // [...] + ret = at_send_command(cmd, NULL); + + free(cmd); + // [...] + RIL_onRequestComplete(t, RIL_E_SUCCESS, + NULL, 0); + } +\end{lstlisting} + +\begin{frame} + \center{Incomming call} +\end{frame} + +\begin{frame} + \center{onUnsolicited} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + static void onUnsolicited (const char *s, + const char *sms_pdu) { + // [...] + if (strStartsWith(s,"+CRING:") + || strStartsWith(s,"RING") + || strStartsWith(s,"NO CARRIER") + || strStartsWith(s,"+CCWA") ) { + RIL_onUnsolicitedResponse ( + RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, + NULL, 0); + // [...] + } + // [...] + } +\end{lstlisting} + +\begin{frame} + \center{RIL\_Init} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + const RIL_RadioFunctions *RIL_Init( + const struct RIL_Env *env, + int argc, char **argv) { + // [...] + ret = pthread_create(&s_tid_mainloop, &attr, + mainLoop, NULL); + // [...] + } +\end{lstlisting} + +\begin{frame} + \center{MainLoop} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + static void * mainLoop(void *param __unused) { + // [...] + ret = at_open(fd, onUnsolicited); + // [...] + } +\end{lstlisting} + +\begin{frame} + \center{at\_open} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + static ATUnsolHandler s_unsolHandler; + // [...] + + int at_open(int fd, ATUnsolHandler h) + { + // [...] + s_unsolHandler = h; + // [...] + ret = pthread_create(&s_tid_reader, &attr, + readerLoop, &attr); + // [...] + } +\end{lstlisting} + +\begin{frame} + \center{readerLoop} +\end{frame} + +\lstset{language=C} +\begin{lstlisting} + +static void *readerLoop(void *arg __unused) +{ + for (;;) { + // [...] + processLine(line); + // [...] + } + // [...] +} +\end{lstlisting} + +\begin{frame} + \center{processLine} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + static void processLine(const char *line) { + pthread_mutex_lock(&s_commandmutex); + if (sp_response == NULL) { + /* no command pending */ + handleUnsolicited(line); + } // [...] +} +\end{lstlisting} + +\lstset{language=C} +\begin{lstlisting} + static void handleUnsolicited(const char *line) + { + if (s_unsolHandler != NULL) { + s_unsolHandler(line, NULL); + } + } +\end{lstlisting} + +\begin{frame} + \center{Other protocols} +\end{frame} + +\begin{frame} + \center{Other protocols: status} + \begin{itemize} + \item "samsung-ipc" + \begin{itemize} + \item Implemented in libsamsung-ipc + \item Usable on Android and GNU/Linux + \item Incomplete + \item No wireshark dissectror + \item No upstream Linux driver yet + \end{itemize} + \item QMI + \begin{itemize} + \item Implemented in libqmi, other? + \item Usable with upstream Linux and in GNU/Linux + \end{itemize} + \item ISI (Nokia: N900, N9, etc) + \begin{itemize} + \item Implemented in Ofono, Freesmartphone.org, other? + \item Wireshark dissector + \item Upstream Linux drivers + \end{itemize} + \item "Palm Pre" + \begin{itemize} + \item Implemented in msmcomm + \item Was usable in GNU/Linux through Freesmartphone.org + \item Code lost? Michael Lauer should push it again soon. + \end{itemize} + \end{itemize} +\end{frame} + +\begin{frame} + \center{Other protocols: characteristics} + \begin{itemize} + \item Like a network protocol + \begin{itemize} + \item sequence number to match query and response + \item Asyncronous + \end{itemize} + \item Free software implementation not always available + \item Or incomplete (samsung-ipc) + \end{itemize} +\end{frame} + +\begin{frame} + \center{Use a supported protocol} + \begin{itemize} + \item Example with the Palm pre + \begin{itemize} + \item Had an unknown protocol that was used by the nonfree default implementation + \item Also had AT commands + \item People implemented the AT commands + \item No ring indication if my memory is correct + \item At the end they implemented the unknown vendor protocol in msmcommd + \end{itemize} + \end{itemize} +\end{frame} + +\begin{frame} +\center{Questions?} + \begin{itemize} + \item Next part is about Samsung IPC + \item Increasing level of complexity + \item Increasing level of complexity + \item $\rightarrow$ Questions on the first part before continuing. + \end{itemize} +\end{frame} + +\begin{thebibliography}{99} +\end{thebibliography} + +\end{document} diff --git a/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Replicant_and_modems_Samsung-ipc.tex b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Replicant_and_modems_Samsung-ipc.tex new file mode 100644 index 0000000..704d123 --- /dev/null +++ b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Replicant_and_modems_Samsung-ipc.tex @@ -0,0 +1,805 @@ +\documentclass{beamer} +\usepackage[english]{babel} +\usepackage{color} +\usepackage{graphicx} +\usepackage{ifthen} +\usepackage[utf8]{inputenc} +\usepackage{listings} +\usepackage{pdfpages} + +\lstdefinestyle{terminal}{ + backgroundcolor=\color{black}, + basicstyle=\scriptsize\color{green}, +} + +%% Based on: +%% https://tex.stackexchange.com/questions/136900/insert-a-full-page-image +\newcommand{\pictureframe}[1] { + { + \begin{frame} + \noindent + \resizebox{\textwidth}{\textheight} + {\includegraphics{#1}} + \hspace*{-\textwidth} + \end{frame} + } +} + +\usetheme{Singapore} + +\title{Samsung-ipc compatible modems in Replicant} +\author{Denis 'GNUtoo' Carikli} +\date{\today} + +\begin{document} + +\maketitle + +%% TODO: Using \itemize{} fails to compile +%% TODO: convert \center frames to chapter title + +\begin{frame} + \center{Samsung IPC} +\end{frame} + +\begin{frame} + \center{Samsung IPC: Hardware part} +\end{frame} + +\begin{frame} + \center{XMM626 $\leftarrow$RAM$\rightarrow$SOC } + \begin{itemize} + \item Galaxy S (I9100) + \item Nexus S (I902x) + \item Galaxy Tab (unsupported) + \end{itemize} +\end{frame} + +\begin{frame} + \center{XMM626 $\leftarrow$RAM$\rightarrow$SOC: Isolation } + \begin{itemize} + \item Nexus S: The modem kernel driver shows that part of a RAM chip is shared between the modem and the SOC + \item No hardware guarantees that the modem cannot take control of the SOC + \item IOMMU: + \begin{itemize} + \item Requires a mainline kernel to trust the code + \item And the SOC documentation on that... + \item And people having analyzed its security... + \item And to be setup before the RAM is even initialized... + \item But the bootloader is not free software... + \end{itemize} + \end{itemize} +\end{frame} + +\begin{frame} + \center{XMM626 $\leftarrow$MIPI$\rightarrow$SOC } + \begin{itemize} + \item Galaxy Nexus (I9250) + \item Galaxy Tab II 7.0 (P3100) + \item Galaxy Tab II 10.1 (P5100) + \end{itemize} +\end{frame} + +\begin{frame} + \center{XMM626 $\leftarrow$MIPI$\rightarrow$SOC: Isolation } + \begin{itemize} + \item Not analyzed in depth but probably ok + \item Same interface than camera and screens + \end{itemize} +\end{frame} + +\begin{frame} + \center{XMM626 $\leftarrow$HSIC$\rightarrow$SOC } + \begin{itemize} + \item Galaxy S2 (I9100) + \item Galaxy SIII (I9300) + \item Galaxy Note (N7000) + \item Galaxy Note II (N7100) + \item Galaxy Note 8.0 (N5100) + \end{itemize} +\end{frame} + +\begin{frame} + \center{XMM626 $\leftarrow$HSIC$\rightarrow$SOC: Isolation } + \begin{itemize} + \item No DMA to the SOC RAM + \item USB-like bus: USB without the PHY + \item The host need to reset the bus to get the devices re-enumerated + \item $\rightarrow$ More complicated for the modem to become a keyboard + \item Ideally (not looked into yet): + \begin{itemize} + \item usbguard + \item USB peripherals whitelist + \item $\rightarrow$ re-usable for USB modems (GTA04, PinePhone, Librem5, etc). + \end{itemize} + \end{itemize} +\end{frame} + +\begin{frame} + \center{Samsung IPC} + \begin{itemize} + \item We will look more specifically at the case with the XMM626 connected through HSIC. + \item Other transports are similar: transports are abstracted by the kernel driver and libsamsung-ipc transport drivers. + \end{itemize} +\end{frame} + +\pictureframe{output/xmm626_hsic.png} + +\begin{frame} + \center{The samsung-ipc protocol} + \begin{itemize} + \item Asyncronous + \item $\rightarrow$ You get asyncronous responses from the modem + \item $\rightarrow$ You match with the request (sequence numbers) + \item $\rightarrow$ libsamsung-ril needs receive asyncronous responses too + \item $\rightarrow$ More complex design with callbacks + \end{itemize} +\end{frame} + +\begin{frame} + \center{libsamsung-ril} +\end{frame} + +\begin{frame} + \center{The initialization not very different from the reference-ril} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + RIL_RadioFunctions ril_radio_functions = { + RIL_VERSION, + ril_on_request, + ril_on_state_request, + ril_supports, + ril_on_cancel, + ril_get_version + }; + ... + + const RIL_RadioFunctions *RIL_Init( + const struct RIL_Env *env, int argc, + char **argv) { + ... + return radio_functions; + } +\end{lstlisting} + +\begin{frame} + \center{The interface with rild is not that different either} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + void ril_on_request(int request, void *data, + size_t size, RIL_Token token) { + ... + ril_request_register(request, data, size, token); + ... +} +\end{lstlisting} + +\begin{frame} +\center{ril\_request\_register} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + int ril_request_register(int request, void *data, + size_t size, RIL_Token token) { + ... + list_end = ril_data->requests; + ... + list = list_head_alloc(list_end, NULL, + (void *) ril_request); + ... + ril_data->requests = list; +} +\end{lstlisting} + +\begin{frame} + \center{Global ril\_Data variable} +\end{frame} + +\lstset{language=bash} +\begin{lstlisting}[style=terminal] +$ git grep "extern.*ril_data;" +samsung-ril.h:extern struct ril_data *ril_data; +\end{lstlisting} + +\begin{frame} + \center{Why?} + \begin{itemize} + \item Asyncronous design $\rightarrow$ Faster + \item Enqueue the request and continue serving new requests. + \item We will see how getting the response works in a second time + \end{itemize} +\end{frame} + +\begin{frame} + \begin{itemize} + \item We got a request to power on the phone from the RIL + \item We got rid of it by adding it to a list + \item Now what happens to it? + \end{itemize} +\end{frame} + +\begin{frame} + \center{RIL\_Init} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + const RIL_RadioFunctions *RIL_Init( + const struct RIL_Env *env, int argc, + char **argv) { + ... + rc = pthread_create(&ril_data->request_thread, + &attr, ril_request_loop, NULL); + ... +} +\end{lstlisting} + +\begin{frame} + \center{ril\_request\_loop} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + +void *ril_request_loop(void *data) { ... + while (1) { + do { + request = ril_request_find_status( + RIL_REQUEST_UNHANDLED); + ... + request->status = RIL_REQUEST_PENDING; + } while (request != NULL); + do { + ... + request = ril_request_find_status( + RIL_REQUEST_PENDING); + ... + rc = ril_request_dispatch(request); + } while (request != NULL); + } +\end{lstlisting} + +\begin{frame} + \center{ril\_request\_dispatch} +\end{frame} + +\lstset{language=C} +\begin{lstlisting} + int ril_request_dispatch( + struct ril_request *request) { + ... + for (i = 0; i < ril_request_handlers_count; + i++) { + ... + if (ril_request_handlers[i].request == + request->request) { + status = ril_request_handlers[i].handler( + quest->data, request->size, + request->token); + ... + request->status = status; ... + } ... + } ... + return 0; + } +\end{lstlisting} + +\begin{frame} + \center{ril\_request\_handler} +\end{frame} + +\lstset{language=C} +\begin{lstlisting} + struct ril_request_handler + ril_request_handlers[] = { + /* Power */ + { + .request = RIL_REQUEST_RADIO_POWER, + .handler = ril_request_radio_power, + }, ... + } +\end{lstlisting} + +\begin{frame} + \center{ril\_request\_radio\_power} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + int ril_request_radio_power(void *data, + size_t size, RIL_Token token) { + ... + power_state = *((int *)data); + ... + if (power_state > 0) { + request_data.state = + IPC_PWR_PHONE_STATE_REQUEST_NORMAL; ... + } else { + request_data.state = + IPC_PWR_PHONE_STATE_REQUEST_LPM; ... + } ... + rc = ipc_fmt_send(ipc_fmt_request_seq(token), + IPC_PWR_PHONE_STATE, IPC_TYPE_EXEC, + (void *) &request_data, + sizeof(request_data)); ... + } +\end{lstlisting} + +\begin{frame} + \center{ipc\_fmt\_send} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + int ipc_fmt_send(unsigned char mseq, + unsigned short command, unsigned char type, + const void *data, size_t size) { + ... + ipc_fmt_data = (struct ipc_fmt_data *) + client->data; + ... + rc = ipc_client_send(ipc_fmt_data->ipc_client, + mseq, command, type, data, size); + ... +} + +\end{lstlisting} + +\begin{frame} + \center{The rest happens in libsamsung-ipc} +\end{frame} + +\lstset{language=bash} +\begin{lstlisting}[style=terminal] +$ git grep IPC_PWR_PHONE_STATE_REQUEST_NORMAL + include/pwr.h: + #define IPC_PWR_PHONE_STATE_REQUEST_NORMAL 0x0202 +$ git grep ipc_client_send + include/samsung-ipc.h: + int ipc_client_send(struct ipc_client *client, ... + samsung-ipc/ipc.c: + int ipc_client_send(struct ipc_client *client, ... +\end{lstlisting} + + +\begin{frame} + \center{Now what happens with notifications from the modem?} +\end{frame} + +\begin{frame} + \center{Again RIL\_Init} +\end{frame} + +\lstset{language=C} +\begin{lstlisting} + const RIL_RadioFunctions *RIL_Init( + const struct RIL_Env *env, + __attribute__((unused)) int argc, + __attribute__((unused)) char **argv) { + ... + rc = ril_client_loop(ril_clients[i]); + ... + } +\end{lstlisting} + +\begin{frame} + \center{ril\_clients[i]?} +\end{frame} + +\begin{frame} + \center{ril\_clients} +\end{frame} +\lstset{language=C} +\begin{lstlisting} +struct ril_client *ril_clients[] = { + &ipc_fmt_client, + &ipc_rfs_client, + &srs_client, +}; +\end{lstlisting} + +\begin{frame} + \center{IPC and RFS} + \begin{itemize} + \item RFS: Modem's remote filesystem (EFS) + \item SRS: For the audio part + \item IPC: The rest of the protocol + \end{itemize} +\end{frame} + +\lstset{language=bash} +\begin{lstlisting}[style=terminal] +$ git grep XMM626_SEC_MODEM_IPC0_DEVICE + modems/xmm626/xmm626_sec_modem.c: + fd = open(XMM626_SEC_MODEM_IPC0_DEVICE, + O_RDWR | O_NOCTTY | O_NONBLOCK); + modems/xmm626/xmm626_sec_modem.h: + #define XMM626_SEC_MODEM_IPC0_DEVICE + "/dev/umts_ipc0" + $ git grep XMM626_SEC_MODEM_RFS0_DEVICE + modems/xmm626/xmm626_sec_modem.c: + fd = open(XMM626_SEC_MODEM_RFS0_DEVICE, + O_RDWR | O_NOCTTY | O_NONBLOCK); + modems/xmm626/xmm626_sec_modem.h: + #define XMM626_SEC_MODEM_RFS0_DEVICE + "/dev/umts_rfs0" +\end{lstlisting} + +\begin{frame} + \center{ril\_client\_loop} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + int ril_client_loop(struct ril_client *client) { + ... + rc = pthread_create(&client->thread, &attr, + ril_client_thread, (void *) client); + ... + } + +\end{lstlisting} + +\begin{frame} + \center{ril\_client\_thread} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + void *ril_client_thread(void *data) { + ... + client = (struct ril_client *) data; + ... + rc = client->handlers->loop(client); + ... + } +\end{lstlisting} + +\begin{frame} + \center{ril\_client} +\end{frame} +\lstset{language=C} +\begin{lstlisting} +struct ril_client ipc_fmt_client = { + .id = RIL_CLIENT_IPC_FMT, + .name = "IPC FMT", + .handlers = &ipc_fmt_handlers, + .callbacks = &ipc_fmt_callbacks, +}; +\end{lstlisting} + +\begin{frame} + \center{ipc\_fmt\_handers} +\end{frame} +\lstset{language=C} +\begin{lstlisting} +struct ril_client_handlers ipc_fmt_handlers = { + .create = ipc_fmt_create, + .destroy = ipc_fmt_destroy, + .open = ipc_fmt_open, + .close = ipc_fmt_close, + .loop = ipc_fmt_loop, +}; +\end{lstlisting} + +\begin{frame} + \center{ipc\_fmt\_loop} +\end{frame} + +\lstset{language=C} +\begin{lstlisting} + int ipc_fmt_loop(struct ril_client *client) { + ... + rc = ipc_client_recv(data->ipc_client, + &message); + ... + rc = ipc_fmt_dispatch(client, &message); + ... + } +\end{lstlisting} + +\begin{frame} + \center{ipc\_fmt\_dispatch} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + int ipc_fmt_dispatch(struct ril_client *client, + struct ipc_message *message) { + ... + for (i = 0; + i < ipc_fmt_dispatch_handlers_count; i++) { + ... + if (ipc_fmt_dispatch_handlers[i].command == + message->command) { + ... + rc = ipc_fmt_dispatch_handlers[i].handler( + message); + ... + } + } + ... +} +\end{lstlisting} + +\begin{frame} + \center{ipc\_fmt\_dispatch\_handlers} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + struct ipc_dispatch_handler + ipc_fmt_dispatch_handlers[] = { + /* Power */ + { + .command = IPC_PWR_PHONE_PWR_UP, + .handler = ipc_pwr_phone_pwr_up, + }, +\end{lstlisting} + +\begin{frame} + \center{ipc\_pwr\_phone\_pwr\_up} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + int ipc_pwr_phone_pwr_up(__attribute__((unused)) + struct ipc_message *message) { + ril_radio_state_update(RADIO_STATE_OFF); + + return 0; + } +\end{lstlisting} + +\begin{frame} + \center{libsamsung-ipc} +\end{frame} + +\begin{frame} + \center{ipc\_client\_send} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + int ipc_client_send(struct ipc_client *client, + unsigned char mseq, unsigned short command, + unsigned char type, const void *data, + size_t size) { + ... + memset(&message, 0, sizeof(message)); + message.mseq = mseq; + message.aseq = 0xff; + message.command = command; + message.type = type; + message.data = (void *) data; + message.size = size; + + return client->ops->send(client, &message); +} +\end{lstlisting} + +\begin{frame} + \center{client$\rightarrow$ops$\rightarrow$send} +\end{frame} + + +\begin{frame} + \center{ipc\_client\_create} +\end{frame} +\lstset{language=C} +\begin{lstlisting} +struct ipc_client *ipc_client_create(int type) { + ... + rc = ipc_device_detect(); + ... + switch (type) { + ... + case IPC_CLIENT_TYPE_FMT: + client->ops = + ipc_devices[device_index].fmt_ops; + break; + ... + } + ... +} +\end{lstlisting} + +\begin{frame} + \center{ipc\_device\_detect} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + int ipc_device_detect(void) { + ... + fd = open("/proc/cpuinfo", O_RDONLY); + ... + if (strncmp(line, "Hardware", 8) == 8) { + ... + if (... && strcmp(kernel_version, + ipc_devices[i].kernel_version) != 0) + ... +} + +\end{lstlisting} + +\begin{frame} + \center{ipc\_devices} +\end{frame} +\lstset{language=C} +\begin{lstlisting} +struct ipc_device_desc ipc_devices[] = { + ... + { + .name = "i9300", + .board_name = "smdk4x12", + .kernel_version = NULL, + .fmt_ops = &i9300_fmt_ops, + .rfs_ops = &i9300_rfs_ops, + .handlers = &i9300_handlers, + .gprs_specs = &i9300_gprs_specs, + .nv_data_specs = &i9300_nv_data_specs, + }, +\end{lstlisting} + +\begin{frame} + \center{ipc\_client\_ops} +\end{frame} +\lstset{language=C} +\begin{lstlisting} +struct ipc_client_ops i9300_fmt_ops = { + .boot = i9300_boot, + .send = xmm626_sec_modem_fmt_send, + .recv = xmm626_sec_modem_fmt_recv, +}; +\end{lstlisting} + +\begin{frame} + \center{xmm626\_sec\_modem\_fmt\_send} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + int xmm626_sec_modem_fmt_send( + struct ipc_client *client, + struct ipc_message *message) { + ... + rc = client->handlers->write( + client->handlers->transport_data, + p, length - count); + } +\end{lstlisting} + + +\begin{frame} + \center{i9300\_handlers} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + struct ipc_client_handlers i9300_handlers = { + .read = i9300_read, + .write = i9300_write, + .open = i9300_open, + .close = i9300_close, + .poll = i9300_poll, + .transport_data = NULL, + .power_on = i9300_power_on, + .power_off = i9300_power_off, + .power_data = NULL, + .gprs_activate = i9300_gprs_activate, + .gprs_deactivate = i9300_gprs_deactivate, + .gprs_data = NULL, + .data_create = i9300_data_create, + .data_destroy = i9300_data_destroy, + }; +\end{lstlisting} + +\begin{frame} + \center{i9300\_open} +\end{frame} +\lstset{language=C} +\begin{lstlisting} +int i9300_open(void *data, int type) +{ + ... + transport_data->fd = + xmm626_sec_modem_open(type); + ... + return 0; +} +\end{lstlisting} + +\begin{frame} + \center{xmm626\_sec\_modem\_open} +\end{frame} +\lstset{language=C} +\begin{lstlisting} +int xmm626_sec_modem_open(int type) { + switch (type) { + case IPC_CLIENT_TYPE_FMT: + fd = open(XMM626_SEC_MODEM_IPC0_DEVICE, + O_RDWR | O_NOCTTY | O_NONBLOCK); + break; + case IPC_CLIENT_TYPE_RFS: + fd = open(XMM626_SEC_MODEM_RFS0_DEVICE, + O_RDWR | O_NOCTTY | O_NONBLOCK); + break; + default: + return -1; + } + ... +} +\end{lstlisting} + +\begin{frame} + \center{xmm626\_sec\_modem\_fmt\_send} +\end{frame} +\lstset{language=bash} +\begin{lstlisting}[style=terminal] + $ git grep XMM626_SEC_MODEM_IPC0_DEVICE + devices/xmm626/xmm626_sec_modem.h: + #define XMM626_SEC_MODEM_IPC0_DEVICE "/dev/umts_ipc0" + $ git grep XMM626_SEC_MODEM_RFS0_DEVICE + devices/xmm626/xmm626_sec_modem.h: + #define XMM626_SEC_MODEM_RFS0_DEVICE "/dev/umts_rfs0" +\end{lstlisting} + +\begin{frame} + \center{i9300\_write} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + int i9300_write(void *data, + const void *buffer, size_t length) { + ... + rc = xmm626_sec_modem_write( + transport_data->fd, buffer, length); + + return rc; +} +\end{lstlisting} + +\begin{frame} + \center{xmm626\_modem\_write} +\end{frame} +\lstset{language=C} +\begin{lstlisting} + int xmm626_sec_modem_write(int fd, + const void *buffer, size_t length) { + ... + status = ioctl(fd, IOCTL_MODEM_STATUS, 0); + if (status != STATE_ONLINE && + status != STATE_BOOTING) + return -1; + + rc = write(fd, buffer, length); + + return rc; +} +\end{lstlisting} + +\begin{frame} + \center{Sharing the work with other Android distributions} + \begin{itemize} + \item Not complete enough to be merged in LineageOS + \end{itemize} +\end{frame} + +\begin{frame} + \center{Sharing the work with GNU/Linux distributions} + \begin{itemize} + \item Freesmartphone.org + \item Ofono + rild + libamsung-ril + libsamsung-ipc + \item Ofono + libsamsung-ipc + \item PostmarketOS? + \item PureOS, Parabola? + \end{itemize} +\end{frame} + +\begin{frame} + \center{Discussions:} + \begin{itemize} + \item Sharing code with other distributions? + \item USB Guard? + \item Device requirements: Require modem to be isolated ? + \item Other modems and GNU/Linux stack (PinePhone, GTA04)? + \item Using GNU/Linux modem stack as much as possible? + \item Automatic testing infrastructure and ofono? + \item GNU/Linux and testing? + \end{itemize} +\end{frame} + +\begin{thebibliography}{99} +\end{thebibliography} + +\end{document} diff --git a/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/.gitignore b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/.gitignore new file mode 100644 index 0000000..76ce7fc --- /dev/null +++ b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/.gitignore @@ -0,0 +1 @@ +*.jpg diff --git a/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/example_modem.dot b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/example_modem.dot new file mode 100644 index 0000000..5263eb9 --- /dev/null +++ b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/example_modem.dot @@ -0,0 +1,38 @@ +graph { + bgcolor="#ffffff00" # Transparent background + ratio=0.8 + overlap=false + subgraph cluster_modem { + label="Modem"; + "MODEM_BUS" [label="USB, Serial port, HSIC, RAM, MIPI, etc"]; + + }; + subgraph cluster_soc { + label="SOC (Exynos, OMAP, etc)"; + subgraph cluster_hardware { + label="Hardware"; + "SOC_BUS" [label="USB, Serial port, HSIC, RAM, MIPI, etc"]; + "SOC_BUS" -- "MODEM_BUS"; + }; + + subgraph cluster_software { + label="Software"; + "libsamsung-ril" [label="libsamsung-ril"]; + "libril" [label="other libril:, reference-ril, qmi-ril, etc"]; + "MODEM_DRIVER" [label="Linux driver: Modem drivers (+ possibly a low level protocol)"]; + + "SOC_BUS" -- "MODEM_DRIVER"; + + "MODEM_DRIVER" -- "libril"; + "libril" -- "rild"; + + "MODEM_DRIVER" -- "libsamsung-ipc"; + "libsamsung-ipc" -- "libsamsung-ril"; + "libsamsung-ril" -- "rild"; + + "rild" -- "framework"; + "framework" -- "applications (dialer, silence, etc)"; + }; + }; + +} diff --git a/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/serial_modem_hardware.dot b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/serial_modem_hardware.dot new file mode 100644 index 0000000..3b3d0dd --- /dev/null +++ b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/serial_modem_hardware.dot @@ -0,0 +1,38 @@ +graph { + bgcolor="#ffffff00" # Transparent background + ratio=0.8 + overlap=false + subgraph cluster_modem { + style=bold + label="Modem"; + "MODEM_BUS" [label="Serial port" style=bold]; + + }; + subgraph cluster_soc { + label="SOC (Exynos, OMAP, etc)"; + subgraph cluster_hardware{ + style=bold; + label="Hardware"; + "SOC_BUS" [label="Serial port" style=bold]; + "SOC_BUS" -- "MODEM_BUS" [style=bold]; + }; + + subgraph cluster_software { + label="Software"; + "framework" [style=dashed]; + "libril" [label="reference-ril" style=dashed]; + "MODEM_DRIVER" [label="Linux drivers: +- Serial port driver +- Power on/off the modem" style=bold ]; + "rild" [style=dashed]; + "applications" [label="(dialer, silence, etc)" style=dashed]; + + "SOC_BUS" -- "MODEM_DRIVER" [style=bold]; + "MODEM_DRIVER" -- "libril" [style=bold]; + "libril" -- "rild" [style=dashed]; + "rild" -- "framework" [style=dashed]; + "framework" -- "applications" [style=dashed]; + }; + }; + +} diff --git a/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/serial_modem_software.dot b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/serial_modem_software.dot new file mode 100644 index 0000000..3d79714 --- /dev/null +++ b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/serial_modem_software.dot @@ -0,0 +1,39 @@ +graph { + bgcolor="#ffffff00" # Transparent background + ratio=0.8 + overlap=false + subgraph cluster_modem { + style=dashed + label="Modem"; + "MODEM_BUS" [label="Serial port" style=dashed]; + + }; + subgraph cluster_soc { + label="SOC (Exynos, OMAP, etc)"; + subgraph cluster_hardware{ + style=dashed; + label="Hardware"; + "SOC_BUS" [label="Serial port" style=dashed]; + "SOC_BUS" -- "MODEM_BUS" [style=dashed]; + }; + + subgraph cluster_software { + label="Software"; + "framework" [style=bold]; + "libril" [label="reference-ril" style=bold]; + "MODEM_DRIVER" [label="Linux drivers: +- Serial port driver +- Power on/off the modem" style=dashed ]; + "rild" [style=bold]; + "applications" [label="(dialer, silence, etc)" + style=bold]; + + "SOC_BUS" -- "MODEM_DRIVER" [style=dashed]; + "MODEM_DRIVER" -- "libril" [style=bold]; + "libril" -- "rild" [style=bold]; + "rild" -- "framework" [style=bold]; + "framework" -- "applications" [style=bold]; + }; + }; + +} diff --git a/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/xmm626_hsic.dot b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/xmm626_hsic.dot new file mode 100644 index 0000000..bccc4ed --- /dev/null +++ b/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/dot/xmm626_hsic.dot @@ -0,0 +1,30 @@ +graph { + bgcolor="#ffffff00" # Transparent background + ratio=0.8 + overlap=false + subgraph cluster_modem { + label="Modem: Intel XMM626"; + "MODEM_HSIC" [label="HSIC (USB without PHY)"]; + + }; + subgraph cluster_soc { + label="SOC (Exynos, OMAP, etc)"; + subgraph cluster_hardware { + label="Hardware"; + "SOC_HSIC" [label="HSIC (USB without PHY)"]; + "SOC_HSIC" -- "MODEM_HSIC"; + }; + + subgraph cluster_software { + label="Software"; + "MODEM_DRIVER" [label="Linux driver: Modem drivers + protocol"]; + "SOC_HSIC" -- "MODEM_DRIVER"; + "MODEM_DRIVER" -- "libsamsung-ipc"; + "libsamsung-ipc" -- "libsamsung-ril"; + "libsamsung-ril" -- "rild"; + "rild" -- "framework"; + "framework" -- "applications (dialer, silence, etc)"; + }; + }; + +} -- cgit v1.2.3