@@ -21,106 +21,6 @@ case "$CONFIG_FLASHROM_OPTIONS" in
2121 ;;
2222esac
2323
24- flashrom_progress () {
25- # The ichspi programmer now spews register status lines constantly that are
26- # brutally slow to feed through the parser in flashrom_progress_tokenize.
27- # Filter the input with grep for only lines containing at least one token
28- # that we care about.
29- grep -E -e ' contents\.\.\.' -e ' done\.' -e ' 0x[0-9a-f]+-(0x[0-9a-f]+):' \
30- -e ' identical' -e ' VERIFIED\.' -e ' FAILED' | \
31- tr ' ' ' \n' | flashrom_progress_tokenize " $1 "
32- }
33-
34- print_flashing_progress () {
35- local spaces=' '
36- local hashes=' ##################################################'
37- local percent pct1 pct2 progressbar progressbar2
38- percent=" $1 "
39- pct1=$(( percent / 2 ))
40- pct2=$(( 50 - percent / 2 ))
41- progressbar=${hashes: 0: $pct1 }
42- progressbar2=${spaces: 0: $pct2 }
43- echo -ne " Flashing: [${progressbar}${spin: $spin_idx : 1}${progressbar2} ] (${percent} %)\\ r"
44- }
45-
46- flashrom_progress_tokenize () {
47- local current=0
48- local total_bytes=" $1 "
49- local percent=0
50- local IN=' '
51- local spin=' -\|/'
52- local spin_idx=0
53- local status=' init'
54- local prev_word=' '
55- local prev_prev_word=' '
56-
57- echo " Initializing Flash Programmer"
58- while true ; do
59- prev_prev_word=$prev_word
60- prev_word=$IN
61- IFS= read -r -t 0.2 IN
62- spin_idx=$(( (spin_idx+ 1 ) % 4 ))
63- if [ " $status " == " init" ]; then
64- if [ " $IN " == " contents..." ]; then
65- status=" reading"
66- echo " Reading old flash contents. Please wait..."
67- fi
68- fi
69- if [ " $status " == " reading" ]; then
70- if echo " ${IN} " | grep " done." > /dev/null ; then
71- status=" writing"
72- IN=
73- fi
74- fi
75- if [ " $status " == " writing" ]; then
76- # walk_eraseblocks() prints info for each block, of the form
77- # , 0xAAAAAA-0xBBBBBB:X
78- # The 'X' is a char indicating the action, but the debug from actually erasing
79- # and writing is mixed into the output so it may be separated. It can also be
80- # interrupted occasionally, so only match a complete token.
81- current=$( echo " $IN " | sed -nE ' s/^0x[0-9a-f]+-(0x[0-9a-f]+):.*$/\1/p' )
82- if [ " $current " != " " ]; then
83- percent=$(( 100 * (current + 1 ) / total_bytes))
84- fi
85- print_flashing_progress " $percent "
86- if [ " $IN " == " done." ]; then
87- status=" verifying"
88- IN=
89- print_flashing_progress 100
90- echo " "
91- echo " Verifying flash contents. Please wait..."
92- fi
93- # This appears before "Erase/write done."; skip the verifying state
94- if [ " $IN " == " identical" ]; then
95- status=" done"
96- IN=
97- print_flashing_progress 100
98- echo " "
99- echo " The flash contents are identical to the image being flashed."
100- break
101- fi
102- fi
103- if [ " $status " == " verifying" ]; then
104- if echo " ${IN} " | grep " VERIFIED." > /dev/null ; then
105- status=" done"
106- echo " The flash contents were verified and the image was flashed correctly."
107- break
108- elif echo " ${IN} " | grep " FAILED" > /dev/null ; then
109- echo ' Error while verifying flash content'
110- break
111- fi
112- fi
113- done
114- echo " "
115- if [ " $status " == " done" ]; then
116- return 0
117- else
118- echo ' Error flashing coreboot -- see timestampped flashrom log in /tmp for more info'
119- echo " "
120- return 1
121- fi
122- }
123-
12424flash_rom () {
12525 ROM=$1
12626 if [ " $READ " -eq 1 ]; then
@@ -148,9 +48,7 @@ flash_rom() {
14848 dd if=/tmp/pchstrp9.bin bs=1 count=4 seek=292 of=/tmp/${CONFIG_BOARD} .rom conv=notrunc > /dev/null 2>&1
14949 fi
15050
151- flashrom $CONFIG_FLASHROM_OPTIONS -w /tmp/${CONFIG_BOARD} .rom \
152- -V -o " /tmp/flashrom-$( date ' +%Y%m%d-%H%M%S' ) .log" 2>&1 | \
153- flashrom_progress " $( stat -c %s " /tmp/${CONFIG_BOARD} .rom" ) " \
51+ flashrom $CONFIG_FLASHROM_OPTIONS -w /tmp/${CONFIG_BOARD} .rom 2>&1 \
15452 || die " $ROM : Flash failed"
15553 fi
15654}
0 commit comments