-
Notifications
You must be signed in to change notification settings - Fork 7
/
fwup-revert.conf
492 lines (452 loc) · 15.5 KB
/
fwup-revert.conf
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# Revert firmware for jetson_nano
#
# To use:
# 1. Run `fwup -c -f fwup-revert.conf -o revert.fw` and copy revert.fw to
# the device. This is done automatically as part of the Nerves system
# build process. The file is stored in `/usr/share/fwup/revert.fw`.
# 2. On the device, run `fwup -t revert revert.fw -d $NERVES_FW_DEVPATH`. If
# it succeeds, reboot. If not, then it's possible that there isn't a previous
# firmware or the metadata about what's stored where is corrupt or out of
# sync.
#
# It is critical that this is kept in sync with the main fwup.conf.
require-fwup-version="1.4.0" # For the GPT support
#
# Firmware metadata
#
# All of these can be overriden using environment variables of the same name.
#
# Run 'fwup -m' to query values in a .fw file.
# Use 'fw_printenv' to query values on the target.
#
# These are used by Nerves libraries to introspect.
define(NERVES_FW_PRODUCT, "Nerves Firmware")
define(NERVES_FW_DESCRIPTION, "")
define(NERVES_FW_VERSION, "${NERVES_SDK_VERSION}")
define(NERVES_FW_PLATFORM, "jetson_nano")
define(NERVES_FW_ARCHITECTURE, "aarch64")
define(NERVES_FW_AUTHOR, "Very")
define(NERVES_FW_DEVPATH, "/dev/mmcblk0")
define(NERVES_FW_APPLICATION_PART0_DEVPATH, "/dev/mmcblk0p16") # Linux part number is 1-based
define(NERVES_FW_APPLICATION_PART0_FSTYPE, "f2fs")
define(NERVES_FW_APPLICATION_PART0_TARGET, "/root")
define(NERVES_PROVISIONING, "${NERVES_SYSTEM}/images/fwup_include/provisioning.conf")
# Default paths if not specified via the commandline
define(ROOTFS, "${NERVES_SYSTEM}/images/rootfs.squashfs")
# This configuration file will create an image that
# has an GPT and the following layout:
#
# +----------------------------+
# | GPT |
# +----------------------------+
# | Firmware configuration data|
# | (formatted as uboot env) |
# +----------------------------+
# | p0: Rootfs A/B (squashfs) |
# +----------------------------+
# | p1: TXC |
# | Contains TegraBoot CPU-side binary |
# +----------------------------+
# | p2: RP1 |
# | Contains Bootloader DTB binary |
# +----------------------------+
# | p3: EBT |
# | Contains CBoot, the final |
# | boot stage CPU bootloader |
# | binary that loads the binary |
# | in the kernel partition |
# +----------------------------+
# | p4: WX0 |
# | Contains warm boot binary |
# +----------------------------+
# | p5: BXF |
# | Contains SC7 entry firmware |
# +----------------------------+
# | p6: BXF-DTB |
# | Reserved for future use by |
# | BPMP DTB binary; can't remove |
# +----------------------------+
# | p7: FX |
# | Reserved for fuse bypass; |
# | removeable |
# +----------------------------+
# | p8: TXS |
# | Contains TOS binary |
# +----------------------------+
# | p9: DXB |
# | Contains kernel DTB binary |
# +----------------------------+
# | p10: LNX |
# | Contains U-Boot |
# +----------------------------+
# | p11: EXS |
# | Contains the encrypted keys |
# +----------------------------+
# | p12: BMP |
# | Contains BMP images for |
# | splash screen display |
# | during boot |
# +----------------------------+
# | p13: RP4 |
# | Contains XUSB module’s |
# | firmware file, making XUSB |
# | a true USB 3.0 compliant |
# | host controller. |
# +----------------------------+
# | p14: BOOT A/B |
# | Linux kernel |
# | nerves_initramfs |
# | device tree file |
# +----------------------------+
define(LINUX_BOOT_TYPE, "bc13c2ff-59e6-4262-a352-b275fd6f7172")
define(LINUX_FILESYSTEM_DATA_TYPE, "0fc63daf-8483-4772-8e79-3d69d8477de4")
define(UBOOT_ENV_OFFSET, 1024)
define(UBOOT_ENV_COUNT, 256) # 128 KB
define(BOOT_A_PART_OFFSET, 28672)
define(BOOT_PART_COUNT, 204800)
define-eval(BOOT_B_PART_OFFSET, "${BOOT_A_PART_OFFSET} + ${BOOT_PART_COUNT}")
define(BOOT_PART_UUID, "338efbad-8508-4f3c-bf56-477ba4bee991")
define-eval(ROOTFS_A_PART_OFFSET, "${BOOT_B_PART_OFFSET} + ${BOOT_PART_COUNT}")
define(ROOTFS_PART_COUNT, 2097152)
define-eval(ROOTFS_B_PART_OFFSET, "${ROOTFS_A_PART_OFFSET} + ${ROOTFS_PART_COUNT}")
define(ROOTFS_PART_UUID, "592ca19f-2cf3-427b-831a-c5fb1efecbe8")
define-eval(APP_PART_OFFSET, "${ROOTFS_B_PART_OFFSET} + ${ROOTFS_PART_COUNT}")
define(APP_PART_COUNT, 8388608)
define(APP_PART_UUID, "5db81cc9-3b32-4916-b559-a98943bc2b8b")
define(TBC_PART_OFFSET, 2048)
define(TBC_PART_COUNT, 256)
define(TBC_PART_UUID, "fcc205c8-2f1c-4dcd-bef4-7b209aa15cca")
define(RP1_PART_OFFSET, 4096)
define(RP1_PART_COUNT, 896)
define(RP1_PART_UUID, "5bdef3de-3e50-4ac1-a4f5-b820cd092654")
define(EBT_PART_OFFSET, 6144)
define(EBT_PART_COUNT, 1152)
define(EBT_PART_UUID, "5b108e13-992f-4617-86d1-fa57c1a05402")
define(WB0_PART_OFFSET, 8192)
define(WB0_PART_COUNT, 128)
define(WB0_PART_UUID, "175e21c1-6cdd-40fc-84dd-44baeb78d634")
define(BPF_PART_OFFSET, 10240)
define(BPF_PART_COUNT, 384)
define(BPF_PART_UUID, "b9cc8b3e-2893-4f20-b3ef-768c3361ab21")
define(BPF_DTB_PART_OFFSET, 12288)
define(BPF_DTB_PART_COUNT, 768)
define(BPF_DTB_PART_UUID, "a166053a-693d-4aa7-acf1-d6d7c941e6dc")
define(FX_PART_OFFSET, 14336)
define(FX_PART_COUNT, 128)
define(FX_PART_UUID, "046954bf-03f4-48ab-89c2-7a2ead344f97")
define(TOS_PART_OFFSET, 16384)
define(TOS_PART_COUNT, 896)
define(TOS_PART_UUID, "7d3e441c-5f24-446c-9c83-5817c293ea12")
define(DTB_PART_OFFSET, 18432)
define(DTB_PART_COUNT, 896)
define(DTB_PART_UUID, "71406e07-8a91-4b92-97ef-11468bb5f3fc")
define(LNX_PART_OFFSET, 20480)
define(LNX_PART_COUNT, 1536)
define(LNX_PART_UUID, "9b9b290e-b7f8-4fb0-9d22-15506fd92a93")
define(EKS_PART_OFFSET, 22528)
define(EKS_PART_COUNT, 128)
define(EKS_PART_UUID, "a5d10080-cc75-479f-af17-9bbedaa5994f")
define(BMP_PART_OFFSET, 24576)
define(BMP_PART_COUNT, 160)
define(BMP_PART_UUID, "9b740b99-1841-4f88-a7fd-c4d18ccfe39f")
define(RP4_PART_OFFSET, 26624)
define(RP4_PART_COUNT, 256)
define(RP4_PART_UUID, "6b1dee7c-a59b-4b0d-a54b-0a8577329179")
# Firmware archive metadata
meta-product = ${NERVES_FW_PRODUCT}
meta-description = ${NERVES_FW_DESCRIPTION}
meta-version = ${NERVES_FW_VERSION}
meta-platform = ${NERVES_FW_PLATFORM}
meta-architecture = ${NERVES_FW_ARCHITECTURE}
meta-author = ${NERVES_FW_AUTHOR}
meta-vcs-identifier = ${NERVES_FW_VCS_IDENTIFIER}
meta-misc = ${NERVES_FW_MISC}
gpt gpt-a {
# UUID for the entire disk
guid = b443fbeb-2c93-481b-88b3-0ecb0aeba911
partition 0 {
name = "APP"
block-offset = ${ROOTFS_A_PART_OFFSET}
block-count = ${ROOTFS_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${ROOTFS_PART_UUID}
}
partition 1 {
name = "TBC"
block-offset = ${TBC_PART_OFFSET}
block-count = ${TBC_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${TBC_PART_UUID}
}
partition 2 {
name = "RP1"
block-offset = ${RP1_PART_OFFSET}
block-count = ${RP1_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${RP1_PART_UUID}
}
partition 3 {
name = "EBT"
block-offset = ${EBT_PART_OFFSET}
block-count = ${EBT_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${EBT_PART_UUID}
}
partition 4 {
name = "WB0"
block-offset = ${WB0_PART_OFFSET}
block-count = ${WB0_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${WB0_PART_UUID}
}
partition 5 {
name = "BPF"
block-offset = ${BPF_PART_OFFSET}
block-count = ${BPF_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${BPF_PART_UUID}
}
partition 6 {
name = "BPF-DTB"
block-offset = ${BPF_DTB_PART_OFFSET}
block-count = ${BPF_DTB_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${BPF_DTB_PART_UUID}
}
partition 7 {
name = "FX"
block-offset = ${FX_PART_OFFSET}
block-count = ${FX_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${FX_PART_UUID}
}
partition 8 {
name = "TOS"
block-offset = ${TOS_PART_OFFSET}
block-count = ${TOS_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${TOS_PART_UUID}
}
partition 9 {
name = "DTB"
block-offset = ${DTB_PART_OFFSET}
block-count = ${DTB_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${DTB_PART_UUID}
}
partition 10 {
name = "LNX"
block-offset = ${LNX_PART_OFFSET}
block-count = ${LNX_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${LNX_PART_UUID}
}
partition 11 {
name = "EKS"
block-offset = ${EKS_PART_OFFSET}
block-count = ${EKS_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${EKS_PART_UUID}
}
partition 12 {
name = "BMP"
block-offset = ${BMP_PART_OFFSET}
block-count = ${BMP_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${BMP_PART_UUID}
}
partition 13 {
name = "RP4"
block-offset = ${RP4_PART_OFFSET}
block-count = ${RP4_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${RP4_PART_UUID}
}
partition 14 {
name = "BOOT-A"
block-offset = ${BOOT_A_PART_OFFSET}
block-count = ${BOOT_PART_COUNT}
type = ${LINUX_BOOT_TYPE}
guid = ${BOOT_PART_UUID}
}
partition 15 {
name = "Application Data Partition"
block-offset = ${APP_PART_OFFSET}
block-count = ${APP_PART_COUNT}
type = ${LINUX_BOOT_TYPE}
guid = ${APP_PART_UUID}
expand = true
}
}
gpt gpt-b {
# UUID for the entire disk
guid = b443fbeb-2c93-481b-88b3-0ecb0aeba911
partition 0 {
name = "APP"
block-offset = ${ROOTFS_B_PART_OFFSET}
block-count = ${ROOTFS_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${ROOTFS_PART_UUID}
}
partition 1 {
name = "TBC"
block-offset = ${TBC_PART_OFFSET}
block-count = ${TBC_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${TBC_PART_UUID}
}
partition 2 {
name = "RP1"
block-offset = ${RP1_PART_OFFSET}
block-count = ${RP1_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${RP1_PART_UUID}
}
partition 3 {
name = "EBT"
block-offset = ${EBT_PART_OFFSET}
block-count = ${EBT_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${EBT_PART_UUID}
}
partition 4 {
name = "WB0"
block-offset = ${WB0_PART_OFFSET}
block-count = ${WB0_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${WB0_PART_UUID}
}
partition 5 {
name = "BPF"
block-offset = ${BPF_PART_OFFSET}
block-count = ${BPF_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${BPF_PART_UUID}
}
partition 6 {
name = "BPF-DTB"
block-offset = ${BPF_DTB_PART_OFFSET}
block-count = ${BPF_DTB_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${BPF_DTB_PART_UUID}
}
partition 7 {
name = "FX"
block-offset = ${FX_PART_OFFSET}
block-count = ${FX_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${FX_PART_UUID}
}
partition 8 {
name = "TOS"
block-offset = ${TOS_PART_OFFSET}
block-count = ${TOS_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${TOS_PART_UUID}
}
partition 9 {
name = "DTB"
block-offset = ${DTB_PART_OFFSET}
block-count = ${DTB_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${DTB_PART_UUID}
}
partition 10 {
name = "LNX"
block-offset = ${LNX_PART_OFFSET}
block-count = ${LNX_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${LNX_PART_UUID}
}
partition 11 {
name = "EKS"
block-offset = ${EKS_PART_OFFSET}
block-count = ${EKS_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${EKS_PART_UUID}
}
partition 12 {
name = "BMP"
block-offset = ${BMP_PART_OFFSET}
block-count = ${BMP_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${BMP_PART_UUID}
}
partition 13 {
name = "RP4"
block-offset = ${RP4_PART_OFFSET}
block-count = ${RP4_PART_COUNT}
type = ${LINUX_FILESYSTEM_DATA_TYPE}
guid = ${RP4_PART_UUID}
}
partition 14 {
name = "BOOT-B"
block-offset = ${BOOT_B_PART_OFFSET}
block-count = ${BOOT_PART_COUNT}
type = ${LINUX_BOOT_TYPE}
guid = ${BOOT_PART_UUID}
}
partition 15 {
name = "Application Data Partition"
block-offset = ${APP_PART_OFFSET}
block-count = ${APP_PART_COUNT}
type = ${LINUX_BOOT_TYPE}
guid = ${APP_PART_UUID}
expand = true
}
}
# Location where installed firmware information is stored.
# While this is called "u-boot", u-boot isn't involved in this
# setup. It just provides a convenient key/value store format.
uboot-environment uboot-env {
block-offset = ${UBOOT_ENV_OFFSET}
block-count = ${UBOOT_ENV_COUNT}
}
task revert.a {
# This task reverts to the A partition, so check that we're running on B
require-uboot-variable(uboot-env, "nerves_fw_active", "b")
# Verify that partition A has the expected platform/architecture
require-uboot-variable(uboot-env, "a.nerves_fw_platform", "${NERVES_FW_PLATFORM}")
require-uboot-variable(uboot-env, "a.nerves_fw_architecture", "${NERVES_FW_ARCHITECTURE}")
on-finish {
info("Reverting to partition A")
uboot_setenv(uboot-env, "nerves_fw_active", "a")
uboot_setenv(uboot-env, "nerves_fw_validated", "1")
gpt_write(gpt-a)
}
}
task revert.b {
# This task reverts to the B partition, so check that we're running on A
require-uboot-variable(uboot-env, "nerves_fw_active", "a")
# Verify that partition B has the expected platform/architecture
require-uboot-variable(uboot-env, "b.nerves_fw_platform", "${NERVES_FW_PLATFORM}")
require-uboot-variable(uboot-env, "b.nerves_fw_architecture", "${NERVES_FW_ARCHITECTURE}")
on-finish {
info("Reverting to partition B")
# Switch over
uboot_setenv(uboot-env, "nerves_fw_active", "b")
uboot_setenv(uboot-env, "nerves_fw_validated", "1")
gpt_write(gpt-b)
}
}
task revert.unexpected.a {
require-uboot-variable(uboot-env, "a.nerves_fw_platform", "${NERVES_FW_PLATFORM}")
require-uboot-variable(uboot-env, "a.nerves_fw_architecture", "${NERVES_FW_ARCHITECTURE}")
on-init {
# Case where A is good, and the desire is to go to B.
error("It doesn't look like there's anything to revert to in partition B.")
}
}
task revert.unexpected.b {
require-uboot-variable(uboot-env, "b.nerves_fw_platform", "${NERVES_FW_PLATFORM}")
require-uboot-variable(uboot-env, "b.nerves_fw_architecture", "${NERVES_FW_ARCHITECTURE}")
on-init {
# Case where B is good, and the desire is to go to A.
error("It doesn't look like there's anything to revert to in partition A.")
}
}
task revert.wrongplatform {
on-init {
error("Expecting platform=${NERVES_FW_PLATFORM} and architecture=${NERVES_FW_ARCHITECTURE}")
}
}