Fastboot MBR and generic partition support
v2 cover Fastboot MBR and generic partition support
This set extends the Fastboot implementation from GPT-only to any partition support. Further it adds a special target "mbr" (configurable) to write the DOS MBR.
Version 2:
Add a fourth patch into the set to move CONFIG_FASTBOOT_GPT_NAME and CONFIG_FASTBOOT_MBR_NAME into cmd/fastboot/Kconfig
Petr Kulhavy (4):
disk: part: implement generic function part_get_info_by_name()
fastboot: add support for writing MBR
disk: part: refactor generic name creation for DOS and ISO
fastboot: move FASTBOOT_FLASH options into Kconfig
README | 9 +++++- cmd/fastboot/Kconfig | 24 ++++++++++++++++ common/fb_mmc.c | 41 +++++++++++++++++++-------- disk/part.c | 58 +++++++++++++++++++++++++++++++++++++ disk/part_amiga.c | 1 + disk/part_dos.c | 52 +++++++++++++++------------------- disk/part_efi.c | 20 +------------ disk/part_iso.c | 26 ++--------------- disk/part_mac.c | 1 + doc/README.android-fastboot | 38 +++++++++++++++++++++++++ include/part.h | 69 +++++++++++++++++++++++++++++++++++++-------- include/part_efi.h | 1 - 12 files changed, 243 insertions(+), 97 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/4 disk: part: implement generic function part_get_info_by_name()
So far partition search by name has been supported only on the EFI partition table. This patch extends the search to all partition tables.
Rename part_get_info_efi_by_name() to part_get_info_by_name(), move it from part_efi.c into part.c and make it a generic function which traverses all part drivers and searches all partitions (in the order given by the linked list).
For this a new variable struct part_driver.max_entries is added, which limits the number of partitions searched. For EFI this was GPT_ENTRY_NUMBERS. Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables.
---
v1: initial
v2: no change
common/fb_mmc.c | 4 ++-- disk/part.c | 26 ++++++++++++++++++++++++++ disk/part_amiga.c | 1 + disk/part_dos.c | 1 + disk/part_efi.c | 20 +------------------- disk/part_iso.c | 1 + disk/part_mac.c | 1 + include/part.h | 32 ++++++++++++++++++++------------ 8 files changed, 53 insertions(+), 33 deletions(-)
common/fb_mmc.c +2 -2
@@ -27,7 +27,7 @@ static int part_get_info_efi_by_name_or_alias(struct blk_desc *dev_desc, {int ret; - ret =part_get_info_efi_by_name (dev_desc, name, info); + ret =part_get_info_by_name (dev_desc, name, info);if (ret) {/* strlen("fastboot_partition_alias_") + 32(part_name) + 1 */ char env_alias_name[25 +32 +1 ];
@@ -38,7 +38,7 @@ static int part_get_info_efi_by_name_or_alias(struct blk_desc *dev_desc,strncat (env_alias_name, name,32 ); aliased_part_name =getenv (env_alias_name);if (aliased_part_name !=NULL ) - ret =part_get_info_efi_by_name (dev_desc, + ret =part_get_info_by_name (dev_desc, aliased_part_name, info); }return ret;
disk/part.c +26 -0
@@ -615,3 +615,29 @@ cleanup:free (dup_str);return ret; } + +int part_get_info_by_name (struct blk_desc *dev_desc,const char *name, +disk_partition_t *info) +{ +struct part_driver *first_drv = + ll_entry_start(struct part_driver, part_driver); + const int n_drvs = ll_entry_count(struct part_driver, part_driver); +struct part_driver *part_drv; + +for (part_drv = first_drv; part_drv != first_drv + n_drvs; part_drv++) { +int ret; +int i; +for (i =1 ; i < part_drv->max_entries; i++) { + ret = part_drv->get_info (dev_desc, i, info); +if (ret !=0 ) { +/* no more entries in table */ +break ; + } +if (strcmp (name, (const char *)info->name) ==0 ) { +/* matched */ +return 0 ; + } + } + } +return -1 ; +}
disk/part_amiga.c +1 -0
@@ -381,6 +381,7 @@ static void part_print_amiga(struct blk_desc *dev_desc)U_BOOT_PART_TYPE (amiga) = { .name ="AMIGA" , .part_type =PART_TYPE_AMIGA , + .max_entries =AMIGA_ENTRY_NUMBERS , .get_info = part_get_info_amiga, .print = part_print_amiga, .test = part_test_amiga,
disk/part_dos.c +1 -0
@@ -300,6 +300,7 @@ int part_get_info_dos(struct blk_desc *dev_desc, int part,U_BOOT_PART_TYPE (dos) = { .name ="DOS" , .part_type =PART_TYPE_DOS , + .max_entries =DOS_ENTRY_NUMBERS , .get_info =part_get_info_ptr (part_get_info_dos), .print =part_print_ptr (part_print_dos), .test = part_test_dos,
disk/part_efi.c +1 -19
@@ -296,25 +296,6 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,return 0 ; } -int part_get_info_efi_by_name (struct blk_desc *dev_desc, -const char *name,disk_partition_t *info) -{ -int ret; -int i; -for (i =1 ; i <GPT_ENTRY_NUMBERS ; i++) { - ret =part_get_info_efi (dev_desc, i, info); -if (ret !=0 ) { -/* no more entries in table */ -return -1 ; - } -if (strcmp (name, (const char *)info->name) ==0 ) { -/* matched */ -return 0 ; - } - } -return -2 ; -} -static int part_test_efi (struct blk_desc *dev_desc) {ALLOC_CACHE_ALIGN_BUFFER_PAD (legacy_mbr, legacymbr,1 , dev_desc->blksz);
@@ -958,6 +939,7 @@ static int is_pte_valid(gpt_entry * pte)U_BOOT_PART_TYPE (a_efi) = { .name ="EFI" , .part_type =PART_TYPE_EFI , + .max_entries =GPT_ENTRY_NUMBERS , .get_info =part_get_info_ptr (part_get_info_efi), .print =part_print_ptr (part_print_efi), .test = part_test_efi,
disk/part_iso.c +1 -0
@@ -257,6 +257,7 @@ static int part_test_iso(struct blk_desc *dev_desc)U_BOOT_PART_TYPE (iso) = { .name ="ISO" , .part_type =PART_TYPE_ISO , + .max_entries =ISO_ENTRY_NUMBERS , .get_info = part_get_info_iso, .print = part_print_iso, .test = part_test_iso,
disk/part_mac.c +1 -0
@@ -239,6 +239,7 @@ static int part_get_info_mac(struct blk_desc *dev_desc, int part,U_BOOT_PART_TYPE (mac) = { .name ="MAC" , .part_type =PART_TYPE_MAC , + .max_entries =MAC_ENTRY_NUMBERS , .get_info = part_get_info_mac, .print = part_print_mac, .test = part_test_mac,
include/part.h +20 -12
@@ -28,6 +28,11 @@ struct block_drvr {#define PART_TYPE_AMIGA 0x04#define PART_TYPE_EFI 0x05 +/* maximum number of partition entries supported by search */ +#define DOS_ENTRY_NUMBERS 8 +#define ISO_ENTRY_NUMBERS 64 +#define MAC_ENTRY_NUMBERS 64 +#define AMIGA_ENTRY_NUMBERS 8/* * Type string for U-Boot bootable partitions */
@@ -146,6 +151,20 @@ int blk_get_device_by_str(const char *ifname, const char *dev_str,int blk_get_device_part_str (const char *ifname,const char *dev_part_str,struct blk_desc **dev_desc,disk_partition_t *info,int allow_whole_dev); + +/** +* part_get_info_by_name() - Search for a partition by name +* among all available registered partitions +* +* @param dev_desc - block device descriptor +* @param gpt_name - the specified table entry name +* @param info - returns the disk partition info +* +* @return - '0' on match, '-1' on no match, otherwise error +*/ +int part_get_info_by_name (struct blk_desc *dev_desc, +const char *name,disk_partition_t *info); +extern const struct block_drvr block_drvr[];#else static inline struct blk_desc *blk_get_dev (const char *ifname,int dev)
@@ -189,6 +208,7 @@ static inline int blk_get_device_part_str(const char *ifname,struct part_driver {const char *name;int part_type; +const int max_entries;/* maximum number of entries to search */ /** * get_info() - Get information about a partition
@@ -225,18 +245,6 @@ struct part_driver {#include <part_efi.h> /* disk/part_efi.c */ /** -* part_get_info_efi_by_name() - Find the specified GPT partition table entry -* -* @param dev_desc - block device descriptor -* @param gpt_name - the specified table entry name -* @param info - returns the disk partition info -* -* @return - '0' on match, '-1' on no match, otherwise error -*/ -int part_get_info_efi_by_name (struct blk_desc *dev_desc, -const char *name,disk_partition_t *info); - -/** * write_gpt_table() - Write the GUID Partition Table to disk * * @param dev_desc - block device descriptor
Signature · 1 line
2.7.4
PATCH v2 1/4 disk: part: implement generic function part_get_info_by_name()
Hi Petr,
Quoted 73 lines · Petr Kulhavy
So far partition search by name has been supported only on the EFI partition table. This patch extends the search to all partition tables.
Rename
part_get_info_efi_by_name()topart_get_info_by_name(), move it frompart_efi.cintopart.cand make it a generic function which traverses all part drivers and searches all partitions (in the order given by the linked list).For this a new variable struct part_driver.max_entries is added, which limits the number of partitions searched. For EFI this was
GPT_ENTRY_NUMBERS. Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables.Signed-off-by Petr Kulhavy <[email protected]>Reviewed-by Tom Rini <[email protected]>---
v1: initial
v2: no changecommon/fb_mmc.c | 4 ++-- disk/part.c | 26 ++++++++++++++++++++++++++ disk/part_amiga.c | 1 + disk/part_dos.c | 1 + disk/part_efi.c | 20 +------------------- disk/part_iso.c | 1 + disk/part_mac.c | 1 + include/part.h | 32 ++++++++++++++++++++------------ 8 files changed, 53 insertions(+), 33 deletions(-)common/fb_mmc.c +2
-2@@ -27,7 +27,7 @@ static int part_get_info_efi_by_name_or_alias(struct blk_desc *dev_desc, {int ret; - ret =part_get_info_efi_by_name (dev_desc, name, info); + ret =part_get_info_by_name (dev_desc, name, info);if (ret) {/* strlen("fastboot_partition_alias_") + 32(part_name) + 1 */ char env_alias_name[25 +32 +1 ];@@ -38,7 +38,7 @@ static int part_get_info_efi_by_name_or_alias(struct blk_desc *dev_desc,strncat (env_alias_name, name,32 ); aliased_part_name =getenv (env_alias_name);if (aliased_part_name !=NULL ) - ret =part_get_info_efi_by_name (dev_desc, + ret =part_get_info_by_name (dev_desc, aliased_part_name, info); }return ret;disk/part.c +16
-0@@ -615,3 +615,29 @@ cleanup:free (dup_str);return ret; } + +int part_get_info_by_name (struct blk_desc *dev_desc,const char *name, +disk_partition_t *info) +{ +struct part_driver *first_drv = + ll_entry_start(struct part_driver, part_driver); + const int n_drvs = ll_entry_count(struct part_driver, part_driver); +struct part_driver *part_drv; + +for (part_drv = first_drv; part_drv != first_drv + n_drvs; part_drv++) { +int ret; +int i; +for (i =1 ; i < part_drv->max_entries; i++) { + ret = part_drv->get_info (dev_desc, i, info); +if (ret !=0 ) { +/* no more entries in table */
disk/part.c cleanup: · line 643
Quoted 10 lines
disk/part.c +10
-0+break ; + } +if (strcmp (name, (const char *)info->name) ==0 ) { +/* matched */ +return 0 ; + } + } + } +return -1 ; +}
I am a little concerned about the additional feature in this code... This function previously only searched for the "name" in the device specified by "FASTBOOT_FLASH_MMC_DEV",
now it seems to be searching through multiple entries (... the "part_drv" loop ...)
Anyway, it seems to still work properly on my boards, so I guess it is OK for now....
Quoted 153 lines
disk/part_amiga.c +1
-0@@ -381,6 +381,7 @@ static void part_print_amiga(struct blk_desc *dev_desc)U_BOOT_PART_TYPE (amiga) = { .name ="AMIGA" , .part_type =PART_TYPE_AMIGA , + .max_entries =AMIGA_ENTRY_NUMBERS , .get_info = part_get_info_amiga, .print = part_print_amiga, .test = part_test_amiga,disk/part_dos.c +1
-0@@ -300,6 +300,7 @@ int part_get_info_dos(struct blk_desc *dev_desc, int part,U_BOOT_PART_TYPE (dos) = { .name ="DOS" , .part_type =PART_TYPE_DOS , + .max_entries =DOS_ENTRY_NUMBERS , .get_info =part_get_info_ptr (part_get_info_dos), .print =part_print_ptr (part_print_dos), .test = part_test_dos,disk/part_efi.c +1
-19@@ -296,25 +296,6 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,return 0 ; } -int part_get_info_efi_by_name (struct blk_desc *dev_desc, -const char *name,disk_partition_t *info) -{ -int ret; -int i; -for (i =1 ; i <GPT_ENTRY_NUMBERS ; i++) { - ret =part_get_info_efi (dev_desc, i, info); -if (ret !=0 ) { -/* no more entries in table */ -return -1 ; - } -if (strcmp (name, (const char *)info->name) ==0 ) { -/* matched */ -return 0 ; - } - } -return -2 ; -} -static int part_test_efi (struct blk_desc *dev_desc) {ALLOC_CACHE_ALIGN_BUFFER_PAD (legacy_mbr, legacymbr,1 , dev_desc->blksz);@@ -958,6 +939,7 @@ static int is_pte_valid(gpt_entry * pte)U_BOOT_PART_TYPE (a_efi) = { .name ="EFI" , .part_type =PART_TYPE_EFI , + .max_entries =GPT_ENTRY_NUMBERS , .get_info =part_get_info_ptr (part_get_info_efi), .print =part_print_ptr (part_print_efi), .test = part_test_efi,disk/part_iso.c +1
-0@@ -257,6 +257,7 @@ static int part_test_iso(struct blk_desc *dev_desc)U_BOOT_PART_TYPE (iso) = { .name ="ISO" , .part_type =PART_TYPE_ISO , + .max_entries =ISO_ENTRY_NUMBERS , .get_info = part_get_info_iso, .print = part_print_iso, .test = part_test_iso,disk/part_mac.c +1
-0@@ -239,6 +239,7 @@ static int part_get_info_mac(struct blk_desc *dev_desc, int part,U_BOOT_PART_TYPE (mac) = { .name ="MAC" , .part_type =PART_TYPE_MAC , + .max_entries =MAC_ENTRY_NUMBERS , .get_info = part_get_info_mac, .print = part_print_mac, .test = part_test_mac,include/part.h +20
-13@@ -28,6 +28,11 @@ struct block_drvr {#define PART_TYPE_AMIGA 0x04#define PART_TYPE_EFI 0x05 +/* maximum number of partition entries supported by search */ +#define DOS_ENTRY_NUMBERS 8 +#define ISO_ENTRY_NUMBERS 64 +#define MAC_ENTRY_NUMBERS 64 +#define AMIGA_ENTRY_NUMBERS 8/* * Type string for U-Boot bootable partitions */ @@ -146,6 +151,20 @@ int blk_get_device_by_str(const char *ifname, const char *dev_str,int blk_get_device_part_str (const char *ifname,const char *dev_part_str,struct blk_desc **dev_desc,disk_partition_t *info,int allow_whole_dev); + +/** +* part_get_info_by_name() - Search for a partition by name +* among all available registered partitions +* +* @param dev_desc - block device descriptor +* @param gpt_name - the specified table entry name +* @param info - returns the disk partition info +* +* @return - '0' on match, '-1' on no match, otherwise error +*/ +int part_get_info_by_name (struct blk_desc *dev_desc, +const char *name,disk_partition_t *info); +extern const struct block_drvr block_drvr[];#else static inline struct blk_desc *blk_get_dev (const char *ifname,int dev)@@ -189,6 +208,7 @@ static inline int blk_get_device_part_str(const char *ifname,struct part_driver {const char *name;int part_type; +const int max_entries;/* maximum number of entries to search */ /** * get_info() - Get information about a partition @@ -225,18 +245,6 @@ struct part_driver {#include <part_efi.h> /* disk/part_efi.c */ /** -* part_get_info_efi_by_name() - Find the specified GPT partition table entry -* -* @param dev_desc - block device descriptor -* @param gpt_name - the specified table entry name -* @param info - returns the disk partition info -* -* @return - '0' on match, '-1' on no match, otherwise error -*/ -int part_get_info_efi_by_name (struct blk_desc *dev_desc, -const char *name,disk_partition_t *info); - -/** * write_gpt_table() - Write the GUID Partition Table to disk * * @param dev_desc - block device descriptor -- 2.7.4
Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.deenteries
http://lists.denx.de/mailman/listinfo/u-boot
PATCH v2 1/4 disk: part: implement generic function part_get_info_by_name()
In reply to Petr KulhavyQuoted 17 lines · Petr Kulhavy
So far partition search by name has been supported only on the EFI partition table. This patch extends the search to all partition tables.
Rename
part_get_info_efi_by_name()topart_get_info_by_name(), move it frompart_efi.cintopart.cand make it a generic function which traverses all part drivers and searches all partitions (in the order given by the linked list).For this a new variable struct part_driver.max_entries is added, which limits the number of partitions searched. For EFI this was
GPT_ENTRY_NUMBERS. Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables.Signed-off-by Petr Kulhavy <[email protected]>Reviewed-by Tom Rini <[email protected]>---
v1: initial
v2: no change
Quoted 9 lines
common/fb_mmc.c | 4 ++-- disk/part.c | 26 ++++++++++++++++++++++++++ disk/part_amiga.c | 1 + disk/part_dos.c | 1 + disk/part_efi.c | 20 +------------------- disk/part_iso.c | 1 + disk/part_mac.c | 1 + include/part.h | 32 ++++++++++++++++++++------------ 8 files changed, 53 insertions(+), 33 deletions(-)
PATCH v2 1/4 disk: part: implement generic function part_get_info_by_name()
In reply to Petr KulhavyQuoted 7 lines · Petr Kulhavy
So far partition search by name has been supported only on the EFI partition table. This patch extends the search to all partition tables.
Rename
part_get_info_efi_by_name()topart_get_info_by_name(), move it frompart_efi.cintopart.cand make it a generic function which traverses all part drivers and searches all partitions (in the order given by the linked list).
Quoted 8 lines
For this a new variable struct part_driver.max_entries is added, which limits the number of partitions searched. For EFI this was
GPT_ENTRY_NUMBERS. Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables.Signed-off-by Petr Kulhavy <[email protected]>Reviewed-by Tom Rini <[email protected]>Acked-by Steve Rae <[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/20161003/30ffc00a/attachment.sig>
PATCH v2 2/4 fastboot: add support for writing MBR
In reply to Petr KulhavyAdd special target "mbr" (otherwise configurable via CONFIG_FASTBOOT_MBR_NAME) to write MBR partition table.
Partitions are now searched using the generic function which finds any partiiton by name. For MBR the partition names hda1, sda1, etc. are used.
---
v1: initial
v2: no change
README | 7 +++++++ common/fb_mmc.c | 40 ++++++++++++++++++++++++++++++++++------ disk/part_dos.c | 20 ++++++++++++++++++++ doc/README.android-fastboot | 37 +++++++++++++++++++++++++++++++++++++ include/part.h | 23 +++++++++++++++++++++++ 5 files changed, 121 insertions(+), 6 deletions(-)
README +7 -0
@@ -1682,6 +1682,13 @@ The following options need to be configured: "fastboot flash" command line matches this value. Default is GPT_ENTRY_NAME (currently "gpt") if undefined. + CONFIG_FASTBOOT_MBR_NAME + The fastboot "flash" command supports writing the downloaded + image to DOS MBR. + This occurs when the "partition name" specified on the + "fastboot flash" command line matches this value. + If not defined the default value "mbr" is used. + - Journaling Flash filesystem support: CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE, CONFIG_JFFS2_NAND_DEV
common/fb_mmc.c +34 -6
@@ -14,15 +14,20 @@#include <mmc.h> #include <div64.h> -#ifndef CONFIG_FASTBOOT_GPT_NAME +#if defined(CONFIG_EFI_PARTITION ) && !defined(CONFIG_FASTBOOT_GPT_NAME )#define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME#endif + +#if defined(CONFIG_DOS_PARTITION ) && !defined(CONFIG_FASTBOOT_MBR_NAME ) +#define CONFIG_FASTBOOT_MBR_NAME "mbr" +#endif +struct fb_mmc_sparse {struct blk_desc *dev_desc; }; -static int part_get_info_efi_by_name_or_alias (struct blk_desc *dev_desc, +static int part_get_info_by_name_or_alias (struct blk_desc *dev_desc,const char *name,disk_partition_t *info) {int ret;
@@ -103,6 +108,7 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,return ; } +#ifdef CONFIG_EFI_PARTITION if (strcmp (cmd,CONFIG_FASTBOOT_GPT_NAME ) ==0 ) {printf ("%s: updating MBR, Primary and Backup GPT(s)\n" , __func__);
@@ -114,14 +120,36 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, }if (write_mbr_and_gpt_partitions (dev_desc, download_buffer)) {printf ("%s: writing GPT partitions failed\n" , __func__); -fastboot_fail ( -"writing GPT partitions failed" ); +fastboot_fail ("writing GPT partitions failed" );return ; }printf ("........ success\n" );fastboot_okay ("" );return ; - }else if (part_get_info_efi_by_name_or_alias (dev_desc, cmd, &info)) { + } +#endif + +#ifdef CONFIG_DOS_PARTITION +if (strcmp (cmd,CONFIG_FASTBOOT_MBR_NAME ) ==0 ) { +printf ("%s: updating MBR\n" , __func__); +if (is_valid_dos_buf (download_buffer)) { +printf ("%s: invalid MBR - refusing to write to flash\n" , + __func__); +fastboot_fail ("invalid MBR partition" ); +return ; + } +if (write_mbr_partition (dev_desc, download_buffer)) { +printf ("%s: writing MBR partition failed\n" , __func__); +fastboot_fail ("writing MBR partition failed" ); +return ; + } +printf ("........ success\n" ); +fastboot_okay ("" ); +return ; + } +#endif + +if (part_get_info_by_name_or_alias (dev_desc, cmd, &info)) {error ("cannot find partition: '%s'\n" , cmd);fastboot_fail ("cannot find partition" );return ;
@@ -172,7 +200,7 @@ void fb_mmc_erase(const char *cmd)return ; } - ret =part_get_info_efi_by_name_or_alias (dev_desc, cmd, &info); + ret =part_get_info_by_name_or_alias (dev_desc, cmd, &info);if (ret) {error ("cannot find partition: '%s'" , cmd);fastboot_fail ("cannot find partition" );
disk/part_dos.c +20 -0
@@ -297,6 +297,26 @@ int part_get_info_dos(struct blk_desc *dev_desc, int part,return part_get_info_extended (dev_desc,0 ,0 ,1 , part, info,0 ); } +int is_valid_dos_buf (void *buf) +{ +return test_block_type (buf) ==DOS_MBR ?0 :-1 ; +} + +int write_mbr_partition (struct blk_desc *dev_desc,void *buf) +{ +if (is_valid_dos_buf (buf)) +return -1 ; + +/* write MBR */ +if (blk_dwrite (dev_desc,0 ,1 , buf) !=1 ) { +printf ("%s: failed writing '%s' (1 blks at 0x0)\n" , + __func__,"MBR" ); +return 1 ; + } + +return 0 ; +} +U_BOOT_PART_TYPE (dos) = { .name ="DOS" , .part_type =PART_TYPE_DOS ,
doc/README.android-fastboot +37 -0
@@ -59,6 +59,43 @@ To define a partition alias add an environment variable similar to: fastboot_partition_alias_<alias partition name>=<actual partition name> Example: fastboot_partition_alias_boot=LNX +Partition Names +=============== +The Fastboot implementation in U-boot allows to write images into disk +partitions (currently on eMMC). Target partitions are referred on the host +computer by their names. + +For GPT/EFI the respective partition name is used. + +For MBR the partitions are referred by generic names according to the +following schema: + + <device type> <device index letter> <partition index> + +Example: hda3, sdb1, usbda1 + +The device type is as follows: + + * IDE, ATAPI and SATA disks: hd + * SCSI disks: sd + * USB media: usbd + * Disk on chip: docd + * other: xx + +The device index starts from 'a' and refers to the interface (e.g. USB +controller, SD/MMC controller) or disk index. The partition index starts +from 1 and describes the partition number on the particular device. + +Writing Partition Table +======================= +Fastboot also allows to write the partition table to the media. This can be +done by writing the respective partition table image to a special target +"gpt" or "mbr". These names can be customized by defining the following +configuration options: + +CONFIG_FASTBOOT_GPT_NAME +CONFIG_FASTBOOT_MBR_NAME + In Action ========= Enter into fastboot by executing the fastboot command in u-boot and you
include/part.h +23 -0
@@ -351,4 +351,27 @@ int gpt_verify_partitions(struct blk_desc *dev_desc, gpt_header *gpt_head, gpt_entry **gpt_pte);#endif +#ifdef CONFIG_DOS_PARTITION +/** +* is_valid_dos_buf() - Ensure that a DOS MBR image is valid +* +* @param buf - buffer which contains the MBR +* +* @return - '0' on success, otherwise error +*/ +int is_valid_dos_buf (void *buf); + +/** +* write_mbr_partition() - write DOS MBR +* +* @param dev_desc - block device descriptor +* @param buf - buffer which contains the MBR +* +* @return - '0' on success, otherwise error +*/ +int write_mbr_partition (struct blk_desc *dev_desc,void *buf); + +#endif + +#endif /* _PART_H */
Signature · 1 line
2.7.4
PATCH v2 2/4 fastboot: add support for writing MBR
Quoted 234 lines · Petr Kulhavy
Add special target "mbr" (otherwise configurable via
CONFIG_FASTBOOT_MBR_NAME) to write MBR partition table.
Partitions are now searched using the generic function which finds any partiiton by name. For MBR the partition names hda1, sda1, etc. are used.Signed-off-by Petr Kulhavy <[email protected]>Reviewed-by Tom Rini <[email protected]>---
v1: initial
v2: no changeREADME | 7 +++++++ common/fb_mmc.c | 40 ++++++++++++++++++++++++++++++++++------ disk/part_dos.c | 20 ++++++++++++++++++++ doc/README.android-fastboot | 37 +++++++++++++++++++++++++++++++++++++ include/part.h | 23 +++++++++++++++++++++++ 5 files changed, 121 insertions(+), 6 deletions(-)README +7
-0@@ -1682,6 +1682,13 @@ The following options need to be configured: "fastboot flash" command line matches this value. Default is GPT_ENTRY_NAME (currently "gpt") if undefined. + CONFIG_FASTBOOT_MBR_NAME + The fastboot "flash" command supports writing the downloaded + image to DOS MBR. + This occurs when the "partition name" specified on the + "fastboot flash" command line matches this value. + If not defined the default value "mbr" is used. + - Journaling Flash filesystem support: CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE, CONFIG_JFFS2_NAND_DEVcommon/fb_mmc.c +34
-6@@ -14,15 +14,20 @@#include <mmc.h> #include <div64.h> -#ifndef CONFIG_FASTBOOT_GPT_NAME +#if defined(CONFIG_EFI_PARTITION ) && !defined(CONFIG_FASTBOOT_GPT_NAME )#define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME#endif + +#if defined(CONFIG_DOS_PARTITION ) && !defined(CONFIG_FASTBOOT_MBR_NAME ) +#define CONFIG_FASTBOOT_MBR_NAME "mbr" +#endif +struct fb_mmc_sparse {struct blk_desc *dev_desc; }; -static int part_get_info_efi_by_name_or_alias (struct blk_desc *dev_desc, +static int part_get_info_by_name_or_alias (struct blk_desc *dev_desc,const char *name,disk_partition_t *info) {int ret;@@ -103,6 +108,7 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,return ; } +#ifdef CONFIG_EFI_PARTITION if (strcmp (cmd,CONFIG_FASTBOOT_GPT_NAME ) ==0 ) {printf ("%s: updating MBR, Primary and Backup GPT(s)\n" , __func__);@@ -114,14 +120,36 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, }if (write_mbr_and_gpt_partitions (dev_desc, download_buffer)) {printf ("%s: writing GPT partitions failed\n" , __func__); -fastboot_fail ( -"writing GPT partitions failed" ); +fastboot_fail ("writing GPT partitions failed" );return ; }printf ("........ success\n" );fastboot_okay ("" );return ; - }else if (part_get_info_efi_by_name_or_alias (dev_desc, cmd, &info)) { + } +#endif + +#ifdef CONFIG_DOS_PARTITION +if (strcmp (cmd,CONFIG_FASTBOOT_MBR_NAME ) ==0 ) { +printf ("%s: updating MBR\n" , __func__); +if (is_valid_dos_buf (download_buffer)) { +printf ("%s: invalid MBR - refusing to write to flash\n" , + __func__); +fastboot_fail ("invalid MBR partition" ); +return ; + } +if (write_mbr_partition (dev_desc, download_buffer)) { +printf ("%s: writing MBR partition failed\n" , __func__); +fastboot_fail ("writing MBR partition failed" ); +return ; + } +printf ("........ success\n" ); +fastboot_okay ("" ); +return ; + } +#endif + +if (part_get_info_by_name_or_alias (dev_desc, cmd, &info)) {error ("cannot find partition: '%s'\n" , cmd);fastboot_fail ("cannot find partition" );return ;@@ -172,7 +200,7 @@ void fb_mmc_erase(const char *cmd)return ; } - ret =part_get_info_efi_by_name_or_alias (dev_desc, cmd, &info); + ret =part_get_info_by_name_or_alias (dev_desc, cmd, &info);if (ret) {error ("cannot find partition: '%s'" , cmd);fastboot_fail ("cannot find partition" );disk/part_dos.c +20
-0@@ -297,6 +297,26 @@ int part_get_info_dos(struct blk_desc *dev_desc, int part,return part_get_info_extended (dev_desc,0 ,0 ,1 , part, info,0 ); } +int is_valid_dos_buf (void *buf) +{ +return test_block_type (buf) ==DOS_MBR ?0 :-1 ; +} + +int write_mbr_partition (struct blk_desc *dev_desc,void *buf) +{ +if (is_valid_dos_buf (buf)) +return -1 ; + +/* write MBR */ +if (blk_dwrite (dev_desc,0 ,1 , buf) !=1 ) { +printf ("%s: failed writing '%s' (1 blks at 0x0)\n" , + __func__,"MBR" ); +return 1 ; + } + +return 0 ; +} +U_BOOT_PART_TYPE (dos) = { .name ="DOS" , .part_type =PART_TYPE_DOS ,doc/README.android-fastboot +37
-0@@ -59,6 +59,43 @@ To define a partition alias add an environment variable similar to: fastboot_partition_alias_<alias partition name>=<actual partition name> Example: fastboot_partition_alias_boot=LNX +Partition Names +=============== +The Fastboot implementation in U-boot allows to write images into disk +partitions (currently on eMMC). Target partitions are referred on the host +computer by their names. + +For GPT/EFI the respective partition name is used. + +For MBR the partitions are referred by generic names according to the +following schema: + + <device type> <device index letter> <partition index> + +Example: hda3, sdb1, usbda1 + +The device type is as follows: + + * IDE, ATAPI and SATA disks: hd + * SCSI disks: sd + * USB media: usbd + * Disk on chip: docd + * other: xx + +The device index starts from 'a' and refers to the interface (e.g. USB +controller, SD/MMC controller) or disk index. The partition index starts +from 1 and describes the partition number on the particular device. + +Writing Partition Table +======================= +Fastboot also allows to write the partition table to the media. This can be +done by writing the respective partition table image to a special target +"gpt" or "mbr". These names can be customized by defining the following +configuration options: + +CONFIG_FASTBOOT_GPT_NAME +CONFIG_FASTBOOT_MBR_NAME + In Action ========= Enter into fastboot by executing the fastboot command in u-boot and youinclude/part.h +23
-1@@ -351,4 +351,27 @@ int gpt_verify_partitions(struct blk_desc *dev_desc, gpt_header *gpt_head, gpt_entry **gpt_pte);#endif +#ifdef CONFIG_DOS_PARTITION +/** +* is_valid_dos_buf() - Ensure that a DOS MBR image is valid +* +* @param buf - buffer which contains the MBR +* +* @return - '0' on success, otherwise error +*/ +int is_valid_dos_buf (void *buf); + +/** +* write_mbr_partition() - write DOS MBR +* +* @param dev_desc - block device descriptor +* @param buf - buffer which contains the MBR +* +* @return - '0' on success, otherwise error +*/ +int write_mbr_partition (struct blk_desc *dev_desc,void *buf); + +#endif + +#endif /* _PART_H */ --2.7.4
Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH v2 2/4 fastboot: add support for writing MBR
In reply to Petr KulhavyQuoted 11 lines · Petr Kulhavy
Add special target "mbr" (otherwise configurable via
CONFIG_FASTBOOT_MBR_NAME) to write MBR partition table.
Partitions are now searched using the generic function which finds any partiiton by name. For MBR the partition names hda1, sda1, etc. are used.Signed-off-by Petr Kulhavy <[email protected]>Reviewed-by Tom Rini <[email protected]>---
v1: initial
v2: no change
Quoted 6 lines
README | 7 +++++++ common/fb_mmc.c | 40 ++++++++++++++++++++++++++++++++++------ disk/part_dos.c | 20 ++++++++++++++++++++ doc/README.android-fastboot | 37 +++++++++++++++++++++++++++++++++++++ include/part.h | 23 +++++++++++++++++++++++ 5 files changed, 121 insertions(+), 6 deletions(-)
PATCH v2 2/4 fastboot: add support for writing MBR
In reply to Petr KulhavyQuoted 9 lines · Petr Kulhavy
Add special target "mbr" (otherwise configurable via
CONFIG_FASTBOOT_MBR_NAME) to write MBR partition table.
Partitions are now searched using the generic function which finds any partiiton by name. For MBR the partition names hda1, sda1, etc. are used.Signed-off-by Petr Kulhavy <[email protected]>Reviewed-by Tom Rini <[email protected]>Acked-by Steve Rae <[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/20161003/f4d4518d/attachment.sig>
PATCH v2 3/4 disk: part: refactor generic name creation for DOS and ISO
In reply to Petr KulhavyIn both DOS and ISO partition tables the same code to create partition name like "hda1" was repeated.
Code moved to into a new function part_set_generic_name() in part.c and optimized. Added recognition of MMC and SD types, name is like "mmcsda1".
---
v1: initial
v2: no change
disk/part.c | 32 ++++++++++++++++++++++++++++++++ disk/part_dos.c | 31 ++----------------------------- disk/part_iso.c | 25 +------------------------ doc/README.android-fastboot | 1 + include/part.h | 14 ++++++++++++++ 5 files changed, 50 insertions(+), 53 deletions(-)
disk/part.c +32 -0
@@ -641,3 +641,35 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name, }return -1 ; } + +void part_set_generic_name (const struct blk_desc *dev_desc, +int part_num,char *name) +{ +char *devtype; + +switch (dev_desc->if_type) { +case IF_TYPE_IDE : +case IF_TYPE_SATA : +case IF_TYPE_ATAPI : + devtype ="hd" ; +break ; +case IF_TYPE_SCSI : + devtype ="sd" ; +break ; +case IF_TYPE_USB : + devtype ="usbd" ; +break ; +case IF_TYPE_DOC : + devtype ="docd" ; +break ; +case IF_TYPE_MMC : +case IF_TYPE_SD : + devtype ="mmcsd" ; +break ; +default : + devtype ="xx" ; +break ; + } + +sprintf (name,"%s%c%d" , devtype,'a' + dev_desc->devnum, part_num); +}
disk/part_dos.c +2 -29
@@ -209,35 +209,8 @@ static int part_get_info_extended(struct blk_desc *dev_desc, info->start = (lbaint_t)(ext_part_sector +le32_to_int (pt->start4)); info->size = (lbaint_t )le32_to_int (pt->size4); -switch (dev_desc->if_type) { -case IF_TYPE_IDE : -case IF_TYPE_SATA : -case IF_TYPE_ATAPI : -sprintf ((char *)info->name,"hd%c%d" , -'a' + dev_desc->devnum, - part_num); -break ; -case IF_TYPE_SCSI : -sprintf ((char *)info->name,"sd%c%d" , -'a' + dev_desc->devnum, - part_num); -break ; -case IF_TYPE_USB : -sprintf ((char *)info->name,"usbd%c%d" , -'a' + dev_desc->devnum, - part_num); -break ; -case IF_TYPE_DOC : -sprintf ((char *)info->name,"docd%c%d" , -'a' + dev_desc->devnum, - part_num); -break ; -default : -sprintf ((char *)info->name,"xx%c%d" , -'a' + dev_desc->devnum, - part_num); -break ; - } +part_set_generic_name (dev_desc, part_num, + (char *)info->name);/* sprintf(info->type, "%d, pt->sys_ind); */ strcpy ((char *)info->type,"U-Boot" ); info->bootable =is_bootable (pt);
disk/part_iso.c +1 -24
@@ -137,30 +137,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num, entry_num=1 ; offset=0x20 ;strcpy ((char *)info->type,"U-Boot" ); -switch (dev_desc->if_type) { -case IF_TYPE_IDE : -case IF_TYPE_SATA : -case IF_TYPE_ATAPI : -sprintf ((char *)info->name,"hd%c%d" , -'a' + dev_desc->devnum, part_num); -break ; -case IF_TYPE_SCSI : -sprintf ((char *)info->name,"sd%c%d" , -'a' + dev_desc->devnum, part_num); -break ; -case IF_TYPE_USB : -sprintf ((char *)info->name,"usbd%c%d" , -'a' + dev_desc->devnum, part_num); -break ; -case IF_TYPE_DOC : -sprintf ((char *)info->name,"docd%c%d" , -'a' + dev_desc->devnum, part_num); -break ; -default : -sprintf ((char *)info->name,"xx%c%d" , -'a' + dev_desc->devnum, part_num); -break ; - } +part_set_generic_name (dev_desc, part_num, (char *)info->name);/* the bootcatalog (including validation Entry) is limited to 2048Bytes * (63 boot entries + validation entry) */ while (offset<2048 ) {
doc/README.android-fastboot +1 -0
@@ -79,6 +79,7 @@ The device type is as follows: * IDE, ATAPI and SATA disks: hd * SCSI disks: sd * USB media: usbd + * MMC and SD cards: mmcsd * Disk on chip: docd * other: xx
include/part.h +14 -0
@@ -165,6 +165,20 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,int part_get_info_by_name (struct blk_desc *dev_desc,const char *name,disk_partition_t *info); +/** +* part_set_generic_name() - create generic partition like hda1 or sdb2 +* +* Helper function for partition tables, which don't hold partition names +* (DOS, ISO). Generates partition name out of the device type and partition +* number. +* +* @dev_desc: pointer to the block device +* @part_num: partition number for which the name is generated +* @name: buffer where the name is written +*/ +void part_set_generic_name (const struct blk_desc *dev_desc, +int part_num,char *name); +extern const struct block_drvr block_drvr[];#else static inline struct blk_desc *blk_get_dev (const char *ifname,int dev)
Signature · 1 line
2.7.4
PATCH v2 3/4 disk: part: refactor generic name creation for DOS and ISO
Quoted 177 lines · Petr Kulhavy
In both DOS and ISO partition tables the same code to create partition name like "hda1" was repeated.
Code moved to into a new function
part_set_generic_name()inpart.cand optimized. Added recognition of MMC and SD types, name is like "mmcsda1".Signed-off-by Petr Kulhavy <[email protected]>Reviewed-by Tom Rini <[email protected]>---
v1: initial
v2: no changedisk/part.c | 32 ++++++++++++++++++++++++++++++++ disk/part_dos.c | 31 ++----------------------------- disk/part_iso.c | 25 +------------------------ doc/README.android-fastboot | 1 + include/part.h | 14 ++++++++++++++ 5 files changed, 50 insertions(+), 53 deletions(-)disk/part.c +32
-0@@ -641,3 +641,35 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name, }return -1 ; } + +void part_set_generic_name (const struct blk_desc *dev_desc, +int part_num,char *name) +{ +char *devtype; + +switch (dev_desc->if_type) { +case IF_TYPE_IDE : +case IF_TYPE_SATA : +case IF_TYPE_ATAPI : + devtype ="hd" ; +break ; +case IF_TYPE_SCSI : + devtype ="sd" ; +break ; +case IF_TYPE_USB : + devtype ="usbd" ; +break ; +case IF_TYPE_DOC : + devtype ="docd" ; +break ; +case IF_TYPE_MMC : +case IF_TYPE_SD : + devtype ="mmcsd" ; +break ; +default : + devtype ="xx" ; +break ; + } + +sprintf (name,"%s%c%d" , devtype,'a' + dev_desc->devnum, part_num); +}disk/part_dos.c +2
-29@@ -209,35 +209,8 @@ static int part_get_info_extended(struct blk_desc *dev_desc, info->start = (lbaint_t)(ext_part_sector +le32_to_int (pt->start4)); info->size = (lbaint_t )le32_to_int (pt->size4); -switch (dev_desc->if_type) { -case IF_TYPE_IDE : -case IF_TYPE_SATA : -case IF_TYPE_ATAPI : -sprintf ((char *)info->name,"hd%c%d" , -'a' + dev_desc->devnum, - part_num); -break ; -case IF_TYPE_SCSI : -sprintf ((char *)info->name,"sd%c%d" , -'a' + dev_desc->devnum, - part_num); -break ; -case IF_TYPE_USB : -sprintf ((char *)info->name,"usbd%c%d" , -'a' + dev_desc->devnum, - part_num); -break ; -case IF_TYPE_DOC : -sprintf ((char *)info->name,"docd%c%d" , -'a' + dev_desc->devnum, - part_num); -break ; -default : -sprintf ((char *)info->name,"xx%c%d" , -'a' + dev_desc->devnum, - part_num); -break ; - } +part_set_generic_name (dev_desc, part_num, + (char *)info->name);/* sprintf(info->type, "%d, pt->sys_ind); */ strcpy ((char *)info->type,"U-Boot" ); info->bootable =is_bootable (pt);disk/part_iso.c +1
-24@@ -137,30 +137,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num, entry_num=1 ; offset=0x20 ;strcpy ((char *)info->type,"U-Boot" ); -switch (dev_desc->if_type) { -case IF_TYPE_IDE : -case IF_TYPE_SATA : -case IF_TYPE_ATAPI : -sprintf ((char *)info->name,"hd%c%d" , -'a' + dev_desc->devnum, part_num); -break ; -case IF_TYPE_SCSI : -sprintf ((char *)info->name,"sd%c%d" , -'a' + dev_desc->devnum, part_num); -break ; -case IF_TYPE_USB : -sprintf ((char *)info->name,"usbd%c%d" , -'a' + dev_desc->devnum, part_num); -break ; -case IF_TYPE_DOC : -sprintf ((char *)info->name,"docd%c%d" , -'a' + dev_desc->devnum, part_num); -break ; -default : -sprintf ((char *)info->name,"xx%c%d" , -'a' + dev_desc->devnum, part_num); -break ; - } +part_set_generic_name (dev_desc, part_num, (char *)info->name);/* the bootcatalog (including validation Entry) is limited to 2048Bytes * (63 boot entries + validation entry) */ while (offset<2048 ) {doc/README.android-fastboot +1
-0@@ -79,6 +79,7 @@ The device type is as follows: * IDE, ATAPI and SATA disks: hd * SCSI disks: sd * USB media: usbd + * MMC and SD cards: mmcsd * Disk on chip: docd * other: xxinclude/part.h +14
-1@@ -165,6 +165,20 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,int part_get_info_by_name (struct blk_desc *dev_desc,const char *name,disk_partition_t *info); +/** +* part_set_generic_name() - create generic partition like hda1 or sdb2 +* +* Helper function for partition tables, which don't hold partition names +* (DOS, ISO). Generates partition name out of the device type and partition +* number. +* +* @dev_desc: pointer to the block device +* @part_num: partition number for which the name is generated +* @name: buffer where the name is written +*/ +void part_set_generic_name (const struct blk_desc *dev_desc, +int part_num,char *name); +extern const struct block_drvr block_drvr[];#else static inline struct blk_desc *blk_get_dev (const char *ifname,int dev) --2.7.4
Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH v2 3/4 disk: part: refactor generic name creation for DOS and ISO
In reply to Petr KulhavyQuoted 12 lines · Petr Kulhavy
In both DOS and ISO partition tables the same code to create partition name like "hda1" was repeated.
Code moved to into a new function
part_set_generic_name()inpart.cand optimized. Added recognition of MMC and SD types, name is like "mmcsda1".Signed-off-by Petr Kulhavy <[email protected]>Reviewed-by Tom Rini <[email protected]>---
v1: initial
v2: no change
Quoted 6 lines
disk/part.c | 32 ++++++++++++++++++++++++++++++++ disk/part_dos.c | 31 ++----------------------------- disk/part_iso.c | 25 +------------------------ doc/README.android-fastboot | 1 + include/part.h | 14 ++++++++++++++ 5 files changed, 50 insertions(+), 53 deletions(-)
PATCH v2 3/4 disk: part: refactor generic name creation for DOS and ISO
In reply to Petr KulhavyQuoted 10 lines · Petr Kulhavy
In both DOS and ISO partition tables the same code to create partition name like "hda1" was repeated.
Code moved to into a new function
part_set_generic_name()inpart.cand optimized. Added recognition of MMC and SD types, name is like "mmcsda1".Signed-off-by Petr Kulhavy <[email protected]>Reviewed-by Tom Rini <[email protected]>Acked-by Steve Rae <[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/20161003/7478ca3a/attachment.sig>
PATCH v2 4/4 fastboot: move FASTBOOT_FLASH options into Kconfig
In reply to Petr KulhavyMove FASTBOOT_MBR_NAME and FASTBOOT_GPT_NAME into Kconfig.
Add dependency on the FASTBOOT_FLASH setting (also for FASTBOOT_MBR_NAME). Remove the now redundant GPT_ENTRY_NAME.
---
v2: initial
README | 2 +- cmd/fastboot/Kconfig | 24 ++++++++++++++++++++++++ common/fb_mmc.c | 9 --------- include/part_efi.h | 1 - 4 files changed, 25 insertions(+), 11 deletions(-)
README +1 -1
@@ -1680,7 +1680,7 @@ The following options need to be configured: to generate and write the Backup GUID Partition Table.) This occurs when the specified "partition name" on the "fastboot flash" command line matches this value. - Default is GPT_ENTRY_NAME (currently "gpt") if undefined. + The default is "gpt" if undefined. CONFIG_FASTBOOT_MBR_NAME The fastboot "flash" command supports writing the downloaded
cmd/fastboot/Kconfig +24 -0
@@ -50,11 +50,35 @@ config FASTBOOT_FLASH config FASTBOOT_FLASH_MMC_DEV int "Define FASTBOOT MMC FLASH default device" + depends on FASTBOOT_FLASH help The fastboot "flash" command requires additional information regarding the non-volatile storage device. Define this to the eMMC device that fastboot should use to store the image. +config FASTBOOT_GPT_NAME + string "Target name for updating GPT" + depends on FASTBOOT_FLASH + default "gpt" + help + The fastboot "flash" command supports writing the downloaded + image to the Protective MBR and the Primary GUID Partition + Table. (Additionally, this downloaded image is post-processed + to generate and write the Backup GUID Partition Table.) + This occurs when the specified "partition name" on the + "fastboot flash" command line matches the value defined here. + The default target name for updating GPT is "gpt". + +config FASTBOOT_MBR_NAME + string "Target name for updating MBR" + depends on FASTBOOT_FLASH + default "mbr" + help + The fastboot "flash" command allows to write the downloaded image + to the Master Boot Record. This occurs when the "partition name" + specified on the "fastboot flash" command line matches the value + defined here. The default target name for updating MBR is "mbr". + endif # USB_FUNCTION_FASTBOOT endmenu
common/fb_mmc.c +0 -9
@@ -14,15 +14,6 @@#include <mmc.h> #include <div64.h> -#if defined(CONFIG_EFI_PARTITION ) && !defined(CONFIG_FASTBOOT_GPT_NAME ) -#define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME -#endif - - -#if defined(CONFIG_DOS_PARTITION ) && !defined(CONFIG_FASTBOOT_MBR_NAME ) -#define CONFIG_FASTBOOT_MBR_NAME "mbr" -#endif -struct fb_mmc_sparse {struct blk_desc *dev_desc; };
include/part_efi.h +0 -1
@@ -27,7 +27,6 @@#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL#define GPT_HEADER_REVISION_V1 0x00010000#define GPT_PRIMARY_PARTITION_TABLE_LBA 1ULL -#define GPT_ENTRY_NAME "gpt"#define GPT_ENTRY_NUMBERS 128#define GPT_ENTRY_SIZE 128
Signature · 1 line
2.7.4
PATCH v2 4/4 fastboot: move FASTBOOT_FLASH options into Kconfig
Quoted 5 lines · Petr Kulhavy
Move
FASTBOOT_MBR_NAMEandFASTBOOT_GPT_NAMEintoKconfig.
Add dependency on theFASTBOOT_FLASHsetting (also forFASTBOOT_MBR_NAME). Remove the now redundantGPT_ENTRY_NAME.Signed-off-by Petr Kulhavy <[email protected]>
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/20160909/8e81ceac/attachment.sig>
PATCH v2 4/4 fastboot: move FASTBOOT_FLASH options into Kconfig
Quoted 10 lines · Tom Rini
Quoted 5 lines · Petr Kulhavy
Move
FASTBOOT_MBR_NAMEandFASTBOOT_GPT_NAMEintoKconfig.
Add dependency on theFASTBOOT_FLASHsetting (also forFASTBOOT_MBR_NAME). Remove the now redundantGPT_ENTRY_NAME.Signed-off-by Petr Kulhavy <[email protected]>Reviewed-by Tom Rini <[email protected]>
Quoted 8 lines
--
Tom_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH v2 4/4 fastboot: move FASTBOOT_FLASH options into Kconfig
In reply to Petr KulhavyQuoted 5 lines · Petr Kulhavy
Move
FASTBOOT_MBR_NAMEandFASTBOOT_GPT_NAMEintoKconfig.
Add dependency on theFASTBOOT_FLASHsetting (also forFASTBOOT_MBR_NAME). Remove the now redundantGPT_ENTRY_NAME.Signed-off-by Petr Kulhavy <[email protected]>
Quoted 8 lines
---
v2: initialREADME | 2 +- cmd/fastboot/Kconfig | 24 ++++++++++++++++++++++++ common/fb_mmc.c | 9 --------- include/part_efi.h | 1 - 4 files changed, 25 insertions(+), 11 deletions(-)
PATCH v2 4/4 fastboot: move FASTBOOT_FLASH options into Kconfig
In reply to Petr KulhavyQuoted 8 lines · Petr Kulhavy
Move
FASTBOOT_MBR_NAMEandFASTBOOT_GPT_NAMEintoKconfig.
Add dependency on theFASTBOOT_FLASHsetting (also forFASTBOOT_MBR_NAME). Remove the now redundantGPT_ENTRY_NAME.Signed-off-by Petr Kulhavy <[email protected]>Reviewed-by Tom Rini <[email protected]>Acked-by Steve Rae <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
But also note that I had to add back in code to define the gpt/mbr default names as until DOS_PARTITION and EFI_PARTITION are in Kconfig we can get code that fails to build here otherwise.
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/20161003/c32c9b2e/attachment.sig>
v2 cover Fastboot MBR and generic partition support
In reply to Petr KulhavyQuoted 28 lines · Petr Kulhavy
This set extends the Fastboot implementation from GPT-only to any partition support. Further it adds a special target "mbr" (configurable) to write the DOS MBR.
Version 2:
Add a fourth patch into the set to moveCONFIG_FASTBOOT_GPT_NAMEandCONFIG_FASTBOOT_MBR_NAMEinto cmd/fastboot/KconfigPetr Kulhavy (4):
disk: part: implement generic functionpart_get_info_by_name()
fastboot: add support for writing MBR
disk: part: refactor generic name creation for DOS and ISO
fastboot: moveFASTBOOT_FLASHoptions intoKconfigREADME | 9 +++++- cmd/fastboot/Kconfig | 24 ++++++++++++++++ common/fb_mmc.c | 41 +++++++++++++++++++-------- disk/part.c | 58 +++++++++++++++++++++++++++++++++++++ disk/part_amiga.c | 1 + disk/part_dos.c | 52 +++++++++++++++------------------- disk/part_efi.c | 20 +------------ disk/part_iso.c | 26 ++--------------- disk/part_mac.c | 1 + doc/README.android-fastboot | 38 +++++++++++++++++++++++++ include/part.h | 69 +++++++++++++++++++++++++++++++++++++-------- include/part_efi.h | 1 - 12 files changed, 243 insertions(+), 97 deletions(-)
Quoted 7 lines
--
2.7.4_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Thanks for this !