Skip to content

Commit

Permalink
Rework partitions / boot sectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Deployment committed May 19, 2017
1 parent 4f6c338 commit 516caca
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.37
0.0.38
63 changes: 35 additions & 28 deletions fwup.conf
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
# Firmware configuration file for the NanoPi NEO
# Firmware configuration file for the Beaglebone Black

# 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 MBR and the following 4 partitions:
# has an MBR and the following 3 partitions:
#
# +----------------------------+
# | MBR |
# +----------------------------+
# | Boot partition (Linux) |
# | Boot partition (FAT32) |
# | u-boot.img |
# | uenv.txt |
# | zImage |
# +----------------------------+
# | p1*: Rootfs A (squashfs) |
# +----------------------------+
# | p2*: Rootfs B (squashfs) |
# | p1*: Rootfs B (squashfs) |
# +----------------------------+
# | p3**: Application (FAT) |
# | p2: Application (FAT32) |
# +----------------------------+
# | p4**: Provision (FAT) |
# | p3: Provision (FAT32) |
# +----------------------------+
# ** these are setup as FAT because that's all fwup will support, but
# it's probably a good idea to reformat them as ext4 in app-space
#
# The p1 partition points to whichever of Rootfs A or B that
# is active.
Expand All @@ -32,22 +30,22 @@ define(BOOT0_OFFSET, 16) # 16 blocks * 512byte/block = 8092 byte offset, per H3
# The boot partition contains u-boot.img, zImage, and has
# room for a debug uEnv.txt if desired
define(BOOT_PART_OFFSET, 2048)
define(BOOT_PART_COUNT, 75276)
define(BOOT_PART_COUNT, 30720)

define(ROOTFS_A_PART_OFFSET, 77324)
define(ROOTFS_A_PART_COUNT, 289044)
define(ROOTFS_B_PART_OFFSET, 366368)
define(ROOTFS_B_PART_COUNT, 289044)
# Let the rootfs have room to grow up to 256 MiB and align
# it to the nearest 1 MB boundary
define(ROOTFS_A_PART_OFFSET, 32768)
define(ROOTFS_A_PART_COUNT, 131072) # 64mb
define(ROOTFS_B_PART_OFFSET, 163840)
define(ROOTFS_B_PART_COUNT, 131072) # 64mb

# Application partition
define(APP_PART_OFFSET, 655412)
define(APP_PART_COUNT, 289044)
define(APP_PART_OFFSET, 294912)
define(APP_PART_COUNT, 131072) # 64mb

# provision is an area we can mount as read-only to hold
# certificates, IDs, or other non-volatile data we don't necessarily
# want in the r/w app partition
define(PROVISION_PART_OFFSET, 944456)
define(PROVISION_PART_COUNT, 20480) # 10mb
# provision partition
define(PROV_PART_OFFSET, 425984)
define(PROV_PART_COUNT, 20480) # 10mb

# Firmware metadata
meta-product = "Nerves Firmware"
Expand Down Expand Up @@ -97,8 +95,8 @@ mbr mbr-a {
type = 0x83 # Linux
}
partition 3 {
block-offset = ${PROVISION_PART_OFFSET}
block-count = ${PROVISION_PART_COUNT}
block-offset = ${PROV_PART_OFFSET}
block-count = ${PROV_PART_COUNT}
type = 0x83 # Linux
}
}
Expand All @@ -121,8 +119,8 @@ mbr mbr-b {
type = 0x83 # Linux
}
partition 3 {
block-offset = ${PROVISION_PART_OFFSET}
block-count = ${PROVISION_PART_COUNT}
block-offset = ${PROV_PART_OFFSET}
block-count = ${PROV_PART_COUNT}
type = 0x83 # Linux
}
}
Expand All @@ -144,6 +142,7 @@ task complete {
fat_setlabel(${BOOT_PART_OFFSET}, "BOOT")
}

#on-resource MLO { fat_write(${BOOT_PART_OFFSET}, "MLO") }
on-resource u-boot.img { fat_write(${BOOT_PART_OFFSET}, "u-boot.img") }
on-resource boot.scr { fat_write(${BOOT_PART_OFFSET}, "boot.scr") }
on-resource zImage { fat_write(${BOOT_PART_OFFSET}, "zImage") }
Expand All @@ -163,8 +162,8 @@ task complete {
# partition can be written in one go.
fat_mkfs(${APP_PART_OFFSET}, ${APP_PART_COUNT})
fat_setlabel(${APP_PART_OFFSET}, "APPDATA")
fat_mkfs(${PROVISION_PART_OFFSET}, ${PROVISION_PART_COUNT})
fat_setlabel(${PROVISION_PART_OFFSET}, "PROVDATA")
fat_mkfs(${PROV_PART_OFFSET}, ${PROV_PART_COUNT})
fat_setlabel(${PROV_PART_OFFSET}, "PROVDATA")
}
}

Expand Down Expand Up @@ -194,14 +193,16 @@ task upgrade.a {
}

on-finish {
# Switch over to boot the new firmware
# Switch over to boot the new firmware
mbr_write(mbr-a)

fat_mv(${BOOT_PART_OFFSET}, "zImage", "zImage.pre")
fat_mv(${BOOT_PART_OFFSET}, "boot.scr", "boot.scr.pre")
#fat_mv(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb", "am335x-boneblack.dtb.pre")

fat_mv(${BOOT_PART_OFFSET}, "zImage.new", "zImage")
fat_mv(${BOOT_PART_OFFSET}, "boot.scr.new", "boot.scr")
#fat_mv(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb.new", "am335x-boneblack.dtb")
}

on-error {
Expand All @@ -222,24 +223,30 @@ task upgrade.b {

on-init {
fat_rm(${BOOT_PART_OFFSET}, "zImage.pre")
#fat_rm(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb.pre")
fat_rm(${BOOT_PART_OFFSET}, "boot.scr.pre")
}

on-resource zImage { fat_write(${BOOT_PART_OFFSET}, "zImage.new") }
on-resource boot.scr { fat_write(${BOOT_PART_OFFSET}, "boot.scr.new") }
#on-resource am335x-boneblack.dtb { fat_write(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb.new") }

on-resource rootfs.img {
# write to the first rootfs partition
raw_write(${ROOTFS_B_PART_OFFSET})
}

on-finish {
# Switch over to boot the new firmware
# Switch over to boot the new firmware
mbr_write(mbr-b)

fat_mv(${BOOT_PART_OFFSET}, "zImage", "zImage.pre")
fat_mv(${BOOT_PART_OFFSET}, "boot.scr", "boot.scr.pre")
#fat_mv(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb", "am335x-boneblack.dtb.pre")

fat_mv(${BOOT_PART_OFFSET}, "zImage.new", "zImage")
fat_mv(${BOOT_PART_OFFSET}, "boot.scr.new", "boot.scr")
#fat_mv(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb.new", "am335x-boneblack.dtb")
}

on-error {
Expand Down

0 comments on commit 516caca

Please sign in to comment.