Project

General

Profile

GTI9100GBootloaderFreedom » History » Version 30

Denis 'GNUtoo' Carikli, 03/27/2020 12:53 AM

1 1 Denis 'GNUtoo' Carikli
h1. I9100GBootloader
2
3 9 Denis 'GNUtoo' Carikli
{{toc}}
4 3 Denis 'GNUtoo' Carikli
5 23 Denis 'GNUtoo' Carikli
h2. Findings, TODO and status
6
7 29 Denis 'GNUtoo' Carikli
* -The I9100G of hpagseddy is unsigned but the omap-usb-tool says the soc is in HS mode.-
8
* -If I recall well, the string was verified by hpagseddy, so MLO was flashed and ran-
9
* -MLO was flashed through heimdall frmo Android 4.x bootloader's odin mode-
10 23 Denis 'GNUtoo' Carikli
* GNUtoo laptop works fine with heimdall with Android 2.3.6 bootloader while GNUtoo desktop doesn't
11
** The device can easily be stuck in "PC screen mode" with the Android 2.3.6 bootloader, so beware if your computer doesn't manage to talk to heimdall in that mode
12
** It might be related to USB timings or to the unfinished coreboot port for the F2A85M-PRO or the fact that I don't use nonfree firmware/fpga binary for the USB3 on the F2A85M-PRO so the machine is stuck on USB2 with USB3 hardware and I've no idea if that has some impacts or not. My laptop is a Thinkpad X200 with USB2.
13
14
We need to solve this OMAP HS mystery:
15
* I've looked at u-boot, barebox, linux, crucible and I didn't find any driver or code for fuses for any OMAP SOC.
16
* GNUtoo is in Paris where we're confined in our homes due to COVID-19 and I can't afford to brick my GT-I9100G
17 29 Denis 'GNUtoo' Carikli
* -It might be due to the fuses having been programmed with the hash of a key / certificate but not being in enforcing mode.-
18 23 Denis 'GNUtoo' Carikli
* The website for breaking motorolla restricted boot is only about OMAP3 devices but it contains infos on the structure of signed MLO
19 24 Denis 'GNUtoo' Carikli
* I've extracted the MLO but I'm unsure of its size and when I sent it through USB to the bootrom it failed. It might be because of the sram size limit but anyway as I don't know how to parse signatures yet (I need to look at the wiki for breaking motorolla restricted boot) I'm unsure of the exact binary size to send. Once I can parse that stuff, I will know the exact size of the signed area and so of the binary.
20 23 Denis 'GNUtoo' Carikli
* I've not managed to get any difference by booting from mmc1
21 1 Denis 'GNUtoo' Carikli
* I've not dumped yet the usual register for booting configuration like SYS_BOOT
22 25 Denis 'GNUtoo' Carikli
23
TODO while reading the TRM:
24
* check the device's OMAP4 the sram size limit
25
* check the load address / memory mapping of MLO in case of USB boot or boot from eMMC.
26
* Check mmc1 booting constraint (card size, look if < 4GiB works)
27
* Read about SYS_BOOT and booting, though fuse infos is most probably missing
28
29 28 Denis 'GNUtoo' Carikli
TODO while reading code:
30
* check if chipsec has infos on OMAP fuses
31
32 1 Denis 'GNUtoo' Carikli
TODO other readings:
33
* Read more on the wiki against motorolla
34
* Try to find a way to access the OMAP wiki and look if there is any stuff on fuses and restricted boot
35
36
Upstreaming:
37
* If infos about fuses are ever found, ideally write drivers and upstream them in Linux, u-boot, Barebox and crucible
38
* Look if crucible is good for adding infos about OM pins, SYS_BOOT etc. Not sure if Linux exports such registers and where
39 29 Denis 'GNUtoo' Carikli
40
Last news 27/03/2919:
41
hpagseddy and GNUtoo tried several tests on their respective devices, and the device always ended up going to the battery charging screen:
42
* Building xloader and loaing it with omap-usb-boot through USB
43
* Same with the addition of a for(;;) loop in the code to see if it hangs (it's supposed to if the code runs)
44
* Same but with the watchdog being configured to reboot after 1 second (it's supposed to reboot if the code is correct and runs)
45
46
hpagseddy and GNUtoo also found that when using odin to flash the MLO partition, odin interface makes the user think that the MLO partition was flashed correctly, while odin didn't flash anything. That may be due to the partition being set Read-Only and/or to the "File Offset" and "File Size" being 0.
47
<pre>
48
-- Entry #0 ---
49
Binary Type: 0 (AP)
50
Device Type: 2 (MMC)
51
Identifier: 1
52
Attributes: 0 (Read-Only)
53
Update Attributes: 0
54
Partition Block Size/Offset: 0
55
Partition Block Count: 0
56
File Offset (Obsolete): 0
57
File Size (Obsolete): 0
58
Partition Name: X-loader
59
Flash Filename: MLO
60
FOTA Filename: 
61
</pre>
62
63 30 Denis 'GNUtoo' Carikli
We know that nothing was successfuly flashed as we dumped MLO, and verified that the binary was signed by looking if it contained the strings that indicate that (PRIMAPP, KEYS, CertPK_)
64 23 Denis 'GNUtoo' Carikli
65 11 Denis 'GNUtoo' Carikli
h2. How to check if you have a signed bootloader
66 3 Denis 'GNUtoo' Carikli
67 11 Denis 'GNUtoo' Carikli
h3. How to check from the bootloader interface to install the recovery.
68 7 Denis 'GNUtoo' Carikli
69 8 Denis 'GNUtoo' Carikli
To do that you need to get into the ODIN MODE that is typically used to install the Replicant recovery:
70 1 Denis 'GNUtoo' Carikli
71 7 Denis 'GNUtoo' Carikli
# Start the device by holding the following key combination: *Volume down, Select, Power*,
72
# Hold the key combination until the device shows a *Warning* message.
73
# Confirm that you want to download a custom OS using volume up
74
# Make sure the device is in *Downloading* mode
75
76
When this is done, it should show some text:
77
<pre>
78
ODIN MODE
79
PRODUCT NAME: GT-I9100G_CHN_CHN
80
</pre>
81
82 10 Denis 'GNUtoo' Carikli
Here CHN_CHN probably refers to the Chinese version. And it looks like that version has a signed bootloader: According to "a thread on the XDA developers forum":https://forum.xda-developers.com/galaxy-s2/development/guide-repair-totally-sleep-dead-boot-t1701471 "Means that you own a chinese bootloader locked I9100G. You can't flash any other bootloader than the chinese one."
83 1 Denis 'GNUtoo' Carikli
84 12 Denis 'GNUtoo' Carikli
h3. How to check with command line utilities
85 5 Denis 'GNUtoo' Carikli
86 1 Denis 'GNUtoo' Carikli
To get the bootrom to try to boot on USB, you need to do the following:
87
* Connect the USB cable to the device but make sure it's not connected on the computer.
88
* Power off the device
89
* Connect the USB cable
90
91
If we do that, we get the following in the kernel log of your laptop:
92
<pre>
93
usb 1-1: new high-speed USB device number 24 using ehci-pci
94
usb 1-1: unable to get BOS descriptor or descriptor too short
95
usb 1-1: New USB device found, idVendor=0451, idProduct=d00f, bcdDevice= 0.00
96
usb 1-1: New USB device strings: Mfr=33, Product=37, SerialNumber=0
97
usb 1-1: Product: OMAP4430
98
usb 1-1: Manufacturer: Texas Instruments
99
</pre>
100
101 22 Denis 'GNUtoo' Carikli
Note that your kernel might need to be compiled with CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
102
to print that. In Parabola CONFIG_USB_ANNOUNCE_NEW_DEVICES=y is enabled.
103
104 1 Denis 'GNUtoo' Carikli
We can also try to get a bit more infos with omap-usb-boot:
105
<pre>
106
$ sudo omap-usb-boot -v -w boot invalidbootmedia
107
Finding and opening USB device
108
Found and opened omap4 USB device: OMAP4430
109
ASIC device id: 4430, HS device
110
Booting from device invalidbootmedia...
111
Booting device invalidbootmedia not found
112
Booting from device failed
113
</pre>
114
115
Here we know the device is signed because it's a "HS device".
116
If it was not signed it would print "GP device" instead.
117 9 Denis 'GNUtoo' Carikli
118 11 Denis 'GNUtoo' Carikli
h3. Using the Android version or other devices properties?
119 9 Denis 'GNUtoo' Carikli
120 15 Denis 'GNUtoo' Carikli
"hpagseddy/i9100g_xloader":https://github.com/hpagseddy/i9100g_xloader is based on "ths-backup/i9100g_xloader":https://github.com/ths-backup/i9100g_xloader which has an ics (Icecream Sandwitch, an Android version) branch only. According to hpagseddy, that branch is also used for Android Jelly brean.
121 9 Denis 'GNUtoo' Carikli
122
It's still unclear if there is some correlation between Android version and signed bootloaders.
123
124
The device that was given to [[People#Denis-GNUtoo-Carikli|GNUtoo]] that has a signed bootloader also has the following characteristics:
125
126
*Software state*: Running the stock OS, unmodified
127
*Android version*: Android 2.3.6
128
*Baseband version*: IG9100GZCLC2
129
*Build number*: GINGERBREAD.ZCLC2
130
*Kernel version*: 2.6.35.7 se.infra@SEI-30#2
131
132 18 Denis 'GNUtoo' Carikli
According to "a thread on XDA":https://forum.xda-developers.com/galaxy-s2/development/bootloader-t1754158 there is a corelation between the @Baseband version@ and the geographic zone that is targeted. And as we can see above, the @Build number@ seem to be related to the @Baseband version@ as well. While the list of baseband versions is incomplete, we can still use it to avoid the Chinese version (CHN_CHN) which has a signed bootloader. 
133 17 Denis 'GNUtoo' Carikli
134
At this point it's also still unclear if any of the other characteristics above correlate to signed or unsigned bootloaders.
135 2 Denis 'GNUtoo' Carikli
136 20 Denis 'GNUtoo' Carikli
As the binaries are under the GPLv2 or later, It would also be a good idea to collect all of them, match them with the device characteristics like the @Build@ number and @Baseband version@, and verify if they are signed or not with some free software tool.
137 19 Denis 'GNUtoo' Carikli
138 21 Denis 'GNUtoo' Carikli
We could even publish the unsigned versions. As for the signed versions, if they cannot run on devices that don't enforce bootloader signatures, it would probably not be a good idea to publish them as the binaries wouldn't respect the 4 freedoms, but we can still check with the FSF if they have good ideas on that point.
139
140 2 Denis 'GNUtoo' Carikli
h2. Source code
141
142
* https://github.com/hpagseddy/i9100g_xloader This got rebuilt and flashed, and it worked on the device it was tested on.
143
* https://blog.the-leviathan.ch/?p=408
144
145 1 Denis 'GNUtoo' Carikli
h2. TODO
146
147 16 Denis 'GNUtoo' Carikli
* Document the various firmware version mentioned here: https://www.sammobile.com/samsung/galaxy-s2/firmware/#GT-I9100G
148 1 Denis 'GNUtoo' Carikli
* Understand how to get unsigned versions (Android version, serial number, etc)
149 13 Denis 'GNUtoo' Carikli
* Get a device with an unsigned bootloader and u-boot and ask samsung for source code
150 14 Denis 'GNUtoo' Carikli
* Check the boot order on unsigned devices (is it possible to boot from USB easily?)
151 6 Denis 'GNUtoo' Carikli
* Try to boot the xloader nevertheless, as the device could be in some "verify but not enforce mode" for signatures