~hacktivista/hackware-boot

ref: 80820834b4e92e3610222a6bea42fd34abd1eb38 hackware-boot/x230t-flash_ec_firmware.sh -rwxr-xr-x 2.4 KiB
80820834Felix Freeman Initial commit. Flash X230t EC firmware. a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
# Copyright 2022 Felix Freeman <libsys@hacktivista.org>
#
# This file is part of "Hackware boot" and licensed under the terms of the
# Hacktivista General Public License version 0.1 or (at your option) any later
# version. You should have received a copy of this license along with the
# software. If not, see <https://hacktivista.org/licenses/>.

echo '> Upgrade EC firmware'

echo 'Installing dependencies: curl and El-Torito'
sudo apt-get install -qy curl genisoimage perl

echo 'Downloading ISO'
curl -#LO https://download.lenovo.com/pccbbs/mobiles/gcuj32us.iso --output-dir /tmp/

echo 'Making ISO bootable'
geteltorito -o /tmp/gcuj32us.bootable.iso /tmp/gcuj32us.iso

# scan removable storages and request if not inserted
while
	STORAGE_DEVICES=$(lsblk -dno PATH,VENDOR,MODEL,SIZE,RM | sed -nEe '/.*1$/{ s/[[:space:]]+/ /g; s/(.*)1/\1/p }' | nl -s ') ' -w 1)
	[ -z "$STORAGE_DEVICES" ]
do
	echo 'Please insert a removable storage device. Then press <Enter> to continue.'
	read -r _CHOICE
done

# select a storage media
STORAGE_DEVICES_COUNT=$(echo "$STORAGE_DEVICES" | wc -l)
while
	cat <<- EOF

	Select a removable storage device:
	$STORAGE_DEVICES

	Type a device number from 1 to $STORAGE_DEVICES_COUNT and press <Enter>.
	If the device is mounted please unmount it before proceeding.
	WARNING: ALL ITS PARTITIONS AND CONTENTS WILL BE WIPED!
	EOF
	read -r CHOICE
	! expr "$CHOICE" : "[1-$STORAGE_DEVICES_COUNT]" 1> /dev/null
do true; done

STORAGE_PATH=$(echo "$STORAGE_DEVICES" | sed -nEe "/$CHOICE/ { s/$CHOICE\) ([^ ]+).*/\1/p }")

# write EC firmware into it
sudo dd if=/tmp/gcuj32us.bootable.iso of="$STORAGE_PATH" bs=1M status=progress
echo 'Done! Please remove the storage device and press <Enter>.'
read -r _CHOICE

cat << EOF
=================================================
NOW WE WILL FLASH THE EC FIRMWARE INTO THE LAPTOP
=================================================

Previous to flashing the firmware please verify the battery is propertly charged and both the battery and the AC power are connected to the laptop.

1. Connect the storage device with the EC Firmware update.
2. Turn it on and press F12 repeatedly to show the boot menu.
3. Select the removable storage. The firmware update software will boot.
4. Select option 2 "Update system program".
5. Read instructions carefully and proceed with the EC firmware update.

When you are done with that press <Enter> here to continue.
EOF
read -r _CHOICE