XMMProtocolInterfaces » History » Version 37
Denis 'GNUtoo' Carikli, 01/31/2022 09:17 AM
GT-I9300: Add second AT UART
1 | 1 | Denis 'GNUtoo' Carikli | h1. XMMProtocolInterfaces |
---|---|---|---|
2 | |||
3 | 5 | Denis 'GNUtoo' Carikli | {{>toc}} |
4 | |||
5 | 10 | Denis 'GNUtoo' Carikli | h2. usb_sel |
6 | 3 | Denis 'GNUtoo' Carikli | |
7 | 21 | Denis 'GNUtoo' Carikli | h3. HOWTO enable the modem usb interface |
8 | 3 | Denis 'GNUtoo' Carikli | |
9 | 21 | Denis 'GNUtoo' Carikli | The modem also has an USB port that can be routed to the smartphone/tablet USB port. |
10 | 1 | Denis 'GNUtoo' Carikli | |
11 | 21 | Denis 'GNUtoo' Carikli | To do that you first need to get a root shell in the device as the commands need to be executed as root. |
12 | |||
13 | 10 | Denis 'GNUtoo' Carikli | Once this is done you need to switch the USB connector to the modem USB. This can be done with the following command: |
14 | 1 | Denis 'GNUtoo' Carikli | <pre> |
15 | 10 | Denis 'GNUtoo' Carikli | echo MODEM > /sys/devices/virtual/sec/switch/usb_sel |
16 | 1 | Denis 'GNUtoo' Carikli | </pre> |
17 | |||
18 | 10 | Denis 'GNUtoo' Carikli | Then nothing will happen, you will still be able to login through adb. |
19 | 1 | Denis 'GNUtoo' Carikli | |
20 | 10 | Denis 'GNUtoo' Carikli | To make the device switch to the modem USB you then need to unplug and replug the USB cable between your computer and the device. |
21 | |||
22 | At this point, if the modem was booted, you'll see a new USB device appearing. |
||
23 | Some serial ports will also appear. |
||
24 | |||
25 | Tested on Replicant 6.0 0004 RC3 |
||
26 | |||
27 | 22 | Denis 'GNUtoo' Carikli | | Device | Distribution | Modem status | USB ids (lsusb from laptop) | tty | |
28 | 1 | Denis 'GNUtoo' Carikli | | GT-I9100 | Replicant 6.0 0004 RC3 | Off | None | N/A | |
29 | | GT-I9100 | Replicant 6.0 0004 RC3 | Booted | 1519:0020 Comneon HSIC Device | /dev/ttyACM0 -> /dev/ttyACM6 | |
||
30 | | GT-I9300 | Replicant 6.0 0004 RC3 | Booted | 1519:0020 Comneon HSIC Device | /dev/ttyACM0 -> /dev/ttyACM6 | |
||
31 | 21 | Denis 'GNUtoo' Carikli | |
32 | When running lsusb on the SOC on the Replicant 11 kernel on a GT-I9300, we also see @1519:0020 Comneon HSIC Device@ once the modem is booted. Once powered on and before booting, the USB ids seen in lsusb with that kernel are these ones: @058b:0041 Infineon Technologies Flash Loader utility@ instead. |
||
33 | |||
34 | As the modem isn't visible either when not powered on, we need to look if it's possible to boot the modem from a laptop for instance. |
||
35 | 10 | Denis 'GNUtoo' Carikli | |
36 | 11 | Denis 'GNUtoo' Carikli | h3. Protocols |
37 | 12 | Denis 'GNUtoo' Carikli | |
38 | 20 | Denis 'GNUtoo' Carikli | |_. Device |_. State |_. UART |_. Protocol | |
39 | | GT-I9100 | modem booted | /dev/ttyACM0 | AT: [[GTI9100ModemTTYACM0]] | |
||
40 | | GT-I9100 | modem booted | /dev/ttyACM1 | Compatible with xgoldmon | |
||
41 | | GT-I9300 | modem booted | /dev/ttyACM0 | AT: [[GTI9300ModemTTYACM0]] | |
||
42 | | GT-I9100 | modem booted | /dev/ttyACM1 | Xgoldmon waits for messages but nothing arrives | |
||
43 | 37 | Denis 'GNUtoo' Carikli | | GT-I9300 | modem booted | /dev/ttyACM3 | AT: [[GTI9300ModemTTYACM0]] | |
44 | |||
45 | 3 | Denis 'GNUtoo' Carikli | |
46 | 19 | Denis 'GNUtoo' Carikli | h3. Xgoldmon |
47 | 1 | Denis 'GNUtoo' Carikli | |
48 | 23 | Denis 'GNUtoo' Carikli | description: Xgoldmon is a software that can get some cellular protocol traces from some Samsung phones using the samsung-ipc protocol. |
49 | git: https://github.com/2b-as/xgoldmon.git |
||
50 | |||
51 | 4 | Denis 'GNUtoo' Carikli | Xgoldmon seem to display things on the GT-I9100: |
52 | 1 | Denis 'GNUtoo' Carikli | <pre> |
53 | # ./xgoldmon -vvvv -i localhost -t s2 -l /dev/ttyACM1 |
||
54 | LOG:>>[HIGH]oembatt.c,310,[DISP] Thermistor : measured_value=1630666778<< |
||
55 | LOG:>>[HIGH]oembatt.c,137,[DISP] oem_set_batt_level : 4220<< |
||
56 | 9 | Denis 'GNUtoo' Carikli | LOG:>>[HIGH]oembatt.c,236,[DISP] BATT : measured_value_mv=4220, AvgBattVal_mv=4007, battery_level=5<< |
57 | LOG:>>[LOW]oemdisplay.c,363,no change -> rssi:4, bat:5<< |
||
58 | LOG:>>[HIGH]oembatt.c,310,[DISP] Thermistor : measured_value=1630666779<< |
||
59 | LOG:>>[HIGH]oembatt.c,137,[DISP] oem_set_batt_level : 4225<< |
||
60 | LOG:>>[HIGH]oembatt.c,236,[DISP] BATT : measured_value_mv=4225, AvgBattVal_mv=4026, battery_level=5<< |
||
61 | LOG:>>[LOW]oemdisplay.c,363,no change -> rssi:4, bat:5<< |
||
62 | 1 | Denis 'GNUtoo' Carikli | LOG:>>[HIGH]oembatt.c,310,[DISP] Thermistor : measured_value=1630666778<< |
63 | LOG:>>[HIGH]oembatt.c,137,[DISP] oem_set_batt_level : 4220<< |
||
64 | LOG:>>[HIGH]oembatt.c,236,[DISP] BATT : measured_value_mv=4220, AvgBattVal_mv=4055, battery_level=5<< |
||
65 | LOG:>>[LOW]oemdisplay.c,363,no change -> rssi:4, bat:5<< |
||
66 | </pre> |
||
67 | |||
68 | And when calling an (inexisting/invalid) number, the frames appear in Wireshark. |
||
69 | 19 | Denis 'GNUtoo' Carikli | |
70 | However on the GT-I9300 it waits for messages that never arrive. |
||
71 | And on the GT-I9100 there seem to be very few messages. |
||
72 | |||
73 | 26 | Denis 'GNUtoo' Carikli | I did some tests and compared a GT-I9100 with Replicant 6 and one with the stock distribution (rooted) and the one running Replicant outputed very few messages while the one running the stock OS outputed many messages. |
74 | |||
75 | 29 | Denis 'GNUtoo' Carikli | Both had the same result when running @AT+TRACE?@ on /dev/ttyACM0: |
76 | 26 | Denis 'GNUtoo' Carikli | <pre> |
77 | at+trace? |
||
78 | +TRACE: 1,921600,"ap=1;st=1;db=1;pr=1;bt=1,lt=1;li=1;ga=1;ae=1","DTM",0 |
||
79 | </pre> |
||
80 | |||
81 | For more background on the values: |
||
82 | <pre> |
||
83 | AT+TRACE=? |
||
84 | +TRACE: description START |
||
85 | |||
86 | |||
87 | at+trace=[<mode>],[<speed>],["<unit>=<umode>[,<unit>=<umode>[;...]]]",["<method>"],[PowerSavingCountdown] |
||
88 | |||
89 | <mode>: |
||
90 | ------------------------------------------------------------- |
||
91 | 0: sets all units OFF [param <unit> will be ignored !] |
||
92 | 1: sets all units ON [param <unit> will be ignored !] |
||
93 | no param: 3rd param. <units> configures trace-units |
||
94 | -> trace? will then display 128 as <mode> |
||
95 | |||
96 | <speed>: (115200,230400,460800,921600,1843200,3000000,3250000,6000000) |
||
97 | |||
98 | |||
99 | <units>: |
||
100 | ------------- |
||
101 | ap: apoxi |
||
102 | st: stack |
||
103 | db: debug |
||
104 | pr: printf |
||
105 | bt: bluetooth |
||
106 | lt: LLT |
||
107 | li: LwIP |
||
108 | gt: GATE |
||
109 | ae: AENEAS |
||
110 | |||
111 | <umode>: |
||
112 | ----------------- |
||
113 | 0: unit-trace OFF |
||
114 | 1: unit-trace ON |
||
115 | |||
116 | |||
117 | <method>: |
||
118 | -------------------------------- |
||
119 | "BTM": byte stuffing trace method |
||
120 | "DTM": direct trace method |
||
121 | "EBTM": extended byte stuffing trace method |
||
122 | |||
123 | |||
124 | <PowerSavingCountdown in msecs>: (0-30000) |
||
125 | |||
126 | |||
127 | i.e.: |
||
128 | -------------------------------------------------- |
||
129 | at+trace=0 |
||
130 | at+trace=,460800 |
||
131 | at+trace=,115200,"st=1,pr=1,bt=1,ap=0,db=1,lt=0,li=0" |
||
132 | at+trace=,,"lt=1,db=1,ga=0" |
||
133 | at+trace=,,,"EBTM" |
||
134 | at+trace=,,,,2000 |
||
135 | |||
136 | +TRACE: description END |
||
137 | |||
138 | OK |
||
139 | </pre> |
||
140 | |||
141 | On the stock OS I most followed xmongold procedure: |
||
142 | <pre> |
||
143 | To enable the logging mode ("diag mode") on the S2, S3 and Note2: |
||
144 | - Go to the Phone application, enter *#9900# and set "Debug Level |
||
145 | Enabled" to "HIGH". The phone will reboot. |
||
146 | - Go to the Phone application again, enter *#7284# and set "USB" to |
||
147 | "MODEM" and tap "SAVE and RESET". The phone will reboot again. |
||
148 | </pre> |
||
149 | But I didn't do the @*#9900@ thing as I didn't see any debug level. |
||
150 | |||
151 | 27 | Denis 'GNUtoo' Carikli | I only had the following menu: |
152 | 26 | Denis 'GNUtoo' Carikli | <pre> |
153 | +-------------------------------------------------+ |
||
154 | | Run dumpstate/logcat/modem log | |
||
155 | +-------------------------------------------------+ |
||
156 | | Delete dumpstate/logcat | |
||
157 | +-------------------------------------------------+ |
||
158 | | run dumpstate/local | |
||
159 | +-------------------------------------------------+ |
||
160 | | Copy kenrel log to the SD card | |
||
161 | +-------------------------------------------------+ |
||
162 | | Run modem log | |
||
163 | +-------------------------------------------------+ |
||
164 | | Copy to sdcard(include CP Ramdump) | |
||
165 | +-------------------------------------------------+ |
||
166 | | Disable fast dormancy (Current State: Enabled ) | |
||
167 | +-------------------------------------------------+ |
||
168 | | Ramdump Mode Enable/HIGH | |
||
169 | +-------------------------------------------------+ |
||
170 | 27 | Denis 'GNUtoo' Carikli | | TCP DUMP START | |
171 | 26 | Denis 'GNUtoo' Carikli | +-------------------------------------------------+ |
172 | 27 | Denis 'GNUtoo' Carikli | | Enable SecLog (currently disabled) | |
173 | +-------------------------------------------------+ |
||
174 | | Exit | |
||
175 | +-------------------------------------------------+ |
||
176 | 26 | Denis 'GNUtoo' Carikli | </pre> |
177 | |||
178 | 28 | Denis 'GNUtoo' Carikli | When using run modem log it did show the following popup: |
179 | 26 | Denis 'GNUtoo' Carikli | <pre> |
180 | +----------------------------+ |
||
181 | | /!\ Dump Result | |
||
182 | +----------------------------+ |
||
183 | | GET MODEM LOG SUCCESS! | |
||
184 | | Please copy to SDcard with | |
||
185 | | other Menu button. | |
||
186 | +----------------------------+ |
||
187 | | OK | |
||
188 | +----------------------------+ |
||
189 | </pre> |
||
190 | |||
191 | 30 | Denis 'GNUtoo' Carikli | As for the following: |
192 | <pre> |
||
193 | - Go to the Phone application again, enter *#7284# and set "USB" to |
||
194 | "MODEM" and tap "SAVE and RESET". The phone will reboot again. |
||
195 | </pre> |
||
196 | 31 | Denis 'GNUtoo' Carikli | I didn't have any "SAVE and RESET" and I probably didn't need to reboot but I probably needed to disconnect and reconnect the USB cable. |
197 | 30 | Denis 'GNUtoo' Carikli | |
198 | The setting stay across reboots (I still have @1519:0020 Comneon HSIC Device@) and in the recovery I don't have any USB device (anymore?). |
||
199 | 26 | Denis 'GNUtoo' Carikli | |
200 | |||
201 | In the one running Replicant I did @AT+TRACE=1@. |
||
202 | 24 | Denis 'GNUtoo' Carikli | |
203 | 32 | Denis 'GNUtoo' Carikli | h2. Upstream kernel |
204 | |||
205 | 36 | Denis 'GNUtoo' Carikli | The upstream driver for the Galaxy SIII (GT-I9300) is in "drivers/extcon/extcon-max77693.c":https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/extcon/extcon-max77693.c |
206 | 32 | Denis 'GNUtoo' Carikli | |
207 | Once loaded we have: |
||
208 | <pre> |
||
209 | [root@u-boot-i9300 ~]# uname -r |
||
210 | 5.10.0-rc2+ |
||
211 | |||
212 | [root@u-boot-i9300 ~]# cd /sys/class/extcon/extcon0 |
||
213 | [root@u-boot-i9300 extcon0]# ls */ |
||
214 | cable.0/: |
||
215 | name state |
||
216 | |||
217 | cable.1/: |
||
218 | name state |
||
219 | |||
220 | cable.2/: |
||
221 | name state |
||
222 | |||
223 | cable.3/: |
||
224 | name state |
||
225 | |||
226 | cable.4/: |
||
227 | name state |
||
228 | |||
229 | cable.5/: |
||
230 | name state |
||
231 | |||
232 | cable.6/: |
||
233 | name state |
||
234 | |||
235 | cable.7/: |
||
236 | name state |
||
237 | |||
238 | cable.8/: |
||
239 | name state |
||
240 | |||
241 | cable.9/: |
||
242 | name state |
||
243 | |||
244 | device/: |
||
245 | driver driver_override extcon input modalias power subsystem uevent |
||
246 | |||
247 | power/: |
||
248 | async autosuspend_delay_ms control runtime_active_kids runtime_active_time runtime_enabled runtime_status runtime_suspended_time runtime_usage |
||
249 | |||
250 | subsystem/: |
||
251 | extcon0 |
||
252 | [root@u-boot-i9300 extcon0]# grep . */name |
||
253 | cable.0/name:USB |
||
254 | cable.1/name:USB-HOST |
||
255 | cable.2/name:SDP |
||
256 | cable.3/name:DCP |
||
257 | cable.4/name:FAST-CHARGER |
||
258 | cable.5/name:SLOW-CHARGER |
||
259 | cable.6/name:CDP |
||
260 | cable.7/name:MHL |
||
261 | cable.8/name:JIG |
||
262 | cable.9/name:DOCK |
||
263 | 33 | Denis 'GNUtoo' Carikli | [root@u-boot-i9300 extcon0]# grep . */state |
264 | cable.0/state:1 |
||
265 | cable.1/state:0 |
||
266 | cable.2/state:1 |
||
267 | cable.3/state:0 |
||
268 | cable.4/state:0 |
||
269 | cable.5/state:0 |
||
270 | cable.6/state:0 |
||
271 | cable.7/state:0 |
||
272 | cable.8/state:0 |
||
273 | cable.9/state:0 |
||
274 | 32 | Denis 'GNUtoo' Carikli | </pre> |
275 | |||
276 | I'm unsure if switching from userspace is implemented or not. |
||
277 | |||
278 | 35 | Denis 'GNUtoo' Carikli | Though some part looks unimplemented. |
279 | |||
280 | In "gpio-rev00-m0.h in the smdk4412 kernel":https://git.replicant.us/replicant/kernel_samsung_smdk4412/tree/arch/arm/mach-exynos/include/mach/gpio-rev00-m0.h#n169 we have: |
||
281 | 32 | Denis 'GNUtoo' Carikli | <pre> |
282 | #define GPIO_USB_SEL EXYNOS4212_GPJ0(1) |
||
283 | </pre> |
||
284 | 1 | Denis 'GNUtoo' Carikli | |
285 | 35 | Denis 'GNUtoo' Carikli | And the "max77693-muic.c driver":https://git.replicant.us/replicant/kernel_samsung_smdk4412/tree/drivers/misc/max77693-muic.c seems to use that to do the switch between the modem USB and the SOC USB. |
286 | 32 | Denis 'GNUtoo' Carikli | And that seems to be used to switch to the modem USB. |
287 | |||
288 | 24 | Denis 'GNUtoo' Carikli | h2. Links |
289 | |||
290 | 25 | Denis 'GNUtoo' Carikli | * https://forum.xda-developers.com/t/info-r-d-i9300-uart-and-nvdata-guide.2928854/ Documentation for some GT-I9300 non-standard AT commands |
291 | * https://forum.xda-developers.com/t/a-sgs2-serial-how-to-talk-to-the-modem-with-at-commands.1471241/ Documentation for GT-I9100 tracing commandsh |