Project

General

Profile

Exynos4Bootrom » History » Version 7

Kurtis Hanna, 09/21/2019 06:55 PM
changed from to form

1 1 Denis 'GNUtoo' Carikli
h1. Exynos4 Bootrom
2
3
h2. Background information
4
5
The Replicant project wants to support devices with free software bootloaders, but most/all the smartphones and tablets supported by Replicant do check the signature of the first stage bootloader.
6
7
A presentation on the situation of some of the devices supported by Replicant was made at the Replicant contributors meeting in July 2019. The "presentation slides":https://ftp.osuosl.org/pub/replicant/conferences/replicant-contributors-meeting-july-2019-france/replicant-and-bootloaders.pdf and "video":https://ftp.osuosl.org/pub/replicant/conferences/replicant-contributors-meeting-july-2019-france/replicant-and-bootloaders.webm are available.
8
9
h2. Exynos 4 signature check
10
11
The Exynos4 bootrom has a strange way to check the signatures:
12
* The first stage bootloader is encrypted
13
* The signature check is not very clear[1]
14
* The header that holds the key has a "func_ptr_BaseAddr" field[1].
15
16
h2. Tests to attempt
17
18 3 Denis 'GNUtoo' Carikli
* Test with qemu[2] if func_ptr_BaseAddr is somehow used by the bootrom, when verifying the BL1.
19 1 Denis 'GNUtoo' Carikli
* Try to understand better the scheme used to check the signature.
20 4 Kurtis Hanna
* Try to see if the fuses can still be written (zeroed) and see whether it's computationally feasible to compute the private key for a zeroed fuses hash.
21 2 Denis 'GNUtoo' Carikli
* Try to understand why encryption is used.
22 1 Denis 'GNUtoo' Carikli
23
h2. Test setup
24
25 3 Denis 'GNUtoo' Carikli
Either qemu[2] or a development board with JTAG can be used to do the test.
26 1 Denis 'GNUtoo' Carikli
27 3 Denis 'GNUtoo' Carikli
Testing with qemu[2] is probably way more easy.
28 1 Denis 'GNUtoo' Carikli
29
fn1. https://fredericb.info/2018/03/emulating-exynos-4210-bootrom-in-qemu.html
30 5 Kurtis Hanna
31 3 Denis 'GNUtoo' Carikli
fn2. https://github.com/frederic/qemu-exynos-bootrom
32 6 Denis 'GNUtoo' Carikli
33 7 Kurtis Hanna
h2. Loading a bootloader from SD
34 6 Denis 'GNUtoo' Carikli
35
When booting Parabola with a Replicant 9 kernel on a Galaxy SIII (i9300), it is possible to erase the bootloader to make the device boot from the microSD instead.
36
37
This could be used to do some testing, for instance to see if the BL1 signature can somehow be bypassed, however as no free software bootloaders do exist yet (u-boot relies on nonfree and non-redistributable software), this is not very useful yet.
38
39
If you really want to erase the bootloader (your device will be broken and will never boot anymore), you could run the following:
40
41
<pre>
42
# echo 0 > /sys/class/block/mmcblk2boot0/force_ro
43
# ddrescue -f /dev/zero /dev/mmcblk2boot0
44
GNU ddrescue 1.24
45
Press Ctrl-C to interrupt
46
     ipos:    4194 kB, non-trimmed:        0 B,  current rate:   4194 kB/s
47
     opos:    4194 kB, non-scraped:        0 B,  average rate:   4194 kB/s
48
non-tried:    9223 PB,  bad-sector:        0 B,    error rate:       0 B/s
49
  rescued:    4194 kB,   bad areas:        0,        run time:          0s
50
pct rescued:    0.00%, read errors:        0,  remaining time:         n/a
51
                              time since last successful read:         n/a
52
Copying non-tried blocks... Pass 1 (forwards)
53
ddrescue: Write error: No space left on device
54
</pre>
55
56
And then verify that it's erased:
57
<pre>
58
# hexdump -C /dev/mmcblk2boot0
59
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
60
*
61
00400000
62
63
</pre>
64
65
Also verify that the following partitions are also erased:
66
* mmcblk2boot1
67
* BOTA0
68
* BOTA1
69
70
I'm not sure what BOTA0 and BOTA1 are but they were already blank in my case.