| # Copyright 2018 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. |
| |
| import("//build/compiled_action.gni") |
| |
| declare_args() { |
| # The size in bytes of the FVM partition image to create. Normally this is |
| # computed to be just large enough to fit the blob and data images. The |
| # default value is "", which means to size based on inputs. Specifying a size |
| # that is too small will result in build failure. |
| fvm_image_size = "" |
| |
| # The size in bytes of the FVM partition on the target eMMC devices. |
| # Specifying this parameter will lead build to generate a fvm.fastboot.blk |
| # suitable for flashing through fastboot for eMMC devices. |
| fvm_emmc_partition_size = "" |
| |
| # The max size of the disk where the FVM is written. This is used for |
| # preallocating metadata to determine how much the FVM can expand on disk. |
| # Only applies to sparse FVM images. At sparse image construction time, the |
| # build fails if the inputs are larger than `fvm_max_disk_size`. At paving |
| # time, the FVM will be sized to the target's disk size up to |
| # `fvm_max_disk_size`. If the size of the disk increases after initial paving, |
| # the FVM will resize up to `fvm_max_disk_size`. During paving, if the target |
| # FVM has declared a smaller size than `fvm_max_disk_size`, the FVM is |
| # reinitialized to the larger size. |
| # The default value is "" which sets the max disk size to the size of the disk |
| # at pave/format time. |
| fvm_max_disk_size = "" |
| |
| # The size of the FVM partition images "slice size". The FVM slice size is a |
| # minimum size of a particular chunk of a partition that is stored within |
| # FVM. A very small slice size may lead to decreased throughput. A very large |
| # slice size may lead to wasted space. The selected default size of 8mb is |
| # selected for conservation of space, rather than performance. |
| fvm_slice_size = "8388608" |
| |
| # Number of slices reserved by FVM for internal usage. A reservation |
| # partition will be added to the FVM image, containing this many slices. |
| # If set to the empty string, then no reservation partition will be added. |
| # Set to 1 by default so that we exercise this feature on all product |
| # configurations. |
| fvm_reserved_slices = "1" |
| |
| # The following blobfs_* and minfs_* arguments are used to determine the |
| # initial dimensions of the blobfs and minfs partitions added to an FVM |
| # image. If they are unset, the sizes of the input blobfs/minfs images will |
| # determine the dimensions of the respective partition within FVM. |
| # |
| # These dimensions cannot make a partition smaller than the image provided |
| # to the FVM tool; in that case, the partition dimensions would be expanded |
| # to fit the input image. |
| # |
| # There are both board-level overrides and product-level dimensions. The |
| # product-level overrides, if set, will take precedence. |
| |
| # minimum_inodes is the number of inodes to reserve for the fs |
| # An empty string does not reserve any additional space than minimum |
| # required for the filesystem. |
| blobfs_board_minimum_inodes = "" |
| blobfs_product_minimum_inodes = "" |
| minfs_board_minimum_inodes = "" |
| minfs_product_minimum_inodes = "" |
| |
| # Number of bytes to reserve for data in the fs. This is in addition |
| # to what is reserved, if any, for the inodes. Data bytes constitutes |
| # "usable" space of the fs. |
| # An empty string does not reserve any additional space than minimum |
| # required for the filesystem. |
| blobfs_board_minimum_data_bytes = "" |
| blobfs_product_minimum_data_bytes = "" |
| minfs_board_minimum_data_bytes = "" |
| minfs_product_minimum_data_bytes = "" |
| |
| # In addition to reserving space for inodes and data, fs needs additional |
| # space for maintaining some internal data structures. So the |
| # space required to reserve inodes and data may exceed sum of the space |
| # needed for inodes and data. |
| # maximum_bytes puts an upper bound on the total bytes reserved for inodes, |
| # data bytes and reservation for all other internal fs metadata. |
| # An empty string does not put any upper bound. A filesystem may |
| # reserve few blocks required for its operations. |
| blobfs_board_maximum_bytes = "" |
| blobfs_product_maximum_bytes = "" |
| minfs_board_maximum_bytes = "" |
| minfs_product_maximum_bytes = "" |
| |
| # TODO(fxbug.dev/67015): Remove these; these are left here to facilitate a |
| # soft transition. DO NOT USE THESE VARIABLES. |
| blobfs_minimum_inodes = "" |
| blob_blobfs_minimum_inodes = "" |
| minfs_minimum_inodes = "" |
| blobfs_minimum_data_bytes = "" |
| blob_blobfs_minimum_data_bytes = "" |
| minfs_minimum_data_bytes = "" |
| blobfs_maximum_bytes = "" |
| blob_blobfs_maximum_bytes = "" |
| minfs_maximum_bytes = "" |
| |
| # End of variables for blobfs/minfs dimensions |
| |
| # Specifying these variables will generate a NAND FVM image suitable for |
| # directly flashing via fastboot. The NAND characteristics are required |
| # in order to properly initialize the FTL metadata in the OOB area. |
| # `max_fvm_size` should also be nonzero or else minfs will not have any |
| # room to initialize on boot. |
| fvm_ftl_nand_page_size = "" |
| fvm_ftl_nand_oob_size = "" |
| fvm_ftl_nand_pages_per_block = "" |
| fvm_ftl_nand_block_count = "" |
| } |
| |
| # Build an FVM partition |
| # |
| # Parameters |
| # |
| # args (optional) |
| # [list of strings] Additional arguments to pass to the FVM tool. |
| # |
| # output_name (required) |
| # [string] The filename to produce. |
| # |
| # partitions (required) |
| # [list of scopes] a list of partitions to be included |
| # dep (required) |
| # [label] The label must be defined earlier in the same file. |
| # type (required) |
| # [string] A partition type accepted by fvm (e.g. blob, data, data-unsafe) |
| # |
| # inputs (optional) |
| # deps (optional) |
| # testonly (optional) |
| # visibility (optional) |
| # metadata (optional) |
| # Same as for any GN `action()` target. |
| template("generate_fvm") { |
| compiled_action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "inputs", |
| "deps", |
| "metadata", |
| "testonly", |
| "visibility", |
| ]) |
| tool = "//src/storage/bin/fvm" |
| outputs = [ invoker.output_name ] |
| args = rebase_path(outputs, root_build_dir) |
| if (defined(invoker.args)) { |
| args += invoker.args |
| } |
| sources = [] |
| if (!defined(deps)) { |
| deps = [] |
| } |
| if (defined(invoker.with_empty_minfs) && invoker.with_empty_minfs) { |
| args += [ "--with-empty-minfs" ] |
| } |
| if (fvm_reserved_slices != "") { |
| args += [ |
| "--reserve-slices", |
| fvm_reserved_slices, |
| ] |
| } |
| if (defined(invoker.partitions)) { |
| foreach(part, invoker.partitions) { |
| args += [ "--${part.type}" ] |
| deps += [ part.dep ] |
| dep_outputs = [] # Reset after last iteration. |
| dep_outputs = get_target_outputs(part.dep) |
| sources += [ dep_outputs[0] ] |
| args += [ rebase_path(dep_outputs[0], root_build_dir) ] |
| if (defined(part.minimum_inodes) && "${part.minimum_inodes}" != "") { |
| args += [ |
| "--minimum-inodes", |
| "${part.minimum_inodes}", |
| ] |
| } |
| if (defined(part.minimum_data_bytes) && |
| "${part.minimum_data_bytes}" != "") { |
| args += [ |
| "--minimum-data-bytes", |
| "${part.minimum_data_bytes}", |
| ] |
| } |
| if (defined(part.maximum_bytes) && "${part.maximum_bytes}" != "") { |
| args += [ |
| "--maximum-bytes", |
| "${part.maximum_bytes}", |
| ] |
| } |
| } |
| } |
| } |
| } |
| |
| fvm_slice_args = [ |
| "--slice", |
| fvm_slice_size, |
| ] |
| |
| fvm_create_args = [ "create" ] + fvm_slice_args |
| |
| fvm_sparse_args = [ |
| "sparse", |
| "--compress", |
| "lz4", |
| ] + fvm_slice_args |
| |
| if (fvm_max_disk_size != "") { |
| fvm_sparse_args += [ |
| "--max-disk-size", |
| fvm_max_disk_size, |
| ] |
| } |