summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWadim Egorov <w.egorov@phytec.de>2020-04-21 12:28:16 +0200
committerStefan Müller-Klieser <s.mueller-klieser@phytec.de>2020-04-28 09:35:17 +0200
commit12687b112df26057ffe3399232b33e6647f79eaa (patch)
tree239ebffdf5bfcd9a6cdf64dc2810a957430fbc35
parentc65fb1ac695f95c8324e2a645412e0dd429204d4 (diff)
downloadmeta-phytec-12687b112df26057ffe3399232b33e6647f79eaa.tar.bz2
meta-phytec-12687b112df26057ffe3399232b33e6647f79eaa.zip
bbu_emmc: Read proper Bits to determine selected boot partition
The PARTITION_CONFIG register consists of multiple bit fields with different information. Use BOOT_PARTITION_ENABLE[5:3] to determine the selected boot partition. Otherwise we could end with a "broken" script if PARTITION_ACCESS or BOOT_ACK fields are set. Also simplify the "mmc extcsd read" parsing for PARTITION_CONFIG. Signed-off-by: Wadim Egorov <w.egorov@phytec.de> Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
-rw-r--r--recipes-devtools/bbu/bbu/imx/bbu_emmc.sh16
1 files changed, 10 insertions, 6 deletions
diff --git a/recipes-devtools/bbu/bbu/imx/bbu_emmc.sh b/recipes-devtools/bbu/bbu/imx/bbu_emmc.sh
index 6abd46b..447695f 100644
--- a/recipes-devtools/bbu/bbu/imx/bbu_emmc.sh
+++ b/recipes-devtools/bbu/bbu/imx/bbu_emmc.sh
@@ -24,6 +24,8 @@ fi
# - 0x1 : Boot partition 0 enabled for boot
# - 0x2 : Boot partition 1 enabled for boot
# - 0x7 : User area enabled for boot
+BOOTPART0_ENABLED=$((1<<3))
+BOOTPART1_ENABLED=$((2<<3))
emmcdev=`cat /proc/cmdline | awk -F'root=' '{print $2}'`
emmcdev=${emmcdev::12}
@@ -36,12 +38,12 @@ if [ ! -e ${emmcdev}boot0 ]; then
exit 1
fi
-partcfg=`mmc extcsd read $emmcdev | grep PARTITION_CONFIG | cut -d':' -f2`
-partcfg=${partcfg:1:4}
+partcfg=`mmc extcsd read $emmcdev | grep -oE "PARTITION_CONFIG: 0x.." | grep -oE "0x.."`
bsize=`ls -l $1 | awk '{print $5}'`
-case "${partcfg}" in
- "0x00") echo "Selected boot source: User area (default)"
+case 1 in
+ $((partcfg == 0)))
+ echo "Selected boot source: User area (default)"
echo "Flashing ${emmcdev}"
dd if=$1 of=${emmcdev} bs=512 skip=2 seek=2
sync
@@ -53,7 +55,8 @@ case "${partcfg}" in
fi
echo "Successfully flashed user area"
;;
- "0x08") echo "Selected boot source: boot0"
+ $(( ($partcfg & $BOOTPART0_ENABLED) != 0 )) )
+ echo "Selected boot source: boot0"
echo "Flashing ${emmcdev}boot1"
echo 0 > ${emmcdev/dev/sys/block}boot1/force_ro
dd if=$1 of=${emmcdev}boot1
@@ -69,7 +72,8 @@ case "${partcfg}" in
mmc bootpart enable 2 0 ${emmcdev}
echo "Successfully flashed boot1"
;;
- "0x10") echo "Selected boot source: boot1"
+ $(( ($partcfg & $BOOTPART1_ENABLED) != 0 )) )
+ echo "Selected boot source: boot1"
echo "Flashing ${emmcdev}boot0"
echo 0 > ${emmcdev/dev/sys/block}boot0/force_ro
dd if=$1 of=${emmcdev}boot0