blob: 63c513f4de9855abbf8d05f66cfc424c05e48778 [file] [log] [blame]
Randall Spanglera51e35b2010-08-20 23:37:541#!/bin/sh -ue
2# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5#
6# A script to mark the current kernel partition as successfully booted.
7
8# Load functions and constants for chromeos-install.
9. "$(dirname "$0")/chromeos-common.sh" || exit 1
10
11if [ "0" = $(id -u) ]; then
12 local sudo=""
13else
14 local sudo=sudo
15fi
16
Nick Sanders4d5a6f92011-05-25 01:37:5017# Extract the kernel partition's UniqueGuid from the command line.
18guid=$(sed 's/.*kern_guid=\([0-9a-fA-F-]\+\).*/\1/' /proc/cmdline)
Randall Spanglera51e35b2010-08-20 23:37:5419
Nick Sanders4d5a6f92011-05-25 01:37:5020# Look through all the known devices to find that one partition.
21kern_dev=$($sudo cgpt find -1 -u $guid)
Randall Spanglera51e35b2010-08-20 23:37:5422
23# Split the kernel device in the base device and paritition number.
24base_dev=$(get_block_dev_from_partition_dev $kern_dev)
25kern_num=$(get_partition_number $kern_dev)
26
27# Mark the kernel as successfully booted (success=1, tries=0).
28$sudo cgpt add $base_dev -i $kern_num -S1 -T0
Bill Richardson93778b02010-12-01 16:27:3729# Mark the kernel as highest priority
30$sudo cgpt prioritize $base_dev -i $kern_num
Bill Richardsonf3a8d952010-10-29 19:17:2731
32# Run the verified boot debugging tool now, because we won't be able to run it
33# manually if there's a problem (no root shell). It leaves a log file that we
34# can look at.
35$sudo dev_debug_vboot --cleanup
Stefan Reinauer27e0e662011-03-10 05:11:2836
Hung-Te Lin995b5fd2011-08-16 10:54:1737# Collect any startup time firmware updater logs (see chromeos_startup)
38FIRMWARE_UPDATE_LOG='/mnt/stateful_partition/update_firmware.log'
39if [ -f "$FIRMWARE_UPDATE_LOG" ]; then
40 echo "Found startup-time firmware updating logs:"
41 stat -c "%y" "$FIRMWARE_UPDATE_LOG"
42 echo "------------------------------------------"
43 cat "$FIRMWARE_UPDATE_LOG" && rm -f "$FIRMWARE_UPDATE_LOG"
44 echo "------------------------------------------"
45fi
46
Stefan Reinauer27e0e662011-03-10 05:11:2847# Run the firmware updater
48FIRMWARE_UPDATE_SCRIPT='/usr/sbin/chromeos-firmwareupdate'
49if [ -x "$FIRMWARE_UPDATE_SCRIPT" ]; then
50 "$FIRMWARE_UPDATE_SCRIPT" --mode=bootok
51fi
52