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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# The offsets of the partitions that change when Hoth is enabled
# From the device tree, in kB
FLASH_IMAGE_DESC_OFFSET:hoth = "${@960 if FLASH_SIZE == '65536' else 7232}"
FLASH_HOTH_UPDATE_OFFSET:hoth = "${@1024 if FLASH_SIZE == '65536' else 31744}"
FLASH_HOTH_MAILBOX_OFFSET:hoth = "${@65472 if FLASH_SIZE == '65536' else 7168}"
FLASH_HOTH_SECONDARY_OFFSET:hoth = "${@61376 if FLASH_SIZE == '65536' else 7296}"
# 64 bit kernels are larger, so they require a different layout
FLASH_IMAGE_DESC_OFFSET:hoth:aarch64 = "${@61312 if FLASH_SIZE == '65536' else 7232}"
FLASH_HOTH_UPDATE_OFFSET:hoth:aarch64 = "${@61376 if FLASH_SIZE == '65536' else 31744}"
# Leave a zero-size u-boot env partition.
FLASH_UBOOT_ENV_OFFSET = "${FLASH_KERNEL_OFFSET}"
# Support BMC image to have secondary hoth firmware
ENABLE_HOTH_SECONDARY ?= "no"
python do_generate_static:append() {
_append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
'image-hoth-update'),
int(d.getVar('FLASH_HOTH_UPDATE_OFFSET', True)),
int(d.getVar('FLASH_SIZE', True)))
if d.getVar('ENABLE_HOTH_SECONDARY',True) == 'yes':
_append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
'image-hoth-update-2nd'),
int(d.getVar('FLASH_HOTH_SECONDARY_OFFSET', True)),
int(d.getVar('FLASH_SIZE', True)))
}
do_generate_static[depends] += "virtual/hoth-firmware:do_deploy"
do_generate_static[depends] += "${@'virtual/hoth-firmware-2nd:do_deploy' if ENABLE_HOTH_SECONDARY == 'yes' else ''}"
python do_generate_layout () {
import time
import json
def convertPart(name, startKb, endKb, static=False, wp=False, persist=False):
regionTypes = []
extraAttrs = {}
if static:
regionTypes.append('STATIC')
if wp:
regionTypes.append('WRITE_PROTECTED')
if persist:
regionTypes.append('PERSISTENT')
if name == 'hoth_mailbox':
regionTypes.append('MAILBOX')
extraAttrs['mailbox_length'] = 1024
start = int(startKb) * 1024
end = int(endKb) * 1024
return {
'name': name,
'offset': start,
'length': end - start,
'region_type': regionTypes,
**extraAttrs,
}
# TODO: make this work for Aspeed too
region = [
convertPart(
'u_boot',
d.getVar('FLASH_UBOOT_OFFSET'),
d.getVar('FLASH_KERNEL_OFFSET'),
static=True,
wp=True),
convertPart(
'kernel',
d.getVar('FLASH_KERNEL_OFFSET'),
d.getVar('FLASH_ROFS_OFFSET'),
static=True,
wp=True),
convertPart(
'rofs',
d.getVar('FLASH_ROFS_OFFSET'),
d.getVar('FLASH_IMAGE_DESC_OFFSET'),
static=True,
wp=True),
convertPart(
'image_descriptor',
d.getVar('FLASH_IMAGE_DESC_OFFSET'),
d.getVar('FLASH_HOTH_UPDATE_OFFSET'),
static=True,
wp=True),
convertPart(
'hoth_update',
d.getVar('FLASH_HOTH_UPDATE_OFFSET'),
d.getVar('FLASH_RWFS_OFFSET')),
convertPart(
'rwfs',
d.getVar('FLASH_RWFS_OFFSET'),
d.getVar('FLASH_HOTH_MAILBOX_OFFSET'),
persist=True),
convertPart(
'hoth_mailbox',
d.getVar('FLASH_HOTH_MAILBOX_OFFSET'),
d.getVar('FLASH_SIZE')),
] if d.getVar('TARGET_ARCH') == "aarch64" else [
convertPart(
'u_boot',
d.getVar('FLASH_UBOOT_OFFSET'),
d.getVar('FLASH_IMAGE_DESC_OFFSET'),
static=True,
wp=True),
convertPart(
'image_descriptor',
d.getVar('FLASH_IMAGE_DESC_OFFSET'),
d.getVar('FLASH_HOTH_UPDATE_OFFSET'),
static=True,
wp=True),
convertPart(
'hoth_update',
d.getVar('FLASH_HOTH_UPDATE_OFFSET'),
d.getVar('FLASH_KERNEL_OFFSET')),
convertPart(
'kernel',
d.getVar('FLASH_KERNEL_OFFSET'),
d.getVar('FLASH_ROFS_OFFSET'),
static=True,
wp=True),
convertPart(
'rofs',
d.getVar('FLASH_ROFS_OFFSET'),
d.getVar('FLASH_HOTH_SECONDARY_OFFSET'),
static=True,
wp=True),
convertPart(
'hoth_secondary',
d.getVar('FLASH_HOTH_SECONDARY_OFFSET'),
d.getVar('FLASH_RWFS_OFFSET')),
convertPart(
'rwfs',
d.getVar('FLASH_RWFS_OFFSET'),
d.getVar('FLASH_HOTH_MAILBOX_OFFSET'),
persist=True),
convertPart(
'hoth_mailbox',
d.getVar('FLASH_HOTH_MAILBOX_OFFSET'),
d.getVar('FLASH_SIZE')),
] if d.getVar('FLASH_SIZE') == '65536' else [
convertPart(
'u_boot',
d.getVar('FLASH_UBOOT_OFFSET'),
d.getVar('FLASH_KERNEL_OFFSET'),
static=True,
wp=True),
convertPart(
'kernel',
d.getVar('FLASH_KERNEL_OFFSET'),
d.getVar('FLASH_HOTH_MAILBOX_OFFSET'),
static=True,
wp=True),
convertPart(
'hoth_mailbox',
d.getVar('FLASH_HOTH_MAILBOX_OFFSET'),
d.getVar('FLASH_IMAGE_DESC_OFFSET')),
convertPart(
'image_descriptor',
d.getVar('FLASH_IMAGE_DESC_OFFSET'),
d.getVar('FLASH_ROFS_OFFSET'),
static=True,
wp=True),
convertPart(
'rofs',
d.getVar('FLASH_ROFS_OFFSET'),
d.getVar('FLASH_RWFS_OFFSET'),
static=True,
wp=True),
convertPart(
'rwfs',
d.getVar('FLASH_RWFS_OFFSET'),
d.getVar('FLASH_HOTH_UPDATE_OFFSET'),
persist=True),
convertPart(
'hoth_update',
d.getVar('FLASH_HOTH_UPDATE_OFFSET'),
d.getVar('FLASH_SIZE')),
]
machine = d.getVar('MACHINE')
platform = d.getVar('PLATFORM')
name = '{} {} image'.format(machine, d.getVar('DISTRO'))
version = d.getVar('GBMC_VERSION').split('.')
if not platform:
raise NameError('PLATFORM not found, unable to generate layout, stopping build')
layout = {
'name': name,
'major': int(version[0]),
'minor': int(version[1]),
'point': int(version[2]),
'subpoint': int(version[3]),
'platform': platform,
'flash_capacity': int(d.getVar('FLASH_SIZE')) * 1024,
'build_timestamp': int(time.time()),
'region': region,
}
dir = d.getVar('DEPLOY_DIR_IMAGE')
os.makedirs(dir, exist_ok=True)
path = os.path.join(dir, 'cr51-image-layout.json')
with open(path, 'w') as f:
json.dump(layout, f, sort_keys=True, indent=4)
}
addtask generate_layout before do_image_complete
|