cmd: gpt: backup boot code before writing MBR
PATCH 1/1 cmd: gpt: backup boot code before writing MBR
From: Vincent Tinelli <[email protected]>
On some cases the first 440 bytes of MBR are used to keep an additional information for ROM boot loader. 'gpt write' command doesn't preserve that area and makes boot code gone.
Preserve boot code area when run 'gpt write' command.
--- disk/part_efi.c | 7 +++++++ 1 file changed, 7 insertions(+)
disk/part_efi.c +7 -0
@@ -324,6 +324,13 @@ static int set_protective_mbr(struct blk_desc *dev_desc)printf ("%s: calloc failed!\n" , __func__);return -1 ; } + +/* Read MBR to backup boot code if it exists */ +if (blk_dread (dev_desc,0 ,1 , p_mbr) !=1 ) { +error ("** Can't read from device %d **\n" , dev_desc->devnum); +return -1 ; + } +/* Append signature */ p_mbr->signature =MSDOS_MBR_SIGNATURE ; p_mbr->partition_record[0 ].sys_ind =EFI_PMBR_OSTYPE_EFI_GPT ;
Signature · 1 line
2.11.0
PATCH 1/1 cmd: gpt: backup boot code before writing MBR
Quoted 6 lines · Andy Shevchenko
From: Vincent Tinelli <[email protected]>
On some cases the first 440 bytes of MBR are used to keep an additional information for ROM boot loader. 'gpt write' command doesn't preserve that area and makes boot code gone.
Quoted 8 lines
Preserve boot code area when run 'gpt write' command.
Signed-off-by Vincent Tinelli <[email protected]>Signed-off-by Brennan Ashton <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- disk/part_efi.c | 7 +++++++ 1 file changed, 7 insertions(+)
PATCH 1/1 cmd: gpt: backup boot code before writing MBR
In reply to Andy ShevchenkoQuoted 6 lines · Andy Shevchenko
From: Vincent Tinelli <[email protected]>
On some cases the first 440 bytes of MBR are used to keep an additional information for ROM boot loader. 'gpt write' command doesn't preserve that area and makes boot code gone.
Quoted 6 lines
Preserve boot code area when run 'gpt write' command.
Signed-off-by Vincent Tinelli <[email protected]>Signed-off-by Brennan Ashton <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170208/f2e23527/attachment.sig>