-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathdtbtool.txt
170 lines (153 loc) · 6.08 KB
/
dtbtool.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
Copyright (c) 2012, The Linux Foundation. All rights reserved.
Redistribution and use in source form and compiled forms (SGML, HTML,
PDF, PostScript, RTF and so forth) with or without modification, are
permitted provided that the following conditions are met:
Redistributions in source form must retain the above copyright
notice, this list of conditions and the following disclaimer as the
first lines of this file unmodified.
Redistributions in compiled form (transformed to other DTDs,
converted to PDF, PostScript, RTF and other formats) must reproduce
the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with
the distribution.
THIS DOCUMENTATION IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND
NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD
DOCUMENTATION PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
June 2014, Ketut P. Kumajaya
Samsung Galaxy Tab 4 7.0 PXA1088 boot image and device tree
documentation.
Android - Table of Device Tree
==============================
0) Document revision
v1.0 - Initial version (dng)
1) Android boot image:
----------------------
1.1) Header:
1) Magic (8B)
2) kernel size (4B)
3) kernel addr (4B)
4) ramdisk size (4B)
5) ramdisk addr (4B)
6) 2ndary size (4B)
7) 2ndary addr (4B)
8) tags addr (4B)
9) page size (4B)
10) unused #1 (4B) (zero in standard Android)
11) unused #2 (4B) (zero in standard Android)
12) product name (16B)
13) kernel cmdline (512B)
14) id (8B)
1.2) Samsung Galaxy Tab 4 7.0 PXA1088 Header:
1) Magic (8B)
2) kernel size (4B)
3) kernel addr (4B)
4) ramdisk size (4B)
5) ramdisk addr (4B)
6) 2ndary size (4B)
7) 2ndary addr (4B)
8) device tree size (4B)
9) unknown (4B) (0x02000000)
8) tags addr (4B)
9) page size (4B)
12) product name (24B)
13) kernel cmdline (512B)
14) id (8B)
1.3) Layout:
A) header (as above - 1 page)
B) kernel (n pages)
C) ramdisk (m pages)
D) second stage (o pages)
2) PXA table of device tree
--------------------------
2.1) Changes:
i) use "unused #1, #2" members in existing boot image
as tags address and page size and use previous tags address as
device tree size
ii) append table of device tree (described later)
after "D) second stage"
2.2) Format:
size
x +------------------+
| | MAGIC ("PXA-DT") | 6B
| +------------------+
header | VERSION | uint32 (initial version 1)
| +------------------+
| | num of DTBs | uint32 (number of DTB entries)
x +------------------+
| | platform id #1 | uint32 (e.g. 3909 for Degas3g)
device +------------------+
#1 | soc rev #1 | uint32 (e.g. 3 for Degas3g v3)
entry +------------------+
| | offset #1 | uint32 (byte offset from start/before MAGIC
| +------------------+ to DTB entry)
| | size #1 | uint32 (size in bytes of DTB blob)
x +------------------+
. .
. . (repeat)
. .
x +------------------+
| | platform id #Z | uint32 (e.g. 3911 for Degaswifi)
| +------------------+
device | soc rev #Z | uint32 (e.g. 3 for Degaswifi v3)
#Z +------------------+
entry | offset #Z | uint32 (byte offset from start/before MAGIC
(last) +------------------+ to DTB entry)
| | 0 ("zero") | uint32 (end of list delimiter)
x +------------------+ to DTB entry)
| padding | variable length for next DTB to start on
+------------------+ page boundary
| DTB #1 | variable (start is page aligned)
| |
| |
+------------------+
| padding | variable length for next DTB to start on
+------------------+ page boundary
.
.
.
+------------------+
| DTB #Z (last) | variable (start is page aligned)
| |
| |
+------------------+
3) Operations
-------------
3.1) Build-time:
1) Each DTS per device will add a "pxa,rev-id" duplet
e.g. pxa1088-degas3g-r03.dts, add
pxa,rev-id = <x y>;
x = ID for Degas3g, Degaswifi, etc.
y = ID for soc revision
2) Kernel compile will generate the DTB
3) Android build will run a new tool (dtbTool)
a) scan the DTB output directory for all compiled DTB
b) decompile the DTB for "pxa,rev-id"
c) generate the PXA table of device tree in sorted
order (platform, variant, soc rev)
d) modified mkbootimg will merge new table of DT
3.2) Run-time:
1) Bootloader will obtain PXA id/soc rev info
either from early bootloaders or via other means
2) Bootloader will check entries #10 for non-zero
value (set to zero for standard boot.img). If the
value is non-zero, refer to page section after
the "second stage" in the boot.img layout
3) Check PXA-DT magic
4) Check PXA-DT version (optional to handle multiple
PXA-DT version)
5) Bootloader scans through the PXA-DT table to look for matching
entry. Search order is:
1) platform ID exact match
2) select the highest soc rev in PXA-DT that is
equal to or lower than the runtime detected soc rev
6) Load the matching DTB blob to the tags addr
7) Bootloader pass the correct DTB to the kernel