cmd: bcb: select user(0) hwpart in __bcb_load()
authorMattijs Korpershoek <mkorpershoek@baylibre.com>
Thu, 13 Oct 2022 12:25:59 +0000 (14:25 +0200)
committerTom Rini <trini@konsulko.com>
Sat, 22 Oct 2022 01:37:47 +0000 (21:37 -0400)
commit64a11fb8c9a1a5ae385043e5f5e197fa213cc702
tree03b88e6c9aaf9fd55838eaeb29b4ba84a59737a0
parent65e8b64d237a8a6e9062568412fae03c1673885c
cmd: bcb: select user(0) hwpart in __bcb_load()

For some blk operations, it's possible that a different hw partition
gets selected via blk_dselect_hwpart().
In that case, only the region of the device covered by that partition
is accessible.

This breaks "bcb load" which attempts to read the gpt and assumes it's
on the user(0) hw partition:

=> bcb load 2 misc
GUID Partition Table Header signature is wrong: 0xDE7B17AD07D9E5D6 != 0x5452415020494645
find_valid_gpt: *** ERROR: Invalid GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
find_valid_gpt: *** ERROR: Invalid Backup GPT ***
Error: mmc 2:misc read failed (-2)

Add a fail-safe in __bcb_load() to ensure we will always read from the
user(0) hwpartition.

This fixes the following fastboot sequence:

$ fastboot erase mmc2boot1    # switch to hwpart1
$ fastboot reboot bootloader  # switch to hwpart0, then reads GPT

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: Sean Anderson <sean.anderson@seco.com>
cmd/bcb.c