Skip to content

Commit 92e29c4

Browse files
committed
Merge branch 'upstream_flashrom_13' into staging_all
2 parents 30cc112 + 979c9dd commit 92e29c4

File tree

2 files changed

+60
-48
lines changed

2 files changed

+60
-48
lines changed

initrd/bin/flash.sh

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ set -e -o pipefail
88
. /etc/ash_functions
99
. /tmp/config
1010

11+
echo
12+
1113
TRACE "Under /bin/flash.sh"
1214

1315
case "$CONFIG_FLASHROM_OPTIONS" in
@@ -20,54 +22,43 @@ case "$CONFIG_FLASHROM_OPTIONS" in
2022
esac
2123

2224
flashrom_progress() {
25+
# The ichspi programmer now spews register status lines constantly that are brutally slow
26+
# to feed through the parser in flashrom_progress_tokenize. Exclude them.
27+
# flashrom_progress_tokenize operates on individual tokens (not lines), so it splits by
28+
# spaces in 'read'. But we also need to separate the last word on a line from the next
29+
# line, so replace newlines.
30+
grep -v -e '^HSFS:' -e '^HSFC:' | tr '\n' ' ' | flashrom_progress_tokenize "$1"
31+
}
32+
33+
print_flashing_progress() {
34+
local spaces=' '
35+
local hashes='##################################################'
36+
local percent pct1 pct2 progressbar progressbar2
37+
percent="$1"
38+
pct1=$((percent / 2))
39+
pct2=$((50 - percent / 2))
40+
progressbar=${hashes:0:$pct1}
41+
progressbar2=${spaces:0:$pct2}
42+
echo -ne "Flashing: [${progressbar}${spin:$spin_idx:1}${progressbar2}] (${percent}%)\\r"
43+
}
44+
45+
flashrom_progress_tokenize() {
2346
local current=0
24-
local total_bytes=0
47+
local total_bytes="$1"
2548
local percent=0
2649
local IN=''
2750
local spin='-\|/'
2851
local spin_idx=0
29-
local progressbar=''
30-
local progressbar2=''
3152
local status='init'
3253
local prev_word=''
3354
local prev_prev_word=''
34-
local spaces=' '
35-
local hashes='##################################################'
3655

37-
progressbar2=$(for i in `seq 48` ; do echo -ne ' ' ; done)
38-
echo -e "\nInitializing Flash Programmer"
56+
echo "Initializing Flash Programmer"
3957
while true ; do
4058
prev_prev_word=$prev_word
4159
prev_word=$IN
42-
read -r -d' ' IN
43-
if [ "$total_bytes" != "0" ]; then
44-
current=$(echo "$IN" | sed -nE 's/.*(0x[0-9a-f]+).*/\1/p')
45-
if [ "${current}" != "" ]; then
46-
percent=$((100 * (current + 1) / total_bytes))
47-
pct1=$((percent / 2))
48-
pct2=$((50 - percent / 2))
49-
progressbar=${hashes:0:$pct1}
50-
progressbar2=${spaces:0:$pct2}
51-
fi
52-
else
53-
if [ "$prev_prev_word" == "Reading" ] && [ "$IN" == "bytes" ]; then
54-
# flashrom may read the descriptor first, so ensure total_bytes is at least 4MB
55-
if [[ $prev_word -gt 4194303 ]]; then
56-
total_bytes=$prev_word
57-
echo "Total flash size : $total_bytes bytes"
58-
fi
59-
fi
60-
if [ "$prev_word" == "total_size:" ]; then
61-
# Next is total size in bytes
62-
total_bytes=$(echo "$IN" | grep -E -o '[0-9]+')
63-
echo "Total flash size : $total_bytes bytes"
64-
fi
65-
fi
66-
if [ "$percent" -gt 99 ]; then
67-
spin_idx=4
68-
else
69-
spin_idx=$(( (spin_idx+1) %4 ))
70-
fi
60+
read -r -d" " -t 0.2 IN
61+
spin_idx=$(( (spin_idx+1) %4 ))
7162
if [ "$status" == "init" ]; then
7263
if [ "$IN" == "contents..." ]; then
7364
status="reading"
@@ -77,17 +68,32 @@ flashrom_progress() {
7768
if [ "$status" == "reading" ]; then
7869
if echo "${IN}" | grep "done." > /dev/null ; then
7970
status="writing"
71+
IN=
8072
fi
8173
fi
8274
if [ "$status" == "writing" ]; then
83-
echo -ne "Flashing: [${progressbar}${spin:$spin_idx:1}${progressbar2}] (${percent}%)\\r"
84-
if echo "$IN" | grep "Verifying" > /dev/null ; then
75+
# walk_eraseblocks() prints info for each block, of the form
76+
# , 0xAAAAAA-0xBBBBBB:X
77+
# The 'X' is a char indicating the action, but the debug from actually erasing
78+
# and writing is mixed into the output so it may be separated. It can also be
79+
# interrupted occasionally, so only match a complete token.
80+
current=$(echo "$IN" | sed -nE 's/^0x[0-9a-f]+-(0x[0-9a-f]+):.*$/\1/p')
81+
if [ "$current" != "" ]; then
82+
percent=$((100 * (current + 1) / total_bytes))
83+
fi
84+
print_flashing_progress "$percent"
85+
if [ "$IN" == "done." ]; then
8586
status="verifying"
87+
IN=
88+
print_flashing_progress 100
8689
echo ""
8790
echo "Verifying flash contents. Please wait..."
8891
fi
89-
if echo "$IN" | grep "identical" > /dev/null ; then
92+
# This appears before "Erase/write done."; skip the verifying state
93+
if [ "$IN" == "identical" ]; then
9094
status="done"
95+
IN=
96+
print_flashing_progress 100
9197
echo ""
9298
echo "The flash contents are identical to the image being flashed."
9399
break
@@ -142,7 +148,8 @@ flash_rom() {
142148
fi
143149

144150
flashrom $CONFIG_FLASHROM_OPTIONS -w /tmp/${CONFIG_BOARD}.rom \
145-
-V -o "/tmp/flashrom-$(date '+%Y%m%d-%H%M%S').log" 2>&1 | flashrom_progress \
151+
-V -o "/tmp/flashrom-$(date '+%Y%m%d-%H%M%S').log" 2>&1 | \
152+
flashrom_progress "$(stat -c %s "/tmp/${CONFIG_BOARD}.rom")" \
146153
|| die "$ROM: Flash failed"
147154
fi
148155
}

modules/flashrom

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,38 @@ modules-$(CONFIG_FLASHROM) += flashrom
22

33
flashrom_depends := pciutils $(musl_dep)
44

5-
flashrom_version := b1f858f65b2abd276542650d8cb9e382da258967
5+
flashrom_version := 1776bb46ba6ea3d1ab2ec3f0cd88158aabed7400
66
flashrom_dir := flashrom-$(flashrom_version)
77
flashrom_tar := $(flashrom_dir).tar.gz
88
flashrom_url := https://github.com/flashrom/flashrom/archive/$(flashrom_version).tar.gz
9-
flashrom_hash := 4873ad50f500629c244fc3fbee64b56403a82307d7f555dfa235336a200c336c
9+
flashrom_hash := 65e262ca4428a0ceddd73f481ed0d8444393b73a78469f266a4457dfc834ecb7
1010

1111
# Default options for flashrom
1212
flashrom_cfg := \
1313
WARNERROR=no \
1414
CONFIG_NOTHING=yes \
1515
CONFIG_INTERNAL=yes \
16-
CONFIG_DUMMY=yes \
17-
CONFIG_AST1100=yes \
16+
CONFIG_INTERNAL_X86=yes \
1817

1918
ifeq "$(CONFIG_TARGET_ARCH)" "ppc64"
2019
flashrom_cfg := \
2120
WARNERROR=no \
2221
CONFIG_NOTHING=yes \
23-
CONFIG_LINUX_MTD=yes \
24-
CONFIG_DUMMY=yes \
25-
CONFIG_AST1100=yes
22+
CONFIG_LINUX_MTD=yes
2623
endif
2724

25+
#Only enable AST1100 if requested per board configs
26+
ifeq "$(CONFIG_FLASHROM_AST1100)" "y"
27+
flashrom_cfg += CONFIG_AST1100=yes
28+
endif
29+
30+
31+
2832
flashrom_target := \
2933
$(MAKE_JOBS) \
3034
$(CROSS_TOOLS) \
31-
$(flashrom_cfg)
35+
$(flashrom_cfg) \
36+
flashrom
3237

3338
flashrom_output := \
3439
flashrom

0 commit comments

Comments
 (0)