blob: 1c6419fbe7af5d1bba755f7c21153f9b36804816 [file] [log] [blame]
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Firmware updating task before UI"
author "chromium-os-dev@chromium.org"
start on starting ui
# This job blocks the start of UI and calls all the tasks sequentially at boot
# if the tasks:
# 1. Show up the boot message by calling `chromeos-boot-alert`.
# 2. Leave the message and enter Chrome UI normally after it is finished.
# Please make sure the tasks running here DO NOT take a long time in the no-op
# case because this job BLOCKS the UI startup.
# It has no main script so that it only runs once at boot before UI starts.
pre-start script
# Update FPMCU firmware.
FP_SCRIPT='/usr/sbin/bio_fw_updater'
FP_LOG_DIR='/var/log/biod'
FP_PRESTART_LOG='/var/log/bio_fw_updater.out'
if [ -e ${FP_SCRIPT} ]; then
mkdir -p "${FP_LOG_DIR}"
logger -t "${UPSTART_JOB}" "Update FPMCU firmware."
"${FP_SCRIPT}" "--log_dir=${FP_LOG_DIR}" >"${FP_PRESTART_LOG}" 2>&1 || \
logger -t "${UPSTART_JOB}" "Failed to update FPMCU firmware."
logger -t "${UPSTART_JOB}" -f "${FP_PRESTART_LOG}"
fi
# Update detachable keyboard firmware.
HAMMERD_SCRIPT='/usr/share/cros/init/hammerd-at-boot.sh'
if [ -e "${HAMMERD_SCRIPT}" ]; then
logger -t "${UPSTART_JOB}" "Update keyboard firmware."
"${HAMMERD_SCRIPT}" || \
logger -t "${UPSTART_JOB}" "Failed to update keyboard firmware."
fi
# Update touch firmware.
TOUCH_SCRIPT='/opt/google/touch/scripts/chromeos-touch-update.sh'
if [ -e "${TOUCH_SCRIPT}" ]; then
logger -t "${UPSTART_JOB}" "Update touch firmware."
"${TOUCH_SCRIPT}" || \
logger -t "${UPSTART_JOB}" "Failed to update touch firmware."
fi
# Some firmware updaters require a reboot immediately after the update. This
# checks if one of them has created a file /tmp/force_reboot_after_fw_update.
# If yes, and we're not booting from a removable device, then reboot.
logit() {
logger -t ${UPSTART_JOB} "$*"
}
. /usr/share/misc/chromeos-common.sh
. /usr/sbin/write_gpt.sh
# Check if rootfs is mounted on a removable device.
rootdev_removable() {
load_base_vars
local dst_drive="$(get_fixed_dst_drive)"
local root_drive="$(rootdev -s -d)"
if [ -z "${dst_drive}" ]; then
logit "no known device"
elif [ "${dst_drive}" != "${root_drive}" ]; then
logit "running on removable device ${dst_drive}, not ${root_drive}"
return 0
else
logit "running on disk ${root_drive}"
fi
return 1
}
REBOOT_FILE="/tmp/force_reboot_after_fw_update"
if [ -e "${REBOOT_FILE}" ]; then
# Immediately delete the file to avoid bootloops.
rm -f "${REBOOT_FILE}"
# If we're *not* booting from a removable device, then reboot the device.
if rootdev_removable; then
logit "rootfs on removable device, not rebooting"
else
logit "reboot required"
reboot
exit 0
fi
fi
display_boot_message action restore_frecon
end script