blob: e8b0b702dedf8f4d52f62d4e0436890d33fcec79 [file] [log] [blame]
# 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/assembly/assembled_system.gni")
import("//build/images/args.gni")
import("//build/images/custom_signing.gni")
import("//build/images/vbmeta.gni")
import("//build/images/vboot/vboot.gni")
import("//build/images/zedboot/zedboot_args.gni")
import("//src/sys/root/build/root.gni")
assert(current_toolchain == default_toolchain,
"//build/images/* are only valid in the Fuchsia toolchain")
root_realm("root") {
core_package_name = "core-invalid"
}
# Zedboot must be included to pave devices until recovery has a replacement
# mechanism. Products can specify recovery_label to determine which
# image to include in zircon-r.
use_zedboot_as_recovery = false
zedboot_metadata_slot = "zedboot"
if (get_label_info(recovery_label, "label_with_toolchain") ==
get_label_info(":zedboot", "label_with_toolchain")) {
use_zedboot_as_recovery = true
zedboot_metadata_slot = "zircon-r"
}
# Note: This ZBI output is also used by a script in //scripts/verify_cmdline_params.
assembled_system("zedboot_assembly") {
testonly = true
output_dir = root_build_dir
image_name = "zedboot"
include_component_id_index = true
include_shell_commands = false
generate_fvm = false
fshost_config = board_zedboot_fshost_config
base_packages = []
devmgr_config = [
"netsvc.all-features=true",
"netsvc.netboot=true",
] + zedboot_devmgr_config
cmdline = [
"console.shell=true",
"netsvc.disable=false",
"kernel.enable-debugging-syscalls=true",
"kernel.enable-serial-syscalls=true",
"virtcon.colorscheme=special",
"virtcon.dpi=160,240,360,480",
]
bootfs_labels = [
":root",
"//build/input:zedboot_bootfs",
"//build/info:bootfs",
"//bundles:bootstrap-zedboot",
"//bundles/drivers:bootstrap",
"//bundles/drivers:usb-host-stack",
"//bundles/drivers:usb-peripheral-stack",
"//bundles/drivers:utils",
"//src/sys/component_manager:component_manager_bootfs_config",
"//src/diagnostics/archivist:default-service-config",
]
# Needed for installer runs.
bootfs_labels += [
"//src/storage/bin/disk-pave:install-disk-image",
"//src/storage/bin/mount",
]
# For debugging.
bootfs_labels += [
"//src/bringup/bin/virtcon:bootfs",
"//src/connectivity/network/bin/ping",
"//src/devices/nand/bin/nand-util",
"//src/devices/nand/drivers/broker:nand-broker",
"//src/diagnostics/bundles:bootstrap",
"//src/security/bin/syscall-check",
"//src/storage/bin/dd",
"//src/storage/bin/umount",
"//src/sys/bin/psutils:killall",
"//src/sys/bin/psutils:ps",
"//src/sys/bin/psutils:threads",
"//src/zircon/bin/ktrace",
"//zircon/third_party/uapp/dash",
]
# zbi arguments
if (custom_signing_script != "") {
zbi_signing_script = custom_signing_script
zbi_signing_script_deps = [ "//build/images/custom_signing:deps" ]
} else if (use_vboot) {
zbi_signing_script = vboot_action.script
zbi_signing_args = vboot_action.args
zbi_signing_script_deps = vboot_action.deps
inputs = vboot_action.inputs
}
metadata = {
images = []
image_paths = []
update_target = []
images += [
{
label = get_label_info(":$target_name", "label_with_toolchain")
if (custom_signing_script == "" && !use_vboot) {
archive = true
if (use_zedboot_as_recovery) {
bootserver_pave = [ "--zirconr" ]
if (zircon_r_partition != "") {
fastboot_flash = [ zircon_r_partition ]
}
}
bootserver_pave_zedboot = [ "--zircona" ]
}
name = zedboot_metadata_slot
path = "zedboot.zbi"
type = "zbi"
},
]
if (custom_signing_script == "" && !use_vboot) {
update_target += [ "zedboot=zedboot.zbi" ]
}
image_paths += [ "IMAGE_ZEDBOOT_ZBI=zedboot.zbi" ]
if (use_zedboot_as_recovery) {
image_paths += [ "IMAGE_ZIRCONR_ZBI=zedboot.zbi" ]
}
# Optionally include the signed images.
if (custom_signing_script != "" || use_vboot) {
images += [
{
label = get_label_info(":$target_name", "label_with_toolchain")
archive = true
if (use_zedboot_as_recovery) {
mkzedboot_mode = [ "vboot" ]
bootserver_pave = [ "--zirconr" ]
if (zircon_r_partition != "") {
fastboot_flash = [ zircon_r_partition ]
}
}
name = "${zedboot_metadata_slot}.signed"
bootserver_pave_zedboot = [ "--zircona" ]
path = "zedboot.zbi.signed"
type = "zbi.signed"
},
]
update_target += [ "zedboot.signed=zedboot.zbi.signed" ]
if (use_zedboot_as_recovery) {
mkzedboot_mode = [ "vboot" ]
image_paths += [ "IMAGE_ZIRCONR_SIGNEDZBI=zedboot.zbi.signed" ]
}
}
# Optionally include the vbmeta.
if (use_vbmeta) {
images += [
{
label = get_label_info(":$target_name", "label_with_toolchain")
archive = true
if (use_zedboot_as_recovery) {
bootserver_pave = [ "--vbmetar" ]
if (vbmeta_r_partition != "") {
fastboot_flash = [ vbmeta_r_partition ]
}
}
name = zedboot_metadata_slot
bootserver_pave_zedboot = [ "--vbmetaa" ]
path = "zedboot.vbmeta"
type = "vbmeta"
},
]
if (use_zedboot_as_recovery) {
image_paths += [ "IMAGE_VBMETAR_RAW=zedboot.vbmeta" ]
# Only include zedboot as recovery.vbmeta if zedboot is used as recovery
update_target += [ "recovery.vbmeta=zedboot.vbmeta" ]
}
}
}
}
if (target_cpu != "arm64" && !use_vboot) {
esp("esp") {
output_name = "zedboot"
cmdline = "efi_cmdline.txt"
deps = [ ":zedboot_assembly" ]
zedboot = "$root_build_dir/zedboot.zbi"
testonly = true
metadata = {
images = [
{
label = get_label_info(":$target_name", "label_with_toolchain")
mkzedboot_mode = [ "efi" ]
name = "zedboot-efi"
path = "zedboot.esp.blk"
type = "blk"
},
]
image_paths = [ "IMAGE_ZEDBOOT_ESP=zedboot.esp.blk" ]
}
}
}
group("zedboot") {
public_deps = [ ":zedboot_assembly" ]
if (target_cpu != "arm64" && !use_vboot) {
public_deps += [ ":esp" ]
}
testonly = true
}