Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1107)

Side by Side Diff: factory_install.sh

Issue 6708106: Fix factory installer for ARM platforms (Closed) Base URL: ssh://gitrw.chromium.org:9222/factory_installer.git@master
Patch Set: Code review Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | factory_reset.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh -ex 1 #!/bin/sh -ex
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 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 . "$(dirname "$0")/chromeos-common.sh" 7 . "$(dirname "$0")/chromeos-common.sh"
8 . "/opt/google/memento_updater/memento_updater_logging.sh" 8 . "/opt/google/memento_updater/memento_updater_logging.sh"
9 . "/opt/google/memento_updater/find_omaha.sh" 9 . "/opt/google/memento_updater/find_omaha.sh"
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 if ! echo "${RESULT}" | grep -Eq "(failed|unavailable)"; then 63 if ! echo "${RESULT}" | grep -Eq "(failed|unavailable)"; then
64 log "Success, time set to $(date)" 64 log "Success, time set to $(date)"
65 return 0 65 return 0
66 fi 66 fi
67 67
68 log $(echo "${RESULT}" | grep -E "(failed|unavailable)") 68 log $(echo "${RESULT}" | grep -E "(failed|unavailable)")
69 log "Failed to set time" 69 log "Failed to set time"
70 return 1 70 return 1
71 } 71 }
72 72
73 list_ethernet_interface() {
74 local candidates="$(ifconfig | grep 'Link encap:Ethernet' | cut -d ' ' -f 1)"
75 for candidate in $candidates; do
76 # output if it is not a wifi interface
77 if ! iw $candidate info >/dev/null 2>&1; then
78 echo $candidate
79 fi
80 done
81 }
82
73 log "Starting Factory Installer." 83 log "Starting Factory Installer."
74 84
75 log "Checking for Firmware Write Protect" 85 log "Checking for Firmware Write Protect"
76 86
77 # Only ChromeOS machines have meaninful output here. 87 # Only ChromeOS machines have meaninful output here.
78 if crossystem hwid >/dev/null; then 88 if crossystem hwid >/dev/null; then
79 # Check for physical firmware write protect. We'll only 89 # Check for physical firmware write protect. We'll only
80 # clear this stuff if the case is open. 90 # clear this stuff if the case is open.
81 if [ "$(crossystem wpsw_cur)" = "0" ]; then 91 if [ "$(crossystem wpsw_cur)" = "0" ]; then
82 # Ensure that flash chips are in a known good state. 92 # Ensure that flash chips are in a known good state.
83 clear_fwwp 93 clear_fwwp
84 94
85 # Ensure that we can wipe TPM if necessary. 95 # Ensure that we can wipe TPM if necessary.
86 clear_tpm 96 clear_tpm
87 fi 97 fi
88 fi 98 fi
89 99
100 #
101 # factory_install.sh implements two operations for assembly line
102 # operators: install (obviously) and reset.
103 #
104 # Somehow the way that operators switch between the two operations
105 # is by plugging in a Ethernet cable.
106 #
107 # The operation is:
108 # * Install if it is connected to Ethernet;
109 # * Reset if developer switch is toggled to consumer mode.
110 #
111 # So we have to detect a possible ethernet connection here.
112 #
113
90 log "Waiting for ethernet connectivity to install" 114 log "Waiting for ethernet connectivity to install"
91 log "Or disable developer mode to factory reset." 115 log "Or disable developer mode to factory reset."
92 while ! ifconfig eth0 | grep -q "inet addr"; do 116 while true; do
117 connected=0
118 for ethernet_interface in $(list_ethernet_interface); do
119 if ifconfig $ethernet_interface | grep -q "inet addr"; then
120 log "$(ifconfig $ethernet_interface | grep 'inet addr')"
121 connected=1
122 break
123 fi
124 done
125 if [ $connected -eq 1 ]; then
126 break
127 fi
128
93 # If developer switch is flipped, go to "reset mode" instead of 129 # If developer switch is flipped, go to "reset mode" instead of
94 # network install mode. Make sure gpio can be read (gpio_setup may 130 # network install mode. Make sure gpio can be read (gpio_setup may
95 # fail if the device is not ready). 131 # fail if the device is not ready).
96 if [ "$(crossystem devsw_cur)" = "0" ]; then 132 if [ "$(crossystem devsw_cur)" = "0" ]; then
97 log "Performing factory reset" 133 log "Performing factory reset"
98 if ! /usr/sbin/factory_reset.sh; then 134 if ! /usr/sbin/factory_reset.sh; then
99 log "Factory reset failed." 135 log "Factory reset failed."
100 exit 1 136 exit 1
101 fi 137 fi
102 138
103 log "Done" 139 log "Done"
104 exit 0 140 exit 0
105 fi 141 fi
106 sleep 1 142 sleep 1
107 done 143 done
108 log "$(ifconfig eth0 | grep 'inet addr')"
109 144
110 set_time || exit 1 145 set_time || exit 1
111 146
112 # TODO(adlr): pick an install device in a matter that works on x86 and ARM. 147 # TODO(crosbug:10680): replace arch detection with crossystem?
113 # This works on x86 only, afaik. 148 if uname -m | grep -q "^i.86\$"; then
114 DST_DRIVE=/dev/sda 149 ARCH="INTEL"
150 elif [ $(uname -m ) = "x86_64" ]; then
151 ARCH="INTEL"
152 elif [ $(uname -m ) = "armv7l" ]; then
153 ARCH="ARM"
154 else
155 log "Error: Failed to auto detect architecture"
156 exit 1
157 fi
158
159 if [ "$ARCH" = "INTEL" ]; then
160 DST_DRIVE=/dev/sda
161 else
162 DST_DRIVE=/dev/mmcblk0
163 fi
115 DST_FACTORY_PART=3 164 DST_FACTORY_PART=3
116 DST_RELEASE_PART=5 165 DST_RELEASE_PART=5
117 DST_OEM_PART=8 166 DST_OEM_PART=8
118 DST_EFI_PART=12 167 DST_EFI_PART=12
119 DST_STATE_PART=1 168 DST_STATE_PART=1
120 DST_FIRMWARE=/tmp/firmware.sh 169 DST_FIRMWARE=/tmp/firmware.sh
121 170
122 # Light up screen in case you can't see our splash image. 171 # Light up screen in case you can't see our splash image.
123 LIGHTUP_SCREEN="/usr/sbin/lightup_screen" 172 LIGHTUP_SCREEN="/usr/sbin/lightup_screen"
124 if [ -x /usr/sbin/lightup_screen ]; then 173 if [ -x "${LIGHTUP_SCREEN}" ]; then
125 ${LIGHTUP_SCREEN} 174 ${LIGHTUP_SCREEN}
126 else 175 else
127 log "${LIGHTUP_SCREEN} does not exist or not executable" 176 log "${LIGHTUP_SCREEN} does not exist or not executable"
128 fi 177 fi
129 178
130 log "Factory Install: Setting partition table" 179 log "Factory Install: Setting partition table"
131 180
132 INST_FLAGS="--dst ${DST_DRIVE} --skip_rootfs --run_as_root --yes" 181 INST_FLAGS="--dst ${DST_DRIVE} --skip_rootfs --run_as_root --yes"
133 182
134 # in factory mode, we need both GPT_LAYOUT and PMBR_CODE always generated. 183 # in factory mode, we need both GPT_LAYOUT and PMBR_CODE always generated.
(...skipping 13 matching lines...) Expand all
148 log "FACTORY INSTALLER STOPPED." 197 log "FACTORY INSTALLER STOPPED."
149 exit 1 198 exit 1
150 fi 199 fi
151 200
152 /usr/sbin/chromeos-install $INST_FLAGS 2>&1 | cat >> "$MEMENTO_AU_LOG" 201 /usr/sbin/chromeos-install $INST_FLAGS 2>&1 | cat >> "$MEMENTO_AU_LOG"
153 202
154 # Load the new partition table. The autoupdater has trouble with loop devices. 203 # Load the new partition table. The autoupdater has trouble with loop devices.
155 sync 204 sync
156 echo 3 > /proc/sys/vm/drop_caches 205 echo 3 > /proc/sys/vm/drop_caches
157 /sbin/sfdisk -R "$DST_DRIVE" 206 /sbin/sfdisk -R "$DST_DRIVE"
207 partprobe # inform the OS of partition table changes
158 208
159 log "Done preparing disk" 209 log "Done preparing disk"
160 210
161 FACTORY_CHANNEL_ARG='--force_track=factory-channel' 211 FACTORY_CHANNEL_ARG='--force_track=factory-channel'
162 RELEASE_CHANNEL_ARG='--force_track=release-channel' 212 RELEASE_CHANNEL_ARG='--force_track=release-channel'
163 OEM_CHANNEL_ARG='--force_track=oempartitionimg-channel' 213 OEM_CHANNEL_ARG='--force_track=oempartitionimg-channel'
164 EFI_CHANNEL_ARG='--force_track=efipartitionimg-channel' 214 EFI_CHANNEL_ARG='--force_track=efipartitionimg-channel'
165 STATE_CHANNEL_ARG='--force_track=stateimg-channel' 215 STATE_CHANNEL_ARG='--force_track=stateimg-channel'
166 FIRMWARE_CHANNEL_ARG='--force_track=firmware-channel' 216 FIRMWARE_CHANNEL_ARG='--force_track=firmware-channel'
167 217
168 # Install the partitions 218 # Install the partitions
169 for i in EFI OEM STATE RELEASE FACTORY FIRMWARE; do 219 for i in EFI OEM STATE RELEASE FACTORY FIRMWARE; do
170 if [ "$i" = "FIRMWARE" ]; then 220 if [ "$i" = "FIRMWARE" ]; then
171 DST="${DST_FIRMWARE}" 221 DST="${DST_FIRMWARE}"
172 else 222 else
173 PART=$(eval "echo \$DST_${i}_PART") 223 PART=$(eval "echo \$DST_${i}_PART")
174 DST="${DST_DRIVE}${PART}" 224 DST="$(make_partition_dev ${DST_DRIVE} ${PART})"
175 fi 225 fi
176 226
177 log "Factory Install: Installing $i image to $DST" 227 log "Factory Install: Installing $i image to $DST"
178 228
179 CHANNEL_ARG=$(eval "echo \$${i}_CHANNEL_ARG") 229 CHANNEL_ARG=$(eval "echo \$${i}_CHANNEL_ARG")
180 KPART="none" 230 KPART="none"
181 if [ "$i" = "FACTORY" -o "$i" = "RELEASE" ]; then 231 if [ "$i" = "FACTORY" -o "$i" = "RELEASE" ]; then
182 # Set up kernel partition 232 # Set up kernel partition
183 KPART="" 233 KPART=""
184 fi 234 fi
(...skipping 24 matching lines...) Expand all
209 fi 259 fi
210 done 260 done
211 261
212 # Release image is not allowed to boot unless the factory test is passed 262 # Release image is not allowed to boot unless the factory test is passed
213 # otherwise the wipe and final verification can be skipped. 263 # otherwise the wipe and final verification can be skipped.
214 # TODO(hungte) do this in memento_updater or postinst may be better 264 # TODO(hungte) do this in memento_updater or postinst may be better
215 # TODO(hungte) make a better way to find location of cgpt 265 # TODO(hungte) make a better way to find location of cgpt
216 if ! cgpt add -i $((${DST_RELEASE_PART} - 1)) -P 0 -T 0 -S 0 ${DST_DRIVE}; then 266 if ! cgpt add -i $((${DST_RELEASE_PART} - 1)) -P 0 -T 0 -S 0 ${DST_DRIVE}; then
217 log "Factory Install: failed to lock release image. Destroy all kernels." 267 log "Factory Install: failed to lock release image. Destroy all kernels."
218 # Destroy kernels otherwise the system is still bootable. 268 # Destroy kernels otherwise the system is still bootable.
219 dd if=/dev/zero of=${DST_DRIVE}$((${DST_RELEASE_PART} - 1)) 269 DST_RELEASE=$(make_partition_dev ${DST_DRIVE} $((${DST_RELEASE_PART} - 1)))
220 dd if=/dev/zero of=${DST_DRIVE}$((${DST_FACTORY_PART} - 1)) 270 DST_FACTORY=$(make_partition_dev ${DST_DRIVE} $((${DST_FACTORY_PART} - 1)))
271 dd if=/dev/zero of=$DST_RELEASE
272 dd if=/dev/zero of=$DST_FACTORY
221 exit 1 273 exit 1
222 fi 274 fi
223 275
224 log "All done installing." 276 log "All done installing."
225 277
226 sleep 3 278 sleep 3
227 shutdown -r now 279 shutdown -r now
228 sleep 1d # sleep indefinitely to avoid respawning rather than shutting down 280 sleep 1d # sleep indefinitely to avoid respawning rather than shutting down
OLDNEW
« no previous file with comments | « no previous file | factory_reset.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698