Skip to content
  • Sam Protsenko's avatar
    disk: efi: Correct backing up the MBR boot code · 955575c8
    Sam Protsenko authored and Tom Rini's avatar Tom Rini committed
    In commit e163a931
    
     ("cmd: gpt: backup boot code before writing MBR")
    there was added the procedure for storing old boot code when doing "gpt
    write". But instead of storing just backup code, the whole MBR was
    stored, and only specific fields were replaced further, keeping
    everything else intact. That's obviously not what we want.
    
    Fix the code to actually store only old boot code and zero out
    everything else. This fixes next testing case:
    
        => mmc write $loadaddr 0x0 0x7b
        => gpt write mmc 1 $partitions
    
    In case when $loadaddr address and further memory contains 0xff, the
    board was bricked (ROM-code probably didn't like partition entries that
    were clobbered with 0xff). With this patch applied, commands above don't
    brick the board.
    
    Signed-off-by: default avatarSam Protsenko <semen.protsenko@linaro.org>
    Cc: Alejandro Hernandez <ajhernandez@ti.com>
    Tested-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
    955575c8