NexusSI902xBootloader » History » Version 14
Paul Kocialkowski, 02/12/2015 08:46 AM
1 | 1 | Paul Kocialkowski | h1. Nexus S (I902x) Bootloader |
---|---|---|---|
2 | |||
3 | 5 | Paul Kocialkowski | The Nexus S (I902x) comes with a bootrom and a set of two proprietary bootloaders. The bootrom: internal ROM (iROM) is stored read-only on the S5PC110 SoC chip. It loads the first bootloader: Samsung Primitive Bootloader (PBL), which loads the second bootloader: Samsung Secondary Bootloader (SBL). These bootloaders are proprietary software. |
4 | 1 | Paul Kocialkowski | |
5 | 11 | Paul Kocialkowski | More information on the booting sequence is available on the S5PC110 User Manual, section 2 (System), part 6 (Booting sequence). |
6 | 3 | Paul Kocialkowski | |
7 | h2. Boot device priority |
||
8 | |||
9 | The S5PC110 bootrom (iROM) allows booting from various devices such as NAND, MMC, eMMC, UART and USB. The boot device priority is selected using the Operating Mode (OM) pins. Boolean values for each pin depend on the voltage applied to the pin: a positive voltage represents a logical 1 while ground represents a logical 0. |
||
10 | |||
11 | 9 | Paul Kocialkowski | h3. OM_STAT register |
12 | |||
13 | The OM_STAT register holds the value of the OM pins. It is available at address: @0xe010e100@. |
||
14 | 12 | Paul Kocialkowski | The register value can be read using: |
15 | 9 | Paul Kocialkowski | <pre> |
16 | # devmem 0xe010e100 8 |
||
17 | 0x09 |
||
18 | </pre> |
||
19 | |||
20 | 5 | Paul Kocialkowski | h3. Board resistors |
21 | 3 | Paul Kocialkowski | |
22 | 4 | Paul Kocialkowski | OM pins are set to boolean values using pull-up (logical 1) and pull-down (logical 0) resistors. The Nexus S (I902x) schematics show all the possible resistors connected to the pins. |
23 | 1 | Paul Kocialkowski | |
24 | 7 | Paul Kocialkowski | According to the Nexus S (I902x) Schematics: |
25 | 4 | Paul Kocialkowski | !crespo_om_schematics.jpg! |
26 | |||
27 | Only a few are actually populated on the board: |
||
28 | 1 | Paul Kocialkowski | !{width: 50%}crespo_om_board.jpg! |
29 | 6 | Paul Kocialkowski | |
30 | According to the Nexus S (I902x) Service Manual: |
||
31 | 4 | Paul Kocialkowski | !{width: 50%}crespo_om_components.jpg! |
32 | 3 | Paul Kocialkowski | |
33 | Resistors highlighted in green are not populated on the board. Hence, the actual layout is the following: |
||
34 | |||
35 | | |_. XOM5 |_. XOM4 |_. XOM3 |_. XOM2 |_. XOM1 |_. XOM0 | |
||
36 | | Pull-up resistor | N/A | N/A | R429 | N/A | N/A | R435 | |
||
37 | | Pull-down resistor | R448 | R447 | N/A | R445 | R444 | N/A | |
||
38 | | Boolean value | 0 | 0 | 1 | 0 | 0 | 1 | |
||
39 | 1 | Paul Kocialkowski | |
40 | 9 | Paul Kocialkowski | h3. First boot device |
41 | |||
42 | 11 | Paul Kocialkowski | According to the S5PC110 User Manual, section 2 (System), part 6.2.4 (OM pin configuration), table 6-3, such a value (0x04) indicates OnenandMux as first boot device. |
43 | 3 | Paul Kocialkowski | |
44 | 1 | Paul Kocialkowski | h2. Secure boot |
45 | |||
46 | 11 | Paul Kocialkowski | According to the S5PC110 User Manual, section 2 (System), part 6 (Booting sequence), the bootrom (iROM) found on the S5PC110 SoC implements secure boot, which is enabled depending on the value of an e-fuse: |
47 | 5 | Paul Kocialkowski | <pre> |
48 | If you select secure booting, iROM code and first boot loader provide integrity checking function (that is it uses |
||
49 | public key algorithm) to verify loaded image. There are 160 e-fuse bits of secure boot key, and they are used to |
||
50 | authenticate loaded public key before the iROM’s integrity check. |
||
51 | </pre> |
||
52 | 1 | Paul Kocialkowski | |
53 | 11 | Paul Kocialkowski | This implies that in secure boot mode, the bootrom (iROM) will check the signature of the first bootloader and refuse to boot if the signature doesn't match the secure boot key. More information on this topic is available on the S5PC110 User Manual, section 2 (System), part 6.2.2 (Booting sequence example), figure 6-2. |
54 | 1 | Paul Kocialkowski | |
55 | 5 | Paul Kocialkowski | On the Nexus S (I902x), secure boot mode appears to be enabled: changing a single byte on the first bootloader ended up in the system refusing to boot. In addition, a few messages from the bootloaders output suggest that such signature checks are enforced: @IROM e-fused - Secure Boot Version@. |
56 | 1 | Paul Kocialkowski | |
57 | 10 | Paul Kocialkowski | h3. SECKEY register |
58 | |||
59 | 12 | Paul Kocialkowski | The SECKEY register holds the public key that is used to check the bootloaders signatures. It is available at address @0xe0e00000@, as mentioned on the S5PC110 User Manual, section 1 (Overview), part 2.1.2 (Special function register map). The register is e-fused and cannot be overwritten on the Nexus S (I902x). |
60 | 1 | Paul Kocialkowski | |
61 | 12 | Paul Kocialkowski | Access to the register requires the CLK_SECKEY clock to be enabled, as mentioned on the S5PC110 User Manual, section 2 (System), part 3.7.5.6 (Clock gating control register). |
62 | 13 | Paul Kocialkowski | The seckey clock can be enabled at boot-time using the following kernel patch: |
63 | 12 | Paul Kocialkowski | <pre> |
64 | diff --git a/arch/arm/mach-s5pv210/clock.c b/arch/arm/mach-s5pv210/clock.c |
||
65 | index 6d3e609..38ebb76 100644 |
||
66 | --- a/arch/arm/mach-s5pv210/clock.c |
||
67 | +++ b/arch/arm/mach-s5pv210/clock.c |
||
68 | @@ -1479,6 +1479,7 @@ void __init_or_cpufreq s5pv210_setup_clocks(void) |
||
69 | unsigned int ptr; |
||
70 | u32 clkdiv0, clkdiv1; |
||
71 | struct clksrc_clk *pclkSrc; |
||
72 | + int i; |
||
73 | |||
74 | /* Set functions for clk_fout_epll */ |
||
75 | clk_fout_epll.enable = s5p_epll_enable; |
||
76 | @@ -1564,6 +1565,16 @@ void __init_or_cpufreq s5pv210_setup_clocks(void) |
||
77 | /* Display the clock source */ |
||
78 | s3c_set_clksrc(pclkSrc, true); |
||
79 | } |
||
80 | + |
||
81 | + for (i = 0; i < ARRAY_SIZE(init_clocks_off); i++) { |
||
82 | + if (init_clocks_off[i].name == NULL) |
||
83 | + break; |
||
84 | + |
||
85 | + if (strcmp("seckey", init_clocks_off[i].name) == 0) { |
||
86 | + printk(KERN_INFO "%s: Enabling seckey clock\n", __func__); |
||
87 | + clk_enable(&init_clocks_off[i]); |
||
88 | + } |
||
89 | + } |
||
90 | } |
||
91 | |||
92 | static struct clk *clks[] __initdata = { |
||
93 | </pre> |
||
94 | 1 | Paul Kocialkowski | |
95 | 12 | Paul Kocialkowski | The register value can then be read using: |
96 | <pre> |
||
97 | # devmem 0xE0E00018 32 |
||
98 | 0x07F0600F |
||
99 | </pre> |
||
100 | |||
101 | A non-zero value on the register indicates that secure boot is enabled, while a zero value indicates that secure boot is disabled. Hence, secure boot is enabled on the Nexus S (I902x). |
||
102 | |||
103 | 10 | Paul Kocialkowski | h3. Bootloaders secure boot |
104 | 5 | Paul Kocialkowski | |
105 | 3 | Paul Kocialkowski | The first bootloader (PBL) appears to be implementing and enforcing a similar secure boot mechanism. However, there is no signature check enforced regarding the Linux kernel. |
106 | 8 | Paul Kocialkowski | |
107 | 1 | Paul Kocialkowski | Since signature checks are enforced by the bootrom and provided that there is apparently no easy way of replacing the public key the signatures are checked against, running free software bootloaders on the Nexus S (I902x) seems impossible. |
108 | |||
109 | 8 | Paul Kocialkowski | It is however possible to run a free software bootloader (U-Boot) as second bootloader using a version of the first bootloader (PBL) that does not enforce the signature check. |
110 | 10 | Paul Kocialkowski | |
111 | 8 | Paul Kocialkowski | |
112 | 12 | Paul Kocialkowski | h2. Bootloaders output |
113 | 1 | Paul Kocialkowski | |
114 | <pre> |
||
115 | ----------------------------------------------------------- |
||
116 | Samsung Primitive Bootloader (PBL) v3.0 |
||
117 | Copyright (C) Samsung Electronics Co., Ltd. 2006-2010 |
||
118 | ----------------------------------------------------------- |
||
119 | |||
120 | Muxed [[OneNAND]] 512MB (0x50) Sync |
||
121 | Scanning Bad Block ....... |
||
122 | Bad Block 77 (5) |
||
123 | Bad Block 295 (5) |
||
124 | Bad Block 1232 (5) |
||
125 | Bad Block 1646 (5) |
||
126 | Bad Block 1831 (5) |
||
127 | Bad Block 2047 (0) |
||
128 | SBL loadding success |
||
129 | |||
130 | Set cpu clk. from 400MHz to 800MHz. |
||
131 | OM=0x9, device=OnenandMux(Audi) |
||
132 | IROM e-fused - Secure Boot Version. |
||
133 | |||
134 | ----------------------------------------------------------- |
||
135 | Samsung Secondary Bootloader (SBL) v3.0 |
||
136 | Copyright (C) Samsung Electronics Co., Ltd. 2006-2010 |
||
137 | |||
138 | Board Name: HERRING REV 52 |
||
139 | Build On: Jan 20 2011 17:19:41 |
||
140 | ----------------------------------------------------------- |
||
141 | |||
142 | MMC SEM16G 15188 MB |
||
143 | Re_partition: magic code(0x0) |
||
144 | Muxed [[OneNAND]] 512MB (0x50) Sync |
||
145 | Scanning Bad Block ....... |
||
146 | Bad Block 77 (5) |
||
147 | Bad Block 295 (5) |
||
148 | Bad Block 1232 (5) |
||
149 | Bad Block 1646 (5) |
||
150 | Bad Block 1831 (5) |
||
151 | Bad Block 2047 (0) |
||
152 | Partitions loading success |
||
153 | Read image(PARAM) from flash ....... |
||
154 | Done |
||
155 | init_fuel_gauge: vcell = 4083mV, soc = 94 |
||
156 | PMIC_IRQ1 = 0xc0 |
||
157 | PMIC_IRQ2 = 0x0 |
||
158 | PMIC_IRQ3 = 0x0 |
||
159 | PMIC_IRQ4 = 0x0 |
||
160 | PMIC_STATUS1 = 0x0 |
||
161 | PMIC_STATUS2 = 0x0 |
||
162 | PMIC_STATUS3 = 0x0 |
||
163 | PMIC_STATUS4 = 0x0 |
||
164 | PMIC_STATUS5 = 0x0 |
||
165 | PMIC_SMPL = 0x0 |
||
166 | Key scan = 0x0 |
||
167 | message.command = |
||
168 | message.status = |
||
169 | message.recovery = |
||
170 | |||
171 | BOOT_MODE_NORMAL (SW_RST(0x00000004), INFORM(0x000000ee)) |
||
172 | LCD ID = 0x0060a953 |
||
173 | Done |
||
174 | Kernel(boot.img) read success from partition no.5 |
||
175 | Setting param.serialnr = 0x3733bab6 0x6de200ec |
||
176 | Setting param.board_rev = 0x34 |
||
177 | Setting param.cmdline = console=ttyFIQ0 no_console_suspend androidboot.serialno=3733BAB66DE200EC androidboot.bootloader=I9020XXKA3 androidboot.baseband=I9020XXKB3 androidboot.info=0x4,0xee,1 androidboot.carrier=EUR gain_code=3 s3cfb.bootloaderfb=0x34a00000 mach-herring.lcd_type=0x00000000 oem_state=unlocked |
||
178 | Setting param.initrd_start = 0x31000000, param.initrd_size = 0x23265 |
||
179 | |||
180 | Starting kernel at 0x30008000... |
||
181 | |||
182 | Uncompressing Linux... done, booting the kernel. |
||
183 | 4 | Paul Kocialkowski | </pre> |
184 | |||
185 | h2. References |
||
186 | |||
187 | * S5PC110 User Manual: http://dl.project-voodoo.org/documentation/S5PC110_EVT1_UM10.pdf |
||
188 | 7 | Paul Kocialkowski | * Nexus S (I902x) Service Manual and Schematics: http://mobilcoms.ru/load/1-1-0-4499 |
189 | 4 | Paul Kocialkowski | |
190 | 14 | Paul Kocialkowski | *These documents are the propriety of Samsung Electronics and are not hosted by the Replicant project.* |
191 | *However, some excerpts from these documents are provided, for the purpose of providing technical evidence of the facts that are mentioned in this page. We believe that this particular use of the copyrighted work is fair use.* |
||
192 | 8 | Paul Kocialkowski | |
193 | * Create your own I9000/S8500 (& all S5PC110 based devices) bootloader&ultimate unbrick (XDA): http://forum.xda-developers.com/showthread.php?t=1233273 |
||
194 | * Hummingbird Interceptor BootLoader: https://code.google.com/p/hummingbird-hibl/ |
||
195 | * U-Boot second bootloader port: https://github.com/hackqiang/crespo-bootloader |
||
196 | * Bootrom (iROM) dump and disassembly: https://github.com/OSLL/boots/tree/master/S5PC110 |