| # Copyright 2021 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # Generates a partitions config to be consumed by the Image Assembler. |
| # |
| # Arguments: |
| # output_path (optional) |
| # [path] Board config output location. |
| # Defaults to $target_out_dir/$target_name.json |
| # |
| # hw_revision (required) |
| # [string] The name of the hardware revision. |
| # This is placed in the flash manifest to ensure partitions are not |
| # flashed to the wrong hardware. |
| # |
| # bootloader_partitions (optional) |
| # [list] List of bootloaders to use when flashing or updating. |
| # Each entry will have the following format. |
| # { |
| # image = "path/to/image" |
| # type = "bl2" |
| # name = "boot1" |
| # } |
| # |
| # If a name is not provided, then the bootloader will not be flashed, but |
| # will still be included in the update package. |
| # |
| # bootstrap_partitions (optional) |
| # [list] List of OEM images to flash when using: |
| # ffx target flash --product fuchsia |
| # |
| # Each entry will have the following format. A file is only flashed to the |
| # partition if the conditional fastboot arg equals the specified value. |
| # { |
| # path = "path/to/image" |
| # partition = "partition" |
| # condition = { |
| # variable = "variable" |
| # value = "value |
| # } |
| # } |
| # |
| # unlock_credentials (optional) |
| # [list] List of zip files containing the credentials used to unlock |
| # a device in fastboot mode. |
| # |
| # zbi_a (optional) |
| # zbi_b (optional) |
| # zbi_r (optional) |
| # [string] The name of the zbi partitions for each slot. |
| # |
| # vbmeta_a (optional) |
| # vbmeta_b (optional) |
| # vbmeta_r (optional) |
| # [string] The name of the vbmeta partitions for each slot. |
| # |
| # fvm (optional) |
| # [string] The name of the fvm partition. |
| # |
| # fxfs (optional) |
| # [string] The name of the fxfs partition. |
| # |
| template("generated_partitions_config") { |
| assert(defined(invoker.hw_revision), "Need to define hw_revision") |
| |
| output_path = "$target_out_dir/$target_name.json" |
| if (defined(invoker.output_path)) { |
| output_path = invoker.output_path |
| } |
| |
| bootloaders = [] |
| if (defined(invoker.bootloader_partitions)) { |
| foreach(part, invoker.bootloader_partitions) { |
| assert(defined(part.image), "All bootloaders must define a path") |
| assert(defined(part.type), "All bootloaders must define a type") |
| |
| path = rebase_path(part.image, root_build_dir) |
| |
| if (defined(part.name)) { |
| bootloaders += [ |
| { |
| image = path |
| type = part.type |
| name = part.name |
| }, |
| ] |
| } else { |
| bootloaders += [ |
| { |
| image = path |
| type = part.type |
| }, |
| ] |
| } |
| } |
| } |
| |
| bootstraps = [] |
| if (defined(invoker.bootstrap_partitions)) { |
| foreach(part, invoker.bootstrap_partitions) { |
| bootstraps += [ |
| { |
| image = rebase_path(part.path, root_build_dir) |
| name = part.partition |
| condition = part.condition |
| }, |
| ] |
| } |
| } |
| |
| credentials = [] |
| if (defined(invoker.unlock_credentials)) { |
| foreach(cred, invoker.unlock_credentials) { |
| credentials += [ rebase_path(cred, root_build_dir) ] |
| } |
| } |
| |
| generated_file(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| "visibility", |
| ]) |
| |
| outputs = [ output_path ] |
| output_conversion = "json" |
| |
| # Aggregate all the non-bootloader partitions. |
| _partitions = [] |
| if (defined(invoker.zbi_a) && invoker.zbi_a != "") { |
| _partitions += [ |
| { |
| name = invoker.zbi_a |
| type = "ZBI" |
| slot = "A" |
| }, |
| ] |
| } |
| if (defined(invoker.zbi_b) && invoker.zbi_b != "") { |
| _partitions += [ |
| { |
| name = invoker.zbi_b |
| type = "ZBI" |
| slot = "B" |
| }, |
| ] |
| } |
| if (defined(invoker.zbi_r) && invoker.zbi_r != "") { |
| _partitions += [ |
| { |
| name = invoker.zbi_r |
| type = "ZBI" |
| slot = "R" |
| }, |
| ] |
| } |
| if (defined(invoker.vbmeta_a) && invoker.vbmeta_a != "") { |
| _partitions += [ |
| { |
| name = invoker.vbmeta_a |
| type = "VBMeta" |
| slot = "A" |
| }, |
| ] |
| } |
| if (defined(invoker.vbmeta_b) && invoker.vbmeta_b != "") { |
| _partitions += [ |
| { |
| name = invoker.vbmeta_b |
| type = "VBMeta" |
| slot = "B" |
| }, |
| ] |
| } |
| if (defined(invoker.vbmeta_r) && invoker.vbmeta_r != "") { |
| _partitions += [ |
| { |
| name = invoker.vbmeta_r |
| type = "VBMeta" |
| slot = "R" |
| }, |
| ] |
| } |
| if (defined(invoker.fvm) && invoker.fvm != "") { |
| _partitions += [ |
| { |
| name = invoker.fvm |
| type = "FVM" |
| }, |
| ] |
| } |
| if (defined(invoker.fxfs) && invoker.fxfs != "") { |
| _partitions += [ |
| { |
| name = invoker.fxfs |
| type = "Fxfs" |
| }, |
| ] |
| } |
| |
| contents = { |
| hardware_revision = invoker.hw_revision |
| bootloader_partitions = bootloaders |
| partitions = _partitions |
| bootstrap_partitions = bootstraps |
| unlock_credentials = credentials |
| } |
| } |
| } |