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