Update generate-squashfs to use new pflash option
In a separate commit, a new option was added to pflash to print
the miscellaneous flags for a particular partition. This commit
updates the generate-squashfs tool to use that option instead of
reading a byte out of the PNOR file.
Resolves openbmc/openbmc#1351
Change-Id: Ie21c51ed1db0a604db2bc43779450a7c4ca75da0
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/generate-squashfs b/generate-squashfs
index 41f369d..4a9ae67 100755
--- a/generate-squashfs
+++ b/generate-squashfs
@@ -21,7 +21,6 @@
# https://github.com/open-power/hostboot/blob/master/src/usr/pnor/ffs.h
let ffs_entry_size=128
let vercheck_offset=112
-let miscflags_offset=113
outfile=""
declare -a partitions=()
tocfile="pnor.toc"
@@ -66,8 +65,6 @@
echo "Parsing PNOR TOC..."
-# Needed to get the READONLY and PRESERVED flags
-# TODO: Get READONLY and PRESERVED flags from pflash instead.
pflash --partition=part --read=${scratch_dir}/part -F ${pnorfile}
pflash --partition=VERSION --read=${scratch_dir}/VERSION -F ${pnorfile}
{
@@ -81,24 +78,18 @@
# "ID=05 MVPD 000d9000..00169000 (actual=00090000) [ECC]"
read -r -a fields <<< "$line"
- # Get any flags attached to end (e.g. [ECC])
- flags=""
- for flag in "${fields[@]:4}"
- do
- flags+=",${flag//[\[\]]/}"
- done
-
id=${fields[0]##*=}
offset=$((${ffs_entry_size} * 10#${id} + ${vercheck_offset}))
vercheck=$(xxd -p -l 0x1 -seek ${offset} ${scratch_dir}/part)
- offset=$((${ffs_entry_size} * 10#${id} + ${miscflags_offset}))
- miscflags=0x$(xxd -p -l 0x1 -seek ${offset} ${scratch_dir}/part)
- if ((miscflags & 0x80)); then
- flags+=",PRESERVED"
- elif ((miscflags & 0x40)); then
- flags+=",READONLY"
- else
- flags+=",READWRITE"
+ export flags=$(pflash --detail=$((10#$id)) -F ${pnorfile} | grep "\[" |
+ sed 's/....$//' | tr '\n' ',' | sed 's/.$//')
+ if [[ $flags != "" ]]; then
+ flags=,$flags
+ fi
+
+ if [[ $(echo $flags | grep "READONLY") == "" &&
+ $(echo $flags | grep "PRESERVED") == "" ]]; then
+ flags=$flags,READWRITE
fi
# Need the partition ID, name, start location, end location, and flags