OLD | NEW |
1 #!/bin/sh -x | 1 #!/bin/sh -x |
2 | 2 |
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # This runs from the factory install/reset shim. This MUST be run | 7 # This runs from the factory install/reset shim. This MUST be run |
8 # from USB, in developer mode. This script will wipe OQC activity and | 8 # from USB, in developer mode. This script will wipe OQC activity and |
9 # put the system back into factory fresh/shippable state. | 9 # put the system back into factory fresh/shippable state. |
10 echo "Factory reset" | 10 echo "Factory reset" |
11 | 11 |
12 # TODO: How do we know what this is for the general case? | 12 # TODO(crosbug:10680): replace arch detection with crossystem? |
13 if [ -b /dev/sda ]; then | 13 if uname -m | grep -q "^i.86\$"; then |
| 14 ARCH="INTEL" |
| 15 elif [ $(uname -m ) = "x86_64" ]; then |
| 16 ARCH="INTEL" |
| 17 elif [ $(uname -m ) = "armv7l" ]; then |
| 18 ARCH="ARM" |
| 19 else |
| 20 echo "Failed to auto detect architecture" |
| 21 exit 1 |
| 22 fi |
| 23 |
| 24 if [ "$ARCH" = "INTEL" ]; then |
14 STATE_DEV="/dev/sda1" | 25 STATE_DEV="/dev/sda1" |
15 elif [ -b /dev/mmcblk0 ]; then | 26 elif [ "$ARCH" = "ARM" ]; then |
16 STATE_DEV="/dev/mmcblk01" | 27 STATE_DEV="/dev/mmcblk0p1" |
17 else | 28 else |
| 29 STATE_DEV="" |
| 30 fi |
| 31 if [ ! -b "$STATE_DEV" ]; then |
18 echo "Failed to find root SSD." | 32 echo "Failed to find root SSD." |
19 exit 1 | 33 exit 1 |
20 fi | 34 fi |
21 | 35 |
22 # Tcsd will bring up the tpm and de-own it, | 36 # Tcsd will bring up the tpm and de-own it, |
23 # as we are in developer/recovery mode. | 37 # as we are in developer/recovery mode. |
24 start tcsd | 38 start tcsd |
25 | 39 |
26 # Just wipe the start of the partition and remake the fs on | 40 # Just wipe the start of the partition and remake the fs on |
27 # the stateful partition. | 41 # the stateful partition. |
28 dd bs=4M count=1 if=/dev/zero of=${STATE_DEV} | 42 dd bs=4M count=1 if=/dev/zero of=${STATE_DEV} |
29 /sbin/mkfs.ext3 "$STATE_DEV" | 43 /sbin/mkfs.ext3 "$STATE_DEV" |
30 | 44 |
31 # Do any board specific resetting here. | 45 # Do any board specific resetting here. |
32 # board_factory_reset.sh will be installed by the board overlay if necessary. | 46 # board_factory_reset.sh will be installed by the board overlay if necessary. |
33 BOARD_RESET=/usr/sbin/board_factory_reset.sh | 47 BOARD_RESET=/usr/sbin/board_factory_reset.sh |
34 if [ -x "${BOARD_RESET}" ]; then | 48 if [ -x "${BOARD_RESET}" ]; then |
35 echo "Running board specific factory reset: ${BOARD_RESET}" | 49 echo "Running board specific factory reset: ${BOARD_RESET}" |
36 ${BOARD_RESET} || exit 1 | 50 ${BOARD_RESET} || exit 1 |
37 fi | 51 fi |
38 | 52 |
39 echo "Done" | 53 echo "Done" |
OLD | NEW |