GalaxyNexusI9250SerialConsole » History » Version 19
Denis 'GNUtoo' Carikli, 01/29/2020 11:19 PM
1 | 16 | Paul Kocialkowski | h1. Galaxy Nexus (I9250) Serial Console |
---|---|---|---|
2 | 1 | Denis 'GNUtoo' Carikli | |
3 | 19 | Denis 'GNUtoo' Carikli | See [[SamsungSerial]] for the hardware setup. |
4 | 1 | Denis 'GNUtoo' Carikli | |
5 | 19 | Denis 'GNUtoo' Carikli | h2. Without patching the kernel on Replicant 6 |
6 | |||
7 | Adding @loglevel=8 fiq_debugger.console_enable=1 fiq_debugger.no_sleep=1@ to the kernel command line enables to see some of the boot of the kernel without having to recompile the kernel. |
||
8 | |||
9 | Though it requires to repack a boot.img to add the commandline arguments. |
||
10 | <pre> |
||
11 | IMAGE ?= boot.img |
||
12 | EXTRA_CMDLINE ?= loglevel=8 fiq_debugger.console_enable=1 fiq_debugger.no_sleep=1 |
||
13 | |||
14 | .PHONY: $(IMAGE) flash |
||
15 | $(IMAGE): |
||
16 | unbootimg --kernel kernel \ |
||
17 | --ramdisk ramdisk \ |
||
18 | -i ../$(IMAGE) |
||
19 | mkbootimg \ |
||
20 | --kernel kernel \ |
||
21 | --ramdisk ramdisk \ |
||
22 | --base 0x80000000 \ |
||
23 | --cmdline "androidboot.hardware=tuna ${EXTRA_CMDLINE}" \ |
||
24 | -o $(IMAGE) |
||
25 | flash: |
||
26 | fastboot flash boot $(IMAGE) |
||
27 | fastboot flash recovery $(IMAGE) |
||
28 | fastboot boot $(IMAGE) |
||
29 | </pre> |
||
30 | |||
31 | h2. Serial console t |
||
32 | |||
33 | |||
34 | 1 | Denis 'GNUtoo' Carikli | |
35 | When you connect the cable you get the FIQ debugger, but what if you want kgdb instead: |
||
36 | * apply that patch: |
||
37 | <pre> |
||
38 | diff --git a/arch/arm/mach-omap2/board-tuna.c b/arch/arm/mach-omap2/board-tuna.c |
||
39 | index a022a43..7098227 100644 |
||
40 | --- a/arch/arm/mach-omap2/board-tuna.c |
||
41 | +++ b/arch/arm/mach-omap2/board-tuna.c |
||
42 | @@ -1001,6 +1001,8 @@ static inline void __init board_serial_init(void) |
||
43 | omap_serial_init_port_pads(0, uart1_pads, uart1_pads_sz, NULL); |
||
44 | omap_serial_init_port_pads(1, tuna_uart2_pads, |
||
45 | ARRAY_SIZE(tuna_uart2_pads), &tuna_uart2_info); |
||
46 | + omap_serial_init_port_pads(2,tuna_uart3_pads, |
||
47 | + ARRAY_SIZE(tuna_uart3_pads), NULL); |
||
48 | omap_serial_init_port_pads(3, tuna_uart4_pads, |
||
49 | ARRAY_SIZE(tuna_uart4_pads), NULL); |
||
50 | } |
||
51 | </pre> |
||
52 | * remove the FIQ debugger in the kernel configuration. |
||
53 | |||
54 | * change the CMDLINE trough the kernel configuration: |
||
55 | Use: |
||
56 | <pre>CONFIG_CMDLINE="console=ttyO2 androidboot.console=ttyO2 [...]"</pre> |
||
57 | Instead of: |
||
58 | <pre>CONFIG_CMDLINE="console=ttyFIQ0 androidboot.console=ttyFIQ0 [...]"</pre> |
||
59 | 2 | Denis 'GNUtoo' Carikli | |
60 | 3 | Denis 'GNUtoo' Carikli | * Verify that you get the kernel messages. |
61 | 2 | Denis 'GNUtoo' Carikli | |
62 | 12 | Denis 'GNUtoo' Carikli | h2. KGDB |
63 | |||
64 | 3 | Denis 'GNUtoo' Carikli | * Then change the cmdline for kgdb |
65 | 4 | Denis 'GNUtoo' Carikli | <pre> |
66 | CONFIG_CMDLINE="kgdboc=ttyO2,115200 console=ttyO2 androidboot.console=ttyO2 [...]" |
||
67 | </pre> |
||
68 | |||
69 | Don't add kgdbwait tough because it result in that: |
||
70 | <pre> |
||
71 | (gdb) set remotebaud 115200 |
||
72 | (gdb) target remote /dev/ttyUSB0 |
||
73 | /dev/ttyUSB0: Device or resource busy. |
||
74 | (gdb) target remote /dev/ttyUSB0 |
||
75 | Remote debugging using /dev/ttyUSB0 |
||
76 | kgdb_breakpoint () |
||
77 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/kernel/debug/debug_core.c:954 |
||
78 | 954 arch_kgdb_breakpoint(); |
||
79 | (gdb) c |
||
80 | Continuing. |
||
81 | |||
82 | Program received signal SIGSEGV, Segmentation fault. |
||
83 | __raw_spin_lock_irqsave (lock=0x288) |
||
84 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/kernel/spinlock.c:112 |
||
85 | 112 BUILD_LOCK_OPS(spin, raw_spinlock); |
||
86 | (gdb) bt |
||
87 | #0 __raw_spin_lock_irqsave (lock=0x288) |
||
88 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/kernel/spinlock.c:112 |
||
89 | #1 0xc061aecc in _raw_spin_lock_irqsave (lock=0x288) |
||
90 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/kernel/spinlock.c:145 |
||
91 | #2 0xc0098620 in try_to_wake_up (p=0x0, state=1611595795, wake_flags=1) |
||
92 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/kernel/sched.c:2681 |
||
93 | #3 0xc009897c in wake_up_process (p=0x288) |
||
94 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/kernel/sched.c:2785 |
||
95 | #4 0xc00e2090 in proc_dohung_task_timeout_secs (table=<value optimized out>, write=<value optimized out>, |
||
96 | buffer=<value optimized out>, lenp=<value optimized out>, ppos=0xc782bf70) |
||
97 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/kernel/hung_task.c:190 |
||
98 | #5 0xc0174178 in proc_sys_call_handler (filp=<value optimized out>, buf=0x24808, count=1, ppos=0xc782bf70, |
||
99 | write=1) at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/fs/proc/proc_sysctl.c:158 |
||
100 | #6 0xc01741b0 in proc_sys_write (filp=0x288, buf=0x600f0013 <Address 0x600f0013 out of bounds>, count=1, |
||
101 | ppos=0xc782a000) |
||
102 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/fs/proc/proc_sysctl.c:176 |
||
103 | #7 0xc0126420 in vfs_write (file=0xc73be500, buf=0x24808 "0", count=<value optimized out>, pos=0xc782bf70) |
||
104 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/fs/read_write.c:377 |
||
105 | #8 0xc0126590 in sys_write (fd=<value optimized out>, buf=0x24808 "0", count=1) |
||
106 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/fs/read_write.c:429 |
||
107 | #9 0xc0055a00 in ?? () |
||
108 | Cannot access memory at address 0x0 |
||
109 | #10 0xc0055a00 in ?? () |
||
110 | Cannot access memory at address 0x0 |
||
111 | Backtrace stopped: previous frame identical to this frame (corrupt stack?) |
||
112 | </pre> |
||
113 | 5 | Denis 'GNUtoo' Carikli | |
114 | 10 | Denis 'GNUtoo' Carikli | * disable the watchdog timer in the kernel, and recompile it and reflash the boot.img. |
115 | 6 | Denis 'GNUtoo' Carikli | |
116 | then open a root console and do: |
||
117 | <pre> |
||
118 | echo g > /proc/sysrq-trigger |
||
119 | </pre> |
||
120 | 7 | Denis 'GNUtoo' Carikli | |
121 | <pre> |
||
122 | gnutoo@gnutoo-laptop:~/embedded/android/replicant-4.0$ . build/envsetup.sh |
||
123 | including device/ti/panda/vendorsetup.sh |
||
124 | including vendor/replicant/vendorsetup.sh |
||
125 | including sdk/bash_completion/adb.bash |
||
126 | gnutoo@gnutoo-laptop:~/embedded/android/replicant-4.0$ lunch replicant_maguro-eng |
||
127 | |||
128 | ============================================ |
||
129 | PLATFORM_VERSION_CODENAME=REL |
||
130 | PLATFORM_VERSION=4.0.4 |
||
131 | TARGET_PRODUCT=replicant_maguro |
||
132 | TARGET_BUILD_VARIANT=eng |
||
133 | TARGET_BUILD_TYPE=release |
||
134 | TARGET_BUILD_APPS= |
||
135 | TARGET_ARCH=arm |
||
136 | TARGET_ARCH_VARIANT=armv7-a-neon |
||
137 | HOST_ARCH=x86 |
||
138 | HOST_OS=linux |
||
139 | HOST_BUILD_TYPE=release |
||
140 | BUILD_ID=IMM76L |
||
141 | ============================================ |
||
142 | |||
143 | |||
144 | gnutoo@gnutoo-laptop:~/embedded/android/replicant-4.0$ arm-linux-androideabi-gdb |
||
145 | GNU gdb (GDB) 7.1-android-gg2 |
||
146 | Copyright (C) 2010 Free Software Foundation, Inc. |
||
147 | License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> |
||
148 | This is free software: you are free to change and redistribute it. |
||
149 | There is NO WARRANTY, to the extent permitted by law. Type "show copying" |
||
150 | and "show warranty" for details. |
||
151 | This GDB was configured as "--host=i686-linux-gnu --target=arm-elf-linux". |
||
152 | For bug reporting instructions, please see: |
||
153 | <http://www.gnu.org/software/gdb/bugs/>. |
||
154 | (gdb) file /home/gnutoo/embedded/android/replicant-4.0/out/target/product/maguro/obj/KERNEL_OBJ/vmlinux |
||
155 | Reading symbols from /home/gnutoo/embedded/android/replicant-4.0/out/target/product/maguro/obj/KERNEL_OBJ/vmlinux...done. |
||
156 | (gdb) set remotebaud 115200 |
||
157 | 8 | Denis 'GNUtoo' Carikli | (gdb) target remote /dev/ttyUSB0 |
158 | Remote debugging using /dev/ttyUSB0 |
||
159 | kgdb_breakpoint () |
||
160 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/kernel/debug/debug_core.c:954 |
||
161 | 954 arch_kgdb_breakpoint(); |
||
162 | (gdb) bt |
||
163 | #0 kgdb_breakpoint () |
||
164 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/kernel/debug/debug_core.c:954 |
||
165 | #1 0xc00df764 in sysrq_handle_dbg (key=-29306880) |
||
166 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/kernel/debug/debug_core.c:745 |
||
167 | #2 0xc02f2e18 in __handle_sysrq (key=103, check_mask=false) |
||
168 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/drivers/tty/sysrq.c:522 |
||
169 | #3 0xc02f2ec4 in write_sysrq_trigger (file=<value optimized out>, buf=<value optimized out>, count=2, |
||
170 | ppos=0xc4a01f70) |
||
171 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/drivers/tty/sysrq.c:870 |
||
172 | #4 0xc016ba88 in proc_reg_write (file=0xc49ea3c0, buf=0x137fc84 "g\n\f@", count=2, ppos=0xc4a01f70) |
||
173 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/fs/proc/inode.c:200 |
||
174 | #5 0xc0126420 in vfs_write (file=0xc49ea3c0, buf=0x137fc84 "g\n\f@", count=<value optimized out>, |
||
175 | pos=0xc4a01f70) at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/fs/read_write.c:377 |
||
176 | #6 0xc0126590 in sys_write (fd=<value optimized out>, buf=0x137fc84 "g\n\f@", count=2) |
||
177 | at /home/gnutoo/embedded/android/replicant-4.0/kernel/samsung/tuna/fs/read_write.c:429 |
||
178 | #7 0xc0055a00 in ?? () |
||
179 | Cannot access memory at address 0x0 |
||
180 | #8 0xc0055a00 in ?? () |
||
181 | Cannot access memory at address 0x0 |
||
182 | Backtrace stopped: previous frame identical to this frame (corrupt stack?) |
||
183 | (gdb) |
||
184 | 7 | Denis 'GNUtoo' Carikli | |
185 | </pre> |
||
186 | 11 | Denis 'GNUtoo' Carikli | |
187 | 12 | Denis 'GNUtoo' Carikli | h2. Multiplexing the serial port |
188 | |||
189 | 11 | Denis 'GNUtoo' Carikli | since we have only 1 serial port, you can also use agent proxy to get kgdb and the console at the same time.... |
190 | <pre> |
||
191 | git clone git://git.kernel.org/pub/scm/utils/kernel/kgdb/agent-proxy.git |
||
192 | cd agent-proxy ; make |
||
193 | </pre> |
||
194 | 12 | Denis 'GNUtoo' Carikli | |
195 | h2. Root on serial port |
||
196 | 13 | Denis 'GNUtoo' Carikli | |
197 | * Modify system/su/su.c: |
||
198 | <pre> |
||
199 | diff --git a/su.c b/su.c |
||
200 | index d36eaed..51137d4 100644 |
||
201 | --- a/su.c |
||
202 | +++ b/su.c |
||
203 | @@ -494,11 +494,13 @@ int main(int argc, char *argv[]) |
||
204 | deny(&ctx); |
||
205 | } |
||
206 | |||
207 | +#if 0 |
||
208 | // disallow su in a shell if appropriate |
||
209 | if (ctx.from.uid == AID_SHELL && (atoi(enabled) == 1)) { |
||
210 | LOGE("Root access is disabled by a system setting - enable it under settings -> developer options"); |
||
211 | deny(&ctx); |
||
212 | } |
||
213 | +#endif |
||
214 | } |
||
215 | |||
216 | if (ctx.from.uid == AID_ROOT || ctx.from.uid == AID_SHELL) |
||
217 | </pre> |
||
218 | * adb push it to /system/xbin/su |
||
219 | * remove /system/bin/su |
||
220 | * chmod +s it: <pre>busybox chmod +s /system/xbin/su</pre> |
||
221 | 14 | Denis 'GNUtoo' Carikli | |
222 | h2. TODO |
||
223 | 15 | Denis 'GNUtoo' Carikli | |
224 | 14 | Denis 'GNUtoo' Carikli | * reliable rebugging (right now it breaks on the wrong line) |
225 | * phone that doesn't power off screen while debugging... |