Commit 5f135672 authored by Youness Alaoui's avatar Youness Alaoui
Browse files

Fix flashrom progress bar size

On broadwell, the hardcoded 16MB flash caused the progress bar to be at 50%
when it finishes flashing.
This reads the total flash size from the flashrom output.
Fixes https://code.puri.sm/kakaroto/coreboot-files/issues/7
parent 79c60d3f
......@@ -249,7 +249,7 @@ get_and_patch_me_11 () {
flashrom_progress() {
local current=0
local total_bytes=0x1000000
local total_bytes=0
local percent=0
local IN=''
local spin='-\|/'
......@@ -257,16 +257,27 @@ flashrom_progress() {
local progressbar=''
local progressbar2=''
local status='init'
local prev_word=''
local prev_prev_word=''
progressbar2=$(for ((i=0; i < 49; i++)) do echo -ne ' ' ; done)
echo "Initializing internal Flash Programmer"
while true ; do
prev_prev_word=$prev_word
prev_word=$IN
read -r -d' ' IN || break
current=$(echo "$IN" | grep -E -o '0x[0-9a-f]+-0x[0-9a-f]+:.*' | grep -E -o "0x[0-9a-f]+" | tail -n 1)
if [ "${current}" != "" ]; then
percent=$((100 * (current + 1) / total_bytes))
progressbar=$(for ((i=0; i < $((percent / 2)); i++)) do echo -ne '#' ; done)
progressbar2=$(for ((i=0; i < $((49 - percent / 2)); i++)) do echo -ne ' ' ; done)
if [ "$total_bytes" != "0" ]; then
current=$(echo "$IN" | grep -E -o '0x[0-9a-f]+-0x[0-9a-f]+:.*' | grep -E -o "0x[0-9a-f]+" | tail -n 1)
if [ "${current}" != "" ]; then
percent=$((100 * (current + 1) / total_bytes))
progressbar=$(for ((i=0; i < $((percent / 2)); i++)) do echo -ne '#' ; done)
progressbar2=$(for ((i=0; i < $((49 - percent / 2)); i++)) do echo -ne ' ' ; done)
fi
else
if [ "$prev_prev_word" == "Reading" ] && [ "$IN" == "bytes" ]; then
total_bytes=$prev_word
echo "Total flash size : $total_bytes bytes"
fi
fi
if [ "$percent" -eq 100 ]; then
spin_idx=4
......@@ -376,12 +387,14 @@ if [ "$machine" = "1" ]; then
COREBOOT_BIOS_SHA="$L13V1_COREBOOT_BIOS_SHA"
COREBOOT_TAG="$L13V1_COREBOOT_VERSION"
SKL=0
BDL_VGA_PCI_ID="8086,1616"
elif [ "$machine" = "2" ]; then
BLOB_DIR="3rdparty/blobs/mainboard/purism/librem15v2"
COREBOOT_FILENAME="coreboot-l15v2.rom"
COREBOOT_BIOS_SHA="$L15V2_COREBOOT_BIOS_SHA"
COREBOOT_TAG="$L15V2_COREBOOT_VERSION"
SKL=0
BDL_VGA_PCI_ID="8086,162b"
elif [ "$machine" = "3" ]; then
BLOB_DIR="3rdparty/blobs/mainboard/purism/librem_skl"
COREBOOT_FILENAME="coreboot-l13v2.rom"
......@@ -506,7 +519,7 @@ if [ "$blobs" == "1" ] || [ "$blobs" == "2" ]; then
check_and_get_url cpu_microcode_blob.bin $BDL_UCODE_URL $BDL_UCODE_SHA "Intel Microcode Update"
extract_binary mrc.bin mrc.bin $BDL_MRC_SHA
extract_binary "fallback/refcode" refcode.elf $BDL_REFCODE_SHA
extract_binary pci8086,1616.rom vgabios.bin $BDL_VBIOS_SHA
extract_binary pci${BDL_VGA_PCI_ID}.rom vgabios.bin $BDL_VBIOS_SHA
else
check_and_copy_descriptor_skl
check_binary descriptor.bin $SKL_DESCRIPTOR_SHA
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment