mirror of
https://github.com/Dasharo/dasharo-tools.git
synced 2026-06-13 10:16:14 -07:00
clevo/ec-flash.sh: add
Signed-off-by: Maciej Pijanowski <maciej.pijanowski@3mdeb.com>
This commit is contained in:
Executable
+85
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
error_exit() {
|
||||
_error_msg="$1"
|
||||
echo "$_error_msg"
|
||||
exit 1
|
||||
}
|
||||
|
||||
error_check() {
|
||||
_error_code=$?
|
||||
_error_msg="$1"
|
||||
[ "$_error_code" -ne 0 ] && error_exit "$_error_msg : ($_error_code)"
|
||||
}
|
||||
|
||||
# Method to access IT5570 IO Depth 2 registers
|
||||
it5570_i2ec() {
|
||||
# TODO: Use /dev/port instead of iotools
|
||||
|
||||
# Address high byte
|
||||
iotools io_write8 0x2e 0x2e
|
||||
iotools io_write8 0x2f 0x11
|
||||
iotools io_write8 0x2e 0x2f
|
||||
iotools io_write8 0x2f $(($2>>8 & 0xff))
|
||||
|
||||
# Address low byte
|
||||
iotools io_write8 0x2e 0x2e
|
||||
iotools io_write8 0x2f 0x10
|
||||
iotools io_write8 0x2e 0x2f
|
||||
iotools io_write8 0x2f $(($2 & 0xff))
|
||||
|
||||
# Data
|
||||
iotools io_write8 0x2e 0x2e
|
||||
iotools io_write8 0x2f 0x12
|
||||
iotools io_write8 0x2e 0x2f
|
||||
|
||||
case $1 in
|
||||
"r")
|
||||
iotools io_read8 0x2f
|
||||
;;
|
||||
"w")
|
||||
iotools io_write8 0x2f $3
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
it5570_shutdown() {
|
||||
echo -n "Syncing disks... "
|
||||
sync
|
||||
echo "Done."
|
||||
echo "The computer will shut down automatically in 5 seconds"
|
||||
sleep 5
|
||||
# shut down using EC external watchdog reset
|
||||
it5570_i2ec w 0x1f01 0x20
|
||||
it5570_i2ec w 0x1f07 0x01
|
||||
}
|
||||
|
||||
update_ec() {
|
||||
echo "Getting EC firmware update..."
|
||||
cp $EC_UPDATE_PATH /tmp/ecupdate.rom
|
||||
error_check "Failed to get EC firmware update file. Please check if path \
|
||||
$EC_UPDATE_PATH is correct."
|
||||
|
||||
echo "Updating EC..."
|
||||
flashrom -p ite_ec -w /tmp/ecupdate.rom
|
||||
error_check "Failed to update EC firmware"
|
||||
|
||||
echo "Successfully updated EC firmware"
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "Usage:"
|
||||
echo " $0 EC_UPDATE_FILE"
|
||||
echo " EC_UPDATE_FILE - This argument takes path to EC update file"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
EC_UPDATE_PATH=$1
|
||||
|
||||
update_ec
|
||||
|
||||
it5570_shutdown
|
||||
Reference in New Issue
Block a user