Skip to contentSkip to conversation

arm: BeagleBone Black: enable fastboot support

PATCH New Dileep Katta 2 participants 4 messages Sep 11, 2014 – Sep 17, 2014 1 message not in the archive USB

lore
Share & tools
lore
#1 lore raw

PATCH v3 1/2 arm: BeagleBone Black: enable fastboot support

In reply to a message not in the archive

Enable Android Fastboot support on am335x_evm board

---
Changes in v2:
-None
Changes in v3:
-None

 include/configs/am335x_evm.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/configs/am335x_evm.h +10 -0
index 35ae0e6..3999405 100644
@@ -291,6 +291,11 @@
 #define CONFIG_AM335X_USB0_MODE	MUSB_PERIPHERAL
 #define CONFIG_AM335X_USB1
 #define CONFIG_AM335X_USB1_MODE MUSB_HOST
+/* Fastboot */
+#define CONFIG_CMD_FASTBOOT
+#define CONFIG_ANDROID_BOOT_IMAGE
+#define CONFIG_USB_FASTBOOT_BUF_ADDR	CONFIG_SYS_LOAD_ADDR
+#define CONFIG_USB_FASTBOOT_BUF_SIZE	0x07000000
 
 #ifdef CONFIG_MUSB_HOST
 #define CONFIG_CMD_USB
@@ -303,8 +308,13 @@
 #define CONFIG_USBNET_HOST_ADDR	"de:ad:be:af:00:00"
 
 /* USB TI's IDs */
+#ifdef CONFIG_CMD_FASTBOOT
+#define CONFIG_G_DNL_VENDOR_NUM 0x0451
+#define CONFIG_G_DNL_PRODUCT_NUM 0xd022 /* TI fastboot PID */
+#else
 #define CONFIG_G_DNL_VENDOR_NUM 0x0403
 #define CONFIG_G_DNL_PRODUCT_NUM 0xBD00
+#endif
 #define CONFIG_G_DNL_MANUFACTURER "Texas Instruments"
 #endif /* CONFIG_MUSB_GADGET */
 
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH v3 2/2 fastboot: Flash command support

Flash command internally uses DFU, and Fastboot command initialization is modified to add DFU and partition initialization Added oem format functionality for GPT table creation
partitioning code is added as disk/part_fastboot.c for better usability

Fastboot flash command code is enabled and being tested on BeagleBone Black.
OMAP3 Beagle configuration is modified to fix the build errors, but this configuration needs to be updated as per the flash functionality.

---
Changes in v2:
- Fixed coding style issues
Changes in v3:
- Removed unnecessary code and flags as per review comments

 common/cmd_fastboot.c           |   5 +
 common/cmd_mmc.c                |   2 +-
 common/cmd_nvedit.c             |   2 +-
 disk/Makefile                   |   1 +
 disk/part_fastboot.c            | 379 ++++++++++++++++++++++++++++++++++++++++
 doc/README.android-fastboot     |  26 +++
 drivers/usb/gadget/f_fastboot.c | 178 ++++++++++++++++++-
 include/configs/am335x_evm.h    |  23 ++-
 include/configs/omap3_beagle.h  |  12 ++
 include/usb/fastboot.h          | 182 +++++++++++++++++++
 10 files changed, 796 insertions(+), 14 deletions(-)
 create mode 100644 disk/part_fastboot.c
 create mode 100644 include/usb/fastboot.h
common/cmd_fastboot.c +5 -0
index 83fa7bd..6d0d0a4 100644
@@ -10,11 +10,15 @@
 #include <common.h>
 #include <command.h>
 #include <g_dnl.h>
+#include <dfu.h>
+#include <usb/fastboot.h>
 
 static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
 	int ret;
 
+	board_partition_init();
+	dfu_init_env_entities("mmc", CONFIG_FB_MMCDEV);
 	ret = g_dnl_register("usb_dnl_fastboot");
 	if (ret)
 		return ret;
@@ -26,6 +30,7 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	}
 
 	g_dnl_unregister();
+	dfu_free_entities();
 	return CMD_RET_SUCCESS;
 }
 
common/cmd_mmc.c +1 -1
index 1e40983..dd7170d 100644
@@ -612,7 +612,7 @@ static cmd_tbl_t cmd_mmc[] = {
 	U_BOOT_CMD_MKENT(setdsr, 2, 0, do_mmc_setdsr, "", ""),
 };
 
