@@ -44,7 +44,7 @@ define(ROOTFS, "${NERVES_SYSTEM}/images/rootfs.squashfs")
44
44
# +----------------------------+
45
45
# | p1*: Rootfs B (squashfs) |
46
46
# +----------------------------+
47
- # | p2: Application (ext4) |
47
+ # | p2: Application (ext4) |
48
48
# +----------------------------+
49
49
#
50
50
# The p0/p1 partition points to whichever of configurations A or B that is
@@ -231,6 +231,10 @@ task upgrade.a {
231
231
# This task upgrades the A partition
232
232
require-partition-offset(1, ${ROOTFS_B_PART_OFFSET})
233
233
234
+ # Verify the expected platform/architecture
235
+ require-uboot-variable(uboot-env, "b.nerves_fw_platform", "${NERVES_FW_PLATFORM}")
236
+ require-uboot-variable(uboot-env, "b.nerves_fw_architecture", "${NERVES_FW_ARCHITECTURE}")
237
+
234
238
on-init {
235
239
info("Upgrading the A partition")
236
240
@@ -242,6 +246,9 @@ task upgrade.a {
242
246
fat_mkfs(${BOOT_A_PART_OFFSET}, ${BOOT_A_PART_COUNT})
243
247
fat_setlabel(${BOOT_A_PART_OFFSET}, "BOOT-A")
244
248
fat_mkdir(${BOOT_A_PART_OFFSET}, "overlays")
249
+
250
+ # Indicate that the entire partition can be cleared
251
+ trim(${ROOTFS_A_PART_OFFSET}, ${ROOTFS_A_PART_COUNT})
245
252
}
246
253
247
254
# Write the new boot partition files and rootfs. The MBR still points
@@ -284,6 +291,10 @@ task upgrade.b {
284
291
# This task upgrades the B partition
285
292
require-partition-offset(1, ${ROOTFS_A_PART_OFFSET})
286
293
294
+ # Verify the expected platform/architecture
295
+ require-uboot-variable(uboot-env, "a.nerves_fw_platform", "${NERVES_FW_PLATFORM}")
296
+ require-uboot-variable(uboot-env, "a.nerves_fw_architecture", "${NERVES_FW_ARCHITECTURE}")
297
+
287
298
on-init {
288
299
info("Upgrading the B partition")
289
300
@@ -295,6 +306,8 @@ task upgrade.b {
295
306
fat_mkfs(${BOOT_B_PART_OFFSET}, ${BOOT_B_PART_COUNT})
296
307
fat_setlabel(${BOOT_B_PART_OFFSET}, "BOOT-B")
297
308
fat_mkdir(${BOOT_B_PART_OFFSET}, "overlays")
309
+
310
+ trim(${ROOTFS_B_PART_OFFSET}, ${ROOTFS_B_PART_COUNT})
298
311
}
299
312
300
313
# Write the new boot partition files and rootfs. The MBR still points
@@ -331,10 +344,18 @@ task upgrade.b {
331
344
332
345
on-error {
333
346
}
334
- }
347
+ }
335
348
336
349
task upgrade.unexpected {
350
+ require-uboot-variable(uboot-env, "a.nerves_fw_platform", "${NERVES_FW_PLATFORM}")
351
+ require-uboot-variable(uboot-env, "a.nerves_fw_architecture", "${NERVES_FW_ARCHITECTURE}")
337
352
on-init {
338
353
error("Please check the media being upgraded. It doesn't look like either the A or B partitions are active.")
339
354
}
340
355
}
356
+
357
+ task upgrade.wrongplatform {
358
+ on-init {
359
+ error("Expecting platform=${NERVES_FW_PLATFORM} and architecture=${NERVES_FW_ARCHITECTURE}")
360
+ }
361
+ }
0 commit comments