blob: 77ac489f97880a1f6c21a9f3d5235349aeb73ff4 [file] [log] [blame]
#!/bin/bash
# Copyright 2017 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.
### (deprecated; use "fx pave" or "fx netboot")
## (deprecated; use "fx pave" or "fx netboot")
##
## usage: fx boot [--netboot] [--force-pave]
## [--artifacts <dir>]
## [--sign-tool <path_to_sign_tool>]
## [--bootloader <path_to_prebuilt_bootloader>]
## [<type>] -- [bootserver arguments]
## <type> see "--help" for list (default: x64 for x64 / arm64 for arm64)
## --netboot Boot from ramdisk containing FVM
## --force-pave Force the target device to pave to persistent storage
## --sign-tool Optional executable to sign kernel images.
## --bootloader Flash the bootloader in addition to other partitions. Only
## works with a limited number of device types.
##
## If <type> is omitted, a guess is made based on $FUCHSIA_ARCH. For x64, all
## x64 images will be supplied (resulting in an FVM pave). For arm64 the default
## <type> is netboot.
set -e
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/lib/image_build_vars.sh
declare -a disks=()
fuchsia_dir="${FUCHSIA_BUILD_DIR}"
zircon_tools="${ZIRCON_TOOLS_DIR}"
force_pave=false
usage() {
fx-command-help
echo
echo "Additional bootserver arguments:"
exec "${ZIRCON_TOOLS_DIR}/bootserver" --help
}
echo >&2
echo >&2 "------ DEPRECATION NOTICE ------"
echo >&2 " fx boot is deprecated"
echo >&2
echo >&2 "use \"fx serve\" for most workflows"
echo >&2
echo >&2 "use \"fx pave\" for solely paving"
echo >&2 "use \"fx netboot\" for solely netbooting"
echo >&2
echo >&2 "note: \"astro --force pave\" is no longer needed"
echo >&2 "------ DEPRECATION NOTICE ------"
echo >&2
sleep 5
netboot=false
bootserver_extra=()
sign_tool=""
machine_type=
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
usage
;;
--netboot)
netboot=true
machine_type="netboot"
;;
--force-pave)
force_pave=true
;;
--sign-tool)
shift
sign_tool="$1"
;;
--bootloader)
shift
disks=("${disks[@]}" --bootloader "${1}")
;;
--)
shift
while [[ $# -gt 0 ]]; do
bootserver_extra=("${bootserver_extra[@]}" "$1")
shift
done
break
;;
-*)
echo >&2 "error: unknown flag: " "$1"
echo >&2
echo >&2 "You may be intending to pass this to bootserver."
echo >&2 "Bootserver flags must be passed at the end of all other flags, e.g."
echo >&2 " fx boot -- -1"
echo >&2
echo >&2 "See \`fx boot --help\` for more information."
exit 1
;;
*)
if [[ -n "$machine_type" ]]; then
echo >&2 "error: machine type already set (to $machine_type), argument \"$1\" not understood"
echo >&2
usage
exit 1
fi
machine_type="$1"
;;
esac
shift
done
if $force_pave; then
case "${machine_type}" in
ram|netboot|zedboot)
echo >&2 "error: Cannot force paving while targeting ${machine_type}"
exit 1
;;
esac
fi
add_fvm=true
ramdisk="${fuchsia_dir}/${IMAGE_BOOT_RAM}"
case "${machine_type}" in
help)
usage
;;
zedboot)
ramdisk="${fuchsia_dir}/${IMAGE_ZEDBOOT_ZBI}"
disks=()
add_fvm=false
;;
ram|netboot)
ramdisk="${fuchsia_dir}/${IMAGE_NETBOOT_RAM}"
disks=()
add_fvm=false
;;
cros|pixel|vboot|efi|acer|nuc)
disks=("${disks[@]}" --efi "${fuchsia_dir}/${IMAGE_ESP_RAW}")
disks=("${disks[@]}" --kernc "${fuchsia_dir}/${IMAGE_ZIRCON_VBOOT}")
;;
arm|arm64)
disks=("${disks[@]}" --zircona "${fuchsia_dir}/${IMAGE_ZIRCONA_ZBI}"
--zirconr "${fuchsia_dir}/${IMAGE_ZIRCONR_ZBI}")
;;
gauss)
if [[ -z "$IMAGE_ZIRCONA_SIGNEDZBI" || -z "$IMAGE_ZIRCONR_SIGNEDZBI" ]]; then
if [[ ! -z "${sign_tool}" ]]; then
GAUSS_SIGN_TOOL="${sign_tool}"
elif [[ -z "${GAUSS_SIGN_TOOL}" ]]; then
echo "Sign tool is required." >&2
usage
fi
"${GAUSS_SIGN_TOOL}" -z "${fuchsia_dir}/${IMAGE_ZIRCONA_ZBI}" \
-o "${fuchsia_dir}/${IMAGE_ZIRCONA_ZBI}.gauss.signed"
export IMAGE_ZIRCONA_SIGNEDZBI="${IMAGE_ZIRCONA_ZBI}.gauss.signed"
"${GAUSS_SIGN_TOOL}" -z "${fuchsia_dir}/${IMAGE_ZIRCONR_ZBI}" \
-o "${fuchsia_dir}/${IMAGE_ZIRCONR_ZBI}.gauss.signed"
export IMAGE_ZIRCONR_SIGNEDZBI="${IMAGE_ZIRCONR_ZBI}.gauss.signed"
fi
disks=("${disks[@]}" --zircona "${fuchsia_dir}/${IMAGE_ZIRCONA_SIGNEDZBI}" \
--zirconr "${fuchsia_dir}/${IMAGE_ZIRCONR_SIGNEDZBI}")
add_fvm=$force_pave
;;
astro)
if [[ -z "$IMAGE_ZIRCONA_SIGNEDZBI" || -z "$IMAGE_ZIRCONR_SIGNEDZBI" ]]; then
if [[ ! -z "${sign_tool}" ]]; then
ASTRO_SIGN_TOOL="${sign_tool}"
elif [[ -z "${ASTRO_SIGN_TOOL}" ]]; then
echo "Sign tool is required." >&2
usage
fi
"${ASTRO_SIGN_TOOL}" -z "${fuchsia_dir}/${IMAGE_ZIRCONA_ZBI}" \
-o "${fuchsia_dir}/${IMAGE_ZIRCONA_ZBI}.astro.signed"
export IMAGE_ZIRCONA_SIGNEDZBI="${IMAGE_ZIRCONA_ZBI}.astro.signed"
"${ASTRO_SIGN_TOOL}" -z "${fuchsia_dir}/${IMAGE_ZIRCONR_ZBI}" \
-o "${fuchsia_dir}/${IMAGE_ZIRCONR_ZBI}.astro.signed"
export IMAGE_ZIRCONR_SIGNEDZBI="${IMAGE_ZIRCONR_ZBI}.astro.signed"
fi
disks=("${disks[@]}" --zircona "${fuchsia_dir}/${IMAGE_ZIRCONA_SIGNEDZBI}"\
--zirconb "${fuchsia_dir}/${IMAGE_ZIRCONR_SIGNEDZBI}"\
--zirconr "${fuchsia_dir}/${IMAGE_ZIRCONR_SIGNEDZBI}")
add_fvm=$force_pave
;;
""|*)
if [[ -n "$machine_type" ]]; then
echo >&2 "Unknown machine type: \"$machine_type\", using ${FUCHSIA_ARCH}"
fi
if [[ "$FUCHSIA_ARCH" == "x64" ]]; then
machine_type="x64"
disks=("${disks[@]}" --efi "${fuchsia_dir}/${IMAGE_ESP_RAW}" \
--kernc "${fuchsia_dir}/${IMAGE_ZIRCON_VBOOT}")
else
machine_type="arm64"
disks=("${disks[@]}" --zircona "${fuchsia_dir}/${IMAGE_ZIRCONA_ZBI}"
--zirconr "${fuchsia_dir}/${IMAGE_ZIRCONR_ZBI}")
fi
esac
if $add_fvm; then
disks=("${disks[@]}" --fvm "${fuchsia_dir}/${IMAGE_FVM_SPARSE}")
fi
name="$(get-device-name)"
if [[ -n "${name}" ]]; then
device_args=("-n" "${name}")
fi
exec "${zircon_tools}/bootserver" \
"${device_args[@]}" \
"${disks[@]}" \
"${ramdisk}" \
"${bootserver_extra[@]}"