Add fastboot UDP support
Subsystems (2)
cover Add fastboot UDP support
This series merges the fastboot UDP support from AOSP into mainline U-Boot.
Open questions:
- what's the correct way of attributing the original authors? I've added Co-authored-by, is that right? checkpatch doesn't seem to know any of the co- tags
- currently there's no NAND support and I've no way of testing that, so my inclination is towards leaving it like that until someone with that particular itch to scratch can look at it
- you can select both USB and UDP fastboot, but the comments in the AOSP code suggest that needs fixing - again, I've no board I can test USB fastboot on
- the USB and UDP code want consolidating, with this series there would then be two separate implementations of the same protocol
- the syntax for the USB fastboot command changes from fastboot <controller> to fastboot usb <controller>, that feels unacceptable and we probably want something like fastboot <controller> or fastboot udp?
- unrelated to this series, but a show-stopper for me, there's no FIT image support, but that doesn't feel unsolveable - something like add an option to pass in the load address and/or use loadaddr, then something else to let you override the bootm invocation on the server side
I've not tested all the code paths yet, but the obvious stuff works (basic interaction, download, boot) - every interaction elicits a WARNING: unknown variable: slot-count on the console; I'm guessing that my local end is sending a getvar for that, but I've not investigated.
Without any way of testing any of the USB/NAND code I'm nervous of wading into that kind of refactoring, would that be a pre-requisite for merging?
Alex Kiernan (5):
dfu: Refactor fastboot_okay/fail to take response
dfu: Extract fastboot_okay/fail to fb_common.c
net: dfu: Merge AOSP UDP fastboot
dfu: Resolve Kconfig dependency loops
net: dfu: Support building without MMC
cmd/fastboot.c | 32 ++- cmd/fastboot/Kconfig | 21 +- cmd/net.c | 6 + common/Makefile | 4 + common/fb_common.c | 44 ++++ common/fb_mmc.c | 114 ++++++--- common/fb_nand.c | 31 +-- common/image-sparse.c | 41 ++- drivers/usb/gadget/f_fastboot.c | 36 +-- include/fastboot.h | 17 +- include/fb_mmc.h | 4 +- include/fb_nand.h | 4 +- include/image-sparse.h | 2 +- include/net.h | 6 +- include/net/fastboot.h | 27 ++ net/Makefile | 1 + net/fastboot.c | 548 ++++++++++++++++++++++++++++++++++++++++ net/net.c | 9 + 18 files changed, 824 insertions(+), 123 deletions(-) create mode 100644 common/fb_common.c create mode 100644 include/net/fastboot.h create mode 100644 net/fastboot.c
Signature · 1 line
2.7.4
RFC PATCH 1/5 dfu: Refactor fastboot_okay/fail to take response
Add the response string as a parameter to fastboot_okay/fail, instead of modifying a global, to match the contract expected by the AOSP U-Boot code.
---
common/fb_mmc.c | 80 ++++++++++++++++++++++------------------- common/fb_nand.c | 31 ++++++++-------- common/image-sparse.c | 41 +++++++++++---------- drivers/usb/gadget/f_fastboot.c | 35 +++++++----------- include/fastboot.h | 4 +-- include/fb_mmc.h | 4 +-- include/fb_nand.h | 4 +-- include/image-sparse.h | 2 +- 8 files changed, 100 insertions(+), 101 deletions(-)
common/fb_mmc.c +44 -36
@@ -74,7 +74,7 @@ static lbaint_t fb_mmc_sparse_reserve(struct sparse_storage *info,static void write_raw_image (struct blk_desc *dev_desc,disk_partition_t *info,const char *part_name,void *buffer, -unsigned int download_bytes) +unsigned int download_bytes,char *response) {lbaint_t blkcnt;lbaint_t blks;
@@ -85,7 +85,7 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info,if (blkcnt > info->size) {pr_err ("too large for partition: '%s'\n" , part_name); -fastboot_fail ("too large for partition" ); +fastboot_fail ("too large for partition" , response);return ; }
@@ -94,13 +94,13 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info, blks =blk_dwrite (dev_desc, info->start, blkcnt, buffer);if (blks != blkcnt) {pr_err ("failed writing to device %d\n" , dev_desc->devnum); -fastboot_fail ("failed writing to device" ); +fastboot_fail ("failed writing to device" , response);return ; }printf ("........ wrote " LBAFU " bytes to '%s'\n" , blkcnt * info->blksz, part_name); -fastboot_okay ("" ); +fastboot_okay ("" , response); }#ifdef CONFIG_ANDROID_BOOT_IMAGE
@@ -115,7 +115,8 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info,*/ static lbaint_t fb_mmc_get_boot_header (struct blk_desc *dev_desc,disk_partition_t *info, -struct andr_img_hdr *hdr) +struct andr_img_hdr *hdr, +char *response) {ulong sector_size;/* boot partition sector size */ lbaint_t hdr_sectors;/* boot image header sectors count */
@@ -126,7 +127,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc, hdr_sectors =DIV_ROUND_UP (sizeof (struct andr_img_hdr ), sector_size);if (hdr_sectors ==0 ) {pr_err ("invalid number of boot sectors: 0" ); -fastboot_fail ("invalid number of boot sectors: 0" ); +fastboot_fail ("invalid number of boot sectors: 0" , response);return 0 ; }
@@ -134,7 +135,8 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc, res =blk_dread (dev_desc, info->start, hdr_sectors, (void *)hdr);if (res != hdr_sectors) {pr_err ("cannot read header from boot partition" ); -fastboot_fail ("cannot read header from boot partition" ); +fastboot_fail ("cannot read header from boot partition" , + response);return 0 ; }
@@ -142,7 +144,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc, res =android_image_check_header (hdr);if (res !=0 ) {pr_err ("bad boot image magic" ); -fastboot_fail ("boot partition not initialized" ); +fastboot_fail ("boot partition not initialized" , response);return 0 ; }
@@ -160,7 +162,8 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc,*/ static int fb_mmc_update_zimage (struct blk_desc *dev_desc,void *download_buffer, -unsigned int download_bytes) +unsigned int download_bytes, +char *response) {uintptr_t hdr_addr;/* boot image header address */ struct andr_img_hdr *hdr;/* boot image header */
@@ -180,7 +183,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, res =part_get_info_by_name (dev_desc,BOOT_PARTITION_NAME , &info);if (res <0 ) {pr_err ("cannot find boot partition" ); -fastboot_fail ("cannot find boot partition" ); +fastboot_fail ("cannot find boot partition" , response);return -1 ; }
@@ -189,17 +192,18 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, hdr = (struct andr_img_hdr *)hdr_addr;/* Read boot image header */ - hdr_sectors =fb_mmc_get_boot_header (dev_desc, &info, hdr); + hdr_sectors =fb_mmc_get_boot_header (dev_desc, &info, hdr, response);if (hdr_sectors ==0 ) {pr_err ("unable to read boot image header" ); -fastboot_fail ("unable to read boot image header" ); +fastboot_fail ("unable to read boot image header" , response);return -1 ; }/* Check if boot image has second stage in it (we don't support it) */ if (hdr->second_size >0 ) {pr_err ("moving second stage is not supported yet" ); -fastboot_fail ("moving second stage is not supported yet" ); +fastboot_fail ("moving second stage is not supported yet" , + response);return -1 ; }
@@ -217,7 +221,8 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, ramdisk_buffer);if (res != ramdisk_sectors) {pr_err ("cannot read ramdisk from boot partition" ); -fastboot_fail ("cannot read ramdisk from boot partition" ); +fastboot_fail ("cannot read ramdisk from boot partition" , + response);return -1 ; }
@@ -226,7 +231,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, res =blk_dwrite (dev_desc, info.start, hdr_sectors, (void *)hdr);if (res ==0 ) {pr_err ("cannot writeback boot image header" ); -fastboot_fail ("cannot write back boot image header" ); +fastboot_fail ("cannot write back boot image header" , response);return -1 ; }
@@ -238,7 +243,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, download_buffer);if (res ==0 ) {pr_err ("cannot write new kernel" ); -fastboot_fail ("cannot write new kernel" ); +fastboot_fail ("cannot write new kernel" , response);return -1 ; }
@@ -250,18 +255,18 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, ramdisk_buffer);if (res ==0 ) {pr_err ("cannot write back original ramdisk" ); -fastboot_fail ("cannot write back original ramdisk" ); +fastboot_fail ("cannot write back original ramdisk" , response);return -1 ; }puts ("........ zImage was updated in boot partition\n" ); -fastboot_okay ("" ); +fastboot_okay ("" , response); return 0; }#endif void fb_mmc_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes) +unsigned int download_bytes,char *response) {struct blk_desc *dev_desc;disk_partition_t info;
@@ -269,7 +274,7 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, dev_desc =blk_get_dev ("mmc" ,CONFIG_FASTBOOT_FLASH_MMC_DEV );if (!dev_desc || dev_desc->type ==DEV_TYPE_UNKNOWN ) {pr_err ("invalid mmc device\n" ); -fastboot_fail ("invalid mmc device" ); +fastboot_fail ("invalid mmc device" , response);return ; }
@@ -280,16 +285,17 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,if (is_valid_gpt_buf (dev_desc, download_buffer)) {printf ("%s: invalid GPT - refusing to write to flash\n" , __func__); -fastboot_fail ("invalid GPT partition" ); +fastboot_fail ("invalid GPT partition" , response);return ; }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" , + response);return ; }printf ("........ success\n" ); -fastboot_okay ("" ); +fastboot_okay ("" , response); return; }#endif
@@ -300,30 +306,32 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,if (is_valid_dos_buf (download_buffer)) {printf ("%s: invalid MBR - refusing to write to flash\n" , __func__); -fastboot_fail ("invalid MBR partition" ); +fastboot_fail ("invalid MBR partition" , response);return ; }if (write_mbr_partition (dev_desc, download_buffer)) {printf ("%s: writing MBR partition failed\n" , __func__); -fastboot_fail ("writing MBR partition failed" ); +fastboot_fail ("writing MBR partition failed" , + response);return ; }printf ("........ success\n" ); -fastboot_okay ("" ); +fastboot_okay ("" , response); return; }#endif #ifdef CONFIG_ANDROID_BOOT_IMAGE if (strncasecmp (cmd,"zimage" ,6 ) ==0 ) { -fb_mmc_update_zimage (dev_desc, download_buffer, download_bytes); +fb_mmc_update_zimage (dev_desc, download_buffer, + download_bytes, response);return ; }#endif if (part_get_info_by_name_or_alias (dev_desc, cmd, &info) <0 ) {pr_err ("cannot find partition: '%s'\n" , cmd); -fastboot_fail ("cannot find partition" ); +fastboot_fail ("cannot find partition" , response);return ; }
@@ -344,14 +352,14 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, sparse.priv = &sparse_priv;write_sparse_image (&sparse, cmd, download_buffer, - download_bytes); + download_bytes, response); }else {write_raw_image (dev_desc, &info, cmd, download_buffer, - download_bytes); + download_bytes, response); } } -void fb_mmc_erase (const char *cmd) +void fb_mmc_erase (const char *cmd,char *response) {int ret;struct blk_desc *dev_desc;
@@ -361,21 +369,21 @@ void fb_mmc_erase(const char *cmd)if (mmc ==NULL ) {pr_err ("invalid mmc device" ); -fastboot_fail ("invalid mmc device" ); +fastboot_fail ("invalid mmc device" , response);return ; } dev_desc =blk_get_dev ("mmc" ,CONFIG_FASTBOOT_FLASH_MMC_DEV );if (!dev_desc || dev_desc->type ==DEV_TYPE_UNKNOWN ) {pr_err ("invalid mmc device" ); -fastboot_fail ("invalid mmc device" ); +fastboot_fail ("invalid mmc device" , response);return ; } ret =part_get_info_by_name_or_alias (dev_desc, cmd, &info);if (ret <0 ) {pr_err ("cannot find partition: '%s'" , cmd); -fastboot_fail ("cannot find partition" ); +fastboot_fail ("cannot find partition" , response);return ; }
@@ -394,11 +402,11 @@ void fb_mmc_erase(const char *cmd) blks =blk_derase (dev_desc, blks_start, blks_size);if (blks != blks_size) {pr_err ("failed erasing from device %d" , dev_desc->devnum); -fastboot_fail ("failed erasing from device" ); +fastboot_fail ("failed erasing from device" , response);return ; }printf ("........ erased " LBAFU " bytes from '%s'\n" , blks_size * info.blksz, cmd); -fastboot_okay ("" ); +fastboot_okay ("" , response); }
common/fb_nand.c +16 -15
@@ -32,7 +32,8 @@ __weak int board_fastboot_write_partition_setup(char *name)static int fb_nand_lookup (const char *partname,struct mtd_info **mtd, -struct part_info **part) +struct part_info **part, +char *response) {struct mtd_device *dev;int ret;
@@ -41,21 +42,21 @@ static int fb_nand_lookup(const char *partname, ret =mtdparts_init ();if (ret) {pr_err ("Cannot initialize MTD partitions\n" ); -fastboot_fail ("cannot init mtdparts" ); +fastboot_fail ("cannot init mtdparts" , response);return ret; } ret =find_dev_and_part (partname, &dev, &pnum, part);if (ret) {pr_err ("cannot find partition: '%s'" , partname); -fastboot_fail ("cannot find partition" ); +fastboot_fail ("cannot find partition" , response);return ret; }if (dev->id->type !=MTD_DEV_TYPE_NAND ) {pr_err ("partition '%s' is not stored on a NAND device" , partname); -fastboot_fail ("not a NAND device" ); +fastboot_fail ("not a NAND device" , response);return -EINVAL ; }
@@ -146,16 +147,16 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info, }void fb_nand_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes) +unsigned int download_bytes,char *response) {struct part_info *part;struct mtd_info *mtd =NULL ;int ret; - ret =fb_nand_lookup (cmd, &mtd, &part); + ret =fb_nand_lookup (cmd, &mtd, &part, response);if (ret) {pr_err ("invalid NAND device" ); -fastboot_fail ("invalid NAND device" ); +fastboot_fail ("invalid NAND device" , response);return ; }
@@ -181,7 +182,7 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer, sparse.priv = &sparse_priv;write_sparse_image (&sparse, cmd, download_buffer, - download_bytes); + download_bytes, response); }else {printf ("Flashing raw image at offset 0x%llx\n" , part->offset);
@@ -194,23 +195,23 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer, }if (ret) { -fastboot_fail ("error writing the image" ); +fastboot_fail ("error writing the image" , response);return ; } -fastboot_okay ("" ); +fastboot_okay ("" , response); } -void fb_nand_erase (const char *cmd) +void fb_nand_erase (const char *cmd,char *response) {struct part_info *part;struct mtd_info *mtd =NULL ;int ret; - ret =fb_nand_lookup (cmd, &mtd, &part); + ret =fb_nand_lookup (cmd, &mtd, &part, response);if (ret) {pr_err ("invalid NAND device" ); -fastboot_fail ("invalid NAND device" ); +fastboot_fail ("invalid NAND device" , response);return ; }
@@ -221,9 +222,9 @@ void fb_nand_erase(const char *cmd) ret =_fb_nand_erase (mtd, part);if (ret) {pr_err ("failed erasing from device %s" , mtd->name); -fastboot_fail ("failed erasing from device" ); +fastboot_fail ("failed erasing from device" , response);return ; } -fastboot_okay ("" ); +fastboot_okay ("" , response); }
common/image-sparse.c +20 -21
114 lines not on this page · raw message
drivers/usb/gadget/f_fastboot.c +13 -22
@@ -151,18 +151,16 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);static int strcmp_l1 (const char *s1,const char *s2); -static char *fb_response_str; - -void fastboot_fail (const char *reason) +void fastboot_fail (const char *reason,char *response) { -strncpy (fb_response_str,"FAIL\0" ,5 ); -strncat (fb_response_str, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); +strncpy (response,"FAIL\0" ,5 ); +strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); } -void fastboot_okay (const char *reason) +void fastboot_okay (const char *reason,char *response) { -strncpy (fb_response_str,"OKAY\0" ,5 ); -strncat (fb_response_str, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); +strncpy (response,"OKAY\0" ,5 ); +strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); }static void fastboot_complete (struct usb_ep *ep,struct usb_request *req)
@@ -598,18 +596,14 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req)return ; } -/* initialize the response buffer */ - fb_response_str = response; - -fastboot_fail ("no flash device defined" ); +fastboot_fail ("no flash device defined" , response);#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV fb_mmc_flash_write (cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR , - download_bytes); + download_bytes, response);#endif #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV -fb_nand_flash_write (cmd, - (void *)CONFIG_FASTBOOT_BUF_ADDR , - download_bytes); +fb_nand_flash_write (cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR , + download_bytes, response);#endif fastboot_tx_write_str (response); }
@@ -650,15 +644,12 @@ static void cb_erase(struct usb_ep *ep, struct usb_request *req)return ; } -/* initialize the response buffer */ - fb_response_str = response; - -fastboot_fail ("no flash device defined" ); +fastboot_fail ("no flash device defined" , response);#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV -fb_mmc_erase (cmd); +fb_mmc_erase (cmd, response);#endif #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV -fb_nand_erase (cmd); +fb_nand_erase (cmd, response);#endif fastboot_tx_write_str (response); }
include/fastboot.h +2 -2
@@ -16,7 +16,7 @@/* The 64 defined bytes plus \0 */ #define FASTBOOT_RESPONSE_LEN (64 + 1) -void fastboot_fail (const char *reason); -void fastboot_okay (const char *reason); +void fastboot_fail (const char *reason,char *response); +void fastboot_okay (const char *reason,char *response);#endif /* _FASTBOOT_H_ */
include/fb_mmc.h +2 -2
@@ -5,5 +5,5 @@*/ void fb_mmc_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes); -void fb_mmc_erase (const char *cmd); +unsigned int download_bytes,char *response); +void fb_mmc_erase (const char *cmd,char *response);
include/fb_nand.h +2 -2
@@ -6,5 +6,5 @@*/ void fb_nand_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes); -void fb_nand_erase (const char *cmd); +unsigned int download_bytes,char *response); +void fb_nand_erase (const char *cmd,char *response);
include/image-sparse.h +1 -1
@@ -37,4 +37,4 @@ static inline int is_sparse_image(void *buf) }void write_sparse_image (struct sparse_storage *info,const char *part_name, -void *data,unsigned sz); +void *data,unsigned int sz,char *response);
Signature · 1 line
2.7.4
RFC PATCH 1/5 dfu: Refactor fastboot_okay/fail to take response
Hi Alex,
Please change the subject prefix - i.e. dfu: is a totally different code.
Maybe fastboot would be more appropriate?
Quoted 3 lines
Add the response string as a parameter to fastboot_okay/fail, instead of modifying a global, to match the contract expected by the AOSP U-Boot code.
I suppose that this change is to make the u-boot mainline code matching the current Android?
Quoted 693 lines
Signed-off-by Alex Kiernan <[email protected]>---
common/fb_mmc.c | 80 ++++++++++++++++++++++------------------- common/fb_nand.c | 31 ++++++++-------- common/image-sparse.c | 41 +++++++++++---------- drivers/usb/gadget/f_fastboot.c | 35 +++++++----------- include/fastboot.h | 4 +-- include/fb_mmc.h | 4 +-- include/fb_nand.h | 4 +-- include/image-sparse.h | 2 +- 8 files changed, 100insertions(+), 101 deletions(-)
common/fb_mmc.c +4
-4@@ -74,7 +74,7 @@ static lbaint_t fb_mmc_sparse_reserve(structsparse_storage *info, static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info, const char *part_name, void *buffer, - unsigned int download_bytes) + unsigned int download_bytes, char *response) { lbaint_t blkcnt;lbaint_t blks;@@ -85,7 +85,7 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info, if (blkcnt > info->size) {pr_err ("too large for partition: '%s'\n" , part_name); -fastboot_fail ("too large for partition" ); +fastboot_fail ("too large for partition" , response);return ; }@@ -94,13 +94,13 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info, blks =blk_dwrite (dev_desc, info->start, blkcnt, buffer);if (blks != blkcnt) {pr_err ("failed writing to device %d\n" , dev_desc->devnum); -fastboot_fail ("failed writing to device" ); +fastboot_fail ("failed writing to device" , response);return ; }printf ("........ wrote " LBAFU " bytes to '%s'\n" , blkcnt * info->blksz, part_name); -fastboot_okay ("" ); +fastboot_okay ("" , response); }#ifdef
CONFIG_ANDROID_BOOT_IMAGEcommon/fb_mmc.c +2
-1@@ -115,7 +115,8 @@ static void write_raw_image(struct blk_desc*dev_desc, disk_partition_t *info, */ static lbaint_t fb_mmc_get_boot_header (struct blk_desc *dev_desc,disk_partition_t *info, -struct andr_img_hdr *hdr) +struct andr_img_hdr *hdr, +char *response) {ulong sector_size;/* boot partition sector size */
lbaint_thdr_sectors; /* boot image header
sectors count */ @@ -126,7 +127,7 @@ staticlbaint_tfb_mmc_get_boot_header(structblk_desc*dev_desc,hdr_sectors=DIV_ROUND_UP(sizeof(struct andr_img_hdr), sector_size); if (hdr_sectors== 0) {pr_err("invalid number of boot sectors: 0");common/fb_mmc.c +1
-1-fastboot_fail ("invalid number of boot sectors: 0" ); + fastboot_fail("invalid number of boot sectors: 0",response); return 0;
common/fb_mmc.c +2
-1}@@ -134,7 +135,8 @@ static lbaint_t fb_mmc_get_boot_header(structblk_desc *dev_desc, res =blk_dread (dev_desc, info->start, hdr_sectors, (void *)hdr);if (res != hdr_sectors) {pr_err ("cannot read header from boot partition" ); -fastboot_fail ("cannot read header from boot partition"); + fastboot_fail("cannot read header from boot partition", + response);return 0 ;common/fb_mmc.c +1
-1}@@ -142,7 +144,7 @@ static lbaint_t fb_mmc_get_boot_header(structblk_desc *dev_desc, res =android_image_check_header (hdr);if (res !=0 ) {pr_err ("bad boot image magic" ); -fastboot_fail ("boot partition not initialized" ); +fastboot_fail ("boot partition not initialized" , response);return 0 ; }@@ -160,7 +162,8 @@ static lbaint_t fb_mmc_get_boot_header(struct
blk_desc*dev_desc, */
static int fb_mmc_update_zimage(structblk_desc*dev_desc,common/fb_mmc.c +2
-1void *download_buffer, - unsigned int download_bytes) + unsigned int download_bytes, + char *response) { uintptr_t hdr_addr; /* boot imageheader address */ struct
andr_img_hdr*hdr; /* boot
image header */ @@ -180,7 +183,7 @@ static int fb_mmc_update_zimage(structblk_desc*dev_desc, res =part_get_info_by_name(dev_desc, BOOT_PARTITION_NAME, &info); if (res < 0) {pr_err("cannot find boot partition");common/fb_mmc.c +1
-1-fastboot_fail ("cannot find boot partition" ); + fastboot_fail("cannot find boot partition",response); return -1;
common/fb_mmc.c +4
-3}@@ -189,17 +192,18 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, hdr = (struct andr_img_hdr *)hdr_addr;/* Read boot image header */ - hdr_sectors =fb_mmc_get_boot_header (dev_desc, &info, hdr); + hdr_sectors =fb_mmc_get_boot_header (dev_desc, &info, hdr, response);if (hdr_sectors ==0 ) {pr_err ("unable to read boot image header" ); -fastboot_fail ("unable to read boot image header" ); +fastboot_fail ("unable to read boot image header" , response);return -1 ; }/* Check if boot image has second stage in it (we don't support it) */ if (hdr->second_size >0 ) {pr_err ("moving second stage is not supported yet" ); -fastboot_fail ("moving second stage is not supported yet"); + fastboot_fail("moving second stage is not supported yet", + response);return -1 ;common/fb_mmc.c +2
-1}@@ -217,7 +221,8 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, ramdisk_buffer);if (res != ramdisk_sectors) {pr_err ("cannot read ramdisk from boot partition" ); -fastboot_fail ("cannot read ramdisk from boot partition"); + fastboot_fail("cannot read ramdisk from boot partition", + response);return -1 ;common/fb_mmc.c +5
-5}@@ -226,7 +231,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, res =blk_dwrite (dev_desc, info.start, hdr_sectors, (void *)hdr);if (res ==0 ) {pr_err ("cannot writeback boot image header" ); -fastboot_fail ("cannot write back boot image header" ); +fastboot_fail ("cannot write back boot image header" , response);return -1 ; }@@ -238,7 +243,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, download_buffer);if (res ==0 ) {pr_err ("cannot write new kernel" ); -fastboot_fail ("cannot write new kernel" ); +fastboot_fail ("cannot write new kernel" , response);return -1 ; }@@ -250,18 +255,18 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, ramdisk_buffer);if (res ==0 ) {pr_err ("cannot write back original ramdisk" ); -fastboot_fail ("cannot write back original ramdisk" ); +fastboot_fail ("cannot write back original ramdisk" , response);return -1 ; }puts ("........ zImage was updated in boot partition\n" ); -fastboot_okay ("" ); +fastboot_okay ("" , response); return 0; }#endif void fb_mmc_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes) +unsigned int download_bytes,char *response) {struct blk_desc *dev_desc;disk_partition_t info;@@ -269,7 +274,7 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, dev_desc = blk_get_dev("mmc",
CONFIG_FASTBOOT_FLASH_MMC_DEV); if (!dev_desc ||dev_desc->type==DEV_TYPE_UNKNOWN) {pr_err("invalid mmc device\n");common/fb_mmc.c +5
-4-fastboot_fail ("invalid mmc device" ); +fastboot_fail ("invalid mmc device" , response);return ; }@@ -280,16 +285,17 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, if (is_valid_gpt_buf(dev_desc, download_buffer)) { printf("%s: invalid GPT - refusing to write to flash\n", __func__); - fastboot_fail("invalid GPT partition"); + fastboot_fail("invalid GPT partition" , response); return; }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", + response);return ; }printf ("........ success\n" ); -fastboot_okay ("" ); +fastboot_okay ("" , response);common/fb_mmc.c +7
-5return; }#endif @@ -300,30 +306,32 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, if (is_valid_dos_buf(download_buffer)) { printf("%s: invalid MBR - refusing to write to flash\n", __func__); - fastboot_fail("invalid MBR partition"); + fastboot_fail("invalid MBR partition" , response); return; }if (write_mbr_partition (dev_desc, download_buffer)) {printf ("%s: writing MBR partition failed\n" , __func__); -fastboot_fail ("writing MBR partition failed"); + fastboot_fail("writing MBR partition failed" , + response);return ; }printf ("........ success\n" ); -fastboot_okay ("" ); +fastboot_okay ("" , response);return ; }#endif #ifdef CONFIG_ANDROID_BOOT_IMAGE if (strncasecmp (cmd,"zimage" ,6 ) ==0 ) { -fb_mmc_update_zimage (dev_desc, download_buffer, download_bytes); +fb_mmc_update_zimage (dev_desc, download_buffer, + download_bytes, response);return ; }#endif if (part_get_info_by_name_or_alias (dev_desc, cmd, &info) <0 ) {pr_err ("cannot find partition: '%s'\n" , cmd); -fastboot_fail ("cannot find partition" ); +fastboot_fail ("cannot find partition" , response);common/fb_mmc.c +3
-3return ; }@@ -344,14 +352,14 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, sparse.priv = &sparse_priv;write_sparse_image (&sparse, cmd, download_buffer, - download_bytes); + download_bytes, response); }else {write_raw_image (dev_desc, &info, cmd, download_buffer, - download_bytes); + download_bytes, response); } } -void fb_mmc_erase (const char *cmd) +void fb_mmc_erase (const char *cmd,char *response) {int ret;common/fb_mmc.c +5
-5struct blk_desc *dev_desc;@@ -361,21 +369,21 @@ void fb_mmc_erase(const char *cmd)if (mmc ==NULL ) {pr_err ("invalid mmc device" ); -fastboot_fail ("invalid mmc device" ); +fastboot_fail ("invalid mmc device" , response);return ; } dev_desc =blk_get_dev ("mmc" ,CONFIG_FASTBOOT_FLASH_MMC_DEV );if (!dev_desc || dev_desc->type ==DEV_TYPE_UNKNOWN ) {pr_err ("invalid mmc device" ); -fastboot_fail ("invalid mmc device" ); +fastboot_fail ("invalid mmc device" , response);return ; } ret =part_get_info_by_name_or_alias (dev_desc, cmd, &info);if (ret <0 ) {pr_err ("cannot find partition: '%s'" , cmd); -fastboot_fail ("cannot find partition" ); +fastboot_fail ("cannot find partition" , response);return ; }@@ -394,11 +402,11 @@ void fb_mmc_erase(const char *cmd) blks =blk_derase (dev_desc, blks_start, blks_size);if (blks != blks_size) {pr_err ("failed erasing from device %d" , dev_desc->devnum); -fastboot_fail ("failed erasing from device" ); +fastboot_fail ("failed erasing from device" , response);return ; }printf ("........ erased " LBAFU " bytes from '%s'\n" , blks_size * info.blksz, cmd); -fastboot_okay ("" ); +fastboot_okay ("" , response);}
common/fb_nand.c +16
-15@@ -32,7 +32,8 @@ __weak int board_fastboot_write_partition_setup(char *name)static int fb_nand_lookup (const char *partname,struct mtd_info **mtd, -struct part_info **part) +struct part_info **part, +char *response) {struct mtd_device *dev;int ret;@@ -41,21 +42,21 @@ static int fb_nand_lookup(const char *partname, ret =mtdparts_init ();if (ret) {pr_err ("Cannot initialize MTD partitions\n" ); -fastboot_fail ("cannot init mtdparts" ); +fastboot_fail ("cannot init mtdparts" , response);return ret; } ret =find_dev_and_part (partname, &dev, &pnum, part);if (ret) {pr_err ("cannot find partition: '%s'" , partname); -fastboot_fail ("cannot find partition" ); +fastboot_fail ("cannot find partition" , response);return ret; }if (dev->id->type !=MTD_DEV_TYPE_NAND ) {pr_err ("partition '%s' is not stored on a NAND device", partname); -fastboot_fail ("not a NAND device" ); +fastboot_fail ("not a NAND device" , response);return -EINVAL ; }@@ -146,16 +147,16 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info, }void fb_nand_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes) +unsigned int download_bytes,char *response) {struct part_info *part;struct mtd_info *mtd =NULL ;int ret; - ret =fb_nand_lookup (cmd, &mtd, &part); + ret =fb_nand_lookup (cmd, &mtd, &part, response);if (ret) {pr_err ("invalid NAND device" ); -fastboot_fail ("invalid NAND device" ); +fastboot_fail ("invalid NAND device" , response);return ; }@@ -181,7 +182,7 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer, sparse.priv = &sparse_priv;write_sparse_image (&sparse, cmd, download_buffer, - download_bytes); + download_bytes, response); }else {printf ("Flashing raw image at offset 0x%llx\n" , part->offset);@@ -194,23 +195,23 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer, }if (ret) { -fastboot_fail ("error writing the image" ); +fastboot_fail ("error writing the image" , response);return ; } -fastboot_okay ("" ); +fastboot_okay ("" , response); } -void fb_nand_erase (const char *cmd) +void fb_nand_erase (const char *cmd,char *response) {struct part_info *part;struct mtd_info *mtd =NULL ;int ret; - ret =fb_nand_lookup (cmd, &mtd, &part); + ret =fb_nand_lookup (cmd, &mtd, &part, response);if (ret) {pr_err ("invalid NAND device" ); -fastboot_fail ("invalid NAND device" ); +fastboot_fail ("invalid NAND device" , response);return ; }@@ -221,9 +222,9 @@ void fb_nand_erase(const char *cmd) ret =_fb_nand_erase (mtd, part);if (ret) {pr_err ("failed erasing from device %s" , mtd->name); -fastboot_fail ("failed erasing from device" ); +fastboot_fail ("failed erasing from device" , response);return ; } -fastboot_okay ("" ); +fastboot_okay ("" , response); }common/image-sparse.c +4
-4@@ -51,7 +51,7 @@void write_sparse_image (struct sparse_storage *info,const char *part_name, -void *data,unsigned sz) +void *data,unsigned int sz,char *response) {lbaint_t blk;lbaint_t blkcnt;@@ -101,7 +101,7 @@ void write_sparse_image(if (offset) {printf ("%s: Sparse image block size issue [%u]\n" , __func__, sparse_header->blk_sz); -fastboot_fail ("sparse image block size issue" ); +fastboot_fail ("sparse image block size issue" , response);return ; }@@ -136,8 +136,8 @@ void write_sparse_image(case CHUNK_TYPE_RAW :if (chunk_header->total_sz != (sparse_header->chunk_hdr_sz + chunk_data_sz)) { - fastboot_fail( - "Bogus chunk size for chunk type Raw"); + fastboot_fail("Bogus chunk size for chunk type Raw", + response);common/image-sparse.c +2
-2return ; }@@ -145,8 +145,8 @@ void write_sparse_image(printf ( "%s: Request would exceed partition size!\n", __func__); - fastboot_fail( -"Request would exceed partition size!"); + fastboot_fail("Request would exceed partition size!", + response);return ;common/image-sparse.c +3
-4}@@ -156,8 +156,7 @@ void write_sparse_image(printf ("%s: %s" LBAFU " [" LBAFU "]\n" , __func__,"Write failed, block #" , blk, blks); -fastboot_fail ( -"flash write failure" ); +fastboot_fail ("flash write failure" , response);return ; } blk += blks;@@ -169,8 +168,8 @@ void write_sparse_image(case CHUNK_TYPE_FILL :if (chunk_header->total_sz != (sparse_header->chunk_hdr_sz +sizeof (uint32_t ))) { - fastboot_fail( - "Bogus chunk size for chunk type FILL"); + fastboot_fail("Bogus chunk size for chunk type FILL", + response);common/image-sparse.c +2
-2return ; }@@ -180,8 +179,8 @@ void write_sparse_image( info->blksz * fill_buf_num_blks, ARCH_DMA_MINALIGN));if (!fill_buf) { -fastboot_fail ( -"Malloc failed for: CHUNK_TYPE_FILL"); + fastboot_fail("Malloc failed for: CHUNK_TYPE_FILL", + response);return ;common/image-sparse.c +2
-2}@@ -198,8 +197,8 @@ void write_sparse_image(printf ( "%s: Request would exceed partition size!\n", __func__); - fastboot_fail( -"Request would exceed partition size!"); + fastboot_fail("Request would exceed partition size!", + response);return ;common/image-sparse.c +2
-2}@@ -214,8 +213,8 @@ void write_sparse_image( __func__,"Write failed, block #", blk, j); -fastboot_fail ( -"flash write failure"); + fastboot_fail("flash write failure", + response);free (fill_buf);common/image-sparse.c +2
-2return ; }@@ -235,8 +234,8 @@ void write_sparse_image(case CHUNK_TYPE_CRC32 :if (chunk_header->total_sz != sparse_header->chunk_hdr_sz) { - fastboot_fail( - "Bogus chunk size for chunk type Dont Care"); + fastboot_fail("Bogus chunk size for chunk type Dont Care", + response);return ;common/image-sparse.c +2
-2} total_blocks += chunk_header->chunk_sz;@@ -246,7 +245,7 @@ void write_sparse_image(default :printf ("%s: Unknown chunk type: %x\n" , __func__, chunk_header->chunk_type); -fastboot_fail ("Unknown chunk type" ); +fastboot_fail ("Unknown chunk type" , response);return ; } }@@ -256,9 +255,9 @@ void write_sparse_image(printf ("........ wrote %u bytes to '%s'\n" , bytes_written, part_name);if (total_blocks != sparse_header->total_blks) -fastboot_fail ("sparse image write failure" ); + fastboot_fail("sparse image write failure",response); else
common/image-sparse.c +1
-1-fastboot_okay ("" ); +fastboot_okay ("" , response);return ; }(quoted diff) +0
-0
b/drivers/usb/gadget/f_fastboot.cindex 7acffb6..6ae1d97 100644drivers/usb/gadget/f_fastboot.c +6
-8@@ -151,18 +151,16 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req); static int strcmp_l1(const char *s1,const char *s2); -static char *fb_response_str; - -void fastboot_fail (const char *reason) +void fastboot_fail (const char *reason,char *response) { -strncpy (fb_response_str,"FAIL\0" ,5 ); -strncat (fb_response_str, reason,FASTBOOT_RESPONSE_LEN -4 - 1); +strncpy (response,"FAIL\0" ,5 ); +strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); } -void fastboot_okay (const char *reason) +void fastboot_okay (const char *reason,char *response) { -strncpy (fb_response_str,"OKAY\0" ,5 ); -strncat (fb_response_str, reason,FASTBOOT_RESPONSE_LEN -4 - 1); +strncpy (response,"OKAY\0" ,5 ); +strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); }static void fastboot_complete(struct
usb_ep*ep, structusb_request
*req) @@ -598,18 +596,14 @@ static voidcb_flash(struct usb_ep *ep, struct usb_request *req)return;drivers/usb/gadget/f_fastboot.c +7
-14} -/* initialize the response buffer */ - fb_response_str = response; - -fastboot_fail ("no flash device defined" ); +fastboot_fail ("no flash device defined" , response);#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV fb_mmc_flash_write (cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR , - download_bytes); + download_bytes, response);#endif #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV -fb_nand_flash_write (cmd, - (void *)CONFIG_FASTBOOT_BUF_ADDR , - download_bytes); +fb_nand_flash_write (cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR , + download_bytes, response);#endif fastboot_tx_write_str (response); }@@ -650,15 +644,12 @@ static void cb_erase(struct usb_ep *ep, struct usb_request *req) return; } -/* initialize the response buffer */ - fb_response_str = response; - -fastboot_fail ("no flash device defined" ); +fastboot_fail ("no flash device defined" , response);#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV -fb_mmc_erase (cmd); +fb_mmc_erase (cmd, response);#endif #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV -fb_nand_erase (cmd); +fb_nand_erase (cmd, response);#endif fastboot_tx_write_str (response); }include/fastboot.h +2
-2@@ -16,7 +16,7 @@/* The 64 defined bytes plus \0 */ #define FASTBOOT_RESPONSE_LEN (64 + 1) -void fastboot_fail (const char *reason); -void fastboot_okay (const char *reason); +void fastboot_fail (const char *reason,char *response); +void fastboot_okay (const char *reason,char *response);#endif /* _FASTBOOT_H_ */ include/fb_mmc.h +2
-2@@ -5,5 +5,5 @@*/ void fb_mmc_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes); -void fb_mmc_erase (const char *cmd); +unsigned int download_bytes,char *response); +void fb_mmc_erase (const char *cmd,char *response);include/fb_nand.h +1
-2@@ -6,5 +6,5 @@*/ void fb_nand_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes); -void fb_nand_erase (const char *cmd); + unsigned int download_bytes, char*response); +void
fb_nand_erase(const char *cmd, char *response);include/image-sparse.h +0
-0
include/image-sparse.h static inline int is_sparse_image(void *buf) · line 40
Quoted 6 lines
include/image-sparse.h +1
-1@@ -37,4 +37,4 @@ static inline int is_sparse_image(void *buf) }void write_sparse_image (struct sparse_storage *info,const char *part_name, -void *data,unsigned sz); +void *data,unsigned int sz,char *response);
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180425/6e3c2fa3/attachment.sig>
RFC PATCH 1/5 dfu: Refactor fastboot_okay/fail to take response
Quoted 7 lines · Lukasz Majewski
Hi Alex,
Please change the subject prefix - i.e. dfu: is a totally different code.
Maybe fastboot would be more appropriate?
Sorry, was trying to pick something in the right kind of space/known to git-mailrc, but I'll change that.
Quoted 7 lines
Quoted 3 lines
Add the response string as a parameter to fastboot_okay/fail, instead of modifying a global, to match the contract expected by the AOSP U-Boot code.
I suppose that this change is to make the u-boot mainline code matching the current Android?
Yes. When you get to the guts of it, the interface that was there, was a bit odd - callers had to initialise the global fb_response_str before calling into the rest of the fastboot code.
Signature · 1 line
Alex Kiernan
RFC PATCH 2/5 dfu: Extract fastboot_okay/fail to fb_common.c
In reply to Alex KiernanAdded common/fb_common.c, where fastboot_okay/fail are implemented so we can call them from a non-USB implementation.
---
common/Makefile | 4 ++++ common/fb_common.c | 26 ++++++++++++++++++++++++++ drivers/usb/gadget/f_fastboot.c | 13 ------------- 3 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 common/fb_common.c
common/Makefile +4 -0
@@ -124,6 +124,10 @@ endif endif endif +ifneq ($(or $(CONFIG_USB_FUNCTION_FASTBOOT),$(CONFIG_UDP_FUNCTION_FASTBOOT)),) +obj-y += fb_common.o +endif + ifdef CONFIG_CMD_EEPROM_LAYOUT obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o endif
common/fb_common.c new file +26 -0
@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2008 - 2009 +* Windriver, <www.windriver.com> +* Tom Rix <[email protected]> +* +* Copyright 2011 Sebastian Andrzej Siewior <[email protected]> +* +* Copyright 2014 Linaro, Ltd. +* Rob Herring <[email protected]> +*/ + +#include <common.h> +#include <fastboot.h> + +void fastboot_fail (const char *reason,char *response) +{ +strncpy (response,"FAIL\0" ,5 ); +strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); +} + +void fastboot_okay (const char *reason,char *response) +{ +strncpy (response,"OKAY\0" ,5 ); +strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); +}
drivers/usb/gadget/f_fastboot.c +0 -13
@@ -150,19 +150,6 @@ static struct usb_gadget_strings *fastboot_strings[] = {static void rx_handler_command (struct usb_ep *ep,struct usb_request *req);static int strcmp_l1 (const char *s1,const char *s2); - -void fastboot_fail (const char *reason,char *response) -{ -strncpy (response,"FAIL\0" ,5 ); -strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); -} - -void fastboot_okay (const char *reason,char *response) -{ -strncpy (response,"OKAY\0" ,5 ); -strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); -} -static void fastboot_complete (struct usb_ep *ep,struct usb_request *req) {int status = req->status;
Signature · 1 line
2.7.4
RFC PATCH 2/5 dfu: Extract fastboot_okay/fail to fb_common.c
Hi Alex,
Quoted 42 lines
Added
common/fb_common.c, where fastboot_okay/fail are implemented so we can call them from a non-USB implementation.Signed-off-by Alex Kiernan <[email protected]>---
common/Makefile | 4 ++++ common/fb_common.c | 26 ++++++++++++++++++++++++++ drivers/usb/gadget/f_fastboot.c | 13 ------------- 3 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 common/fb_common.ccommon/Makefile +3
-0@@ -124,6 +124,10 @@ endif endif endif +ifneq ($(or $(CONFIG_USB_FUNCTION_FASTBOOT),$(CONFIG_UDP_FUNCTION_FASTBOOT)),) +obj-y += fb_common.o +endif + ifdef CONFIG_CMD_EEPROM_LAYOUT obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o endifcommon/fb_common.c new file +9
-0@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2008 - 2009 +* Windriver, <www.windriver.com> +* Tom Rix <[email protected]> +* +* Copyright 2011 Sebastian Andrzej Siewior <[email protected]> +* +* Copyright 2014 Linaro, Ltd.
common/fb_common.c line 19
Quoted 10 lines
common/fb_common.c new file +10
-0+* Rob Herring <[email protected]> +*/ + +#include <common.h> +#include <fastboot.h> + +void fastboot_fail (const char *reason,char *response) +{ +strncpy (response,"FAIL\0" ,5 ); +strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 );
^^^^^^^ This looks a bit "hand-crafted". I suppose that it is to prevent not adding "reason" when response is large ?
Quoted 21 lines
common/fb_common.c new file +7
-0+} + +void fastboot_okay (const char *reason,char *response) +{ +strncpy (response,"OKAY\0" ,5 ); +strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); +}(quoted diff) +0
-0
b/drivers/usb/gadget/f_fastboot.cindex 6ae1d97..fda4505 100644drivers/usb/gadget/f_fastboot.c +0
-6@@ -150,19 +150,6 @@ static struct usb_gadget_strings *fastboot_strings[] = { static void rx_handler_command(struct usb_ep *ep,struct usb_request *req);static int strcmp_l1 (const char *s1,const char *s2); - -void fastboot_fail (const char *reason,char *response) -{ -strncpy (response,"FAIL\0" ,5 ); -strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); -}
drivers/usb/gadget/f_fastboot.c static struct usb_gadget_strings · line 155
Quoted 10 lines
drivers/usb/gadget/f_fastboot.c +0
-7- -void fastboot_okay (const char *reason,char *response) -{ -strncpy (response,"OKAY\0" ,5 ); -strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); -} -static void fastboot_complete (struct usb_ep *ep,struct usb_request *req) {int status = req->status;
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180425/5a77ee0b/attachment.sig>
RFC PATCH 2/5 dfu: Extract fastboot_okay/fail to fb_common.c
Quoted 50 lines · Lukasz Majewski
Hi Alex,
Quoted 48 lines
Added
common/fb_common.c, where fastboot_okay/fail are implemented so we can call them from a non-USB implementation.Signed-off-by Alex Kiernan <[email protected]>---
common/Makefile | 4 ++++ common/fb_common.c | 26 ++++++++++++++++++++++++++ drivers/usb/gadget/f_fastboot.c | 13 ------------- 3 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 common/fb_common.ccommon/Makefile +3
-0@@ -124,6 +124,10 @@ endif endif endif +ifneq ($(or $(CONFIG_USB_FUNCTION_FASTBOOT),$(CONFIG_UDP_FUNCTION_FASTBOOT)),) +obj-y += fb_common.o +endif + ifdef CONFIG_CMD_EEPROM_LAYOUT obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o endifcommon/fb_common.c new file +15
-0@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2008 - 2009 +* Windriver, <www.windriver.com> +* Tom Rix <[email protected]> +* +* Copyright 2011 Sebastian Andrzej Siewior <[email protected]> +* +* Copyright 2014 Linaro, Ltd. +* Rob Herring <[email protected]> +*/ + +#include <common.h> +#include <fastboot.h> +
Quoted 8 lines
common/fb_common.c line 19
Quoted 4 lines
common/fb_common.c new file +4
-0+void fastboot_fail (const char *reason,char *response) +{ +strncpy (response,"FAIL\0" ,5 ); +strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 );^^^^^^^ This looks a bit "hand-crafted". I suppose that it is to prevent not adding "reason" when response is large ?
It is a bit, isn't it. Obviously it was a simple cut & paste refactor, but I can't think of any reason not to turn it into an snprintf.
Signature · 1 line
Alex Kiernan
RFC PATCH 3/5 net: dfu: Merge AOSP UDP fastboot
In reply to Alex KiernanMerge UDP fastboot support from AOSP:
https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8
---
cmd/fastboot.c | 32 ++- cmd/fastboot/Kconfig | 18 +- cmd/net.c | 6 + common/fb_common.c | 18 ++ common/fb_mmc.c | 34 +++- include/fastboot.h | 13 ++ include/net.h | 6 +- include/net/fastboot.h | 27 +++ net/Makefile | 1 + net/fastboot.c | 542 +++++++++++++++++++++++++++++++++++++++++++++++++ net/net.c | 9 + 11 files changed, 692 insertions(+), 14 deletions(-) create mode 100644 include/net/fastboot.h create mode 100644 net/fastboot.c
cmd/fastboot.c +27 -5
@@ -11,18 +11,37 @@#include <command.h> #include <console.h> #include <g_dnl.h> +#include <net.h> #include <usb.h> static int do_fastboot (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) { +#ifdef CONFIG_USB_FUNCTION_FASTBOOT int controller_index;char *usb_controller;int ret; +#endif if (argc <2 )return CMD_RET_USAGE ; - usb_controller = argv[1 ]; +if (!strcmp (argv[1 ],"udp" )) { +#ifndef CONFIG_UDP_FUNCTION_FASTBOOT +pr_err ("Fastboot UDP not enabled\n" ); +return -1 ; +#else +return do_fastboot_udp (cmdtp, flag, argc, argv); +#endif + } + +if (strcmp (argv[1 ],"usb" ) || argc <3 ) +return CMD_RET_USAGE ; + +#ifndef CONFIG_USB_FUNCTION_FASTBOOT +pr_err ("Fastboot USB not enabled\n" ); +return -1 ; +#else + usb_controller = argv[2 ]; controller_index =simple_strtoul (usb_controller,NULL ,0 ); ret =board_usb_init (controller_index,USB_INIT_DEVICE );
@@ -59,11 +78,14 @@ exit:board_usb_cleanup (controller_index,USB_INIT_DEVICE );return ret; +#endif }U_BOOT_CMD ( - fastboot,2 ,1 , do_fastboot, -"use USB Fastboot protocol" , -"<USB_controller>\n" -" - run as a fastboot usb device" + fastboot,3 ,1 , do_fastboot, +"use USB or UDP Fastboot protocol" , +"[usb,udp] <USB_controller>\n" +" - run as a fastboot usb or udp device\n" +" usb: specify <USB_controller>\n" +" udp: requires ip_addr set and ethernet initialized\n" );
cmd/fastboot/Kconfig +13 -5
@@ -16,17 +16,25 @@ config USB_FUNCTION_FASTBOOT help This enables the USB part of the fastboot gadget. +config UDP_FUNCTION_FASTBOOT + select NET + bool "Enable fastboot protocol over UDP" + help + This enables the fastboot protocol over UDP. + config CMD_FASTBOOT bool "Enable FASTBOOT command" + depends on USB_FUNCTION_FASTBOOT || UDP_FUNCTION_FASTBOOT help This enables the command "fastboot" which enables the Android - fastboot mode for the platform's USB device. Fastboot is a USB - protocol for downloading images, flashing and device control - used on Android devices. + fastboot mode for the platform. Fastboot is a protocol for + downloading images, flashing and device control used on + Android devices. Fastboot requires either network stack + enabled or support for acting as a USB device. See doc/README.android-fastboot for more information. -if USB_FUNCTION_FASTBOOT +if USB_FUNCTION_FASTBOOT || UDP_FUNCTION_FASTBOOT config FASTBOOT_BUF_ADDR hex "Define FASTBOOT buffer address"
@@ -129,6 +137,6 @@ config FASTBOOT_MBR_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 +endif # USB_FUNCTION_FASTBOOT || UDP_FUNCTION_FASTBOOT endif # FASTBOOT
cmd/net.c +6 -0
@@ -74,6 +74,12 @@ U_BOOT_CMD( );#endif +#ifdef CONFIG_UDP_FUNCTION_FASTBOOT +int do_fastboot_udp (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +return netboot_common (FASTBOOT , cmdtp, argc, argv); +} +#endif #ifdef CONFIG_CMD_RARP int do_rarpb (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[])
common/fb_common.c +18 -0
@@ -12,6 +12,9 @@#include <common.h> #include <fastboot.h> +#ifdef CONFIG_UDP_FUNCTION_FASTBOOT +#include <net/fastboot.h> +#endif void fastboot_fail (const char *reason,char *response) {
@@ -24,3 +27,18 @@ void fastboot_okay(const char *reason, char *response)strncpy (response,"OKAY\0" ,5 );strncat (response, reason,FASTBOOT_RESPONSE_LEN -4 -1 ); } + +void timed_send_info (ulong *start,const char *msg) +{ +#ifdef CONFIG_UDP_FUNCTION_FASTBOOT +/* Initialize timer */ +if (*start ==0 ) + *start =get_timer (0 ); +ulong time =get_timer (*start); +/* Send INFO packet to host every 30 seconds */ +if (time >=30000 ) { + *start =get_timer (0 ); +fastboot_send_info (msg); + } +#endif +}
common/fb_mmc.c +31 -3
@@ -29,6 +29,9 @@#define CONFIG_FASTBOOT_MBR_NAME "mbr"#endif +#define FASTBOOT_MAX_BLK_WRITE 16384 +static ulong timer; +#define BOOT_PARTITION_NAME "boot"struct fb_mmc_sparse {
@@ -57,13 +60,38 @@ static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,return ret; } +static lbaint_t fb_mmc_blk_write (struct blk_desc *block_dev,lbaint_t start, +lbaint_t blkcnt,const void *buffer) +{ +lbaint_t blk = start; +lbaint_t blks_written; +lbaint_t cur_blkcnt; +lbaint_t blks =0 ; +int i; + +for (i =0 ; i < blkcnt; i +=FASTBOOT_MAX_BLK_WRITE ) { + cur_blkcnt =min ((int )blkcnt - i,FASTBOOT_MAX_BLK_WRITE ); +if (!buffer) { +timed_send_info (&timer,"writing" ); + blks_written =blk_dwrite (block_dev, blk, cur_blkcnt, + buffer + (i * block_dev->blksz)); + }else { +timed_send_info (&timer,"erasing" ); + blks_written =blk_derase (block_dev, blk, cur_blkcnt); + } + blk += blks_written; + blks += blks_written; + } +return blks; +} +static lbaint_t fb_mmc_sparse_write (struct sparse_storage *info,lbaint_t blk,lbaint_t blkcnt,const void *buffer) {struct fb_mmc_sparse *sparse = info->priv;struct blk_desc *dev_desc = sparse->dev_desc; -return blk_dwrite (dev_desc, blk, blkcnt, buffer); +return fb_mmc_blk_write (dev_desc, blk, blkcnt, buffer); } static lbaint_t fb_mmc_sparse_reserve(struct sparse_storage *info,
@@ -91,7 +119,7 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info,puts ("Flashing Raw Image\n" ); - blks =blk_dwrite (dev_desc, info->start, blkcnt, buffer); + blks =fb_mmc_blk_write (dev_desc, info->start, blkcnt, buffer);if (blks != blkcnt) {pr_err ("failed writing to device %d\n" , dev_desc->devnum);fastboot_fail ("failed writing to device" , response);
@@ -399,7 +427,7 @@ void fb_mmc_erase(const char *cmd, char *response)printf ("Erasing blocks " LBAFU " to " LBAFU " due to alignment\n" , blks_start, blks_start + blks_size); - blks =blk_derase (dev_desc, blks_start, blks_size); + blks =fb_mmc_blk_write (dev_desc, blks_start, blks_size,NULL );if (blks != blks_size) {pr_err ("failed erasing from device %d" , dev_desc->devnum);fastboot_fail ("failed erasing from device" , response);
include/fastboot.h +13 -0
@@ -19,4 +19,17 @@void fastboot_fail (const char *reason,char *response);void fastboot_okay (const char *reason,char *response); +/** +* Send an INFO packet during long commands based on timer. If +* CONFIG_UDP_FUNCTION_FASTBOOT is defined, an INFO packet is sent +* if the time is 30 seconds after start. Else, noop. +* +* TODO: Handle the situation where both UDP and USB fastboot are +* enabled. +* +* @param start: Time since last INFO packet was sent. +* @param msg: String describing the reason for waiting +*/ +void timed_send_info (ulong *start,const char *msg); +#endif /* _FASTBOOT_H_ */
include/net.h +5 -1
@@ -535,7 +535,7 @@ extern int net_restart_wrap; /* Tried all network devices */enum proto_t {BOOTP ,RARP ,ARP ,TFTPGET ,DHCP ,PING ,DNS ,NFS ,CDP ,NETCONS ,SNTP , -TFTPSRV ,TFTPPUT ,LINKLOCAL +TFTPSRV ,TFTPPUT ,LINKLOCAL ,FASTBOOT };extern char net_boot_file_name[1024 ];/* Boot File name */
@@ -549,6 +549,10 @@ extern char *net_dns_resolve; /* The host to resolve */extern char *net_dns_env_var;/* the env var to put the ip into */ #endif +#if defined(CONFIG_UDP_FUNCTION_FASTBOOT ) +int do_fastboot_udp (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +#endif +#if defined(CONFIG_CMD_PING )extern struct in_addr net_ping_ip;/* the ip address to ping */ #endif
include/net/fastboot.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-2-Clause +* +* Copyright (C) 2016 The Android Open Source Project +*/ + +#ifndef __NET_FASTBOOT_H__ +#define __NET_FASTBOOT_H__ + +/**********************************************************************/ +/* +* Global functions and variables. +*/ + +/** +* Wait for incoming fastboot comands. +*/ +void fastboot_start_server (void ); +/** +* Send an INFO packet during long commands +* +* @param msg: String describing the reason for waiting +*/ +void fastboot_send_info (const char *msg); + +/**********************************************************************/ + +#endif /* __NET_FASTBOOT_H__ */
net/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-$(CONFIG_CMD_PING) += ping.o obj-$(CONFIG_CMD_RARP) += rarp.o obj-$(CONFIG_CMD_SNTP) += sntp.o obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o +obj-$(CONFIG_UDP_FUNCTION_FASTBOOT) += fastboot.o # Disable this warning as it is triggered by: # sprintf(buf, index ? "foo%d" : "foo", index)
net/fastboot.c new file +542 -0
542 lines not on this page · raw message
net/net.c +9 -0
@@ -87,6 +87,9 @@#include <environment.h> #include <errno.h> #include <net.h> +#if defined(CONFIG_UDP_FUNCTION_FASTBOOT ) +#include <net/fastboot.h> +#endif #include <net/tftp.h> #if defined(CONFIG_LED_STATUS )#include <miiphy.h>
@@ -453,6 +456,11 @@ restart:tftp_start_server ();break ;#endif +#ifdef CONFIG_UDP_FUNCTION_FASTBOOT +case FASTBOOT : +fastboot_start_server (); +break ; +#endif #if defined(CONFIG_CMD_DHCP )case DHCP :bootp_reset ();
@@ -1324,6 +1332,7 @@ common:/* Fall through */ case NETCONS : +case FASTBOOT :case TFTPSRV :if (net_ip.s_addr ==0 ) {puts ("*** ERROR: `ipaddr' not set\n" );
Signature · 1 line
2.7.4
RFC PATCH 4/5 dfu: Resolve Kconfig dependency loops
In reply to Alex KiernanFix recursive dependencies in Kconfig introduced by fastboot UDP
---
cmd/fastboot/Kconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
cmd/fastboot/Kconfig +3 -2
@@ -2,13 +2,13 @@ comment "FASTBOOT" menuconfig FASTBOOT bool "Fastboot support" - depends on USB_GADGET default y if ARCH_SUNXI && USB_MUSB_GADGET if FASTBOOT config USB_FUNCTION_FASTBOOT bool "Enable USB fastboot gadget" + depends on USB_GADGET default y select USB_GADGET_DOWNLOAD imply ANDROID_BOOT_IMAGE
@@ -17,7 +17,7 @@ config USB_FUNCTION_FASTBOOT This enables the USB part of the fastboot gadget. config UDP_FUNCTION_FASTBOOT - select NET + depends on NET bool "Enable fastboot protocol over UDP" help This enables the fastboot protocol over UDP.
@@ -66,6 +66,7 @@ config FASTBOOT_BUF_SIZE config FASTBOOT_USB_DEV int "USB controller number" + depends on USB_FUNCTION_FASTBOOT default 0 help Some boards have USB OTG controller other than 0. Define this
Signature · 1 line
2.7.4
RFC PATCH 4/5 dfu: Resolve Kconfig dependency loops
Hi Alex,
Quoted 44 lines
Fix recursive dependencies in
Kconfigintroduced by fastboot UDPSigned-off-by Alex Kiernan <[email protected]>---
cmd/fastboot/Kconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)cmd/fastboot/Kconfig +3
-2@@ -2,13 +2,13 @@ comment "FASTBOOT" menuconfig FASTBOOT bool "Fastboot support" - depends on USB_GADGET default y if ARCH_SUNXI && USB_MUSB_GADGET if FASTBOOT config USB_FUNCTION_FASTBOOT bool "Enable USB fastboot gadget" + depends on USB_GADGET default y select USB_GADGET_DOWNLOAD imply ANDROID_BOOT_IMAGE@@ -17,7 +17,7 @@ config USB_FUNCTION_FASTBOOT This enables the USB part of the fastboot gadget. config UDP_FUNCTION_FASTBOOT - select NET + depends on NET bool "Enable fastboot protocol over UDP" help This enables the fastboot protocol over UDP.@@ -66,6 +66,7 @@ config FASTBOOT_BUF_SIZE config FASTBOOT_USB_DEV int "USB controller number" + depends on USB_FUNCTION_FASTBOOT default 0 help Some boards have USB OTG controller other than 0. Define
Quoted 1 line
this
I think that it should be possible to have fastboot support enabled for both USB and ETH if a board has those interfaces present.
Then by using proper commands:
fastboot usb or fastboot udp we can decide which medium would be used.
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180425/edf14849/attachment.sig>
RFC PATCH 4/5 dfu: Resolve Kconfig dependency loops
2018-04-25 9:53 GMT+02:00 Lukasz Majewski <[email protected]>:
Quoted 51 lines
Hi Alex,
Quoted 44 lines
Fix recursive dependencies in
Kconfigintroduced by fastboot UDPSigned-off-by Alex Kiernan <[email protected]>---
cmd/fastboot/Kconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)cmd/fastboot/Kconfig +3
-2@@ -2,13 +2,13 @@ comment "FASTBOOT" menuconfig FASTBOOT bool "Fastboot support" - depends on USB_GADGET default y if ARCH_SUNXI && USB_MUSB_GADGET if FASTBOOT config USB_FUNCTION_FASTBOOT bool "Enable USB fastboot gadget" + depends on USB_GADGET default y select USB_GADGET_DOWNLOAD imply ANDROID_BOOT_IMAGE@@ -17,7 +17,7 @@ config USB_FUNCTION_FASTBOOT This enables the USB part of the fastboot gadget. config UDP_FUNCTION_FASTBOOT - select NET + depends on NET bool "Enable fastboot protocol over UDP" help This enables the fastboot protocol over UDP.@@ -66,6 +66,7 @@ config FASTBOOT_BUF_SIZE config FASTBOOT_USB_DEV int "USB controller number" + depends on USB_FUNCTION_FASTBOOT default 0 help Some boards have USB OTG controller other than 0. DefineQuoted 1 line
this
I think that it should be possible to have fastboot support enabled for both USB and ETH if a board has those interfaces present.
Quoted 5 lines
Then by using proper commands:
fastboot usb or fastboot udp we can decide which medium would be used.
I agree that compiling support for both should be possible (I'm not sure
if it is really that useful). I was referring to that supporting fastboot in both interfaces at the same time would be very complicated; but selecting at runtime whether you want "fastboot udp" or "fastboot usb" is easy.
deymo
RFC PATCH 5/5 net: dfu: Support building without MMC
In reply to Alex KiernanIf the fastboot flash/erase commands are disabled, remove that support so we still build correctly.
---
net/fastboot.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/fastboot.c +6 -0
@@ -59,8 +59,10 @@ static int fastboot_our_port;static void fb_getvar (char *);static void fb_download (char *,unsigned int ,char *); +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH_MMC )static void fb_flash (char *);static void fb_erase (char *); +#endif static void fb_continue (char *);static void fb_reboot (char *);static void boot_downloaded_image (void );
@@ -169,10 +171,12 @@ static void fastboot_send(struct fastboot_header fb_header, char *fastboot_data,fb_getvar (response); }else if (!strcmp ("download" , cmd_string)) {fb_download (fastboot_data, fastboot_data_len, response); +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH_MMC ) } else if (!strcmp("flash", cmd_string)) {fb_flash (response); }else if (!strcmp ("erase" , cmd_string)) {fb_erase (response); +#endif }else if (!strcmp ("boot" , cmd_string)) {write_fb_response ("OKAY" ,"" , response); }else if (!strcmp ("continue" , cmd_string)) {
@@ -367,6 +371,7 @@ static void fb_download(char *fastboot_data, unsigned int fastboot_data_len, } } +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH_MMC )/** * Writes the previously downloaded image to the partition indicated by * cmd_parameter. Writes to response.
@@ -389,6 +394,7 @@ static void fb_erase(char *response) {fb_mmc_erase (cmd_parameter, response); } +#endif /** * Continues normal boot process by running "bootcmd". Writes
Signature · 1 line
2.7.4
cover Add fastboot UDP support
In reply to Alex Kiernan+Jocelyn.
Thanks Alex for taking the time to port this!! Some comments inline here about your questions.
2018-04-24 11:37 GMT+02:00 Alex Kiernan <[email protected]>:
Quoted 4 lines
This series merges the fastboot UDP support from AOSP into mainline U-Boot.
Quoted 9 lines
Open questions:
- what's the correct way of attributing the original authors? I've added Co-authored-by, is that right? checkpatch doesn't seem to know any of the co- tags
- currently there's no NAND support and I've no way of testing that, so my inclination is towards leaving it like that until someone with that particular itch to scratch can look at it
Fastboot uses partition names, like "system" and "boot" which have a meaning in the Android partition scheme. For GPT, we just use the partition names as the android names; but if you are booting from some other storage like NAND where you don't have that then you need some mapping glue ("system" --> device and partition number). I've seen U-Boot modifications for several devices where they just stick a table hard-coded in the U-Boot code; which works great for that device but it isn't really a generic approach. Other than handling the names issue, I don't see any problem with supporting NAND here, but a generic way to set global names / alias would be needed for this.
Quoted 4 lines
- you can select both USB and UDP fastboot, but the comments in the AOSP code suggest that needs fixing - again, I've no board I can test USB fastboot on
I thought we checked in the Kconfig that you couldn't enable both. I don't remember the details now but yeah you can't wait for network or USB traffic on the current code.
- the USB and UDP code want consolidating, with this series there would
Quoted 10 lines
then be two separate implementations of the same protocol
- the syntax for the USB fastboot command changes fromfastboot <controller>
tofastboot usb <controller>, that feels unacceptable and we probably want something likefastboot <controller>orfastboot udp?
- unrelated to this series, but a show-stopper for me, there's no FIT image support, but that doesn't feel unsolveable - something like add an option to pass in the load address and/or use loadaddr, then something else to let you override the bootm invocation on the server side
Quoted 5 lines
I've not tested all the code paths yet, but the obvious stuff works (basic interaction, download, boot) - every interaction elicits a
WARNING: unknown variable: slot-counton the console; I'm guessing that my local end is sending a getvar for that, but I've not investigated.
Yes, there's a bit of different handling of partitions for A/B android devices. Instead of "system" you have two partitions: "system_a" and "system_b" (potentially more although 2 is the most common case) so to know whether you have an old device or a newer device the fastboot client checks the "slot-count" variable. Undefined means of course that you have an old-style device, but if you return something like "2" you would be able to flash "system" on the "slot A" which is translated (again in the fastboot client) to flash "system_a" partition. This is useful when using the higher level operations like flashall/update and you want to specify to flash only "slot A", "slot B" or even both of them. There are other fastboot variables that require some plumbing, such as "has-slot:<partition>" to tell whether "system" is a partition that indeed has the two versions _a and _b. Typically some partitions are twice (like "system" and "boot") and some other are not (like "misc" or "userdata"). Anyway, this as is should work for either old-style partition schemes or by force flashing "system_a" with the system.img.
Quoted 39 lines
Without any way of testing any of the USB/NAND code I'm nervous of wading into that kind of refactoring, would that be a pre-requisite for merging?
Alex Kiernan (5):
dfu: Refactor fastboot_okay/fail to take response
dfu: Extract fastboot_okay/fail tofb_common.c
net: dfu: Merge AOSP UDP fastboot
dfu: ResolveKconfigdependency loops
net: dfu: Support building without MMCcmd/fastboot.c | 32 ++- cmd/fastboot/Kconfig | 21 +- cmd/net.c | 6 + common/Makefile | 4 + common/fb_common.c | 44 ++++ common/fb_mmc.c | 114 ++++++--- common/fb_nand.c | 31 +-- common/image-sparse.c | 41 ++- drivers/usb/gadget/f_fastboot.c | 36 +-- include/fastboot.h | 17 +- include/fb_mmc.h | 4 +- include/fb_nand.h | 4 +- include/image-sparse.h | 2 +- include/net.h | 6 +- include/net/fastboot.h | 27 ++ net/Makefile | 1 + net/fastboot.c | 548 ++++++++++++++++++++++++++++++ ++++++++++ net/net.c | 9 + 18 files changed, 824 insertions(+), 123 deletions(-) create mode 100644 common/fb_common.c create mode 100644 include/net/fastboot.h create mode 100644 net/fastboot.c--
2.7.4
cover Add fastboot UDP support
Quoted 3 lines · Alex Deymo
+Jocelyn.
Thanks Alex for taking the time to port this!!
It turned out to be a great opportunity to play with coccinelle on something trivial, which I'd been meaning to do for ages... the refactor to add response into the fastboot_okay/fail call chain was a breeze with it.
Quoted 16 lines
2018-04-24 11:37 GMT+02:00 Alex Kiernan <[email protected]>:
Quoted 5 lines
This series merges the fastboot UDP support from AOSP into mainline U-Boot.
Quoted 8 lines
Open questions:
- what's the correct way of attributing the original authors? I've added Co-authored-by, is that right? checkpatch doesn't seem to know any of the co- tags
- currently there's no NAND support and I've no way of testing that, so my inclination is towards leaving it like that until someone with that particular itch to scratch can look at it
Quoted 11 lines
Fastboot uses partition names, like "system" and "boot" which have a meaning in the Android partition scheme. For GPT, we just use the partition names as the android names; but if you are booting from some other storage like NAND where you don't have that then you need some mapping glue ("system" --> device and partition number). I've seen U-Boot modifications for several devices where they just stick a table hard-coded in the U-Boot code; which works great for that device but it isn't really a generic approach. Other than handling the names issue, I don't see any problem with supporting NAND here, but a generic way to set global names / alias would be needed for this.
With the fastboot NAND support in mainline it looks like we end up in mtdparts to deliver that mapping through environment variables. No actual idea what that looks like when you're driving it.
Quoted 10 lines
Quoted 4 lines
- you can select both USB and UDP fastboot, but the comments in the AOSP code suggest that needs fixing - again, I've no board I can test USB fastboot on
I thought we checked in the
Kconfigthat you couldn't enable both. I don't remember the details now but yeah you can't wait for network or USB traffic on the current code.
The version I picked from (o-mr1-iot-preview-8) has them as independent symbols, but making them a choice would resolve the issue for now.
Quoted 6 lines
Quoted 4 lines
I've not tested all the code paths yet, but the obvious stuff works (basic interaction, download, boot) - every interaction elicits a
WARNING: unknown variable: slot-counton the console; I'm guessing that my local end is sending a getvar for that, but I've not investigated.
Quoted 17 lines
Yes, there's a bit of different handling of partitions for A/B android devices. Instead of "system" you have two partitions: "
system_a" and "system_b" (potentially more although 2 is the most common case) so to know whether you have an old device or a newer device the fastboot client checks the "slot-count" variable. Undefined means of course that you have an old-style device, but if you return something like "2" you would be able to flash "system" on the "slot A" which is translated (again in the fastboot client) to flash "system_a" partition. This is useful when using the higher level operations like flashall/update and you want to specify to flash only "slot A", "slot B" or even both of them. There are other fastboot variables that require some plumbing, such as "has-slot:<partition>" to tell whether "system" is a partition that indeed has the two versions _a and _b. Typically some partitions are twice (like "system" and "boot") and some other are not (like "misc" or "userdata"). Anyway, this as is should work for either old-style partition schemes or by force flashing "system_a" with the system.img.
Cool, thanks... that saves me a bunch of investigation!
Signature · 1 line
Alex Kiernan
cover Add fastboot UDP support
Thanks so much for porting this, Alex!
Quoted 55 lines · Alex Kiernan
Quoted 3 lines · Alex Deymo
+Jocelyn.
Thanks Alex for taking the time to port this!!
It turned out to be a great opportunity to play with coccinelle on something trivial, which I'd been meaning to do for ages... the refactor to add response into the fastboot_okay/fail call chain was a breeze with it.
Quoted 16 lines
2018-04-24 11:37 GMT+02:00 Alex Kiernan <[email protected]>:
Quoted 5 lines
This series merges the fastboot UDP support from AOSP into mainline U-Boot.
Quoted 8 lines
Open questions:
- what's the correct way of attributing the original authors? I've added Co-authored-by, is that right? checkpatch doesn't seem to know any of the co- tags
- currently there's no NAND support and I've no way of testing that, so my inclination is towards leaving it like that until someone with that particular itch to scratch can look at itQuoted 1 line
Fastboot uses partition names, like "system" and "boot" which have a
meaning
Quoted 1 line
in the Android partition scheme. For GPT, we just use the partition
names as
Quoted 1 line
the android names; but if you are booting from some other storage like
NAND
Quoted 3 lines
where you don't have that then you need some mapping glue ("system" --> device and partition number). I've seen U-Boot modifications for several devices where they just stick a table hard-coded in the U-Boot code;
which
Quoted 2 lines
works great for that device but it isn't really a generic approach. Other than handling the names issue, I don't see any problem with supporting
NAND
Quoted 3 lines
here, but a generic way to set global names / alias would be needed for this.
With the fastboot NAND support in mainline it looks like we end up in mtdparts to deliver that mapping through environment variables. No actual idea what that looks like when you're driving it.
Quoted 7 lines
Quoted 4 lines
- you can select both USB and UDP fastboot, but the comments in the AOSP code suggest that needs fixing - again, I've no board I can test USB fastboot on
I thought we checked in the
Kconfigthat you couldn't enable both. Idon't
Quoted 9 lines
Quoted 1 line
remember the details now but yeah you can't wait for network or USB
traffic
Quoted 2 lines
on the current code.
The version I picked from (o-mr1-iot-preview-8) has them as independent symbols, but making them a choice would resolve the issue for now.
You can select both network and USB fastboot to be enabled with the Kconfig, but at runtime you have to select to wait on either USB or network by running
"fastboot udp" or "fastboot usb <USB_controller>". When the Android bootloader
gets the command to reboot back to fastboot, it will read the "fastbootcmd" env
variable and run that as a command (common/android_bootloader.c:151).
Quoted 39 lines
Quoted 4 lines
Quoted 4 lines
I've not tested all the code paths yet, but the obvious stuff works (basic interaction, download, boot) - every interaction elicits a
WARNING: unknown variable: slot-counton the console; I'm guessingthat
Quoted 6 lines
Quoted 1 line
my local end is sending a getvar for that, but I've not investigated.
Yes, there's a bit of different handling of partitions for A/B android devices. Instead of "system" you have two partitions: "
system_a" and "system_b" (potentially more although 2 is the most common case) so toknow
Quoted 1 line
whether you have an old device or a newer device the fastboot client
checks
Quoted 2 lines
the "slot-count" variable. Undefined means of course that you have an old-style device, but if you return something like "2" you would be able
to
Quoted 2 lines
flash "system" on the "slot A" which is translated (again in the fastboot client) to flash "
system_a" partition. This is useful when using thehigher
Quoted 1 line
level operations like flashall/update and you want to specify to flash
only
Quoted 1 line
"slot A", "slot B" or even both of them. There are other fastboot
variables
Quoted 1 line
that require some plumbing, such as "has-slot:<partition>" to tell
whether
Quoted 4 lines
"system" is a partition that indeed has the two versions _a and _b. Typically some partitions are twice (like "system" and "boot") and some other are not (like "misc" or "userdata"). Anyway, this as is should work for either old-style partition schemes or by force flashing "
system_a"with
Quoted 2 lines
the system.img.
Cool, thanks... that saves me a bunch of investigation!
--
Alex Kiernan
cover Add fastboot UDP support
Quoted 72 lines · Jocelyn Bohr
Thanks so much for porting this, Alex!
Quoted 64 lines · Alex Kiernan
Quoted 3 lines · Alex Deymo
+Jocelyn.
Thanks Alex for taking the time to port this!!
It turned out to be a great opportunity to play with coccinelle on something trivial, which I'd been meaning to do for ages... the refactor to add response into the fastboot_okay/fail call chain was a breeze with it.
Quoted 18 lines
2018-04-24 11:37 GMT+02:00 Alex Kiernan <[email protected]>:
Quoted 7 lines
This series merges the fastboot UDP support from AOSP into mainline U-Boot.
Open questions:
Quoted 8 lines
- what's the correct way of attributing the original authors? I've added
Co-authored-by, is that right? checkpatch doesn't seem to know any of the co- tags
- currently there's no NAND support and I've no way of testing that, so my inclination is towards leaving it like that until someone with
that
particular itch to scratch can look at itQuoted 17 lines
Fastboot uses partition names, like "system" and "boot" which have a meaning
in the Android partition scheme. For GPT, we just use the partition names as
the android names; but if you are booting from some other storage like NAND
where you don't have that then you need some mapping glue ("system" --> device and partition number). I've seen U-Boot modifications for several devices where they just stick a table hard-coded in the U-Boot code; which
works great for that device but it isn't really a generic approach. Other
than handling the names issue, I don't see any problem with supporting NAND
here, but a generic way to set global names / alias would be needed for this.With the fastboot NAND support in mainline it looks like we end up in mtdparts to deliver that mapping through environment variables. No actual idea what that looks like when you're driving it.
Quoted 6 lines
Quoted 4 lines
- you can select both USB and UDP fastboot, but the comments in the AOSP code suggest that needs fixing - again, I've no board I can test USB fastboot on
Quoted 6 lines
I thought we checked in the
Kconfigthat you couldn't enable both. I don't
remember the details now but yeah you can't wait for network or USB traffic
on the current code.Quoted 3 lines
The version I picked from (o-mr1-iot-preview-8) has them as independent symbols, but making them a choice would resolve the issue for now.
Quoted 9 lines
You can select both network and USB fastboot to be enabled with the
Kconfig, but at runtime you have to select to wait on either USB or network by running
"fastboot udp" or "fastboot usb <USB_controller>". When the Android bootloader
gets the command to reboot back to fastboot, it will read the "fastbootcmd" env
variable and run that as a command (common/android_bootloader.c:151).
Thanks for that (especially the detail on android_bootloader which I'd not read through). The bit that concerns me is in timed_send_info:
+/**
+ * Send an INFO packet during long commands based on timer. If
+ * CONFIG_UDP_FUNCTION_FASTBOOT is defined, an INFO packet is sent
+ * if the time is 30 seconds after start. Else, noop.
+ *
+ * TODO: Handle the situation where both UDP and USB fastboot are
+ * enabled.
+ *
+ * @param start: Time since last INFO packet was sent.
+ * @param msg: String describing the reason for waiting
+ */
+void timed_send_info(ulong *start, const char *msg);
The code in timed_send_info is guarded with an ifdef, rather than based on the transport that's been selected at runtime. Do we need to make timed_send_info work based on the runtime state, rather than the compile time, or can we drop the ifdef guard and remove the TODO? I guess I'm assuming the former, but with no way to test USB I don't want head off down the wrong road!
Signature · 1 line
Alex Kiernan
cover Add fastboot UDP support
Quoted 3 lines · Alex Kiernan
Quoted 2 lines · Jocelyn Bohr
Thanks so much for porting this, Alex!
...
Quoted 27 lines
Quoted 10 lines
You can select both network and USB fastboot to be enabled with the
Kconfig, but at runtime you have to select to wait on either USB or network by running
"fastboot udp" or "fastboot usb <USB_controller>". When the Android bootloader
gets the command to reboot back to fastboot, it will read the "fastbootcmd" env
variable and run that as a command (common/android_bootloader.c:151).Thanks for that (especially the detail on
android_bootloaderwhich I'd not read through). The bit that concerns me is intimed_send_info:+/**
+ * Send an INFO packet during long commands based on timer. If
+ *CONFIG_UDP_FUNCTION_FASTBOOTis defined, an INFO packet is sent
+ * if the time is 30 seconds after start. Else, noop.
+ *
+ * TODO: Handle the situation where both UDP and USB fastboot are
+ * enabled.
+ *
+ * @param start: Time since last INFO packet was sent.
+ * @param msg: String describing the reason for waiting
+ */
+voidtimed_send_info(ulong *start, const char *msg);
Quoted 7 lines
The code in
timed_send_infois guarded with an ifdef, rather than based on the transport that's been selected at runtime. Do we need to maketimed_send_infowork based on the runtime state, rather than the compile time, or can we drop the ifdef guard and remove the TODO? I guess I'm assuming the former, but with no way to test USB I don't want head off down the wrong road!
Having started digging through how we'd merge the two code paths, it's clear if you had UDP and USB both enabled at compile time and then try and run the USB path it'll try and do UDP things in timed_send_info, which can't be good!
Signature · 1 line
Alex Kiernan
cover Add fastboot UDP support
Quoted 46 lines · On Wed, 25 Apr 2018 13:50:50 +0100 Alex Kiernan <[email protected]> wrote:
Quoted 4 lines · Alex Kiernan
Quoted 2 lines · Jocelyn Bohr
Thanks so much for porting this, Alex!
...
Quoted 29 lines
Quoted 10 lines
You can select both network and USB fastboot to be enabled with the
Kconfig, but at runtime you have to select to wait on either USB or network by running
"fastboot udp" or "fastboot usb <USB_controller>". When the Android bootloader
gets the command to reboot back to fastboot, it will read the "fastbootcmd" env
variable and run that as a command (common/android_bootloader.c:151).Thanks for that (especially the detail on
android_bootloaderwhich I'd not read through). The bit that concerns me is intimed_send_info:+/**
+ * Send an INFO packet during long commands based on timer. If
+ *CONFIG_UDP_FUNCTION_FASTBOOTis defined, an INFO packet is
sent
+ * if the time is 30 seconds after start. Else, noop.
+ *
+ * TODO: Handle the situation where both UDP and USB fastboot are
+ * enabled.
+ *
+ * @param start: Time since last INFO packet was sent.
+ * @param msg: String describing the reason for waiting
+ */
+voidtimed_send_info(ulong *start, const char *msg);Quoted 7 lines
The code in
timed_send_infois guarded with an ifdef, rather than based on the transport that's been selected at runtime. Do we need to maketimed_send_infowork based on the runtime state, rather than the compile time, or can we drop the ifdef guard and remove the TODO? I guess I'm assuming the former, but with no way to test USB I don't want head off down the wrong road!
Quoted 5 lines
Having started digging through how we'd merge the two code paths, it's clear if you had UDP and USB both enabled at compile time and then try and run the USB path it'll try and do UDP things in
timed_send_info, which can't be good!
I think that we can assume operation of only one medium in a time - i.e.
when you issue fastboot usb then no UDP support (and opposite).
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180425/d9c5972a/attachment.sig>
cover Add fastboot UDP support
In reply to Jocelyn BohrHi Jocelyn and Alex,
It's great to see you are getting this feature from google code to be mainline code.
My opinion is that we should have the same fastboot cmd handling in both UDP and USB in a common file, but not have separate code in net/fastboot.c and drivers/usb/gadget/f_fastboot.c, could you try to merge these two in one?
Thanks,
- Kever
cover Add fastboot UDP support
Hi Kever,
Quoted 10 lines
Hi Jocelyn and Alex,
It's great to see you are getting this feature from google code to be mainline code.
My opinion is that we should have the same fastboot cmd handling in both UDP and USB in a common file, but not have separate code in
net/fastboot.canddrivers/usb/gadget/f_fastboot.c, could you try to merge these two in one?
I've already proposed to put common code (the protocol handling) into /drivers/fastboot and have only small glue code for USB and NET.
Quoted 8 lines
Thanks,
- Kever_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180427/e7970950/attachment.sig>
cover Add fastboot UDP support
Quoted 8 lines · Lukasz Majewski
Hi Kever,
Quoted 6 lines
Hi Jocelyn and Alex,
It's great to see you are getting this feature from google code
to be mainline code.
Quoted 8 lines
Quoted 4 lines
My opinion is that we should have the same fastboot cmd handling
in both UDP and USB in a common file, but not have separate code innet/fastboot.canddrivers/usb/gadget/f_fastboot.c, could you try to merge these two in one?I've already proposed to put common code (the protocol handling) into /drivers/fastboot and have only small glue code for USB and NET.
I'm working towards that. I'm starting with the command implementations, then I'll look at the protocol.
Hopefully I'll get an RFCv2 out sometime over the weekend with the first bits done.
Signature · 1 line
Alex Kiernan
cover Add fastboot UDP support
Quoted 18 lines · Alex Kiernan
Quoted 8 lines · Lukasz Majewski
Hi Kever,
Quoted 6 lines
Hi Jocelyn and Alex,
It's great to see you are getting this feature from google code
to be mainline code.Quoted 8 lines
Quoted 4 lines
My opinion is that we should have the same fastboot cmd handling
in both UDP and USB in a common file, but not have separate code innet/fastboot.canddrivers/usb/gadget/f_fastboot.c, could you try to merge these two in one?I've already proposed to put common code (the protocol handling) into /drivers/fastboot and have only small glue code for USB and NET.
Quoted 6 lines
I'm working towards that. I'm starting with the command implementations, then I'll look at the protocol.
Hopefully I'll get an RFCv2 out sometime over the weekend with the first bits done.
Just posted a v2, still needs more work, but getting feedback on the direction would be useful.
Signature · 1 line
Alex Kiernan
cover Add fastboot UDP support
Great, I will check out v2! And yes free to add a "Signed-off-by" for me on any of the original patchsets.
Quoted 33 lines · Alex Kiernan
Quoted 18 lines · Alex Kiernan
Quoted 8 lines · Lukasz Majewski
Hi Kever,
Quoted 6 lines
Hi Jocelyn and Alex,
It's great to see you are getting this feature from google code
to be mainline code.Quoted 8 lines
Quoted 4 lines
My opinion is that we should have the same fastboot cmd handling
in both UDP and USB in a common file, but not have separate code innet/fastboot.canddrivers/usb/gadget/f_fastboot.c, could you try to merge these two in one?I've already proposed to put common code (the protocol handling) into /drivers/fastboot and have only small glue code for USB and NET.
Quoted 6 lines
I'm working towards that. I'm starting with the command implementations, then I'll look at the protocol.
Hopefully I'll get an RFCv2 out sometime over the weekend with the first bits done.
Just posted a v2, still needs more work, but getting feedback on the direction would be useful.
--
Alex Kiernan
cover Add fastboot UDP support
In reply to Alex KiernanHi Alex,
Quoted 39 lines
Quoted 3 lines · Alex Deymo
+Jocelyn.
Thanks Alex for taking the time to port this!!
It turned out to be a great opportunity to play with coccinelle on something trivial, which I'd been meaning to do for ages... the refactor to add response into the fastboot_okay/fail call chain was a breeze with it.
Quoted 16 lines
2018-04-24 11:37 GMT+02:00 Alex Kiernan <[email protected]>:
Quoted 5 lines
This series merges the fastboot UDP support from AOSP into mainline U-Boot.
Quoted 8 lines
Open questions:
- what's the correct way of attributing the original authors? I've added Co-authored-by, is that right? checkpatch doesn't seem to know any of the co- tags
- currently there's no NAND support and I've no way of testing that, so my inclination is towards leaving it like that until someone with that particular itch to scratch can look at itQuoted 11 lines
Fastboot uses partition names, like "system" and "boot" which have a meaning in the Android partition scheme. For GPT, we just use the partition names as the android names; but if you are booting from some other storage like NAND where you don't have that then you need some mapping glue ("system" --> device and partition number). I've seen U-Boot modifications for several devices where they just stick a table hard-coded in the U-Boot code; which works great for that device but it isn't really a generic approach. Other than handling the names issue, I don't see any problem with supporting NAND here, but a generic way to set global names / alias would be needed for this.
Quoted 2 lines
With the fastboot NAND support in mainline it looks like we end up in mtdparts to deliver that mapping through environment variables.
When you mentioned about NAND partitions - I also have thought about mtdparts. They are well supported in mainline.
Quoted 2 lines
No
actual idea what that looks like when you're driving it.
Many boards use them - so there should not be any issue with finding examples.
Quoted 42 lines
Quoted 11 lines
Quoted 5 lines
- you can select both USB and UDP fastboot, but the comments in the AOSP code suggest that needs fixing - again, I've no board I can
test USB fastboot onI thought we checked in the
Kconfigthat you couldn't enable both. I don't remember the details now but yeah you can't wait for network or USB traffic on the current code.The version I picked from (o-mr1-iot-preview-8) has them as independent symbols, but making them a choice would resolve the issue for now.
Quoted 17 lines
Quoted 5 lines
I've not tested all the code paths yet, but the obvious stuff works (basic interaction, download, boot) - every interaction elicits a
WARNING: unknown variable: slot-counton the console; I'm guessing that my local end is sending a getvar for that, but I've not investigated.Yes, there's a bit of different handling of partitions for A/B android devices. Instead of "system" you have two partitions:
"system_a" and "system_b" (potentially more although 2 is the most common case) so to know whether you have an old device or a newer device the fastboot client checks the "slot-count" variable. Undefined means of course that you have an old-style device, but if you return something like "2" you would be able to flash "system" on the "slot A" which is translated (again in the fastboot client) to flash "system_a" partition. This is useful when using the higher level operations like flashall/update and you want to specify toQuoted 8 lines
flash only "slot A", "slot B" or even both of them. There are other fastboot variables that require some plumbing, such as "has-slot:<partition>" to tell whether "system" is a partition that indeed has the two versions _a and _b. Typically some partitions are twice (like "system" and "boot") and some other are not (like "misc" or "userdata"). Anyway, this as is should work for either old-style partition schemes or by force flashing "
system_a" with the system.img.
Quoted 2 lines
Cool, thanks... that saves me a bunch of investigation!
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180425/f5ded8ea/attachment.sig>
cover Add fastboot UDP support
In reply to Alex KiernanHi Alex,
Quoted 5 lines
Open questions:
- what's the correct way of attributing the original authors? I've added Co-authored-by, is that right? checkpatch doesn't seem to know any of the co- tags
I think that two authors (Alex and Jocelyn) have replied to your e-mail.
Maybe it would be doable to have S-o-B or Acked-by from them?
Quoted 3 lines
- currently there's no NAND support and I've no way of testing that, so my inclination is towards leaving it like that until someone with that particular itch to scratch can look at it
As I've written in the other mail - please look into "mtdparts".
Quoted 3 lines
- you can select both USB and UDP fastboot, but the comments in the AOSP code suggest that needs fixing - again, I've no board I can
test USB fastboot on
I need to check if I do posses a bort with fastboot support (as I mostly test DFU).
Quoted 2 lines
- the USB and UDP code want consolidating, with this series there would then be two separate implementations of the same protocol
Yes - this is an issue.
For USB the fastboot protocol (at least some its logic) is implemented in drivers/usb/gadget/f_fastboot.c
I think that some medium agnostic code (like protocol itself) can be unified.
I also think that it would be a good idea to have ./drivers/fastboot directory introduced to move common code there - and leave only USB related code in f_fastboot.c
Please as a reference, look on how ./drivers/dfu is organised.
Quoted 4 lines
- the syntax for the USB fastboot command changes from
fastboot <controller>tofastboot usb <controller>, that feels unacceptable and we probably want something likefastboot <controller>orfastboot udp?
Similar issue was with "thor"/"ums"/"dfu" command previously.
For backward compatibility we can make an alias:
fastboot <controller> -> fastboot usb <controller>
IMHO, it would be great to have
fastboot usb <controller>
fastboot udp ip.... (etc)
(It would be great to have the same syntax as it is in Android).
Quoted 5 lines
- unrelated to this series, but a show-stopper for me, there's no FIT image support, but that doesn't feel unsolveable - something like add an option to pass in the load address and/or use loadaddr, then something else to let you override the bootm invocation on the server side
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180425/1e77583c/attachment.sig>
cover Add fastboot UDP support
Hi Alex,
Quoted 8 lines
Quoted 2 lines
- the USB and UDP code want consolidating, with this series there would then be two separate implementations of the same protocol
Yes - this is an issue.
For USB the fastboot protocol (at least some its logic) is implemented in
drivers/usb/gadget/f_fastboot.c
Quoted 6 lines
I think that some medium agnostic code (like protocol itself) can be unified.
I also think that it would be a good idea to have
./drivers/fastbootdirectory introduced to move common code there - and leave only USB related code inf_fastboot.c
Especially that we do have fb_nand.c and fb_mmc.c in ./common.
In that way we could move them to ./drivers/fastboot.
Quoted 2 lines
Please as a reference, look on how
./drivers/dfuis organised.
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180425/83fe83f8/attachment.sig>
cover Add fastboot UDP support
In reply to Lukasz MajewskiQuoted 4 lines · Lukasz Majewski
Hi Alex,
Quoted 2 lines
Open questions:
Quoted 8 lines
Quoted 3 lines
- what's the correct way of attributing the original authors? I've added Co-authored-by, is that right? checkpatch doesn't seem to know any of the co- tags
I think that two authors (Alex and Jocelyn) have replied to your e-mail.
Maybe it would be doable to have S-o-B or Acked-by from them?
Alex, Jocelyn, would you be happy for me to add a Signed-off-by from you?
Signature · 1 line
Alex Kiernan
cover Add fastboot UDP support
2018-04-25 10:43 GMT+02:00 Alex Kiernan <[email protected]>:
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
- what's the correct way of attributing the original authors? I've added Co-authored-by, is that right? checkpatch doesn't seem to know any of the co- tags
I think that two authors (Alex and Jocelyn) have replied to your e-mail.
Maybe it would be doable to have S-o-B or Acked-by from them?
Alex, Jocelyn, would you be happy for me to add a Signed-off-by from you?
Sure!
cover Add fastboot UDP support
In reply to Alex KiernanQuoted 4 lines · Alex Kiernan
This series merges the fastboot UDP support from AOSP into mainline U-Boot.
Can you please point me out from which AOSP code exactly this code was ported? Links to code, maybe some docs. Thanks.
Quoted 67 lines
Open questions:
- what's the correct way of attributing the original authors? I've added Co-authored-by, is that right? checkpatch doesn't seem to know any of the co- tags
- currently there's no NAND support and I've no way of testing that, so my inclination is towards leaving it like that until someone with that particular itch to scratch can look at it
- you can select both USB and UDP fastboot, but the comments in the AOSP code suggest that needs fixing - again, I've no board I can test USB fastboot on
- the USB and UDP code want consolidating, with this series there would then be two separate implementations of the same protocol
- the syntax for the USB fastboot command changes fromfastboot <controller>tofastboot usb <controller>, that feels unacceptable and we probably want something likefastboot <controller>orfastboot udp?
- unrelated to this series, but a show-stopper for me, there's no FIT image support, but that doesn't feel unsolveable - something like add an option to pass in the load address and/or use loadaddr, then something else to let you override the bootm invocation on the server sideI've not tested all the code paths yet, but the obvious stuff works (basic interaction, download, boot) - every interaction elicits a
WARNING: unknown variable: slot-counton the console; I'm guessing that my local end is sending a getvar for that, but I've not investigated.Without any way of testing any of the USB/NAND code I'm nervous of wading into that kind of refactoring, would that be a pre-requisite for merging?
Alex Kiernan (5):
dfu: Refactor fastboot_okay/fail to take response
dfu: Extract fastboot_okay/fail tofb_common.c
net: dfu: Merge AOSP UDP fastboot
dfu: ResolveKconfigdependency loops
net: dfu: Support building without MMCcmd/fastboot.c | 32 ++- cmd/fastboot/Kconfig | 21 +- cmd/net.c | 6 + common/Makefile | 4 + common/fb_common.c | 44 ++++ common/fb_mmc.c | 114 ++++++--- common/fb_nand.c | 31 +-- common/image-sparse.c | 41 ++- drivers/usb/gadget/f_fastboot.c | 36 +-- include/fastboot.h | 17 +- include/fb_mmc.h | 4 +- include/fb_nand.h | 4 +- include/image-sparse.h | 2 +- include/net.h | 6 +- include/net/fastboot.h | 27 ++ net/Makefile | 1 + net/fastboot.c | 548 ++++++++++++++++++++++++++++++++++++++++ net/net.c | 9 + 18 files changed, 824 insertions(+), 123 deletions(-) create mode 100644 common/fb_common.c create mode 100644 include/net/fastboot.h create mode 100644 net/fastboot.c--
2.7.4_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
cover Add fastboot UDP support
Hi Sam,
Quoted 9 lines · Sam Protsenko
Quoted 4 lines · Alex Kiernan
This series merges the fastboot UDP support from AOSP into mainline U-Boot.
Can you please point me out from which AOSP code exactly this code was ported? Links to code, maybe some docs. Thanks.
Sure:
https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8
Signature · 1 line
Alex Kiernan
cover Add fastboot UDP support
In reply to Sam ProtsenkoQuoted 11 lines · Alex Kiernan
Quoted 4 lines
This series merges the fastboot UDP support from AOSP into mainline U-Boot.
Can you please point me out from which AOSP code exactly this code was ported? Links to code, maybe some docs. Thanks.
The documentation for fastboot over UDP (as well as the rest of the transport layers) is in the userspace fastboot tool, you can read the README.md in AOSP:
https://android.googlesource.com/platform/system/core/+/master/fastboot