-static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	cmd_tbl_t *cp;
 
common/cmd_nvedit.c +1 -1
index 855808c..a100109 100644
@@ -686,7 +686,7 @@ ulong getenv_ulong(const char *name, int base, ulong default_val)
 
 #ifndef CONFIG_SPL_BUILD
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
+int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
 		       char * const argv[])
 {
 	printf("Saving Environment to %s...\n", env_name_spec);
disk/Makefile +1 -0
index 6970cec..4b7a9ef 100644
@@ -13,3 +13,4 @@ obj-$(CONFIG_DOS_PARTITION)   += part_dos.o
 obj-$(CONFIG_ISO_PARTITION)   += part_iso.o
 obj-$(CONFIG_AMIGA_PARTITION) += part_amiga.o
 obj-$(CONFIG_EFI_PARTITION)   += part_efi.o
+obj-$(CONFIG_CMD_FASTBOOT)    += part_fastboot.o
disk/part_fastboot.c new file +379 -0

379 lines not on this page · raw message

doc/README.android-fastboot +26 -0
index f1d128c..5420e5e 100644
@@ -46,6 +46,14 @@ buffer should be as large as possible for a platform. The location of the
 buffer and size are set with CONFIG_USB_FASTBOOT_BUF_ADDR and
 CONFIG_USB_FASTBOOT_BUF_SIZE.
 
+Fastboot flash command uses DFU and storage(NAND/MMC) specific
+functionality, and hence related definitions needs to be defined:
+
+DFU_ALT_INFO
+CONFIG_STORAGE_EMMC
+CONFIG_FB_MMCDEV
+
+
 In Action
 =========
 Enter into fastboot by executing the fastboot command in u-boot and you
@@ -89,3 +97,21 @@ and on the gadget side you should see:
 |OK
 |
 |Starting kernel ...
+
+Flash command in action, on the client side:
+
+|>fastboot flash bootloader u-boot.img
+|target reported max download size of 1835008 bytes
+|sending 'bootloader' (395 KB)...
+|OKAY [  0.144s]
+|writing 'bootloader'...
+|OKAY [  0.009s]
+|finished. total time: 0.153s
+
+and on the gadget side you should see:
+|Starting download of 405019 bytes
+|...
+|downloading of 405019 bytes finished
+|download_bytes: 0x62e1b
+|Writing 'bootloader'
+|Writing 'bootloader' DONE!
drivers/usb/gadget/f_fastboot.c +171 -7

255 lines not on this page · raw message

include/configs/am335x_evm.h +18 -5
index 3999405..2227a88 100644
@@ -87,6 +87,7 @@
 		"uuid_disk=${uuid_gpt_disk};" \
 		"name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}\0" \
 	"optargs=\0" \
+	"dfu_alt_info=" DFU_ALT_INFO "\0" \
 	"mmcdev=0\0" \
 	"mmcroot=/dev/mmcblk0p2 ro\0" \
 	"mmcrootfstype=ext4 rootwait\0" \
@@ -303,6 +304,16 @@
 #endif
 
 #ifdef CONFIG_MUSB_GADGET
+
+#define CONFIG_FB_MMCDEV			1
+
+/*Uncomment this to enable NAND fastboot*/
+/*#define CONFIG_NAND */
+
+/*Uncomment this to support eMMC booting*/
+#define CONFIG_STORAGE_EMMC
+
+
 #define CONFIG_USB_ETHER
 #define CONFIG_USB_ETH_RNDIS
 #define CONFIG_USBNET_HOST_ADDR	"de:ad:be:af:00:00"
@@ -336,14 +347,13 @@
 #define CONFIG_DFU_MMC
 #define CONFIG_CMD_DFU
 #define DFU_ALT_INFO_MMC \
-	"dfu_alt_info_mmc=" \
 	"boot part 0 1;" \
 	"rootfs part 0 2;" \
 	"MLO fat 0 1;" \
-	"MLO.raw mmc 0x100 0x100;" \
-	"u-boot.img.raw mmc 0x300 0x400;" \
-	"spl-os-args.raw mmc 0x80 0x80;" \
-	"spl-os-image.raw mmc 0x900 0x2000;" \
+	"MLO.raw raw 0x100 0x100;" \
+	"u-boot.img.raw raw 0x300 0x400;" \
+	"spl-os-args.raw raw 0x80 0x80;" \
+	"spl-os-image.raw raw 0x900 0x2000;" \
 	"spl-os-args fat 0 1;" \
 	"spl-os-image fat 0 1;" \
 	"u-boot.img fat 0 1;" \
@@ -374,6 +384,9 @@
 	DFU_ALT_INFO_MMC \
 	DFU_ALT_INFO_RAM \
 	DFU_ALT_INFO_NAND
+#ifdef CONFIG_DFU_MMC
+#define DFU_ALT_INFO DFU_ALT_INFO_MMC
+#endif
 #endif
 
 /*
include/configs/omap3_beagle.h +12 -0
index 644e97f..84594a0 100644
@@ -77,6 +77,18 @@
 #define CONFIG_USB_FASTBOOT_BUF_ADDR	CONFIG_SYS_LOAD_ADDR
 #define CONFIG_USB_FASTBOOT_BUF_SIZE	0x07000000
 
+#ifdef CONFIG_CMD_FASTBOOT
+#define CONFIG_FB_MMCDEV			1
+#define CONFIG_DFU_FUNCTION
+#define CONFIG_DFU_MMC
+#define CONFIG_CMD_DFU
+#define DFU_ALT_INFO_MMC ""
+#endif
+
+#ifdef CONFIG_DFU_MMC
+#define DFU_ALT_INFO DFU_ALT_INFO_MMC
+#endif
+
 /* USB EHCI */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
include/usb/fastboot.h new file +182 -0

182 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#3 lore raw

PATCH v3 2/2 fastboot: Flash command support

Dear Dileep Katta,

Quoted 6 lines · In message <[email protected]> you…

Flash command internally uses DFU, and Fastboot command initialization is modified to add DFU and partition initialization Added oem format functionality for GPT table creation
partitioning code is added as disk/part_fastboot.c for better usability

Fastboot flash command code is enabled and being tested on BeagleBone Black.
OMAP3 Beagle configuration is modified to fix the build errors, but this configuration needs to be updated as per the flash functionality.

Please fix the line length in the commit message.

Also, checkpatch says:

	WARNING: do not add new typedefs
	#1073: FILE: include/usb/fastboot.h:98:
	+typedef struct fastboot_ptentry fastboot_ptentry;
Quoted 16 lines
drivers/usb/gadget/f_fastboot.c +16 -0
+int handle_flash(char *part_name, char *response, char *transfer_buffer)
+{
+	int status = 0;
+	printf("download_bytes: 0x%x\n", download_bytes);
+	if (download_bytes) {
+		struct fastboot_ptentry *ptn;
+
+		/* Next is the partition name */
+		ptn = fastboot_flash_find_ptn(part_name);
+
+		if (ptn == 0) {
+			printf("Partition:[%s] does not exist\n", part_name);
+			sprintf(response, "FAILpartition does not exist");
+		} else if ((download_bytes > ptn->length) &&
+			!(ptn->flags & FASTBOOT_PTENTRY_FLAGS_WRITE_ENV)) {
+			printf("Image too large for the partition\n");

drivers/usb/gadget/f_fastboot.c static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) · line 646

Quoted 10 lines
drivers/usb/gadget/f_fastboot.c +10 -0
+			sprintf(response, "FAILimage too large for partition");
+		} else if (ptn->flags & FASTBOOT_PTENTRY_FLAGS_WRITE_ENV) {
+			/* Check if this is not really a flash write,
+			 * but instead a saveenv
+			 */
+			unsigned int i = 0;
+			/* Env file is expected with a NULL delimeter between
+			 * env variables So replace New line Feeds(0x0a) with
+			 * NULL (0x00)
+			 */

Incorrect multiline comment style. Please fix globally.

Also this sequence of comment - declaration - comment is highly confusing. What is the first comment ("Check if..") actually related to?

drivers/usb/gadget/f_fastboot.c static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) · line 654

Quoted 8 lines
drivers/usb/gadget/f_fastboot.c +8 -0
+			for (i = 0; i < download_bytes; i++) {
+				if (transfer_buffer[i] == 0x0a)
+					transfer_buffer[i] = 0x00;
+			}
+			memset(env_ptr->data, 0, ENV_SIZE);
+			memcpy(env_ptr->data, transfer_buffer, download_bytes);
+			do_env_save(NULL, 0, 1, NULL);
+			printf("saveenv to '%s' DONE!\n", ptn->name);

I think it is a bad idea to split formatting / reformatting envrionment data alll over the place. This should be done only once, in the environment handling code. Also, I do not like you using do_env_save() here - this should remain a static function. Why do't you simply use saveenv() here?

Finally, the "saveenv to '%s' DONE!\n" is IMO too verbose. No news is Good News - we usually do not report abot the success of operations, as this is what we expect. We should only print error messages when such occur - which points out another problem of that code: there is no error checking nor handling there...

disk/part_fastboot.c line 157

Quoted 6 lines
disk/part_fastboot.c new file +6 -0
+static void end_ptbl(struct ptable *ptbl)
+{
+	struct efi_header *hdr = &ptbl->header;
+	u32 n;
+
+	n = crc32(0, 0, 0);

What exactly is this good for?

disk/part_fastboot.c line 161

Quoted 4 lines
disk/part_fastboot.c new file +4 -0
+	n = crc32(n, (void *)ptbl->entry, sizeof(ptbl->entry));
+	hdr->entries_crc32 = n;
+
+	n = crc32(0, 0, 0);

What exactly is this good for?

disk/part_fastboot.c line 251

Quoted 10 lines
disk/part_fastboot.c new file +8 -0
+	n = crc32(0, (void *)&ptbl->header, sizeof(ptbl->header));
+	hdr->crc32 = n;
+}
 
 
+	for (n = 0; n < (128/4); n++) {
+		/* read partition */
+		source[0] = '\0';
+		dest[0] = '\0';
+		length[0] = '\0';

You overwrite source, dest, and length by the sprintf()s just a few lines below. So why are you doing this here?

Quoted 6 lines
disk/part_fastboot.c new file +6 -0
+		mmc_read[2] = source;
+		mmc_read[3] = dest;
+		mmc_read[4] = length;
+
+		sprintf(source, "%p", entry);
+		sprintf(dest, "0x%x", 0x1+n);

disk/part_fastboot.c line 276

Quoted 10 lines
disk/part_fastboot.c new file +8 -0
+		sprintf(length, "0x%x", 1);
 
 
+int board_mmc_fbtptn_init(void)
+{
+	char *mmc_init[2] = {"mmc", "rescan",};
+	char dev[2];
+	char *mmc_dev[3] = {"mmc", "dev", NULL};
+
+	mmc_dev[2] = dev;

Why do you initialize mmc_dev[2] with another value just a line above? Why don't you use the correct value right from the beginning?

disk/part_fastboot.c line 287

Quoted 9 lines
disk/part_fastboot.c new file +9 -0
+	if (do_mmcops(NULL, 0, 3, mmc_dev)) {
+		printf("MMC DEV: %d selection FAILED!\n", CONFIG_FB_MMCDEV);
+		return -1;
+	}
+
+	if (do_mmcops(NULL, 0, 2, mmc_init)) {
+			printf("FAIL:Init of MMC card\n");
+			return 1;
+	}

What exactly are your return codes? Here you return -1 in case of error, there +1 - what's the logic behind that?

disk/part_fastboot.c line 299

Quoted 4 lines
disk/part_fastboot.c new file +4 -0
+int do_format(void)
+{
+	struct ptable *ptbl = &the_ptable;
+	/* unsigned sector_sz; */

Please remove dead code.

disk/part_fastboot.c line 304

Quoted 1 line
disk/part_fastboot.c new file +1 -0
+	printf("\ndo_format ..!!");

Is this not overly verbose?

disk/part_fastboot.c line 306

Quoted 2 lines
disk/part_fastboot.c new file +2 -0
+	/* get mmc info */
+	struct mmc *mmc = find_mmc_device(CONFIG_FB_MMCDEV);

Please do not mix code and declarations. Also, always add a blank line after declarations.

disk/part_fastboot.c line 316

Quoted 4 lines
disk/part_fastboot.c new file +4 -0
+	if (mmc_init(mmc)) {
+		printf("\n mmc init FAILED");
+		return -1;
+	} else{

After the return, no else is needed here.

disk/part_fastboot.c line 352

Quoted 12 lines
disk/part_fastboot.c new file +11 -0
+		printf("\nmmc capacity is: %llu", mmc->capacity);
+		printf("\nmmc: number of blocks:0x%lx", mmc->block_dev.lba);
+		printf("\nmmc: block size:0x%lx", mmc->block_dev.blksz);
+	}
 
+	/* 10/11:modified as per PSP release support */
+	char *mmc_write[5]  = {"mmc", "write", NULL, NULL, NULL};
+	char source[32], dest[32], length[32];
+
+	char dev[2];
+	char *mmc_dev[3] = {"mmc", "dev", NULL};
+	mmc_dev[2] = dev;

See above - please do not mix code and declarations, please use the right initialization right away.

disk/part_fastboot.c line 372

Quoted 2 lines
disk/part_fastboot.c new file +2 -0
+	} else {
+		printf("Writing mbr is DONE!\n");

Less verbose, please.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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
At the source of every error which is blamed on the computer you will
find at least two human errors, including the error of blaming it  on
the computer.
#4 lore raw

PATCH v3 2/2 fastboot: Flash command support

Thanks for the review comments. Working on the fix.

Regards,
Dileep

Quoted 194 lines · Wolfgang Denk

Dear Dileep Katta,

Quoted 6 lines · In message <[email protected]> you…

Flash command internally uses DFU, and Fastboot command initialization is modified to add DFU and partition initialization Added oem format functionality for GPT table creation
partitioning code is added as disk/part_fastboot.c for better usability

Fastboot flash command code is enabled and being tested on BeagleBone Black.
OMAP3 Beagle configuration is modified to fix the build errors, but this configuration needs to be updated as per the flash functionality.

Please fix the line length in the commit message.

Also, checkpatch says:

        WARNING: do not add new typedefs
        #1073: FILE: include/usb/fastboot.h:98:
        +typedef struct fastboot_ptentry fastboot_ptentry;
Quoted 16 lines
drivers/usb/gadget/f_fastboot.c +16 -0
+int handle_flash(char *part_name, char *response, char *transfer_buffer)
+{
+     int status = 0;
+     printf("download_bytes: 0x%x\n", download_bytes);
+     if (download_bytes) {
+             struct fastboot_ptentry *ptn;
+
+             /* Next is the partition name */
+             ptn = fastboot_flash_find_ptn(part_name);
+
+             if (ptn == 0) {
+                     printf("Partition:[%s] does not exist\n", part_name);
+                     sprintf(response, "FAILpartition does not exist");
+             } else if ((download_bytes > ptn->length) &&
+                     !(ptn->flags & FASTBOOT_PTENTRY_FLAGS_WRITE_ENV)) {
+                     printf("Image too large for the partition\n");

drivers/usb/gadget/f_fastboot.c static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) · line 646

Quoted 10 lines
drivers/usb/gadget/f_fastboot.c +10 -0
+                     sprintf(response, "FAILimage too large for partition");
+             } else if (ptn->flags & FASTBOOT_PTENTRY_FLAGS_WRITE_ENV) {
+                     /* Check if this is not really a flash write,
+                      * but instead a saveenv
+                      */
+                     unsigned int i = 0;
+                     /* Env file is expected with a NULL delimeter between
+                      * env variables So replace New line Feeds(0x0a) with
+                      * NULL (0x00)
+                      */

Incorrect multiline comment style. Please fix globally.

Also this sequence of comment - declaration - comment is highly confusing. What is the first comment ("Check if..") actually related to?

drivers/usb/gadget/f_fastboot.c static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) · line 654

Quoted 8 lines
drivers/usb/gadget/f_fastboot.c +8 -0
+                     for (i = 0; i < download_bytes; i++) {
+                             if (transfer_buffer[i] == 0x0a)
+                                     transfer_buffer[i] = 0x00;
+                     }
+                     memset(env_ptr->data, 0, ENV_SIZE);
+                     memcpy(env_ptr->data, transfer_buffer, download_bytes);
+                     do_env_save(NULL, 0, 1, NULL);
+                     printf("saveenv to '%s' DONE!\n", ptn->name);

I think it is a bad idea to split formatting / reformatting envrionment data alll over the place. This should be done only once, in the environment handling code. Also, I do not like you using do_env_save() here - this should remain a static function. Why do't you simply use saveenv() here?

Finally, the "saveenv to '%s' DONE!\n" is IMO too verbose. No news is Good News - we usually do not report abot the success of operations, as this is what we expect. We should only print error messages when such occur - which points out another problem of that code: there is no error checking nor handling there...

disk/part_fastboot.c line 157

Quoted 6 lines
disk/part_fastboot.c new file +6 -0
+static void end_ptbl(struct ptable *ptbl)
+{
+     struct efi_header *hdr = &ptbl->header;
+     u32 n;
+
+     n = crc32(0, 0, 0);

What exactly is this good for?

disk/part_fastboot.c line 161

Quoted 4 lines
disk/part_fastboot.c new file +4 -0
+     n = crc32(n, (void *)ptbl->entry, sizeof(ptbl->entry));
+     hdr->entries_crc32 = n;
+
+     n = crc32(0, 0, 0);

What exactly is this good for?

disk/part_fastboot.c line 251

Quoted 10 lines
disk/part_fastboot.c new file +8 -0
+     n = crc32(0, (void *)&ptbl->header, sizeof(ptbl->header));
+     hdr->crc32 = n;
+}
 
 
+     for (n = 0; n < (128/4); n++) {
+             /* read partition */
+             source[0] = '\0';
+             dest[0] = '\0';
+             length[0] = '\0';

You overwrite source, dest, and length by the sprintf()s just a few lines below. So why are you doing this here?

Quoted 6 lines
disk/part_fastboot.c new file +6 -0
+             mmc_read[2] = source;
+             mmc_read[3] = dest;
+             mmc_read[4] = length;
+
+             sprintf(source, "%p", entry);
+             sprintf(dest, "0x%x", 0x1+n);

disk/part_fastboot.c line 276

Quoted 10 lines
disk/part_fastboot.c new file +8 -0
+             sprintf(length, "0x%x", 1);
 
 
+int board_mmc_fbtptn_init(void)
+{
+     char *mmc_init[2] = {"mmc", "rescan",};
+     char dev[2];
+     char *mmc_dev[3] = {"mmc", "dev", NULL};
+
+     mmc_dev[2] = dev;

Why do you initialize mmc_dev[2] with another value just a line above? Why don't you use the correct value right from the beginning?

disk/part_fastboot.c line 287

Quoted 9 lines
disk/part_fastboot.c new file +9 -0
+     if (do_mmcops(NULL, 0, 3, mmc_dev)) {
+             printf("MMC DEV: %d selection FAILED!\n", CONFIG_FB_MMCDEV);
+             return -1;
+     }
+
+     if (do_mmcops(NULL, 0, 2, mmc_init)) {
+                     printf("FAIL:Init of MMC card\n");
+                     return 1;
+     }

What exactly are your return codes? Here you return -1 in case of error, there +1 - what's the logic behind that?

disk/part_fastboot.c line 299

Quoted 4 lines
disk/part_fastboot.c new file +4 -0
+int do_format(void)
+{
+     struct ptable *ptbl = &the_ptable;
+     /* unsigned sector_sz; */

Please remove dead code.

Quoted 1 line

+ printf("\ndo_format ..!!");

Is this not overly verbose?

disk/part_fastboot.c line 306

Quoted 2 lines
disk/part_fastboot.c new file +2 -0
+     /* get mmc info */
+     struct mmc *mmc = find_mmc_device(CONFIG_FB_MMCDEV);

Please do not mix code and declarations. Also, always add a blank line after declarations.

disk/part_fastboot.c line 316

Quoted 4 lines
disk/part_fastboot.c new file +4 -0
+     if (mmc_init(mmc)) {
+             printf("\n mmc init FAILED");
+             return -1;
+     } else{

After the return, no else is needed here.

disk/part_fastboot.c line 352

Quoted 12 lines
disk/part_fastboot.c new file +11 -0
+             printf("\nmmc capacity is: %llu", mmc->capacity);
+             printf("\nmmc: number of blocks:0x%lx", mmc->block_dev.lba);
+             printf("\nmmc: block size:0x%lx", mmc->block_dev.blksz);
+     }
 
+     /* 10/11:modified as per PSP release support */
+     char *mmc_write[5]  = {"mmc", "write", NULL, NULL, NULL};
+     char source[32], dest[32], length[32];
+
+     char dev[2];
+     char *mmc_dev[3] = {"mmc", "dev", NULL};
+     mmc_dev[2] = dev;

See above - please do not mix code and declarations, please use the right initialization right away.

disk/part_fastboot.c line 372

Quoted 2 lines
disk/part_fastboot.c new file +2 -0
+     } else {
+             printf("Writing mbr is DONE!\n");

Less verbose, please.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
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 At the source of every error which is blamed on the computer you will find at least two human errors, including the error of blaming it on the computer.