mirror of
https://github.com/linuxboot/heads.git
synced 2025-01-29 15:44:07 +00:00
Add read mode to flash.sh
If we want to modify a running BIOS we will need the ability to pull down the current BIOS, modify it, and then reflash. This change adds a read option to flash.sh and pulls down three versions of the BIOS and only exists successfully if all three match.
This commit is contained in:
parent
b276e355d9
commit
a9bf4eb874
@ -23,27 +23,49 @@ esac
|
||||
|
||||
flash_rom() {
|
||||
ROM=$1
|
||||
cp "$ROM" /tmp/${CONFIG_BOARD}.rom
|
||||
sha256sum /tmp/${CONFIG_BOARD}.rom
|
||||
if [ "$CLEAN" -eq 0 ]; then
|
||||
preserve_rom /tmp/${CONFIG_BOARD}.rom \
|
||||
|| die "$ROM: Config preservation failed"
|
||||
fi
|
||||
if [ "$READ" -eq 1 ]; then
|
||||
flashrom $FLASHROM_OPTIONS -r "${ROM}.1" \
|
||||
|| die "$ROM: Read failed"
|
||||
flashrom $FLASHROM_OPTIONS -r "${ROM}.2" \
|
||||
|| die "$ROM: Read failed"
|
||||
flashrom $FLASHROM_OPTIONS -r "${ROM}.3" \
|
||||
|| die "$ROM: Read failed"
|
||||
if [ `sha256sum ${ROM}.[123] | cut -f1 -d ' ' | uniq | wc -l` -eq 1 ]; then
|
||||
mv ${ROM}.1 $ROM
|
||||
rm ${ROM}.[23]
|
||||
else
|
||||
die "$ROM: Read inconsistent"
|
||||
fi
|
||||
else
|
||||
cp "$ROM" /tmp/${CONFIG_BOARD}.rom
|
||||
sha256sum /tmp/${CONFIG_BOARD}.rom
|
||||
if [ "$CLEAN" -eq 0 ]; then
|
||||
preserve_rom /tmp/${CONFIG_BOARD}.rom \
|
||||
|| die "$ROM: Config preservation failed"
|
||||
fi
|
||||
|
||||
flashrom $FLASHROM_OPTIONS -w /tmp/${CONFIG_BOARD}.rom \
|
||||
|| die "$ROM: Flash failed"
|
||||
flashrom $FLASHROM_OPTIONS -w /tmp/${CONFIG_BOARD}.rom \
|
||||
|| die "$ROM: Flash failed"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" = "-c" ]; then
|
||||
if [ "$1" == "-c" ]; then
|
||||
CLEAN=1
|
||||
READ=0
|
||||
ROM="$2"
|
||||
elif [ "$1" == "-r" ]; then
|
||||
CLEAN=0
|
||||
READ=1
|
||||
ROM="$2"
|
||||
touch $ROM
|
||||
else
|
||||
CLEAN=0
|
||||
READ=0
|
||||
ROM="$1"
|
||||
fi
|
||||
|
||||
if [ ! -e "$ROM" ]; then
|
||||
die "Usage: $0 [-c] <path_to_image.rom>"
|
||||
die "Usage: $0 [-c|-r] <path_to_image.rom>"
|
||||
fi
|
||||
|
||||
flash_rom $ROM
|
||||
|
Loading…
x
Reference in New Issue
Block a user