-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfwup.conf
695 lines (629 loc) · 24.6 KB
/
fwup.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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
# Firmware configuration file for the Giant Board
require-fwup-version="1.0.0"
#
# 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}
# File resources are listed in the order that they are included in the .fw file
# This is important, since this is the order that they're written on a firmware
# update due to the event driven nature of the update system.
file-resource nvtboot_cpu.bin.encrypt {
host-path = "${NERVES_SYSTEM}/images/nvtboot_cpu.bin.encrypt"
}
file-resource bootloader-tegra210-p3448-0000-p3449-0000-b00.dtb.encrypt {
host-path = "${NERVES_SYSTEM}/images/tegra210-p3448-0000-p3449-0000-b00.dtb.encrypt"
}
file-resource kernel-tegra210-p3448-0000-p3449-0000-b00.dtb.encrypt {
host-path = "${NERVES_SYSTEM}/images/tegra210-p3448-0000-p3449-0000-b00.dtb.encrypt"
}
file-resource tegra210-p3448-0000-p3449-0000-b00.dtb {
host-path = "${NERVES_SYSTEM}/images/tegra210-p3448-0000-p3449-0000-b00.dtb"
}
file-resource cboot.bin.encrypt {
host-path = "${NERVES_SYSTEM}/images/cboot.bin.encrypt"
}
file-resource warmboot.bin.encrypt {
host-path = "${NERVES_SYSTEM}/images/warmboot.bin.encrypt"
}
file-resource sc7entry-firmware.bin.encrypt {
host-path = "${NERVES_SYSTEM}/images/sc7entry-firmware.bin.encrypt"
}
file-resource tos-mon-only.img.encrypt {
host-path = "${NERVES_SYSTEM}/images/tos-mon-only.img.encrypt"
}
file-resource boot.img.encrypt {
host-path = "${NERVES_SYSTEM}/images/boot.img.encrypt"
}
file-resource uboot-env.bin {
host-path = "${NERVES_SYSTEM}/images/uboot-env.bin"
}
file-resource eks.img {
host-path = "${NERVES_SYSTEM}/images/eks.img"
}
file-resource bmp.blob {
host-path = "${NERVES_SYSTEM}/images/bmp.blob"
}
file-resource rp4.blob {
host-path = "${NERVES_SYSTEM}/images/rp4.blob"
}
file-resource nerves_initramfs {
host-path = "${NERVES_SYSTEM}/images/nerves_initramfs.uImage"
}
file-resource Image {
host-path = "${NERVES_SYSTEM}/images/Image"
}
file-resource rootfs.img {
host-path = ${ROOTFS}
# Error out if the rootfs size exceeds the partition size
assert-size-lte = ${ROOTFS_PART_COUNT}
}
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}
}
# This firmware task writes everything to the destination media
task complete {
# Only match if not mounted
require-unmounted-destination = true
on-init {
gpt_write(gpt-a)
fat_mkfs(${BOOT_A_PART_OFFSET}, ${BOOT_PART_COUNT})
fat_setlabel(${BOOT_A_PART_OFFSET}, "BOOT-A")
}
on-resource uboot-env.bin {
# Boot to the A partition first and don't fail back.
# If this fails, we bricked the board with no recovery.
raw_write(${UBOOT_ENV_OFFSET})
# Include provisioning instructions
include("${NERVES_PROVISIONING}")
# Add in the generic Nerves metadata variables.
uboot_setenv(uboot-env, "nerves_fw_active", "a")
uboot_setenv(uboot-env, "nerves_fw_autovalidate", "1")
uboot_setenv(uboot-env, "nerves_fw_validated", "1")
uboot_setenv(uboot-env, "nerves_fw_booted", "0")
uboot_setenv(uboot-env, "nerves_fw_devpath", ${NERVES_FW_DEVPATH})
uboot_setenv(uboot-env, "a.nerves_fw_application_part0_devpath", ${NERVES_FW_APPLICATION_PART0_DEVPATH})
uboot_setenv(uboot-env, "a.nerves_fw_application_part0_fstype", ${NERVES_FW_APPLICATION_PART0_FSTYPE})
uboot_setenv(uboot-env, "a.nerves_fw_application_part0_target", ${NERVES_FW_APPLICATION_PART0_TARGET})
uboot_setenv(uboot-env, "a.nerves_fw_product", ${NERVES_FW_PRODUCT})
uboot_setenv(uboot-env, "a.nerves_fw_description", ${NERVES_FW_DESCRIPTION})
uboot_setenv(uboot-env, "a.nerves_fw_version", ${NERVES_FW_VERSION})
uboot_setenv(uboot-env, "a.nerves_fw_platform", ${NERVES_FW_PLATFORM})
uboot_setenv(uboot-env, "a.nerves_fw_architecture", ${NERVES_FW_ARCHITECTURE})
uboot_setenv(uboot-env, "a.nerves_fw_author", ${NERVES_FW_AUTHOR})
uboot_setenv(uboot-env, "a.nerves_fw_vcs_identifier", ${NERVES_FW_VCS_IDENTIFIER})
uboot_setenv(uboot-env, "a.nerves_fw_misc", ${NERVES_FW_MISC})
uboot_setenv(uboot-env, "a.nerves_fw_uuid", "\${FWUP_META_UUID}")
}
on-resource nvtboot_cpu.bin.encrypt {raw_write(${TBC_PART_OFFSET})}
on-resource bootloader-tegra210-p3448-0000-p3449-0000-b00.dtb.encrypt {
raw_write(${RP1_PART_OFFSET})
}
on-resource kernel-tegra210-p3448-0000-p3449-0000-b00.dtb.encrypt {
raw_write(${DTB_PART_OFFSET})
}
on-resource cboot.bin.encrypt {raw_write(${EBT_PART_OFFSET})}
on-resource warmboot.bin.encrypt {raw_write(${WB0_PART_OFFSET})}
on-resource sc7entry-firmware.bin.encrypt {raw_write(${BPF_PART_OFFSET})}
on-resource tos-mon-only.img.encrypt {raw_write(${TOS_PART_OFFSET})}
on-resource boot.img.encrypt {raw_write(${LNX_PART_OFFSET})}
on-resource eks.img {raw_write(${EKS_PART_OFFSET})}
on-resource bmp.blob {raw_write(${BMP_PART_OFFSET})}
on-resource rp4.blob {raw_write(${RP4_PART_OFFSET})}
on-resource nerves_initramfs { fat_write(${BOOT_A_PART_OFFSET}, "nerves_initramfs") }
on-resource Image {fat_write(${BOOT_A_PART_OFFSET}, "Image")}
on-resource tegra210-p3448-0000-p3449-0000-b00.dtb {fat_write(${BOOT_A_PART_OFFSET}, "tegra210-p3448-0000-p3449-0000-b00.dtb")}
on-resource rootfs.img {
# write to the first rootfs partition
raw_write(${ROOTFS_A_PART_OFFSET})
}
}
task upgrade.a {
# This task upgrades the A partition, so make sure we're running
# on B.
require-uboot-variable(uboot-env, "nerves_fw_active", "b")
# Require that the running version of firmware has been validated.
# If it has not, then failing back is not guaranteed to work.
require-uboot-variable(uboot-env, "nerves_fw_validated", "1")
# Verify 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-init {
info("Upgrading partition A")
# Clear some firmware information just in case this update gets
# interrupted midway. If this partition was bootable, it's not going to
# be soon.
uboot_unsetenv(uboot-env, "a.nerves_fw_version")
uboot_unsetenv(uboot-env, "a.nerves_fw_platform")
uboot_unsetenv(uboot-env, "a.nerves_fw_architecture")
uboot_unsetenv(uboot-env, "a.nerves_fw_uuid")
# Indicate that the entire partition can be cleared
trim(${BOOT_A_PART_OFFSET}, ${BOOT_PART_COUNT})
trim(${ROOTFS_A_PART_OFFSET}, ${ROOTFS_PART_COUNT})
# Reset the previous contents of the A boot partition
fat_mkfs(${BOOT_A_PART_OFFSET}, ${BOOT_PART_COUNT})
fat_setlabel(${BOOT_A_PART_OFFSET}, "BOOT-A")
}
on-resource nerves_initramfs { fat_write(${BOOT_A_PART_OFFSET}, "nerves_initramfs") }
on-resource Image {fat_write(${BOOT_A_PART_OFFSET}, "Image")}
on-resource tegra210-p3448-0000-p3449-0000-b00.dtb {fat_write(${BOOT_A_PART_OFFSET}, "tegra210-p3448-0000-p3449-0000-b00.dtb")}
on-resource rootfs.img {
# write to the first rootfs partition
raw_write(${ROOTFS_A_PART_OFFSET})
}
on-finish {
# Update firmware metadata
uboot_setenv(uboot-env, "a.nerves_fw_application_part0_devpath", ${NERVES_FW_APPLICATION_PART0_DEVPATH})
uboot_setenv(uboot-env, "a.nerves_fw_application_part0_fstype", ${NERVES_FW_APPLICATION_PART0_FSTYPE})
uboot_setenv(uboot-env, "a.nerves_fw_application_part0_target", ${NERVES_FW_APPLICATION_PART0_TARGET})
uboot_setenv(uboot-env, "a.nerves_fw_product", ${NERVES_FW_PRODUCT})
uboot_setenv(uboot-env, "a.nerves_fw_description", ${NERVES_FW_DESCRIPTION})
uboot_setenv(uboot-env, "a.nerves_fw_version", ${NERVES_FW_VERSION})
uboot_setenv(uboot-env, "a.nerves_fw_platform", ${NERVES_FW_PLATFORM})
uboot_setenv(uboot-env, "a.nerves_fw_architecture", ${NERVES_FW_ARCHITECTURE})
uboot_setenv(uboot-env, "a.nerves_fw_author", ${NERVES_FW_AUTHOR})
uboot_setenv(uboot-env, "a.nerves_fw_vcs_identifier", ${NERVES_FW_VCS_IDENTIFIER})
uboot_setenv(uboot-env, "a.nerves_fw_misc", ${NERVES_FW_MISC})
uboot_setenv(uboot-env, "a.nerves_fw_uuid", "\${FWUP_META_UUID}")
# Reset the validation status and boot to A
# next time.
uboot_setenv(uboot-env, "nerves_fw_active", "a")
uboot_setenv(uboot-env, "nerves_fw_validated", "0")
uboot_setenv(uboot-env, "nerves_fw_booted", "0")
gpt_write(gpt-a)
}
}
task upgrade.b {
# This task upgrades the B partition, so make sure we're running
# on A.
require-uboot-variable(uboot-env, "nerves_fw_active", "a")
# Require that the running version of firmware has been validated.
# If it has not, then failing back is not guaranteed to work.
require-uboot-variable(uboot-env, "nerves_fw_validated", "1")
# Verify 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-init {
info("Upgrading partition B")
# Clear some firmware information just in case this update gets
# interrupted midway.
uboot_unsetenv(uboot-env, "b.nerves_fw_version")
uboot_unsetenv(uboot-env, "b.nerves_fw_platform")
uboot_unsetenv(uboot-env, "b.nerves_fw_architecture")
uboot_unsetenv(uboot-env, "b.nerves_fw_uuid")
# Indicate that the entire partition can be cleared
trim(${BOOT_B_PART_OFFSET}, ${BOOT_PART_COUNT})
trim(${ROOTFS_B_PART_OFFSET}, ${ROOTFS_PART_COUNT})
# Reset the previous contents of the A boot partition
fat_mkfs(${BOOT_B_PART_OFFSET}, ${BOOT_PART_COUNT})
fat_setlabel(${BOOT_B_PART_OFFSET}, "BOOT-A")
}
on-resource nerves_initramfs { fat_write(${BOOT_B_PART_OFFSET}, "nerves_initramfs") }
on-resource Image {fat_write(${BOOT_B_PART_OFFSET}, "Image")}
on-resource tegra210-p3448-0000-p3449-0000-b00.dtb {fat_write(${BOOT_B_PART_OFFSET}, "tegra210-p3448-0000-p3449-0000-b00.dtb")}
on-resource rootfs.img {
# write to the first rootfs partition
raw_write(${ROOTFS_B_PART_OFFSET})
}
on-finish {
# Update firmware metadata
uboot_setenv(uboot-env, "b.nerves_fw_application_part0_devpath", ${NERVES_FW_APPLICATION_PART0_DEVPATH})
uboot_setenv(uboot-env, "b.nerves_fw_application_part0_fstype", ${NERVES_FW_APPLICATION_PART0_FSTYPE})
uboot_setenv(uboot-env, "b.nerves_fw_application_part0_target", ${NERVES_FW_APPLICATION_PART0_TARGET})
uboot_setenv(uboot-env, "b.nerves_fw_product", ${NERVES_FW_PRODUCT})
uboot_setenv(uboot-env, "b.nerves_fw_description", ${NERVES_FW_DESCRIPTION})
uboot_setenv(uboot-env, "b.nerves_fw_version", ${NERVES_FW_VERSION})
uboot_setenv(uboot-env, "b.nerves_fw_platform", ${NERVES_FW_PLATFORM})
uboot_setenv(uboot-env, "b.nerves_fw_architecture", ${NERVES_FW_ARCHITECTURE})
uboot_setenv(uboot-env, "b.nerves_fw_author", ${NERVES_FW_AUTHOR})
uboot_setenv(uboot-env, "b.nerves_fw_vcs_identifier", ${NERVES_FW_VCS_IDENTIFIER})
uboot_setenv(uboot-env, "b.nerves_fw_misc", ${NERVES_FW_MISC})
uboot_setenv(uboot-env, "b.nerves_fw_uuid", "\${FWUP_META_UUID}")
# Reset the validation status and boot to B next time.
uboot_setenv(uboot-env, "nerves_fw_active", "b")
uboot_setenv(uboot-env, "nerves_fw_validated", "0")
uboot_setenv(uboot-env, "nerves_fw_booted", "0")
gpt_write(gpt-b)
}
}
task upgrade.unvalidated {
require-uboot-variable(uboot-env, "nerves_fw_validated", "0")
on-init {
error("Please validate the running firmware before upgrading it again.")
}
}
task upgrade.wrong {
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 {
error("Please check the media being upgraded. It doesn't look like either the A or B partitions are active.")
}
}
task upgrade.wrongplatform {
on-init {
error("Expecting platform=${NERVES_FW_PLATFORM} and architecture=${NERVES_FW_ARCHITECTURE}")
}
}