Skip to content
Snippets Groups Projects
  • Mattijs Korpershoek's avatar
    14657373
    HACK: fastboot: mmc: switch back to userdata hwpart after · 14657373
    Mattijs Korpershoek authored
    
    To erase/flash hwpartitions, we first change hwpart from
    EMMC_USER (0) to EMMC_BOOT{1,2} by calling raw_part_get_info_by_name().
    
    However, we don't switch back to EMMC_USER at the end of an erase.
    Therefore, all other fastboot commands are ran on the EMMC_BOOT{1,2}
    hwpart instead of the EMMC_USER hwpart.
    
    For example, the following sequence is broken:
    
    $ fastboot erase bootenv # switch to hwpart 2
    $ fastboot reboot bootloader  # attempts to read GPT from hwpart 2
    
    The GPT being stored in EMMC_USER, the above command generates
    this error:
    
    >  writing 128 blocks starting at 8064...
    >  ........ wrote 65536 bytes to 'bootenv'
    >  GUID Partition Table Header signature is wrong: 0xFB4EC30FC5B7E5B2 != 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)
    
    Fix it by switching back to EMMC_USER at the end of mmc_boot_ops().
    
    Note: this is more visible since commit a362ce21 ("fastboot: Implement generic fastboot_set_reboot_flag")
    because "fastboot reboot bootloader" will access the "misc" partition.
    
    Signed-off-by: default avatarMattijs Korpershoek <mkorpershoek@baylibre.com>
    14657373
    History
    HACK: fastboot: mmc: switch back to userdata hwpart after
    Mattijs Korpershoek authored
    
    To erase/flash hwpartitions, we first change hwpart from
    EMMC_USER (0) to EMMC_BOOT{1,2} by calling raw_part_get_info_by_name().
    
    However, we don't switch back to EMMC_USER at the end of an erase.
    Therefore, all other fastboot commands are ran on the EMMC_BOOT{1,2}
    hwpart instead of the EMMC_USER hwpart.
    
    For example, the following sequence is broken:
    
    $ fastboot erase bootenv # switch to hwpart 2
    $ fastboot reboot bootloader  # attempts to read GPT from hwpart 2
    
    The GPT being stored in EMMC_USER, the above command generates
    this error:
    
    >  writing 128 blocks starting at 8064...
    >  ........ wrote 65536 bytes to 'bootenv'
    >  GUID Partition Table Header signature is wrong: 0xFB4EC30FC5B7E5B2 != 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)
    
    Fix it by switching back to EMMC_USER at the end of mmc_boot_ops().
    
    Note: this is more visible since commit a362ce21 ("fastboot: Implement generic fastboot_set_reboot_flag")
    because "fastboot reboot bootloader" will access the "misc" partition.
    
    Signed-off-by: default avatarMattijs Korpershoek <mkorpershoek@baylibre.com>