#
# 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, "grisp2")
define(NERVES_FW_ARCHITECTURE, "arm")
define(NERVES_FW_AUTHOR, "The Nerves Team")

define(NERVES_FW_DEVPATH, "/dev/rootdisk0")
define(NERVES_FW_APPLICATION_PART0_DEVPATH, "/dev/rootdisk0p3") # 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 MBR and the
# following layout in GRiSPv2's ~4 GB eMMC:
#
# +----------------------------+
# | MBR                        |
# +----------------------------+
# | Barebox (#1-1791)          |
# +----------------------------+
# | Barebox env (#1792-2047)   |
# +----------------------------+
# | U-Boot environment         |
# +----------------------------+
# | p1: RootFS A (squashfs)    |
# +----------------------------+
# | p2: RootFS B (squashfs)    |
# +----------------------------+
# | p3: Application (f2fs)     |
# +----------------------------+
#
# The Barebox, and RootFS locations match the GRiSPv2 eMMC layout
# See https://github.com/grisp/grisp_demo/blob/sylane/make-image/make_image.sh
#
# Nerves currently keeps its boot state in the U-Boot environment block that
# immediately preceeds the rootfs partitions. The application data paration
# immediately follow the partitions. This area is currently unspecified for the
# GRiSP2.

# Nerves state
define(UBOOT_ENV_OFFSET, 7936)
define(UBOOT_ENV_COUNT, 256)  # 128 KB

# Match the GRiSPv2 eMMC layout
# See https://github.com/grisp/grisp_demo/blob/sylane/make-image/make_image.sh
define(ROOTFS_A_PART_OFFSET, 8192)
define(ROOTFS_A_PART_COUNT, 524288)
define(ROOTFS_B_PART_OFFSET, 532480)
define(ROOTFS_B_PART_COUNT, ${ROOTFS_A_PART_COUNT})

# 2.5G Application partition
define-eval(APP_PART_OFFSET, "${ROOTFS_B_PART_OFFSET} + ${ROOTFS_B_PART_COUNT}")
define(APP_PART_COUNT, 5242880)

# 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}
