Re: [U-Boot] [PATCH v2 2/4] fastboot: call board_usb_init() to enable usb

2015-03-27 Thread Dileep Katta
Experts,
Please send your valuable comments if this patch needs any change.

Regards, Dileep

On 14/03/2015, Lukasz Majewski  wrote:
> On Sat, 14 Mar 2015 00:58:51 +0530
> Dileep Katta  wrote:
>
>> Hi Lukasz,
>>
>> On 13 March 2015 at 13:23, Lukasz Majewski 
>> wrote:
>>
>> > Hi Dileep,
>> >
>> > > g_dnl_gadget_register() fails for dra7xx dwc3 gadget when running
>> > > cmd_fastboot. Calling board_usb_init() to fix this.
>> > > fastboot command is now added with an optional controller index
>> > > argument with default value as 0, to facilitate configurable
>> > > controller index.
>> > >
>> > > Signed-off-by: Angela Stegmaier 
>> > > Signed-off-by: Dileep Katta 
>> > > ---
>> > > Changes in v2:
>> > >   - Changed fastboot command to facilitate passing controller
>> > > index
>> > >   - Added board_usb_cleanup()
>> > > This patch considers the following change by Inha Song, without
>> > > which the build will be broken on BeagleBone Black platform
>> > >   https://patchwork.ozlabs.org/patch/430303/
>> > >
>> > >  common/cmd_fastboot.c | 15 ---
>> > >  1 file changed, 12 insertions(+), 3 deletions(-)
>> > >
>> > > diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
>> > > index 346ab80..9ca4a2f 100644
>> > > --- a/common/cmd_fastboot.c
>> > > +++ b/common/cmd_fastboot.c
>> > > @@ -10,11 +10,19 @@
>> > >  #include 
>> > >  #include 
>> > >  #include 
>> > > +#include 
>> > >
>> > >  static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char
>> > > *const argv[]) {
>> > >   int ret;
>> > > + int controller_index = 0;
>> > >
>> > > + if (argc == 2) {
>> > > + char *usb_controller = argv[1];
>> > > + controller_index = simple_strtoul(usb_controller,
>> > > NULL, 0);
>> > > + }
>> > > +
>> > > + board_usb_init(controller_index, USB_INIT_DEVICE);
>> > >   g_dnl_clear_detach();
>> > >   ret = g_dnl_register("usb_dnl_fastboot");
>> > >   if (ret)
>> > > @@ -36,12 +44,13 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int
>> > > flag, int argc, char *const argv[])
>> > >   g_dnl_unregister();
>> > >   g_dnl_clear_detach();
>> > > + board_usb_cleanup(controller_index, USB_INIT_DEVICE);
>> > >   return CMD_RET_SUCCESS;
>> > >  }
>> > >
>> > >  U_BOOT_CMD(
>> > > - fastboot,   1,  0,  do_fastboot,
>> > > + fastboot,   2,  0,  do_fastboot,
>> > >   "use USB Fastboot protocol",
>> > > - "\nLukasz Majewski "
>> > > - "- run as a fastboot usb device"
>> > > + "[]\n"
>> > > + "- run as a fastboot usb device via "
>> > >  );
>> >
>> > Acked-by: Lukasz Majewski 
>> >
>> > Since I'm not CC'ed to all patches, I assume that this work would go
>> > via other tree?
>> >
>> Other patches are TI board specific and I am working on next version
>> of the patches as per the review comments.
>> I felt that this is generic functionality and hence sent it
>> separately. Do you want me send all patches?
>
> No, it is not necessary. Regarding above, I assume that Tom will
> probably fetch those patches.
>
> I was just concern about tree to which this patch should belong.
>
> Regards,
> Lukasz
>
>>
>> Regards, Dileep
>>
>> >
>> > --
>> > Best regards,
>> >
>> > Lukasz Majewski
>> >
>> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
>> >
>> ___
>> U-Boot mailing list
>> U-Boot@lists.denx.de
>> http://lists.denx.de/mailman/listinfo/u-boot
>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 3/3] fastboot: ARM: OMAP5: Enable reboot-bootloader

2015-03-27 Thread Dileep Katta
Implemented fb_set_reboot_flag() for OMAP5 to set
an environment variable 'dofastboot' when reboot-bootloader called.

This environment variable will be checked in boot command and fastboot
will be called if the variable is set.
If the bootcmd env variable of OMAP5 common is overwritten with board-specific
command, then these changes will not apply.

This was originally intended for DRA7 platform, but now applies to all OMAP5.

Ref:
http://git.omapzoom.org/?p=repo/u-boot.git;a=commit;h=19da2e436e9806259cf1f4988b9e046ab256bf2c

Signed-off-by: Angela Stegmaier 
Signed-off-by: Dileep Katta 
---
Changes in v2:
- None
Changes in v3:
- Changed the implementation to be more abstract
- Used environment variable instead of board-specific registers
- Moved the code to OMAP5
Changes in v4:
- Removed udelay and sleep after saveenv

 arch/arm/cpu/armv7/omap-common/boot-common.c | 10 ++
 include/configs/ti_omap5_common.h|  7 +++
 2 files changed, 17 insertions(+)

diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c 
b/arch/arm/cpu/armv7/omap-common/boot-common.c
index 17500f2..55ca94d 100644
--- a/arch/arm/cpu/armv7/omap-common/boot-common.c
+++ b/arch/arm/cpu/armv7/omap-common/boot-common.c
@@ -162,3 +162,13 @@ void arch_preboot_os(void)
ahci_reset(DWC_AHSATA_BASE);
 }
 #endif
+
+#ifdef CONFIG_CMD_FASTBOOT
+int fb_set_reboot_flag(void)
+{
+   printf("Setting reboot to fastboot flag ...\n");
+   setenv("dofastboot", "1");
+   saveenv();
+   return 0;
+}
+#endif
diff --git a/include/configs/ti_omap5_common.h 
b/include/configs/ti_omap5_common.h
index cd92454..24f8021 100644
--- a/include/configs/ti_omap5_common.h
+++ b/include/configs/ti_omap5_common.h
@@ -141,13 +141,20 @@
"loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile};\0" \
DFUARGS \
 
+
 #define CONFIG_BOOTCOMMAND \
+   "if test ${dofastboot} -eq 1; then " \
+   "echo Boot fastboot requested, resetting dofastboot ...;" \
+   "setenv dofastboot 0; saveenv;" \
+   "echo Booting into fastboot ...; fastboot;" \
+   "fi;" \
"run findfdt; " \
"run mmcboot;" \
"setenv mmcdev 1; " \
"setenv bootpart 1:2; " \
"setenv mmcroot /dev/mmcblk0p2 rw; " \
"run mmcboot;" \
+   ""
 
 
 /*
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 3/3] fastboot: ARM: OMAP5: Enable reboot-bootloader

2015-03-27 Thread Dileep Katta
On 27/03/2015, Tom Rini  wrote:
> On Wed, Mar 25, 2015 at 04:04:52AM +0530, Dileep Katta wrote:
>
>> Implemented fb_set_reboot_flag() for OMAP5 to set
>> an environment variable 'dofastboot' when reboot-bootloader called.
>>
>> This environment variable will be checked in boot command and fastboot
>> will be called if the variable is set.
>> If the bootcmd env variable of OMAP5 common is overwritten with
>> board-specific
>> command, then these changes will not apply.
> [snip]
>> +printf("Setting reboot to fastboot flag ...\n");
>> +setenv("dofastboot", "1");
>> +saveenv();
>> +udelay(60);
> [snip]
>>  #define CONFIG_BOOTCOMMAND \
>> +"if test ${dofastboot} -eq 1; then " \
>> +"echo Boot fastboot requested, resetting dofastboot ...;" \
>> +"setenv dofastboot 0; saveenv; sleep 1;" \
>> +"echo Booting into fastboot ...; fastboot;" \
>
> No.  When saveenv returns environment is saved.  If it doesn't there's a
> bug that must be addressed.
sleep/udelay not required. Will remove and send an updated patch.
>
> --
> Tom
>
Thanks for the comment.
Regards, Dileep
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 3/3] fastboot: ARM: OMAP5: Enable reboot-bootloader

2015-03-24 Thread Dileep Katta
Implemented fb_set_reboot_flag() for OMAP5 to set
an environment variable 'dofastboot' when reboot-bootloader called.

This environment variable will be checked in boot command and fastboot
will be called if the variable is set.
If the bootcmd env variable of OMAP5 common is overwritten with board-specific
command, then these changes will not apply.

This was originally intended for DRA7 platform, but now applies to all OMAP5.

Ref:
http://git.omapzoom.org/?p=repo/u-boot.git;a=commit;h=19da2e436e9806259cf1f4988b9e046ab256bf2c

Signed-off-by: Angela Stegmaier 
Signed-off-by: Dileep Katta 
---
Changes in v2:
- None
Changes in v3:
- Changed the implementation to be more abstract
- Used environment variable instead of board-specific registers
- Moved the code to OMAP5

 arch/arm/cpu/armv7/omap-common/boot-common.c | 11 +++
 include/configs/ti_omap5_common.h|  7 +++
 2 files changed, 18 insertions(+)

diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c 
b/arch/arm/cpu/armv7/omap-common/boot-common.c
index 17500f2..1aff7c8 100644
--- a/arch/arm/cpu/armv7/omap-common/boot-common.c
+++ b/arch/arm/cpu/armv7/omap-common/boot-common.c
@@ -162,3 +162,14 @@ void arch_preboot_os(void)
ahci_reset(DWC_AHSATA_BASE);
 }
 #endif
+
+#ifdef CONFIG_CMD_FASTBOOT
+int fb_set_reboot_flag(void)
+{
+   printf("Setting reboot to fastboot flag ...\n");
+   setenv("dofastboot", "1");
+   saveenv();
+   udelay(60);
+   return 0;
+}
+#endif
diff --git a/include/configs/ti_omap5_common.h 
b/include/configs/ti_omap5_common.h
index cd92454..c5d97ea 100644
--- a/include/configs/ti_omap5_common.h
+++ b/include/configs/ti_omap5_common.h
@@ -141,13 +141,20 @@
"loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile};\0" \
DFUARGS \
 
+
 #define CONFIG_BOOTCOMMAND \
+   "if test ${dofastboot} -eq 1; then " \
+   "echo Boot fastboot requested, resetting dofastboot ...;" \
+   "setenv dofastboot 0; saveenv; sleep 1;" \
+   "echo Booting into fastboot ...; fastboot;" \
+   "fi;" \
"run findfdt; " \
"run mmcboot;" \
"setenv mmcdev 1; " \
"setenv bootpart 1:2; " \
"setenv mmcroot /dev/mmcblk0p2 rw; " \
"run mmcboot;" \
+   ""
 
 
 /*
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 2/3] ARM: DRA7: Set serial number environment variable

2015-03-24 Thread Dileep Katta
This patch populates serial number environment variable from
die_id_0 and die_id_1 register values for DRA7xx boards.

The function is added in omap common code so that this can be re-used.

Serial# environment variable will be useful to show correct
information in "fastboot devices" commands.

Ref:
http://git.omapzoom.org/?p=repo/u-boot.git;a=commit;h=a6bcaaf67f6e4bcd97808f53d0ceb4b0c04d583c

Signed-off-by: Angela Stegmaier 
Signed-off-by: Dileep Katta 
---
Changes in v2:
- None
Changes in v3:
- corrected the error in the computation of serial# variable
- Made it more generic and reusable as per the comments

 arch/arm/cpu/armv7/omap-common/utils.c | 13 +
 arch/arm/cpu/armv7/omap5/prcm-regs.c   |  4 
 arch/arm/include/asm/omap_common.h |  5 +
 board/ti/dra7xx/evm.c  |  6 ++
 4 files changed, 28 insertions(+)

diff --git a/arch/arm/cpu/armv7/omap-common/utils.c 
b/arch/arm/cpu/armv7/omap-common/utils.c
index 1696c2d..df5f817 100644
--- a/arch/arm/cpu/armv7/omap-common/utils.c
+++ b/arch/arm/cpu/armv7/omap-common/utils.c
@@ -60,3 +60,16 @@ void __weak usb_fake_mac_from_die_id(u32 *id)
eth_setenv_enetaddr("usbethaddr", device_mac);
}
 }
+
+void __weak usb_set_serial_num_from_die_id(u32 *id)
+{
+   char serialno[72];
+   uint32_t serialno_lo, serialno_hi;
+
+   if (!getenv("serial#")) {
+   serialno_hi = id[0];
+   serialno_lo = id[1];
+   sprintf(serialno, "%08x%08x", serialno_hi, serialno_lo);
+   setenv("serial#", serialno);
+   }
+}
diff --git a/arch/arm/cpu/armv7/omap5/prcm-regs.c 
b/arch/arm/cpu/armv7/omap5/prcm-regs.c
index 440bb40..f80d36d 100644
--- a/arch/arm/cpu/armv7/omap5/prcm-regs.c
+++ b/arch/arm/cpu/armv7/omap5/prcm-regs.c
@@ -440,6 +440,10 @@ struct omap_sys_ctrl_regs const dra7xx_ctrl = {
.control_emif1_sdram_config_ext = 0x4AE0C144,
.control_emif2_sdram_config_ext = 0x4AE0C148,
.control_wkup_ldovbb_mpu_voltage_ctrl   = 0x4AE0C158,
+   .control_std_fuse_die_id_0  = 0x4AE0C200,
+   .control_std_fuse_die_id_1  = 0x4AE0C208,
+   .control_std_fuse_die_id_2  = 0x4AE0C20C,
+   .control_std_fuse_die_id_3  = 0x4AE0C210,
.control_padconf_mode   = 0x4AE0C5A0,
.control_xtal_oscillator= 0x4AE0C5A4,
.control_i2c_2  = 0x4AE0C5A8,
diff --git a/arch/arm/include/asm/omap_common.h 
b/arch/arm/include/asm/omap_common.h
index bd43099..13a57ab 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -362,6 +362,10 @@ struct omap_sys_ctrl_regs {
u32 control_core_control_io1;
u32 control_core_control_io2;
u32 control_id_code;
+   u32 control_std_fuse_die_id_0;
+   u32 control_std_fuse_die_id_1;
+   u32 control_std_fuse_die_id_2;
+   u32 control_std_fuse_die_id_3;
u32 control_std_fuse_opp_bgap;
u32 control_ldosram_iva_voltage_ctrl;
u32 control_ldosram_mpu_voltage_ctrl;
@@ -578,6 +582,7 @@ void abb_setup(u32 fuse, u32 ldovbb, u32 setup, u32 control,
 s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb);
 
 void usb_fake_mac_from_die_id(u32 *id);
+void usb_set_serial_num_from_die_id(u32 *id);
 
 /* ABB */
 #define OMAP_ABB_NOMINAL_OPP   0
diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index 3089fa2..cadff5a 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -93,10 +93,16 @@ int board_init(void)
 int board_late_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+   u32 id[4];
+
if (omap_revision() == DRA722_ES1_0)
setenv("board_name", "dra72x");
else
setenv("board_name", "dra7xx");
+
+   id[0] = readl((*ctrl)->control_std_fuse_die_id_0);
+   id[1] = readl((*ctrl)->control_std_fuse_die_id_1);
+   usb_set_serial_num_from_die_id(id);
 #endif
return 0;
 }
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 1/3] ARM: DRA7XX: Enable Fastboot

2015-03-24 Thread Dileep Katta
- Fastboot is enable by default for DRA7XX
- This is based on following patch modified accordingly
http://git.omapzoom.org/?p=repo/u-boot.git;a=commit;h=b2e04f92b5d91c708b6fd6b79d2266966ac51f4b

Signed-off-by: Angela Stegmaier 
Signed-off-by: Dileep Katta 
---
Changes in v2:
- Merged the header file content to existing dra7xx_evm.h to avoid 
duplication
- Removed unnecessary definitions as per comments
Changes in v3:
- Added the changes on dwc3_gadget developer branch of DFU tree
- Added the changes as part of existing dra7xx_evm_defconfig
- Enabled fastboot by default
- Kept fastboot aware VID/PID only
- reverted change made for U-Boot offset

 include/configs/dra7xx_evm.h | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index e94b618..7acd907 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -84,6 +84,14 @@
DFU_ALT_INFO_EMMC \
DFU_ALT_INFO_RAM
 
+/* Fastboot */
+#define CONFIG_CMD_FASTBOOT
+#define CONFIG_ANDROID_BOOT_IMAGE
+#define CONFIG_USB_FASTBOOT_BUF_ADDRCONFIG_SYS_LOAD_ADDR
+#define CONFIG_USB_FASTBOOT_BUF_SIZE0x2F00
+#define CONFIG_FASTBOOT_FLASH
+#define CONFIG_FASTBOOT_FLASH_MMC_DEV   1
+
 #include 
 
 /* Enhance our eMMC support / experience. */
@@ -181,8 +189,8 @@
 #define CONFIG_USBDOWNLOAD_GADGET
 #define CONFIG_USB_GADGET_VBUS_DRAW 2
 #define CONFIG_G_DNL_MANUFACTURER "Texas Instruments"
-#define CONFIG_G_DNL_VENDOR_NUM 0x0403
-#define CONFIG_G_DNL_PRODUCT_NUM 0xBD00
+#define CONFIG_G_DNL_VENDOR_NUM 0x0451
+#define CONFIG_G_DNL_PRODUCT_NUM 0xd022
 #define CONFIG_USB_GADGET_DUALSPEED
 
 /* USB Device Firmware Update support */
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/1] ARM: DRA7XX: Add config file for Android with fastboot support

2015-03-23 Thread Dileep Katta
Hi Tom,

On 19 March 2015 at 18:45, Tom Rini  wrote:

> On Thu, Mar 19, 2015 at 02:42:16AM +0530, Dileep Katta wrote:
> > Hi Tom,
> >
> > On 18 March 2015 at 21:41, Tom Rini  wrote:
> >
> > > On Wed, Mar 18, 2015 at 12:08:23AM +0530, Dileep Katta wrote:
> > >
> > > >   - Added new configuration for Android fastboot
> > > >   - This is based on following patch modified accordingly
> > > >
> > >
> http://git.omapzoom.org/?p=repo/u-boot.git;a=commit;h=b2e04f92b5d91c708b6fd6b79d2266966ac51f4b
> > > >
> > > > Signed-off-by: Angela Stegmaier 
> > > > Signed-off-by: Dileep Katta 
> > > [snip]
> > > > @@ -43,6 +43,16 @@
> > > >   "uuid_disk=${uuid_gpt_disk};" \
> > > >   "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}"
> > > >
> > > > +#ifdef CONFIG_DRA7XX_ANDROID
> > > > +/* Fastboot */
> > > > +#define CONFIG_CMD_FASTBOOT
> > > > +#define CONFIG_ANDROID_BOOT_IMAGE
> > > > +#define CONFIG_USB_FASTBOOT_BUF_ADDRCONFIG_SYS_LOAD_ADDR
> > > > +#define CONFIG_USB_FASTBOOT_BUF_SIZE0x2F00
> > > > +#define CONFIG_FASTBOOT_FLASH
> > > > +#define CONFIG_FASTBOOT_FLASH_MMC_DEV   1
> > > > +#endif
> > > > +
> > > >  #include 
> > >
> > > No, just enable fastboot.  There's a growing population of people whose
> > > workflow is "use fastboot to shove a new test kernel at my device" that
> > > aren't strictly using Android, lets enable them.
> > >
> > OK, will enable fastboot unconditional.
> > Now there is no much difference for android_defconfig, but will still
> keep
> > separate config for future changes.
>
> I remain unconvinced that we need a separate config upstream still.
>
Will remove separate config.

>
> > > > @@ -115,7 +125,11 @@
> > > >  #define CONFIG_SPL_SPI_SUPPORT
> > > >  #define CONFIG_SPL_SPI_LOAD
> > > >  #define CONFIG_SPL_SPI_FLASH_SUPPORT
> > > > +#ifdef CONFIG_DRA7XX_ANDROID
> > > > +#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x8
> > > > +#else
> > > >  #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x4
> > > > +#endif
> > >
> > > Why are you moving U-Boot so much higher in SPI flash?
> >
> > This is done to accommodate  larger size MLO.
>
> Oh that's right.  Some parts can be made with a larger SRAM and thus we
> could use a larger MLO.  But are we?  What functionality would we be
> shoving into a larger MLO that would make sense to do this really?
> Frankly I had been thinking that in these parts it makes more sense to
> jump to full U-Boot and skip SPL rather than make SPL be very
> complicated.
>
Strictly speaking, its not required now, and can be changed when required.

>
> > > > +#define CONFIG_USBDOWNLOAD_GADGET
> > > > +#define CONFIG_USB_GADGET_VBUS_DRAW 2
> > > > +#define CONFIG_G_DNL_MANUFACTURER "Texas Instruments"
> > > > +#ifdef CONFIG_CMD_FASTBOOT
> > > > +#define CONFIG_G_DNL_VENDOR_NUM 0x0451
> > > > +#define CONFIG_G_DNL_PRODUCT_NUM 0xd022
> > > > +#else
> > > > +#define CONFIG_G_DNL_VENDOR_NUM 0x0403
> > > > +#define CONFIG_G_DNL_PRODUCT_NUM 0xBD00
> > > > +#endif
> > > > +#define CONFIG_USB_GADGET_DUALSPEED
> > >
> > > Why can't we always use one vid/pid?
> > >
> > As we are restricted to use the vid which fastboot host application
> knows,
> > the other/original
> > vid/pid kept intact for the dependent functionality, if any.
> > Will check if 0x0403/0xBD00 could be removed.
>
> I think we can just always use the VID/PID that fastboot knows, DFU
> isn't nearly so picky and other gadget use cases don't care I believe.
>
Will use fastboot aware  VID/PID pair, always.

>
> --
> Tom
>
Regards, Dileep
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/1] ARM: DRA7XX: Add config file for Android with fastboot support

2015-03-18 Thread Dileep Katta
Hi Tom,

On 18 March 2015 at 21:41, Tom Rini  wrote:

> On Wed, Mar 18, 2015 at 12:08:23AM +0530, Dileep Katta wrote:
>
> >   - Added new configuration for Android fastboot
> >   - This is based on following patch modified accordingly
> >
> http://git.omapzoom.org/?p=repo/u-boot.git;a=commit;h=b2e04f92b5d91c708b6fd6b79d2266966ac51f4b
> >
> > Signed-off-by: Angela Stegmaier 
> > Signed-off-by: Dileep Katta 
> [snip]
> > @@ -43,6 +43,16 @@
> >   "uuid_disk=${uuid_gpt_disk};" \
> >   "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}"
> >
> > +#ifdef CONFIG_DRA7XX_ANDROID
> > +/* Fastboot */
> > +#define CONFIG_CMD_FASTBOOT
> > +#define CONFIG_ANDROID_BOOT_IMAGE
> > +#define CONFIG_USB_FASTBOOT_BUF_ADDRCONFIG_SYS_LOAD_ADDR
> > +#define CONFIG_USB_FASTBOOT_BUF_SIZE0x2F00
> > +#define CONFIG_FASTBOOT_FLASH
> > +#define CONFIG_FASTBOOT_FLASH_MMC_DEV   1
> > +#endif
> > +
> >  #include 
>
> No, just enable fastboot.  There's a growing population of people whose
> workflow is "use fastboot to shove a new test kernel at my device" that
> aren't strictly using Android, lets enable them.
>
OK, will enable fastboot unconditional.
Now there is no much difference for android_defconfig, but will still keep
separate config for future changes.

>
> > @@ -115,7 +125,11 @@
> >  #define CONFIG_SPL_SPI_SUPPORT
> >  #define CONFIG_SPL_SPI_LOAD
> >  #define CONFIG_SPL_SPI_FLASH_SUPPORT
> > +#ifdef CONFIG_DRA7XX_ANDROID
> > +#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x8
> > +#else
> >  #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x4
> > +#endif
>
> Why are you moving U-Boot so much higher in SPI flash?
>
This is done to accommodate  larger size MLO.

>
> > @@ -130,6 +144,22 @@
> >  #define CONFIG_OMAP_USB_PHY
> >  #define CONFIG_OMAP_USB2PHY2_HOST
> >
> > +/* USB GADGET */
> > +#define CONFIG_USB_GADGET
> > +#define CONFIG_MUSB_GADGET
> > +#define CONFIG_MUSB_PIO_ONLY
>
> This board doesn't have MUSB, DWC3 only.
>
Thanks. DWC3 is enabled in dwc3_gadget developer branch of DFU custodian
tree.
Will submit the updated patch on top of the same

>
> > +#define CONFIG_USBDOWNLOAD_GADGET
> > +#define CONFIG_USB_GADGET_VBUS_DRAW 2
> > +#define CONFIG_G_DNL_MANUFACTURER "Texas Instruments"
> > +#ifdef CONFIG_CMD_FASTBOOT
> > +#define CONFIG_G_DNL_VENDOR_NUM 0x0451
> > +#define CONFIG_G_DNL_PRODUCT_NUM 0xd022
> > +#else
> > +#define CONFIG_G_DNL_VENDOR_NUM 0x0403
> > +#define CONFIG_G_DNL_PRODUCT_NUM 0xBD00
> > +#endif
> > +#define CONFIG_USB_GADGET_DUALSPEED
>
> Why can't we always use one vid/pid?
>
As we are restricted to use the vid which fastboot host application knows,
the other/original
vid/pid kept intact for the dependent functionality, if any.
Will check if 0x0403/0xBD00 could be removed.

>
> --
> Tom
>
Regards, Dileep
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/1] ARM: DRA7XX: Add config file for Android with fastboot support

2015-03-17 Thread Dileep Katta
- Added new configuration for Android fastboot
- This is based on following patch modified accordingly
http://git.omapzoom.org/?p=repo/u-boot.git;a=commit;h=b2e04f92b5d91c708b6fd6b79d2266966ac51f4b

Signed-off-by: Angela Stegmaier 
Signed-off-by: Dileep Katta 
---
Changes in v2:
- Merged the header file content to existing dra7xx_evm.h to avoid 
duplication
- Removed unnecessary definitions as per comments

 board/ti/dra7xx/MAINTAINERS  |  1 +
 configs/dra7xx_evm_android_defconfig |  5 +
 include/configs/dra7xx_evm.h | 30 ++
 3 files changed, 36 insertions(+)
 create mode 100644 configs/dra7xx_evm_android_defconfig

diff --git a/board/ti/dra7xx/MAINTAINERS b/board/ti/dra7xx/MAINTAINERS
index 5ec6769..1b5ae71 100644
--- a/board/ti/dra7xx/MAINTAINERS
+++ b/board/ti/dra7xx/MAINTAINERS
@@ -6,3 +6,4 @@ F:  include/configs/dra7xx_evm.h
 F: configs/dra7xx_evm_defconfig
 F: configs/dra7xx_evm_qspiboot_defconfig
 F: configs/dra7xx_evm_uart3_defconfig
+F: configs/dra7xx_evm_android_defconfig
diff --git a/configs/dra7xx_evm_android_defconfig 
b/configs/dra7xx_evm_android_defconfig
new file mode 100644
index 000..5fdce85
--- /dev/null
+++ b/configs/dra7xx_evm_android_defconfig
@@ -0,0 +1,5 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=1,DRA7XX_ANDROID"
++S:CONFIG_ARM=y
++S:CONFIG_OMAP54XX=y
++S:CONFIG_TARGET_DRA7XX_EVM=y
diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index dee2b11..dd20e08 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -43,6 +43,16 @@
"uuid_disk=${uuid_gpt_disk};" \
"name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}"
 
+#ifdef CONFIG_DRA7XX_ANDROID
+/* Fastboot */
+#define CONFIG_CMD_FASTBOOT
+#define CONFIG_ANDROID_BOOT_IMAGE
+#define CONFIG_USB_FASTBOOT_BUF_ADDRCONFIG_SYS_LOAD_ADDR
+#define CONFIG_USB_FASTBOOT_BUF_SIZE0x2F00
+#define CONFIG_FASTBOOT_FLASH
+#define CONFIG_FASTBOOT_FLASH_MMC_DEV   1
+#endif
+
 #include 
 
 /* Enhance our eMMC support / experience. */
@@ -115,7 +125,11 @@
 #define CONFIG_SPL_SPI_SUPPORT
 #define CONFIG_SPL_SPI_LOAD
 #define CONFIG_SPL_SPI_FLASH_SUPPORT
+#ifdef CONFIG_DRA7XX_ANDROID
+#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x8
+#else
 #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x4
+#endif
 
 #define CONFIG_SUPPORT_EMMC_BOOT
 
@@ -130,6 +144,22 @@
 #define CONFIG_OMAP_USB_PHY
 #define CONFIG_OMAP_USB2PHY2_HOST
 
+/* USB GADGET */
+#define CONFIG_USB_GADGET
+#define CONFIG_MUSB_GADGET
+#define CONFIG_MUSB_PIO_ONLY
+#define CONFIG_USBDOWNLOAD_GADGET
+#define CONFIG_USB_GADGET_VBUS_DRAW 2
+#define CONFIG_G_DNL_MANUFACTURER "Texas Instruments"
+#ifdef CONFIG_CMD_FASTBOOT
+#define CONFIG_G_DNL_VENDOR_NUM 0x0451
+#define CONFIG_G_DNL_PRODUCT_NUM 0xd022
+#else
+#define CONFIG_G_DNL_VENDOR_NUM 0x0403
+#define CONFIG_G_DNL_PRODUCT_NUM 0xBD00
+#endif
+#define CONFIG_USB_GADGET_DUALSPEED
+
 /* SATA */
 #define CONFIG_BOARD_LATE_INIT
 #define CONFIG_CMD_SCSI
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/4] fastboot: call board_usb_init() to enable usb

2015-03-13 Thread Dileep Katta
Hi Lukasz,

On 13 March 2015 at 13:23, Lukasz Majewski  wrote:

> Hi Dileep,
>
> > g_dnl_gadget_register() fails for dra7xx dwc3 gadget when running
> > cmd_fastboot. Calling board_usb_init() to fix this.
> > fastboot command is now added with an optional controller index
> > argument with default value as 0, to facilitate configurable
> > controller index.
> >
> > Signed-off-by: Angela Stegmaier 
> > Signed-off-by: Dileep Katta 
> > ---
> > Changes in v2:
> >   - Changed fastboot command to facilitate passing controller
> > index
> >   - Added board_usb_cleanup()
> > This patch considers the following change by Inha Song, without which
> > the build will be broken on BeagleBone Black platform
> >   https://patchwork.ozlabs.org/patch/430303/
> >
> >  common/cmd_fastboot.c | 15 ---
> >  1 file changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
> > index 346ab80..9ca4a2f 100644
> > --- a/common/cmd_fastboot.c
> > +++ b/common/cmd_fastboot.c
> > @@ -10,11 +10,19 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char
> > *const argv[]) {
> >   int ret;
> > + int controller_index = 0;
> >
> > + if (argc == 2) {
> > + char *usb_controller = argv[1];
> > + controller_index = simple_strtoul(usb_controller,
> > NULL, 0);
> > + }
> > +
> > + board_usb_init(controller_index, USB_INIT_DEVICE);
> >   g_dnl_clear_detach();
> >   ret = g_dnl_register("usb_dnl_fastboot");
> >   if (ret)
> > @@ -36,12 +44,13 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int
> > flag, int argc, char *const argv[])
> >   g_dnl_unregister();
> >   g_dnl_clear_detach();
> > + board_usb_cleanup(controller_index, USB_INIT_DEVICE);
> >   return CMD_RET_SUCCESS;
> >  }
> >
> >  U_BOOT_CMD(
> > - fastboot,   1,  0,  do_fastboot,
> > + fastboot,   2,  0,  do_fastboot,
> >   "use USB Fastboot protocol",
> > - "\nLukasz Majewski "
> > - "- run as a fastboot usb device"
> > + "[]\n"
> > + "- run as a fastboot usb device via "
> >  );
>
> Acked-by: Lukasz Majewski 
>
> Since I'm not CC'ed to all patches, I assume that this work would go
> via other tree?
>
Other patches are TI board specific and I am working on next version of the
patches as per the review comments.
I felt that this is generic functionality and hence sent it separately. Do
you want me send all patches?

Regards, Dileep

>
> --
> Best regards,
>
> Lukasz Majewski
>
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/4] fastboot: call board_usb_init() to enable usb

2015-03-12 Thread Dileep Katta
g_dnl_gadget_register() fails for dra7xx dwc3 gadget when running
cmd_fastboot. Calling board_usb_init() to fix this.
fastboot command is now added with an optional controller index argument
with default value as 0, to facilitate configurable controller index.

Signed-off-by: Angela Stegmaier 
Signed-off-by: Dileep Katta 
---
Changes in v2:
- Changed fastboot command to facilitate passing controller index
- Added board_usb_cleanup()
This patch considers the following change by Inha Song, without which
the build will be broken on BeagleBone Black platform
https://patchwork.ozlabs.org/patch/430303/

 common/cmd_fastboot.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
index 346ab80..9ca4a2f 100644
--- a/common/cmd_fastboot.c
+++ b/common/cmd_fastboot.c
@@ -10,11 +10,19 @@
 #include 
 #include 
 #include 
+#include 
 
 static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const 
argv[])
 {
int ret;
+   int controller_index = 0;
 
+   if (argc == 2) {
+   char *usb_controller = argv[1];
+   controller_index = simple_strtoul(usb_controller, NULL, 0);
+   }
+
+   board_usb_init(controller_index, USB_INIT_DEVICE);
g_dnl_clear_detach();
ret = g_dnl_register("usb_dnl_fastboot");
if (ret)
@@ -36,12 +44,13 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int 
argc, char *const argv[])
 
g_dnl_unregister();
g_dnl_clear_detach();
+   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
return CMD_RET_SUCCESS;
 }
 
 U_BOOT_CMD(
-   fastboot,   1,  0,  do_fastboot,
+   fastboot,   2,  0,  do_fastboot,
"use USB Fastboot protocol",
-   "\n"
-   "- run as a fastboot usb device"
+   "[]\n"
+   "- run as a fastboot usb device via "
 );
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/4] fastboot: call board_usb_init() to enable usb

2015-03-11 Thread Dileep Katta
On 5 March 2015 at 20:07, Tom Rini  wrote:

> On Thu, Mar 05, 2015 at 12:36:57AM +0530, Dileep Katta wrote:
> > On 4 March 2015 at 23:59, Tom Rini  wrote:
> >
> > > On Wed, Mar 04, 2015 at 05:05:11PM +, Stegmaier, Angela wrote:
> > > > Hi Dileep,
> > > >
> > > > > -Original Message-
> > > > > From: Dileep Katta [mailto:dileep.ka...@linaro.org]
> > > > > Sent: Tuesday, March 03, 2015 5:11 AM
> > > > > To: u-boot@lists.denx.de; robherri...@gmail.com; Rini, Tom;
> > > > > rob.herr...@linaro.org; s...@broadcom.com; l.majew...@samsung.com;
> > > > > Stegmaier, Angela
> > > > > Cc: Dileep Katta
> > > > > Subject: [U-Boot][PATCH v2 2/4] fastboot: call board_usb_init() to
> > > enable
> > > > > usb
> > > > >
> > > > > g_dnl_gadget_register() fails for dra7xx dwc3 gadget when running
> > > > > cmd_fastboot.
> > > > > Calling board_usb_init() fixes this.
> > > > >
> > > > > Signed-off-by: Angela Stegmaier 
> > > > > Signed-off-by: Dileep Katta 
> > > > > ---
> > > > >  common/cmd_fastboot.c | 2 ++
> > > > >  1 file changed, 2 insertions(+)
> > > > >
> > > > > diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c index
> > > > > 346ab80..d7b8f6d 100644
> > > > > --- a/common/cmd_fastboot.c
> > > > > +++ b/common/cmd_fastboot.c
> > > > > @@ -10,11 +10,13 @@
> > > > >  #include 
> > > > >  #include 
> > > > >  #include 
> > > > > +#include 
> > > > >
> > > > >  static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char
> > > *const
> > > > > argv[])  {
> > > > > int ret;
> > > > >
> > > > > +   board_usb_init(0, USB_INIT_DEVICE);
> > > >
> > > > The controller index should be configurable.
>
We are not getting controller Index as an argument for fastboot function.
Might have to add extra logic to get the same.
But do we need configurable index here for fastboot?
Experts, please advise.

> Also, should
> > > board_usb_cleanup be called at the end?
> > >
> > > I _really_ _really_ want to see if we can modify things so that we
> don't
> > > have to sprinkle ever gadget driver with a cleanup() and every gadget
> > > too if we don't have to.  Thanks!
> >
> > Most of the boards have board_usb_cleanup() as just a stub. For some, the
> > function is not present, and adding board_usb_cleanup() here breaks the
> > build for others with fastboot enabled.
>
> That's a problem that needs fixing since those boards without a
> functional board_usb_cleanup() are likely causing breakage in Linux.
>
Will add the board_usb_cleanup() function at the end.

>
> --
> Tom
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v1 1/4] ARM: DRA7XX: Add config file for Android with fastboot support

2015-03-11 Thread Dileep Katta
Hi Tom and Lukasz,

On 4 March 2015 at 22:22, Tom Rini  wrote:

> On Tue, Mar 03, 2015 at 04:40:41PM +0530, Dileep Katta wrote:
>
> > Signed-off-by: Angela Stegmaier 
> > Signed-off-by: Dileep Katta 
> > ---
> >  arch/arm/cpu/armv7/omap5/Kconfig |   5 +
> >  board/ti/dra7xx/Kconfig  |  13 ++
> >  board/ti/dra7xx/MAINTAINERS  |   2 +
> >  configs/dra7xx_evm_android_defconfig |   5 +
> >  include/configs/dra7xx_evm_android.h | 313
> +++
> >  5 files changed, 338 insertions(+)
> >  create mode 100644 configs/dra7xx_evm_android_defconfig
> >  create mode 100644 include/configs/dra7xx_evm_android.h
>
> I _really_ don't like how we're duplicating large hunks of dra7xx_evm.h.
> The first question is, what parts of this are not appropriate to just do
> in dra7xx_evm.h directly?  And the second question would be, which of
> those cannot simply be done via Kconfig choices.
>
> --
> Tom
>
Discussed this with Angela from TI, and arrived at a common header file so
that the duplication could be avoided. Will send a follow-up patch with the
update.
Thanks for the comments.

Regards, Dileep
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v1 1/1] fastboot: Add support for flashing zImage

2015-03-05 Thread Dileep Katta
Hi Lukasz,

On 4 March 2015 at 18:38, Lukasz Majewski  wrote:

> Hi Rob,
>
> > On Wed, Feb 25, 2015 at 4:56 PM, Dileep Katta
> >  wrote:
> > > This patch adds support to flash zImage to the boot partition on
> > > eMMC. Usage: fastboot flash zImage 
> >
> > So this replaces the kernel in an existing bootimage. What's wrong
> > with "fastboot flash boot", "fastboot flash:raw boot " or
> > "fastboot boot "? It is a bit fragile to be updating your
> > kernel without updating the ramdisk. arm64 has no zImage, so this
> > command is somewhat arm32 specific.
> >
> > Fastboot is already plagued with a variety of implementations and
> > behaviors. Some unification here would be good and just adding
> > whatever various commands have been added to vendor u-boot's is not
> > going to help. Adding to the combinations of things to test also
> > bothers me.
> >
> > Rob
> >
> > >
> > > Signed-off-by: Angela Stegmaier 
> > >
> > > Signed-off-by: Dileep Katta 
> > > ---
> > >  drivers/usb/gadget/f_fastboot.c | 152
> > >  1 file changed, 152
> > > insertions(+)
> > >
> > > diff --git a/drivers/usb/gadget/f_fastboot.c
> > > b/drivers/usb/gadget/f_fastboot.c index 310175a..d3d16c0 100644
> > > --- a/drivers/usb/gadget/f_fastboot.c
> > > +++ b/drivers/usb/gadget/f_fastboot.c
> > > @@ -23,6 +23,7 @@
> > >  #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
> > >  #include 
> > >  #endif
> > > +#include 
> > >
> > >  #define FASTBOOT_VERSION   "0.4"
> > >
> > > @@ -492,6 +493,152 @@ static void cb_continue(struct usb_ep *ep,
> > > struct usb_request *req) }
> > >
> > >  #ifdef CONFIG_FASTBOOT_FLASH
> > > +static int fastboot_update_zimage(void);
> > > +
> > > +static u32 fastboot_get_boot_ptn(struct andr_img_hdr *hdr, char
> > > *response,
> > > +   block_dev_desc_t
> > > *dev_desc) +{
> > > +   u32 hdr_sectors = 0;
> > > +   u32 sector_size;
> > > +   int status = 0;
> > > +   strcpy(response, "OKAY");
> > > +   disk_partition_t info;
> > > +
> > > +   status = get_partition_info_efi_by_name(dev_desc, "boot",
> > > &info);
> > > +   if (status) {
> > > +   strcpy(response, "FAILCannot find boot partition");
> > > +   goto out;
> > > +   }
> > > +
> > > +   /* Read the boot image header */
> > > +   sector_size = info.blksz;
> > > +   hdr_sectors = (sizeof(struct andr_img_hdr)/sector_size) + 1;
> > > +   status = dev_desc->block_read(dev_desc->dev, info.start,
> > > + hdr_sectors, (void *)hdr);
> > > +
> > > +   if (status < 0) {
> > > +   strcpy(response, "FAILCannot read hdr from boot
> > > partition");
> > > +   goto out;
> > > +   }
> > > +   if (android_image_check_header(hdr) != 0) {
> > > +   printf("bad boot image magic\n");
> > > +   strcpy(response, "FAILBoot partition not
> > > initialized");
> > > +   goto out;
> > > +   }
> > > +
> > > +   return hdr_sectors;
> > > +
> > > +out:
> > > +   strcpy(response, "INFO");
> > > +   fastboot_tx_write_str(response);
> > > +
> > > +   return -1;
> > > +}
> > > +
> > > +#define CEIL(a, b) (((a) / (b)) + ((a % b) > 0 ? 1 : 0))
> > > +
> > > +static int fastboot_update_zimage(void)
> > > +{
> > > +   struct andr_img_hdr *hdr = NULL;
> > > +   u8 *ramdisk_buffer;
> > > +   u32 ramdisk_sector_start, ramdisk_sectors;
> > > +   u32 kernel_sector_start, kernel_sectors;
> > > +   u32 hdr_sectors = 0;
> > > +   u32 sectors_per_page = 0;
> > > +   int ret = 0;
> > > +   block_dev_desc_t *dev_desc;
> > > +   disk_partition_t info;
> > > +   char response[RESPONSE_LEN];
> > > +   u32 addr = CONFIG_USB_FASTBOOT_BUF_ADDR;
> > > +
> > > +   strcpy(response, "OKAY");
> > > +   printf("Fla

Re: [U-Boot] [PATCH v2 2/4] fastboot: call board_usb_init() to enable usb

2015-03-04 Thread Dileep Katta
On 4 March 2015 at 23:59, Tom Rini  wrote:

> On Wed, Mar 04, 2015 at 05:05:11PM +, Stegmaier, Angela wrote:
> > Hi Dileep,
> >
> > > -Original Message-
> > > From: Dileep Katta [mailto:dileep.ka...@linaro.org]
> > > Sent: Tuesday, March 03, 2015 5:11 AM
> > > To: u-boot@lists.denx.de; robherri...@gmail.com; Rini, Tom;
> > > rob.herr...@linaro.org; s...@broadcom.com; l.majew...@samsung.com;
> > > Stegmaier, Angela
> > > Cc: Dileep Katta
> > > Subject: [U-Boot][PATCH v2 2/4] fastboot: call board_usb_init() to
> enable
> > > usb
> > >
> > > g_dnl_gadget_register() fails for dra7xx dwc3 gadget when running
> > > cmd_fastboot.
> > > Calling board_usb_init() fixes this.
> > >
> > > Signed-off-by: Angela Stegmaier 
> > > Signed-off-by: Dileep Katta 
> > > ---
> > >  common/cmd_fastboot.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c index
> > > 346ab80..d7b8f6d 100644
> > > --- a/common/cmd_fastboot.c
> > > +++ b/common/cmd_fastboot.c
> > > @@ -10,11 +10,13 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >
> > >  static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char
> *const
> > > argv[])  {
> > > int ret;
> > >
> > > +   board_usb_init(0, USB_INIT_DEVICE);
> >
> > The controller index should be configurable. Also, should
> board_usb_cleanup be called at the end?
>
> I _really_ _really_ want to see if we can modify things so that we don't
> have to sprinkle ever gadget driver with a cleanup() and every gadget
> too if we don't have to.  Thanks!
>
Most of the boards have board_usb_cleanup() as just a stub. For some, the
function is not present, and adding board_usb_cleanup() here breaks the
build for others with fastboot enabled.

>
> --
> Tom
>
Regards, Dileep
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v1 4/4] ARM: DRA7: fastboot: Implement reboot-bootloader command

2015-03-03 Thread Dileep Katta
Hi Rob,

On 3 March 2015 at 19:45, Rob Herring  wrote:

> On Tue, Mar 3, 2015 at 5:10 AM, Dileep Katta 
> wrote:
> > Signed-off-by: Angela Stegmaier 
> > Signed-off-by: Dileep Katta 
> > ---
> >  board/ti/dra7xx/Makefile |  1 +
> >  board/ti/dra7xx/fastboot.c   | 45
> 
> >  common/cmd_bootm.c   |  5 
> >  drivers/usb/gadget/f_fastboot.c  |  5 
> >  include/configs/dra7xx_evm_android.h | 14 +++
> >  5 files changed, 70 insertions(+)
> >  create mode 100644 board/ti/dra7xx/fastboot.c
> >
> > diff --git a/board/ti/dra7xx/Makefile b/board/ti/dra7xx/Makefile
> > index 434e8d1..ae730ae 100644
> > --- a/board/ti/dra7xx/Makefile
> > +++ b/board/ti/dra7xx/Makefile
> > @@ -6,3 +6,4 @@
> >  #
> >
> >  obj-y  := evm.o
> > +obj-$(CONFIG_CMD_FASTBOOT) += fastboot.o
> > diff --git a/board/ti/dra7xx/fastboot.c b/board/ti/dra7xx/fastboot.c
> > new file mode 100644
> > index 000..e05010d
> > --- /dev/null
> > +++ b/board/ti/dra7xx/fastboot.c
> > @@ -0,0 +1,45 @@
> > +/*
> > + * (C) Copyright 2013
> > + * Texas Instruments Incorporated, 
> > + *
> > + * Lokesh Vutla 
> > + *
> > + * Based on previous work by:
> > + * Aneesh V   
> > + * Steve Sakoman  
> > + *
> > + * SPDX-License-Identifier:GPL-2.0+
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +
> > +int fb_set_reboot_flag(void)
> > +{
> > +   /* clear all reset events */
> > +   __raw_writel(DRA7XX_PRM_RSTST_CLR, PRM_RSTST);
> > +   strncpy((char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE, "bootloader",
> > +   DRA7XX_REBOOT_REASON_SIZE - 1);
> > +   *(((char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE) +
> > +   DRA7XX_REBOOT_REASON_SIZE - 1) = '\0';
> > +   /* trigger warm reset */
> > +   __raw_writel(DRA7XX_PRM_RSTCTRL_RESET_WARM_BIT,
> DRA7XX_PRM_RSTCTRL);
>
> Does this reset immediately? If so, then you will fail to send a
> response to the client.
>
> > +
> > +   return 0;
> > +}
> > +
> > +int fb_check_reboot_flag(void)
> > +{
> > +   /* Check if we are coming from a warm reset */
> > +   if (__raw_readl(DRA7XX_PRM_RSTST) &
> DRA7XX_PRM_RSTST_RESET_WARM_BIT)
> > +   if (!strncmp((const char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE,
> > +   "bootloader",
> DRA7XX_REBOOT_REASON_SIZE)) {
> > +   strncpy((char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE, "",
> > +   DRA7XX_REBOOT_REASON_SIZE);
> > +   return 0;
> > +   }
> > +
> > +   return 1;
> > +}
> > diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
> > index 48199bf..00791be 100644
> > --- a/common/cmd_bootm.c
> > +++ b/common/cmd_bootm.c
> > @@ -729,6 +729,11 @@ int do_booti(cmd_tbl_t *cmdtp, int flag, int argc,
> char * const argv[])
> >  {
> > int ret;
> >
> > +#if defined(CONFIG_CMD_FASTBOOT)
> > +   if (!fb_check_reboot_flag())
> > +   do_fastboot(cmdtp, flag, argc, argv);
> > +#endif
>
> Part of the booti command? First, booti is for arm64 Image files. How
> does this work for you?

This was ported from an existing DRA7 implementation as per latest u-boot.
Should have sent it
as RFC patch, as this is not verified due to unavailability of board.

>


> More importantly, this should not be tied into any bootX command. It
> should probably be done in a boot script. If the flag is set, the
> board code can set some environment variable. Then the boot script can
> run the fastboot command if the env var is set.
>
> > +
> > /* Consume 'booti' */
> > argc--; argv++;
> >
> > diff --git a/drivers/usb/gadget/f_fastboot.c
> b/drivers/usb/gadget/f_fastboot.c
> > index 206b6d1..a450357 100644
> > --- a/drivers/usb/gadget/f_fastboot.c
> > +++ b/drivers/usb/gadget/f_fastboot.c
> > @@ -332,6 +332,11 @@ int __weak fb_set_reboot_flag(void)
> > return -ENOSYS;
> >  }
> >
> > +int __weak fb_check_reboot_flag(void)
> > +{
> > +   return -ENOSYS;
> > +}
> > +
> >  static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
> >  {
> > char *cmd = req->buf;
> > diff --git a/include/configs/dra7xx_evm_android.h
> b/include/configs/dra7xx_evm_

Re: [U-Boot] [PATCH v1 4/4] ARM: DRA7: fastboot: Implement reboot-bootloader command - Implemented fb_set_reboot_flag() for DRA7 - Defined a weak function, fb_check_reboot_flag() - Implemented for DRA

2015-03-03 Thread Dileep Katta
Corrected Tom Rini's Mail id.

Regards, Dileep

On 3 March 2015 at 16:40, Dileep Katta  wrote:

> Signed-off-by: Angela Stegmaier 
> Signed-off-by: Dileep Katta 
> ---
>  board/ti/dra7xx/Makefile |  1 +
>  board/ti/dra7xx/fastboot.c   | 45
> 
>  common/cmd_bootm.c   |  5 
>  drivers/usb/gadget/f_fastboot.c  |  5 
>  include/configs/dra7xx_evm_android.h | 14 +++
>  5 files changed, 70 insertions(+)
>  create mode 100644 board/ti/dra7xx/fastboot.c
>
> diff --git a/board/ti/dra7xx/Makefile b/board/ti/dra7xx/Makefile
> index 434e8d1..ae730ae 100644
> --- a/board/ti/dra7xx/Makefile
> +++ b/board/ti/dra7xx/Makefile
> @@ -6,3 +6,4 @@
>  #
>
>  obj-y  := evm.o
> +obj-$(CONFIG_CMD_FASTBOOT) += fastboot.o
> diff --git a/board/ti/dra7xx/fastboot.c b/board/ti/dra7xx/fastboot.c
> new file mode 100644
> index 000..e05010d
> --- /dev/null
> +++ b/board/ti/dra7xx/fastboot.c
> @@ -0,0 +1,45 @@
> +/*
> + * (C) Copyright 2013
> + * Texas Instruments Incorporated, 
> + *
> + * Lokesh Vutla 
> + *
> + * Based on previous work by:
> + * Aneesh V   
> + * Steve Sakoman  
> + *
> + * SPDX-License-Identifier:GPL-2.0+
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +
> +int fb_set_reboot_flag(void)
> +{
> +   /* clear all reset events */
> +   __raw_writel(DRA7XX_PRM_RSTST_CLR, PRM_RSTST);
> +   strncpy((char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE, "bootloader",
> +   DRA7XX_REBOOT_REASON_SIZE - 1);
> +   *(((char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE) +
> +   DRA7XX_REBOOT_REASON_SIZE - 1) = '\0';
> +   /* trigger warm reset */
> +   __raw_writel(DRA7XX_PRM_RSTCTRL_RESET_WARM_BIT,
> DRA7XX_PRM_RSTCTRL);
> +
> +   return 0;
> +}
> +
> +int fb_check_reboot_flag(void)
> +{
> +   /* Check if we are coming from a warm reset */
> +   if (__raw_readl(DRA7XX_PRM_RSTST) &
> DRA7XX_PRM_RSTST_RESET_WARM_BIT)
> +   if (!strncmp((const char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE,
> +   "bootloader", DRA7XX_REBOOT_REASON_SIZE)) {
> +   strncpy((char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE, "",
> +   DRA7XX_REBOOT_REASON_SIZE);
> +   return 0;
> +   }
> +
> +   return 1;
> +}
> diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
> index 48199bf..00791be 100644
> --- a/common/cmd_bootm.c
> +++ b/common/cmd_bootm.c
> @@ -729,6 +729,11 @@ int do_booti(cmd_tbl_t *cmdtp, int flag, int argc,
> char * const argv[])
>  {
> int ret;
>
> +#if defined(CONFIG_CMD_FASTBOOT)
> +   if (!fb_check_reboot_flag())
> +   do_fastboot(cmdtp, flag, argc, argv);
> +#endif
> +
> /* Consume 'booti' */
> argc--; argv++;
>
> diff --git a/drivers/usb/gadget/f_fastboot.c
> b/drivers/usb/gadget/f_fastboot.c
> index 206b6d1..a450357 100644
> --- a/drivers/usb/gadget/f_fastboot.c
> +++ b/drivers/usb/gadget/f_fastboot.c
> @@ -332,6 +332,11 @@ int __weak fb_set_reboot_flag(void)
> return -ENOSYS;
>  }
>
> +int __weak fb_check_reboot_flag(void)
> +{
> +   return -ENOSYS;
> +}
> +
>  static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
>  {
> char *cmd = req->buf;
> diff --git a/include/configs/dra7xx_evm_android.h
> b/include/configs/dra7xx_evm_android.h
> index 68e7eec..2038e00 100644
> --- a/include/configs/dra7xx_evm_android.h
> +++ b/include/configs/dra7xx_evm_android.h
> @@ -310,4 +310,18 @@
>  #endif
>  #endif  /* NOR support */
>
> +#define DRA7XX_PUBLIC_SAR_RAM_1_FREE   (0x4AE26000 + 0xFE0)
> +#define DRA7XX_PRM_RSTCTRL_RESET_WARM_BIT  (1<<0)
> +#define DRA7XX_PRM_RSTST_RESET_WARM_BIT(1<<1)
> +#define DRA7XX_PRM_RSTST   0x4AE07D04
> +#define DRA7XX_PRM_RSTCTRL 0x4AE07D00
> +#define DRA7XX_PRM_RSTST_CLR   0xfff
> +#define DRA7XX_REBOOT_REASON_SIZE  0xf
> +
> +#define CONFIG_BOARD_MACH_TYPE  4070
> +#define MEMORY_BASE 0x8000
> +#define CONFIG_ADDR_ATAGS   (MEMORY_BASE + 0x100)
> +#define CONFIG_ADDR_DOWNLOAD(MEMORY_BASE + 0x0200)
> +#define DEVICE_TREE 0x82f8
> +
>  #endif /* __CONFIG_DRA7XX_EVM_ANDROID_H */
> --
> 1.8.3.2
>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v1 3/4] ARM: DRA7: Set serial number environment variable

2015-03-03 Thread Dileep Katta
Corrected Tom Rini's Mail id and patch version.

Regards, Dileep

On 3 March 2015 at 16:40, Dileep Katta  wrote:

> Adds the registers to get the serial number of dra7xx boards.
> Serial# environment variable will be set if not done already.
> This will be useful to show correct information in
> "fastboot devices" commands.
>
> Signed-off-by: Angela Stegmaier 
> Signed-off-by: Dileep Katta 
> ---
>  arch/arm/cpu/armv7/omap5/prcm-regs.c |  2 ++
>  arch/arm/include/asm/omap_common.h   |  2 ++
>  board/ti/dra7xx/evm.c| 11 +++
>  3 files changed, 15 insertions(+)
>
> diff --git a/arch/arm/cpu/armv7/omap5/prcm-regs.c
> b/arch/arm/cpu/armv7/omap5/prcm-regs.c
> index 0745d42..020a964 100644
> --- a/arch/arm/cpu/armv7/omap5/prcm-regs.c
> +++ b/arch/arm/cpu/armv7/omap5/prcm-regs.c
> @@ -440,6 +440,8 @@ struct omap_sys_ctrl_regs const dra7xx_ctrl = {
> .control_emif1_sdram_config_ext = 0x4AE0C144,
> .control_emif2_sdram_config_ext = 0x4AE0C148,
> .control_wkup_ldovbb_mpu_voltage_ctrl   = 0x4AE0C158,
> +   .control_std_fuse_die_id_3  = 0x4AE0C210,
> +   .control_std_fuse_prod_id_0 = 0x4AE0C214,
> .control_padconf_mode   = 0x4AE0C5A0,
> .control_xtal_oscillator= 0x4AE0C5A4,
> .control_i2c_2  = 0x4AE0C5A8,
> diff --git a/arch/arm/include/asm/omap_common.h
> b/arch/arm/include/asm/omap_common.h
> index 323952f..b329803 100644
> --- a/arch/arm/include/asm/omap_common.h
> +++ b/arch/arm/include/asm/omap_common.h
> @@ -362,6 +362,8 @@ struct omap_sys_ctrl_regs {
> u32 control_core_control_io1;
> u32 control_core_control_io2;
> u32 control_id_code;
> +   u32 control_std_fuse_die_id_3;
> +   u32 control_std_fuse_prod_id_0;
> u32 control_std_fuse_opp_bgap;
> u32 control_ldosram_iva_voltage_ctrl;
> u32 control_ldosram_mpu_voltage_ctrl;
> diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
> index 6522241..e20d950 100644
> --- a/board/ti/dra7xx/evm.c
> +++ b/board/ti/dra7xx/evm.c
> @@ -88,10 +88,21 @@ int board_init(void)
>  int board_late_init(void)
>  {
>  #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
> +   char serialno[72];
> +   uint32_t serialno_lo, serialno_hi;
> +
> if (omap_revision() == DRA722_ES1_0)
> setenv("board_name", "dra72x");
> else
> setenv("board_name", "dra7xx");
> +
> +   if (!getenv("serial#")) {
> +   printf("serial# not set, setting...\n");
> +   serialno_lo = readl((*ctrl)->control_std_fuse_die_id_3);
> +   serialno_hi = readl((*ctrl)->control_std_fuse_prod_id_0);
> +   sprintf(serialno, "%08x%08x", serialno_hi, serialno_lo);
> +   setenv("serial#", serialno);
> +   }
>  #endif
> return 0;
>  }
> --
> 1.8.3.2
>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v1 2/4] fastboot: call board_usb_init() to enable usb

2015-03-03 Thread Dileep Katta
Corrected Tom Rini's mail id. And patch version. (My bad)

Regards, Dileep

On 3 March 2015 at 16:40, Dileep Katta  wrote:

> g_dnl_gadget_register() fails for dra7xx dwc3 gadget
> when running cmd_fastboot.
> Calling board_usb_init() fixes this.
>
> Signed-off-by: Angela Stegmaier 
> Signed-off-by: Dileep Katta 
> ---
>  common/cmd_fastboot.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
> index 346ab80..d7b8f6d 100644
> --- a/common/cmd_fastboot.c
> +++ b/common/cmd_fastboot.c
> @@ -10,11 +10,13 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const
> argv[])
>  {
> int ret;
>
> +   board_usb_init(0, USB_INIT_DEVICE);
> g_dnl_clear_detach();
> ret = g_dnl_register("usb_dnl_fastboot");
> if (ret)
> --
> 1.8.3.2
>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v1 1/4] ARM: DRA7XX: Add config file for Android with fastboot support

2015-03-03 Thread Dileep Katta
Corrected Tom Rini's mail id.

Regards,
Dileep

On 3 March 2015 at 16:40, Dileep Katta  wrote:

> Signed-off-by: Angela Stegmaier 
> Signed-off-by: Dileep Katta 
> ---
>  arch/arm/cpu/armv7/omap5/Kconfig |   5 +
>  board/ti/dra7xx/Kconfig  |  13 ++
>  board/ti/dra7xx/MAINTAINERS  |   2 +
>  configs/dra7xx_evm_android_defconfig |   5 +
>  include/configs/dra7xx_evm_android.h | 313
> +++
>  5 files changed, 338 insertions(+)
>  create mode 100644 configs/dra7xx_evm_android_defconfig
>  create mode 100644 include/configs/dra7xx_evm_android.h
>
> diff --git a/arch/arm/cpu/armv7/omap5/Kconfig
> b/arch/arm/cpu/armv7/omap5/Kconfig
> index aca862d..d8e9b2d 100644
> --- a/arch/arm/cpu/armv7/omap5/Kconfig
> +++ b/arch/arm/cpu/armv7/omap5/Kconfig
> @@ -12,6 +12,11 @@ config TARGET_OMAP5_UEVM
>  config TARGET_DRA7XX_EVM
> bool "TI DRA7XX"
>
> +config TARGET_DRA7XX_EVM_ANDROID
> +   bool "TI DRA7XX ANDROID"
> +   ---help---
> +   TI DRA7XX build for Android. Enables Fastboot.
> +
>  config TARGET_BEAGLE_X15
> bool "BeagleBoard X15"
>
> diff --git a/board/ti/dra7xx/Kconfig b/board/ti/dra7xx/Kconfig
> index 3bbd866..6837998 100644
> --- a/board/ti/dra7xx/Kconfig
> +++ b/board/ti/dra7xx/Kconfig
> @@ -10,3 +10,16 @@ config SYS_CONFIG_NAME
> default "dra7xx_evm"
>
>  endif
> +
> +if TARGET_DRA7XX_EVM_ANDROID
> +
> +config SYS_BOARD
> +   default "dra7xx"
> +
> +config SYS_VENDOR
> +   default "ti"
> +
> +config SYS_CONFIG_NAME
> +   default "dra7xx_evm_android"
> +
> +endif
> diff --git a/board/ti/dra7xx/MAINTAINERS b/board/ti/dra7xx/MAINTAINERS
> index 5ec6769..efd4f81 100644
> --- a/board/ti/dra7xx/MAINTAINERS
> +++ b/board/ti/dra7xx/MAINTAINERS
> @@ -6,3 +6,5 @@ F:  include/configs/dra7xx_evm.h
>  F: configs/dra7xx_evm_defconfig
>  F: configs/dra7xx_evm_qspiboot_defconfig
>  F: configs/dra7xx_evm_uart3_defconfig
> +F: include/configs/dra7xx_evm_android.h
> +F: configs/dra7xx_evm_android_defconfig
> diff --git a/configs/dra7xx_evm_android_defconfig
> b/configs/dra7xx_evm_android_defconfig
> new file mode 100644
> index 000..64ae4b3
> --- /dev/null
> +++ b/configs/dra7xx_evm_android_defconfig
> @@ -0,0 +1,5 @@
> +CONFIG_SPL=y
> +CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=1"
> ++S:CONFIG_ARM=y
> ++S:CONFIG_OMAP54XX=y
> ++S:CONFIG_TARGET_DRA7XX_EVM_ANDROID=y
> diff --git a/include/configs/dra7xx_evm_android.h
> b/include/configs/dra7xx_evm_android.h
> new file mode 100644
> index 000..68e7eec
> --- /dev/null
> +++ b/include/configs/dra7xx_evm_android.h
> @@ -0,0 +1,313 @@
> +/*
> + * (C) Copyright 2013
> + * Texas Instruments Incorporated.
> + * Lokesh Vutla  
> + *
> + * Configuration settings for the TI DRA7XX board.
> + * See ti_omap5_common.h for omap5 common settings.
> + *
> + * SPDX-License-Identifier:GPL-2.0+
> + */
> +
> +#ifndef __CONFIG_DRA7XX_EVM_ANDROID_H
> +#define __CONFIG_DRA7XX_EVM_ANDROID_H
> +
> +#define CONFIG_DRA7XX
> +#define CONFIG_BOARD_EARLY_INIT_F
> +
> +#ifndef CONFIG_QSPI_BOOT
> +/* MMC ENV related defines */
> +#define CONFIG_ENV_IS_IN_MMC
> +#define CONFIG_SYS_MMC_ENV_DEV 1   /* SLOT2: eMMC(1) */
> +#define CONFIG_ENV_SIZE(128 << 10)
> +#define CONFIG_ENV_OFFSET  0xE
> +#define CONFIG_ENV_OFFSET_REDUND   (CONFIG_ENV_OFFSET +
> CONFIG_ENV_SIZE)
> +#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
> +#endif
> +#define CONFIG_CMD_SAVEENV
> +
> +#if (CONFIG_CONS_INDEX == 1)
> +#define CONSOLEDEV "ttyO0"
> +#elif (CONFIG_CONS_INDEX == 3)
> +#define CONSOLEDEV "ttyO2"
> +#endif
> +#define CONFIG_SYS_NS16550_COM1UART1_BASE  /* Base
> EVM has UART0 */
> +#define CONFIG_SYS_NS16550_COM2UART2_BASE  /* UART2 */
> +#define CONFIG_SYS_NS16550_COM3UART3_BASE  /* UART3 */
> +#define CONFIG_BAUDRATE115200
> +
> +#define CONFIG_SYS_OMAP_ABE_SYSCK
> +
> +/* Define the default GPT table for eMMC */
> +#define PARTS_DEFAULT \
> +   "uuid_disk=${uuid_gpt_disk};" \
> +   "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}"
> +
> +#ifdef CONFIG_NAND
> +/* Define NAND information. */
> +#define NANDARGS \
> +   "mtdids=" MTDIDS_DEFAULT "\0" \
> +   "mtdparts=" MTDPARTS_DEFAULT "\0" \
> +   "nandargs=setenv bootargs con

[U-Boot] [PATCH v1 4/4] ARM: DRA7: fastboot: Implement reboot-bootloader command - Implemented fb_set_reboot_flag() for DRA7 - Defined a weak function, fb_check_reboot_flag() - Implemented for DRA7

2015-03-03 Thread Dileep Katta
Signed-off-by: Angela Stegmaier 
Signed-off-by: Dileep Katta 
---
 board/ti/dra7xx/Makefile |  1 +
 board/ti/dra7xx/fastboot.c   | 45 
 common/cmd_bootm.c   |  5 
 drivers/usb/gadget/f_fastboot.c  |  5 
 include/configs/dra7xx_evm_android.h | 14 +++
 5 files changed, 70 insertions(+)
 create mode 100644 board/ti/dra7xx/fastboot.c

diff --git a/board/ti/dra7xx/Makefile b/board/ti/dra7xx/Makefile
index 434e8d1..ae730ae 100644
--- a/board/ti/dra7xx/Makefile
+++ b/board/ti/dra7xx/Makefile
@@ -6,3 +6,4 @@
 #
 
 obj-y  := evm.o
+obj-$(CONFIG_CMD_FASTBOOT) += fastboot.o
diff --git a/board/ti/dra7xx/fastboot.c b/board/ti/dra7xx/fastboot.c
new file mode 100644
index 000..e05010d
--- /dev/null
+++ b/board/ti/dra7xx/fastboot.c
@@ -0,0 +1,45 @@
+/*
+ * (C) Copyright 2013
+ * Texas Instruments Incorporated, 
+ *
+ * Lokesh Vutla 
+ *
+ * Based on previous work by:
+ * Aneesh V   
+ * Steve Sakoman  
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#include 
+#include 
+#include 
+#include 
+
+
+int fb_set_reboot_flag(void)
+{
+   /* clear all reset events */
+   __raw_writel(DRA7XX_PRM_RSTST_CLR, PRM_RSTST);
+   strncpy((char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE, "bootloader",
+   DRA7XX_REBOOT_REASON_SIZE - 1);
+   *(((char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE) +
+   DRA7XX_REBOOT_REASON_SIZE - 1) = '\0';
+   /* trigger warm reset */
+   __raw_writel(DRA7XX_PRM_RSTCTRL_RESET_WARM_BIT, DRA7XX_PRM_RSTCTRL);
+
+   return 0;
+}
+
+int fb_check_reboot_flag(void)
+{
+   /* Check if we are coming from a warm reset */
+   if (__raw_readl(DRA7XX_PRM_RSTST) & DRA7XX_PRM_RSTST_RESET_WARM_BIT)
+   if (!strncmp((const char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE,
+   "bootloader", DRA7XX_REBOOT_REASON_SIZE)) {
+   strncpy((char *)DRA7XX_PUBLIC_SAR_RAM_1_FREE, "",
+   DRA7XX_REBOOT_REASON_SIZE);
+   return 0;
+   }
+
+   return 1;
+}
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 48199bf..00791be 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -729,6 +729,11 @@ int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
 {
int ret;
 
+#if defined(CONFIG_CMD_FASTBOOT)
+   if (!fb_check_reboot_flag())
+   do_fastboot(cmdtp, flag, argc, argv);
+#endif
+
/* Consume 'booti' */
argc--; argv++;
 
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 206b6d1..a450357 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -332,6 +332,11 @@ int __weak fb_set_reboot_flag(void)
return -ENOSYS;
 }
 
+int __weak fb_check_reboot_flag(void)
+{
+   return -ENOSYS;
+}
+
 static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
 {
char *cmd = req->buf;
diff --git a/include/configs/dra7xx_evm_android.h 
b/include/configs/dra7xx_evm_android.h
index 68e7eec..2038e00 100644
--- a/include/configs/dra7xx_evm_android.h
+++ b/include/configs/dra7xx_evm_android.h
@@ -310,4 +310,18 @@
 #endif
 #endif  /* NOR support */
 
+#define DRA7XX_PUBLIC_SAR_RAM_1_FREE   (0x4AE26000 + 0xFE0)
+#define DRA7XX_PRM_RSTCTRL_RESET_WARM_BIT  (1<<0)
+#define DRA7XX_PRM_RSTST_RESET_WARM_BIT(1<<1)
+#define DRA7XX_PRM_RSTST   0x4AE07D04
+#define DRA7XX_PRM_RSTCTRL 0x4AE07D00
+#define DRA7XX_PRM_RSTST_CLR   0xfff
+#define DRA7XX_REBOOT_REASON_SIZE  0xf
+
+#define CONFIG_BOARD_MACH_TYPE  4070
+#define MEMORY_BASE 0x8000
+#define CONFIG_ADDR_ATAGS   (MEMORY_BASE + 0x100)
+#define CONFIG_ADDR_DOWNLOAD(MEMORY_BASE + 0x0200)
+#define DEVICE_TREE 0x82f8
+
 #endif /* __CONFIG_DRA7XX_EVM_ANDROID_H */
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 3/4] ARM: DRA7: Set serial number environment variable

2015-03-03 Thread Dileep Katta
Adds the registers to get the serial number of dra7xx boards.
Serial# environment variable will be set if not done already.
This will be useful to show correct information in
"fastboot devices" commands.

Signed-off-by: Angela Stegmaier 
Signed-off-by: Dileep Katta 
---
 arch/arm/cpu/armv7/omap5/prcm-regs.c |  2 ++
 arch/arm/include/asm/omap_common.h   |  2 ++
 board/ti/dra7xx/evm.c| 11 +++
 3 files changed, 15 insertions(+)

diff --git a/arch/arm/cpu/armv7/omap5/prcm-regs.c 
b/arch/arm/cpu/armv7/omap5/prcm-regs.c
index 0745d42..020a964 100644
--- a/arch/arm/cpu/armv7/omap5/prcm-regs.c
+++ b/arch/arm/cpu/armv7/omap5/prcm-regs.c
@@ -440,6 +440,8 @@ struct omap_sys_ctrl_regs const dra7xx_ctrl = {
.control_emif1_sdram_config_ext = 0x4AE0C144,
.control_emif2_sdram_config_ext = 0x4AE0C148,
.control_wkup_ldovbb_mpu_voltage_ctrl   = 0x4AE0C158,
+   .control_std_fuse_die_id_3  = 0x4AE0C210,
+   .control_std_fuse_prod_id_0 = 0x4AE0C214,
.control_padconf_mode   = 0x4AE0C5A0,
.control_xtal_oscillator= 0x4AE0C5A4,
.control_i2c_2  = 0x4AE0C5A8,
diff --git a/arch/arm/include/asm/omap_common.h 
b/arch/arm/include/asm/omap_common.h
index 323952f..b329803 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -362,6 +362,8 @@ struct omap_sys_ctrl_regs {
u32 control_core_control_io1;
u32 control_core_control_io2;
u32 control_id_code;
+   u32 control_std_fuse_die_id_3;
+   u32 control_std_fuse_prod_id_0;
u32 control_std_fuse_opp_bgap;
u32 control_ldosram_iva_voltage_ctrl;
u32 control_ldosram_mpu_voltage_ctrl;
diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index 6522241..e20d950 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -88,10 +88,21 @@ int board_init(void)
 int board_late_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+   char serialno[72];
+   uint32_t serialno_lo, serialno_hi;
+
if (omap_revision() == DRA722_ES1_0)
setenv("board_name", "dra72x");
else
setenv("board_name", "dra7xx");
+
+   if (!getenv("serial#")) {
+   printf("serial# not set, setting...\n");
+   serialno_lo = readl((*ctrl)->control_std_fuse_die_id_3);
+   serialno_hi = readl((*ctrl)->control_std_fuse_prod_id_0);
+   sprintf(serialno, "%08x%08x", serialno_hi, serialno_lo);
+   setenv("serial#", serialno);
+   }
 #endif
return 0;
 }
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/4] fastboot: call board_usb_init() to enable usb

2015-03-03 Thread Dileep Katta
g_dnl_gadget_register() fails for dra7xx dwc3 gadget
when running cmd_fastboot.
Calling board_usb_init() fixes this.

Signed-off-by: Angela Stegmaier 
Signed-off-by: Dileep Katta 
---
 common/cmd_fastboot.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
index 346ab80..d7b8f6d 100644
--- a/common/cmd_fastboot.c
+++ b/common/cmd_fastboot.c
@@ -10,11 +10,13 @@
 #include 
 #include 
 #include 
+#include 
 
 static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const 
argv[])
 {
int ret;
 
+   board_usb_init(0, USB_INIT_DEVICE);
g_dnl_clear_detach();
ret = g_dnl_register("usb_dnl_fastboot");
if (ret)
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 1/4] ARM: DRA7XX: Add config file for Android with fastboot support

2015-03-03 Thread Dileep Katta
Signed-off-by: Angela Stegmaier 
Signed-off-by: Dileep Katta 
---
 arch/arm/cpu/armv7/omap5/Kconfig |   5 +
 board/ti/dra7xx/Kconfig  |  13 ++
 board/ti/dra7xx/MAINTAINERS  |   2 +
 configs/dra7xx_evm_android_defconfig |   5 +
 include/configs/dra7xx_evm_android.h | 313 +++
 5 files changed, 338 insertions(+)
 create mode 100644 configs/dra7xx_evm_android_defconfig
 create mode 100644 include/configs/dra7xx_evm_android.h

diff --git a/arch/arm/cpu/armv7/omap5/Kconfig b/arch/arm/cpu/armv7/omap5/Kconfig
index aca862d..d8e9b2d 100644
--- a/arch/arm/cpu/armv7/omap5/Kconfig
+++ b/arch/arm/cpu/armv7/omap5/Kconfig
@@ -12,6 +12,11 @@ config TARGET_OMAP5_UEVM
 config TARGET_DRA7XX_EVM
bool "TI DRA7XX"
 
+config TARGET_DRA7XX_EVM_ANDROID
+   bool "TI DRA7XX ANDROID"
+   ---help---
+   TI DRA7XX build for Android. Enables Fastboot.
+
 config TARGET_BEAGLE_X15
bool "BeagleBoard X15"
 
diff --git a/board/ti/dra7xx/Kconfig b/board/ti/dra7xx/Kconfig
index 3bbd866..6837998 100644
--- a/board/ti/dra7xx/Kconfig
+++ b/board/ti/dra7xx/Kconfig
@@ -10,3 +10,16 @@ config SYS_CONFIG_NAME
default "dra7xx_evm"
 
 endif
+
+if TARGET_DRA7XX_EVM_ANDROID
+
+config SYS_BOARD
+   default "dra7xx"
+
+config SYS_VENDOR
+   default "ti"
+
+config SYS_CONFIG_NAME
+   default "dra7xx_evm_android"
+
+endif
diff --git a/board/ti/dra7xx/MAINTAINERS b/board/ti/dra7xx/MAINTAINERS
index 5ec6769..efd4f81 100644
--- a/board/ti/dra7xx/MAINTAINERS
+++ b/board/ti/dra7xx/MAINTAINERS
@@ -6,3 +6,5 @@ F:  include/configs/dra7xx_evm.h
 F: configs/dra7xx_evm_defconfig
 F: configs/dra7xx_evm_qspiboot_defconfig
 F: configs/dra7xx_evm_uart3_defconfig
+F: include/configs/dra7xx_evm_android.h
+F: configs/dra7xx_evm_android_defconfig
diff --git a/configs/dra7xx_evm_android_defconfig 
b/configs/dra7xx_evm_android_defconfig
new file mode 100644
index 000..64ae4b3
--- /dev/null
+++ b/configs/dra7xx_evm_android_defconfig
@@ -0,0 +1,5 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=1"
++S:CONFIG_ARM=y
++S:CONFIG_OMAP54XX=y
++S:CONFIG_TARGET_DRA7XX_EVM_ANDROID=y
diff --git a/include/configs/dra7xx_evm_android.h 
b/include/configs/dra7xx_evm_android.h
new file mode 100644
index 000..68e7eec
--- /dev/null
+++ b/include/configs/dra7xx_evm_android.h
@@ -0,0 +1,313 @@
+/*
+ * (C) Copyright 2013
+ * Texas Instruments Incorporated.
+ * Lokesh Vutla  
+ *
+ * Configuration settings for the TI DRA7XX board.
+ * See ti_omap5_common.h for omap5 common settings.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __CONFIG_DRA7XX_EVM_ANDROID_H
+#define __CONFIG_DRA7XX_EVM_ANDROID_H
+
+#define CONFIG_DRA7XX
+#define CONFIG_BOARD_EARLY_INIT_F
+
+#ifndef CONFIG_QSPI_BOOT
+/* MMC ENV related defines */
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV 1   /* SLOT2: eMMC(1) */
+#define CONFIG_ENV_SIZE(128 << 10)
+#define CONFIG_ENV_OFFSET  0xE
+#define CONFIG_ENV_OFFSET_REDUND   (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#endif
+#define CONFIG_CMD_SAVEENV
+
+#if (CONFIG_CONS_INDEX == 1)
+#define CONSOLEDEV "ttyO0"
+#elif (CONFIG_CONS_INDEX == 3)
+#define CONSOLEDEV "ttyO2"
+#endif
+#define CONFIG_SYS_NS16550_COM1UART1_BASE  /* Base EVM has 
UART0 */
+#define CONFIG_SYS_NS16550_COM2UART2_BASE  /* UART2 */
+#define CONFIG_SYS_NS16550_COM3UART3_BASE  /* UART3 */
+#define CONFIG_BAUDRATE115200
+
+#define CONFIG_SYS_OMAP_ABE_SYSCK
+
+/* Define the default GPT table for eMMC */
+#define PARTS_DEFAULT \
+   "uuid_disk=${uuid_gpt_disk};" \
+   "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}"
+
+#ifdef CONFIG_NAND
+/* Define NAND information. */
+#define NANDARGS \
+   "mtdids=" MTDIDS_DEFAULT "\0" \
+   "mtdparts=" MTDPARTS_DEFAULT "\0" \
+   "nandargs=setenv bootargs console=${console} " \
+   "${optargs} " \
+   "root=${nandroot} " \
+   "rootfstype=${nandrootfstype}\0" \
+   "nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,2048\0" \
+   "nandrootfstype=ubifs rootwait=1\0" \
+   "nandboot=echo Booting from nand ...; " \
+   "run nandargs; " \
+   "nand read ${fdtaddr} NAND.u-boot-spl-os; " \
+   "nand read ${loadaddr} NAND.kernel; " \
+   "bootz ${loadaddr} - ${fdtaddr}\0"
+#define NANDBOOT   "run nandboot; "
+#endif
+
+#define DFU_ALT_INFO_MMC \
+   "dfu_alt_info_mmc=" \
+  

Re: [U-Boot] [PATCH v1 1/2] fastboot: Add support to flash u-boot and MLO to QSPI

2015-02-27 Thread Dileep Katta
Thanks Rob and Tom.

On 22 February 2015 at 08:29, Tom Rini  wrote:

> On Thu, Feb 19, 2015 at 02:04:01PM -0600, Rob Herring wrote:
> > On Wed, Feb 18, 2015 at 4:53 PM, Dileep Katta 
> wrote:
> > > This adds the functionality to flash u-boot and MLO images to QSPI
> using fastboot
> > >
> > > Signed-off-by: Dileep Katta 
> > > ---
> > > Note: This is on top of Rob Herring patches submitted to support oem
> format command
> > >  drivers/usb/gadget/f_fastboot.c | 75
> +
> > >  1 file changed, 75 insertions(+)
> > >
> > > diff --git a/drivers/usb/gadget/f_fastboot.c
> b/drivers/usb/gadget/f_fastboot.c
> > > index f7d84bf..a170eea 100644
> > > --- a/drivers/usb/gadget/f_fastboot.c
> > > +++ b/drivers/usb/gadget/f_fastboot.c
> > > @@ -492,10 +492,23 @@ static void cb_continue(struct usb_ep *ep,
> struct usb_request *req)
> > >  }
> > >
> > >  #ifdef CONFIG_FASTBOOT_FLASH
> > > +#ifdef CONFIG_SPL_SPI_SUPPORT
> > > +int boot_from_spi = 0;
> > > +#endif
> > > +
> > >  static void cb_flash(struct usb_ep *ep, struct usb_request *req)
> > >  {
> > > char *cmd = req->buf;
> > > char response[RESPONSE_LEN];
> > > +#ifdef CONFIG_SPL_SPI_SUPPORT
> > > +   char source[32];
> > > +   int status = 0;
> > > +   char *sf_probe[3] = {"sf", "probe", "0"};
> > > +   char *sf_write_xloader[5] = {"sf", "write", NULL, "0",
> "2"};
> > > +   char *sf_update_xloader[5] = {"sf", "update", NULL, "0",
> "2"};
> > > +   char *sf_write_bl[5] = {"sf", "write", NULL, "8", "8"};
> > > +   char *sf_update_bl[5] = {"sf", "update", NULL, "8",
> "8"};
> > > +#endif
> > >
> > > strsep(&cmd, ":");
> > > if (!cmd) {
> > > @@ -505,6 +518,68 @@ static void cb_flash(struct usb_ep *ep, struct
> usb_request *req)
> > > }
> > >
> > > strcpy(response, "FAILno flash device defined");
> > > +#ifdef CONFIG_SPL_SPI_SUPPORT
> > > +   /*
> > > +* Check if this is for xloader or bootloader.
> > > +* Also, check if we have to flash to SPI
> > > +*/
> > > +   if (strcmp(cmd, "xloader") == 0 && boot_from_spi) {
> >
> > xloader is pretty specific to TI, so it belongs in TI specific code.
>
> And it's not even "xloader", it's SPL.  So are there external tools
> relying on this that can't be updated?
>

There are no such tools. Will change the name.

Will send a patch incorporating the suggestions from Rob and Tom.

Regards, Dileep

>
> --
> Tom
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 1/1] fastboot: Add support for flashing zImage

2015-02-25 Thread Dileep Katta
This patch adds support to flash zImage to the boot partition on eMMC.
Usage: fastboot flash zImage 

Signed-off-by: Angela Stegmaier 

Signed-off-by: Dileep Katta 
---
 drivers/usb/gadget/f_fastboot.c | 152 
 1 file changed, 152 insertions(+)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 310175a..d3d16c0 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -23,6 +23,7 @@
 #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
 #include 
 #endif
+#include 
 
 #define FASTBOOT_VERSION   "0.4"
 
@@ -492,6 +493,152 @@ static void cb_continue(struct usb_ep *ep, struct 
usb_request *req)
 }
 
 #ifdef CONFIG_FASTBOOT_FLASH
+static int fastboot_update_zimage(void);
+
+static u32 fastboot_get_boot_ptn(struct andr_img_hdr *hdr, char *response,
+   block_dev_desc_t *dev_desc)
+{
+   u32 hdr_sectors = 0;
+   u32 sector_size;
+   int status = 0;
+   strcpy(response, "OKAY");
+   disk_partition_t info;
+
+   status = get_partition_info_efi_by_name(dev_desc, "boot", &info);
+   if (status) {
+   strcpy(response, "FAILCannot find boot partition");
+   goto out;
+   }
+
+   /* Read the boot image header */
+   sector_size = info.blksz;
+   hdr_sectors = (sizeof(struct andr_img_hdr)/sector_size) + 1;
+   status = dev_desc->block_read(dev_desc->dev, info.start,
+ hdr_sectors, (void *)hdr);
+
+   if (status < 0) {
+   strcpy(response, "FAILCannot read hdr from boot partition");
+   goto out;
+   }
+   if (android_image_check_header(hdr) != 0) {
+   printf("bad boot image magic\n");
+   strcpy(response, "FAILBoot partition not initialized");
+   goto out;
+   }
+
+   return hdr_sectors;
+
+out:
+   strcpy(response, "INFO");
+   fastboot_tx_write_str(response);
+
+   return -1;
+}
+
+#define CEIL(a, b) (((a) / (b)) + ((a % b) > 0 ? 1 : 0))
+
+static int fastboot_update_zimage(void)
+{
+   struct andr_img_hdr *hdr = NULL;
+   u8 *ramdisk_buffer;
+   u32 ramdisk_sector_start, ramdisk_sectors;
+   u32 kernel_sector_start, kernel_sectors;
+   u32 hdr_sectors = 0;
+   u32 sectors_per_page = 0;
+   int ret = 0;
+   block_dev_desc_t *dev_desc;
+   disk_partition_t info;
+   char response[RESPONSE_LEN];
+   u32 addr = CONFIG_USB_FASTBOOT_BUF_ADDR;
+
+   strcpy(response, "OKAY");
+   printf("Flashing zImage...%d bytes\n", download_bytes);
+
+   dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
+   if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
+   sprintf(response + strlen(response),
+   "FAILInvalid mmc device");
+   ret = -1;
+   goto out;
+   }
+
+   addr += CEIL(download_bytes, 0x1000) * 0x1000;
+   hdr = (struct andr_img_hdr *)addr;
+
+   hdr_sectors = fastboot_get_boot_ptn(hdr, response, dev_desc);
+   if (hdr_sectors <= 0) {
+   sprintf(response + strlen(response),
+   "FAILInvalid number of boot sectors %d", hdr_sectors);
+   ret = -1;
+   goto out;
+   }
+   ret = get_partition_info_efi_by_name(dev_desc, "boot", &info);
+   if (ret) {
+   strcpy(response, "FAILCannot find boot partition");
+   ret = -1;
+   goto out;
+   }
+
+   /* Extract ramdisk location and read it into local buffer */
+   sectors_per_page = hdr->page_size / info.blksz;
+   ramdisk_sector_start = info.start + sectors_per_page;
+   ramdisk_sector_start += CEIL(hdr->kernel_size, hdr->page_size)*
+sectors_per_page;
+   ramdisk_sectors = CEIL(hdr->ramdisk_size, hdr->page_size)*
+  sectors_per_page;
+
+   ramdisk_buffer = (u8 *)hdr;
+   ramdisk_buffer += (hdr_sectors * info.blksz);
+   ret = dev_desc->block_read(dev_desc->dev, ramdisk_sector_start,
+  ramdisk_sectors, ramdisk_buffer);
+   if (ret < 0) {
+   sprintf(response, "FAILCannot read ramdisk from 'boot'");
+   ret = -1;
+   goto out;
+   }
+
+   /* Change the boot img hdr */
+   hdr->kernel_size = download_bytes;
+   ret = dev_desc->block_write(dev_desc->dev, info.start,
+   hdr_sectors, (void *)hdr);
+   if (ret < 0) {
+   sprintf(response, "FAILCannot writeback boot img hdr");
+   ret = -1;
+   goto out;

Re: [U-Boot] [PATCH v1 1/1] fastboot: Update getvar command to get 'userdata' partition size

2015-02-25 Thread Dileep Katta
Hi Rob,


On 20 February 2015 at 20:24, Rob Herring  wrote:

> On Wed, Feb 18, 2015 at 1:52 PM, Dileep Katta 
> wrote:
> > This patch adds functionality to getvar command to get the userdata
> partition
> > size.
>
> This is non-standard and doesn't scale to other partitions. There is
>

Is there a way to add support for retrieving some non-standard variables,
such as cpu_type or
board specific information in getvar or other command(oem!) in fastboot?

already a standard var "partition-size:". There is also
> "partition-type:" which probably needs to be supported as
> well. It would probably be good to have generic code to retrieve
> fastboot variables from a u-boot environment variables. Something like
> this:
>
> fastboot: allow retrieving fastboot variables from env
>
> Signed-off-by: Rob Herring 
>
> Thanks for the suggestion.
Is it fine to extend fb_mmc_get_ptn_size() in this patch to to support standard
var "partition-size:"
and similar functionality for partition-type?
or using "mtdparts" environment variable to get partition-type or
partition-size is preferable? Please advise.

Regards, Dileep

diff --git a/drivers/usb/gadget/f_fastboot.c
> b/drivers/usb/gadget/f_fastboot.c
> index 310175a..31e1063 100644
> --- a/drivers/usb/gadget/f_fastboot.c
> +++ b/drivers/usb/gadget/f_fastboot.c
> @@ -364,8 +364,15 @@ static void cb_getvar(struct usb_ep *ep, struct
> usb_request *req)
> else
> strcpy(response, "FAILValue not set");
> } else {
> -   error("unknown variable: %s\n", cmd);
> -   strcpy(response, "FAILVariable not implemented");
> +   char envstr[32];
> +   snprintf(envstr, sizeof(envstr) - 1, "fastboot.%s", cmd);
> +   s = getenv(envstr);
> +   if (s) {
> +   strncat(response, s, chars_left);
> +   } else {
> +   error("unknown variable: %s\n", cmd);
> +   strcpy(response, "FAILVariable not implemented");
> +   }
> }
> fastboot_tx_write_str(response);
>  }
>
> Rob
>
> > Signed-off-by: Dileep Katta 
> > ---
> >  common/fb_mmc.c | 38
> ++
> >  drivers/usb/gadget/f_fastboot.c |  2 ++
> >  include/fb_mmc.h|  2 ++
> >  3 files changed, 42 insertions(+)
> >
> > diff --git a/common/fb_mmc.c b/common/fb_mmc.c
> > index 6ea3938..1bb6335 100644
> > --- a/common/fb_mmc.c
> > +++ b/common/fb_mmc.c
> > @@ -32,6 +32,44 @@ void fastboot_okay(const char *s)
> > strncat(response_str, s, RESPONSE_LEN - 4 - 1);
> >  }
> >
> > +void fb_mmc_get_ptn_size(const char *cmd, char *response)
> > +{
> > +   int ret;
> > +   block_dev_desc_t *dev_desc;
> > +   disk_partition_t info;
> > +   u32 sz_mb;
> > +   u64 sz = 0;
> > +   char buf[RESPONSE_LEN];
> > +
> > +   /* initialize the response buffer */
> > +   response_str = response;
> > +
> > +   dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
> > +   if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
> > +   error("invalid mmc device");
> > +   fastboot_fail("invalid mmc device");
> > +   return;
> > +   }
> > +
> > +   ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
> > +   if (ret) {
> > +   error("cannot find partition: '%s'", cmd);
> > +   fastboot_fail("cannot find partition");
> > +   return;
> > +   }
> > +
> > +   sz = (info.size * (u64)info.blksz) >> 10;
> > +
> > +   if (sz >= 0x) {
> > +   sz_mb = (u32)(sz >> 10);
> > +   sprintf(buf, "0x%d MB", sz_mb);
> > +   fastboot_okay(buf);
> > +   } else {
> > +   sprintf(buf, "%d KB", (u32)sz);
> > +   fastboot_okay(buf);
> > +   }
> > +}
> > +
> >  static void write_raw_image(block_dev_desc_t *dev_desc,
> disk_partition_t *info,
> > const char *part_name, void *buffer,
> > unsigned int download_bytes)
> > diff --git a/drivers/usb/gadget/f_fastboot.c
> b/drivers/usb/gadget/f_fastboot.c
> > index 310175a..17b64ef 100644
> > --- a/drivers/usb/gadget/f_fa

Re: [U-Boot] [PATCH v2 1/1] usb: gadget: fastboot: Add fastboot erase

2015-02-24 Thread Dileep Katta
Thanks Lukasz.

Regards,
Dileep

On 24 February 2015 at 14:44, Lukasz Majewski 
wrote:

> Hi Dileep,
>
> > Adds the fastboot erase functionality, to erase a partition
> > specified by name. The erase is performed based on erase group size,
> > to avoid erasing other partitions. The start address and the size
> > is aligned to the erase group size for this.
> >
> > Currently only supports erasing from eMMC.
> >
> > Signed-off-by: Dileep Katta 
> > ---
> > Changes in v2:
> >   - Removed unnecessary newline for error() messages
> >   - Made the command conditional on CONFIG_FASTBOOT_FLASH
> >   - Updated doc/README.android-fastboot to reflect the support
> >  common/fb_mmc.c | 56
> > +
> > doc/README.android-fastboot |  5 ++--
> > drivers/usb/gadget/f_fastboot.c | 25 ++
> > include/fb_mmc.h|  1 + 4 files changed, 84
> > insertions(+), 3 deletions(-)
> >
> > diff --git a/common/fb_mmc.c b/common/fb_mmc.c
> > index 6ea3938..513b7ab 100644
> > --- a/common/fb_mmc.c
> > +++ b/common/fb_mmc.c
> > @@ -10,6 +10,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  #ifndef CONFIG_FASTBOOT_GPT_NAME
> >  #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME
> > @@ -110,3 +111,58 @@ void fb_mmc_flash_write(const char *cmd, void
> > *download_buffer, write_raw_image(dev_desc, &info, cmd,
> > download_buffer, download_bytes);
> >  }
> > +
> > +void fb_mmc_erase(const char *cmd, char *response)
> > +{
> > + int ret;
> > + block_dev_desc_t *dev_desc;
> > + disk_partition_t info;
> > + lbaint_t blks, blks_start, blks_size, grp_size;
> > + struct mmc *mmc =
> > find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV); +
> > + if (mmc == NULL) {
> > + error("invalid mmc device");
> > + fastboot_fail("invalid mmc device");
> > + return;
> > + }
> > +
> > + /* initialize the response buffer */
> > + response_str = response;
> > +
> > + dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
> > + if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
> > + error("invalid mmc device");
> > + fastboot_fail("invalid mmc device");
> > + return;
> > + }
> > +
> > + ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
> > + if (ret) {
> > + error("cannot find partition: '%s'", cmd);
> > + fastboot_fail("cannot find partition");
> > + return;
> > + }
> > +
> > + /* Align blocks to erase group size to avoid erasing other
> > partitions */
> > + grp_size = mmc->erase_grp_size;
> > + blks_start = (info.start + grp_size - 1) & ~(grp_size - 1);
> > + if (info.size >= grp_size)
> > + blks_size = (info.size - (blks_start - info.start)) &
> > + (~(grp_size - 1));
> > + else
> > + blks_size = 0;
> > +
> > + printf("Erasing blocks " LBAFU " to " LBAFU " due to
> > alignment\n",
> > +blks_start, blks_start + blks_size);
> > +
> > + blks = dev_desc->block_erase(dev_desc->dev, blks_start,
> > blks_size);
> > + if (blks != blks_size) {
> > + error("failed erasing from device %d",
> > dev_desc->dev);
> > + fastboot_fail("failed erasing from device");
> > + return;
> > + }
> > +
> > + printf(" erased " LBAFU " bytes from '%s'\n",
> > +blks_size * info.blksz, cmd);
> > + fastboot_okay("");
> > +}
> > diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot
> > index 1677609..5526a43 100644
> > --- a/doc/README.android-fastboot
> > +++ b/doc/README.android-fastboot
> > @@ -6,9 +6,8 @@ Overview
> >  The protocol that is used over USB is described in
> >  README.android-fastboot-protocol in same directory.
> >
> > -The current implementation does not yet support the erase command or
> > the -"oem format" command, and there is minimal support for the flash
> > command; -it only supports eMMC devices.
> > +The current implementation is a

[U-Boot] [PATCH v1 2/2] fastboot: Add support in fastboot oem command to set QSPI as boot device

2015-02-18 Thread Dileep Katta
Fastboot oem command is updated with SPI specific functionality.

Signed-off-by: Dileep Katta 
---
Note: This is on top of Rob Herring patches submitted to support oem format 
command
Ref: https://patchwork.ozlabs.org/patch/433056/
 https://patchwork.ozlabs.org/patch/433057/
 drivers/usb/gadget/f_fastboot.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index a170eea..04fa4c2 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -591,7 +591,33 @@ static void cb_flash(struct usb_ep *ep, struct usb_request 
*req)
 static void cb_oem(struct usb_ep *ep, struct usb_request *req)
 {
char *cmd = req->buf;
+
 #ifdef CONFIG_FASTBOOT_FLASH
+#ifdef CONFIG_SPL_SPI_SUPPORT
+   char *sf_erase[4] = {"sf", "erase", "0", "2"};
+   int status;
+   char *sf_probe[3] = {"sf", "probe", "0"};
+   if (strncmp(req->buf + 4, "spi", 3) == 0) {
+   boot_from_spi = 1;
+   status = do_spi_flash(NULL, 0, 3, sf_probe);
+   if (status) {
+   fastboot_tx_write_str("FAILcould not probe SPI");
+   return;
+   }
+   status = do_spi_flash(NULL, 0, 4, sf_erase);
+   if (status) {
+   fastboot_tx_write_str("FAILcould not erase SPI");
+   return;
+   }
+   fastboot_tx_write_str("OKAY");
+   return;
+   } else if (strncmp(req->buf + 4, "mmc", 3) == 0) {
+   boot_from_spi = 0;
+   fastboot_tx_write_str("OKAY");
+   return;
+   }
+#endif
+
if (strncmp("format", cmd + 4, 6) == 0) {
char cmdbuf[32];
 sprintf(cmdbuf, "gpt write mmc %x $partitions",
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 1/2] fastboot: Add support to flash u-boot and MLO to QSPI

2015-02-18 Thread Dileep Katta
This adds the functionality to flash u-boot and MLO images to QSPI using 
fastboot

Signed-off-by: Dileep Katta 
---
Note: This is on top of Rob Herring patches submitted to support oem format 
command
 drivers/usb/gadget/f_fastboot.c | 75 +
 1 file changed, 75 insertions(+)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index f7d84bf..a170eea 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -492,10 +492,23 @@ static void cb_continue(struct usb_ep *ep, struct 
usb_request *req)
 }
 
 #ifdef CONFIG_FASTBOOT_FLASH
+#ifdef CONFIG_SPL_SPI_SUPPORT
+int boot_from_spi = 0;
+#endif
+
 static void cb_flash(struct usb_ep *ep, struct usb_request *req)
 {
char *cmd = req->buf;
char response[RESPONSE_LEN];
+#ifdef CONFIG_SPL_SPI_SUPPORT
+   char source[32];
+   int status = 0;
+   char *sf_probe[3] = {"sf", "probe", "0"};
+   char *sf_write_xloader[5] = {"sf", "write", NULL, "0", "2"};
+   char *sf_update_xloader[5] = {"sf", "update", NULL, "0", "2"};
+   char *sf_write_bl[5] = {"sf", "write", NULL, "8", "8"};
+   char *sf_update_bl[5] = {"sf", "update", NULL, "8", "8"};
+#endif
 
strsep(&cmd, ":");
if (!cmd) {
@@ -505,6 +518,68 @@ static void cb_flash(struct usb_ep *ep, struct usb_request 
*req)
}
 
strcpy(response, "FAILno flash device defined");
+#ifdef CONFIG_SPL_SPI_SUPPORT
+   /*
+* Check if this is for xloader or bootloader.
+* Also, check if we have to flash to SPI
+*/
+   if (strcmp(cmd, "xloader") == 0 && boot_from_spi) {
+   printf("Flashing %s to SPI\n", cmd);
+   status = do_spi_flash(NULL, 0, 3, sf_probe);
+   if (status) {
+   fastboot_tx_write_str("FAILcould not probe SPI");
+   return;
+   }
+   sf_write_xloader[2] = source;
+   sf_update_xloader[2] = source;
+   sprintf(source, "0x%x",
+   (unsigned int)CONFIG_USB_FASTBOOT_BUF_ADDR);
+
+   printf("Updating X-LOADER to SPI\n");
+   status = do_spi_flash(NULL, 0, 5, sf_update_xloader);
+   if (status) {
+   fastboot_tx_write_str("FAILupdate xloader failed");
+   return;
+   }
+
+   printf("Writing X-LOADER to SPI\n");
+   status = do_spi_flash(NULL, 0, 5, sf_write_xloader);
+   if (status) {
+   fastboot_tx_write_str("FAILwrite xloader failed");
+   return;
+   }
+   printf("Writing xloader DONE\n");
+   fastboot_tx_write_str("OKAY");
+   return;
+   }
+   if (strcmp(cmd, "bootloader") == 0 && boot_from_spi) {
+   printf("Flashing %s to SPI\n", cmd);
+   status = do_spi_flash(NULL, 0, 3, sf_probe);
+   if (status) {
+   fastboot_tx_write_str("FAILcould not probe SPI");
+   return;
+   }
+   sf_write_bl[2] = source;
+   sf_update_bl[2] = source;
+   sprintf(source, "0x%x",
+   (unsigned int)CONFIG_USB_FASTBOOT_BUF_ADDR);
+   printf("Updating bootloader to SPI\n");
+   status = do_spi_flash(NULL, 0, 5, sf_update_bl);
+   if (status) {
+   fastboot_tx_write_str("FAILupdate bootloader failed");
+   return;
+   }
+   printf("Writing bootloader to SPI\n");
+   status = do_spi_flash(NULL, 0, 5, sf_write_bl);
+   if (status) {
+   fastboot_tx_write_str("FAILwrite bootloader failed");
+   return;
+   }
+   printf("Writing bootloader DONE\n");
+   fastboot_tx_write_str("OKAY");
+   return;
+   }
+#endif
 #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
fb_mmc_flash_write(cmd, (void *)CONFIG_USB_FASTBOOT_BUF_ADDR,
   download_bytes, response);
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 1/1] fastboot: Update getvar command to get 'userdata' partition size

2015-02-18 Thread Dileep Katta
This patch adds functionality to getvar command to get the userdata partition
size.

Signed-off-by: Dileep Katta 
---
 common/fb_mmc.c | 38 ++
 drivers/usb/gadget/f_fastboot.c |  2 ++
 include/fb_mmc.h|  2 ++
 3 files changed, 42 insertions(+)

diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index 6ea3938..1bb6335 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -32,6 +32,44 @@ void fastboot_okay(const char *s)
strncat(response_str, s, RESPONSE_LEN - 4 - 1);
 }
 
+void fb_mmc_get_ptn_size(const char *cmd, char *response)
+{
+   int ret;
+   block_dev_desc_t *dev_desc;
+   disk_partition_t info;
+   u32 sz_mb;
+   u64 sz = 0;
+   char buf[RESPONSE_LEN];
+
+   /* initialize the response buffer */
+   response_str = response;
+
+   dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
+   if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
+   error("invalid mmc device");
+   fastboot_fail("invalid mmc device");
+   return;
+   }
+
+   ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
+   if (ret) {
+   error("cannot find partition: '%s'", cmd);
+   fastboot_fail("cannot find partition");
+   return;
+   }
+
+   sz = (info.size * (u64)info.blksz) >> 10;
+
+   if (sz >= 0x) {
+   sz_mb = (u32)(sz >> 10);
+   sprintf(buf, "0x%d MB", sz_mb);
+   fastboot_okay(buf);
+   } else {
+   sprintf(buf, "%d KB", (u32)sz);
+   fastboot_okay(buf);
+   }
+}
+
 static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,
const char *part_name, void *buffer,
unsigned int download_bytes)
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 310175a..17b64ef 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -363,6 +363,8 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request 
*req)
strncat(response, s, chars_left);
else
strcpy(response, "FAILValue not set");
+   } else if (!strcmp_l1("userdata_size", cmd)) {
+   fb_mmc_get_ptn_size("userdata", response);
} else {
error("unknown variable: %s\n", cmd);
strcpy(response, "FAILVariable not implemented");
diff --git a/include/fb_mmc.h b/include/fb_mmc.h
index 1ad1d13..353f325 100644
--- a/include/fb_mmc.h
+++ b/include/fb_mmc.h
@@ -4,5 +4,7 @@
  * SPDX-License-Identifier:GPL-2.0+
  */
 
+void fb_mmc_get_ptn_size(const char *cmd, char *response);
+
 void fb_mmc_flash_write(const char *cmd, void *download_buffer,
unsigned int download_bytes, char *response);
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/1] usb: gadget: fastboot: Add fastboot erase

2015-02-17 Thread Dileep Katta
Adds the fastboot erase functionality, to erase a partition
specified by name. The erase is performed based on erase group size,
to avoid erasing other partitions. The start address and the size
is aligned to the erase group size for this.

Currently only supports erasing from eMMC.

Signed-off-by: Dileep Katta 
---
Changes in v2:
- Removed unnecessary newline for error() messages
- Made the command conditional on CONFIG_FASTBOOT_FLASH
- Updated doc/README.android-fastboot to reflect the support
 common/fb_mmc.c | 56 +
 doc/README.android-fastboot |  5 ++--
 drivers/usb/gadget/f_fastboot.c | 25 ++
 include/fb_mmc.h|  1 +
 4 files changed, 84 insertions(+), 3 deletions(-)

diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index 6ea3938..513b7ab 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifndef CONFIG_FASTBOOT_GPT_NAME
 #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME
@@ -110,3 +111,58 @@ void fb_mmc_flash_write(const char *cmd, void 
*download_buffer,
write_raw_image(dev_desc, &info, cmd, download_buffer,
download_bytes);
 }
+
+void fb_mmc_erase(const char *cmd, char *response)
+{
+   int ret;
+   block_dev_desc_t *dev_desc;
+   disk_partition_t info;
+   lbaint_t blks, blks_start, blks_size, grp_size;
+   struct mmc *mmc = find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV);
+
+   if (mmc == NULL) {
+   error("invalid mmc device");
+   fastboot_fail("invalid mmc device");
+   return;
+   }
+
+   /* initialize the response buffer */
+   response_str = response;
+
+   dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
+   if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
+   error("invalid mmc device");
+   fastboot_fail("invalid mmc device");
+   return;
+   }
+
+   ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
+   if (ret) {
+   error("cannot find partition: '%s'", cmd);
+   fastboot_fail("cannot find partition");
+   return;
+   }
+
+   /* Align blocks to erase group size to avoid erasing other partitions */
+   grp_size = mmc->erase_grp_size;
+   blks_start = (info.start + grp_size - 1) & ~(grp_size - 1);
+   if (info.size >= grp_size)
+   blks_size = (info.size - (blks_start - info.start)) &
+   (~(grp_size - 1));
+   else
+   blks_size = 0;
+
+   printf("Erasing blocks " LBAFU " to " LBAFU " due to alignment\n",
+  blks_start, blks_start + blks_size);
+
+   blks = dev_desc->block_erase(dev_desc->dev, blks_start, blks_size);
+   if (blks != blks_size) {
+   error("failed erasing from device %d", dev_desc->dev);
+   fastboot_fail("failed erasing from device");
+   return;
+   }
+
+   printf(" erased " LBAFU " bytes from '%s'\n",
+  blks_size * info.blksz, cmd);
+   fastboot_okay("");
+}
diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot
index 1677609..5526a43 100644
--- a/doc/README.android-fastboot
+++ b/doc/README.android-fastboot
@@ -6,9 +6,8 @@ Overview
 The protocol that is used over USB is described in
 README.android-fastboot-protocol in same directory.
 
-The current implementation does not yet support the erase command or the
-"oem format" command, and there is minimal support for the flash command;
-it only supports eMMC devices.
+The current implementation is a minimal support of the erase command,the
+"oem format" command and flash command;it only supports eMMC devices.
 
 Client installation
 ===
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index f7d84bf..6138906 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -535,6 +535,28 @@ static void cb_oem(struct usb_ep *ep, struct usb_request 
*req)
}
 }
 
+#ifdef CONFIG_FASTBOOT_FLASH
+static void cb_erase(struct usb_ep *ep, struct usb_request *req)
+{
+   char *cmd = req->buf;
+   char response[RESPONSE_LEN];
+
+   strsep(&cmd, ":");
+   if (!cmd) {
+   error("missing partition name");
+   fastboot_tx_write_str("FAILmissing partition name");
+   return;
+   }
+
+   strcpy(response, "FAILno flash device defined");
+
+#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+   fb_mmc_erase(cmd, response);
+#endif
+   fastboot

Re: [U-Boot] [PATCH v1 1/1] usb: gadget: fastboot: Add fastboot erase

2015-02-17 Thread Dileep Katta
On 17 February 2015 at 02:51, Steve Rae  wrote:

>
>
> On 15-02-16 12:40 PM, Dileep Katta wrote:
>
>> Hi Steve,
>>
>> On 14 February 2015 at 02:15, Steve Rae  wrote:
>>
>>
>>>
>>> On 15-02-12 12:29 AM, Dileep Katta wrote:
>>>
>>>  Hi Steve,
>>>>
>>>> On 11 February 2015 at 05:25, Steve Rae  wrote:
>>>>
>>>>
>>>>> Hi, Dileep
>>>>>
>>>>>
>>>>> On 15-02-10 12:49 AM, Dileep Katta wrote:
>>>>>
>>>>>
>>>>>> Adds the fastboot erase functionality, to erase a partition
>>>>>> specified by name. The erase is performed based on erase group size,
>>>>>> to avoid erasing other partitions. The start address and the size
>>>>>> is aligned to the erase group size for this.
>>>>>>
>>>>>> Currently only supports erasing from eMMC.
>>>>>>
>>>>>> Signed-off-by: Dileep Katta 
>>>>>> ---
>>>>>> Note: The changes are on top of oem command support added by
>>>>>> r...@kernel.org
>>>>>>
>>>>>> common/fb_mmc.c | 58
>>>>>> ++
>>>>>> +++
>>>>>> drivers/usb/gadget/f_fastboot.c | 23 
>>>>>> include/fb_mmc.h|  1 +
>>>>>> 3 files changed, 82 insertions(+)
>>>>>>
>>>>>> diff --git a/common/fb_mmc.c b/common/fb_mmc.c
>>>>>> index 6ea3938..3911989 100644
>>>>>> --- a/common/fb_mmc.c
>>>>>> +++ b/common/fb_mmc.c
>>>>>> @@ -10,6 +10,7 @@
>>>>>> #include 
>>>>>> #include 
>>>>>> #include 
>>>>>> +#include 
>>>>>>
>>>>>> #ifndef CONFIG_FASTBOOT_GPT_NAME
>>>>>> #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME
>>>>>> @@ -110,3 +111,60 @@ void fb_mmc_flash_write(const char *cmd, void
>>>>>> *download_buffer,
>>>>>>   write_raw_image(dev_desc, &info, cmd,
>>>>>> download_buffer,
>>>>>>   download_bytes);
>>>>>> }
>>>>>> +
>>>>>> +void fb_mmc_erase(const char *cmd, char *response)
>>>>>> +{
>>>>>> +   int ret;
>>>>>> +   block_dev_desc_t *dev_desc;
>>>>>> +   disk_partition_t info;
>>>>>> +   lbaint_t blks, blks_start, blks_size, grp_size;
>>>>>> +   struct mmc *mmc = find_mmc_device(CONFIG_
>>>>>> FASTBOOT_FLASH_MMC_DEV);
>>>>>> +
>>>>>> +   if (mmc == NULL) {
>>>>>> +   error("invalid mmc device\n");
>>>>>>
>>>>>>
>>>>> no newline with error()
>>>>>
>>>>>  Will remove
>>>>
>>>>
>>>>>   +   fastboot_fail("invalid mmc device");
>>>>>
>>>>>> +   return;
>>>>>> +   }
>>>>>> +
>>>>>> +   /* initialize the response buffer */
>>>>>> +   response_str = response;
>>>>>> +
>>>>>> +   dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
>>>>>> +   if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
>>>>>> +   error("invalid mmc device\n");
>>>>>>
>>>>>>
>>>>> no newline with error()
>>>>>
>>>>>  Will remove
>>>>
>>>>
>>>>>
>>>>>   +   fastboot_fail("invalid mmc device");
>>>>>
>>>>>> +   return;
>>>>>> +   }
>>>>>> +
>>>>>> +   ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
>>>>>> +   if (ret) {
>>>>>> +   error("cannot find partition: '%s'\n", cmd);
>>>>>>
>>>>>>
>>>>> no newline with error()
>>>>>
>>>>>  Will remove
>>>>
>>>&

Re: [U-Boot] [PATCH v1 1/1] usb: gadget: fastboot: Add fastboot erase

2015-02-16 Thread Dileep Katta
Hi Steve,

On 14 February 2015 at 02:15, Steve Rae  wrote:

>
>
> On 15-02-12 12:29 AM, Dileep Katta wrote:
>
>> Hi Steve,
>>
>> On 11 February 2015 at 05:25, Steve Rae  wrote:
>>
>>>
>>> Hi, Dileep
>>>
>>>
>>> On 15-02-10 12:49 AM, Dileep Katta wrote:
>>>
>>>>
>>>> Adds the fastboot erase functionality, to erase a partition
>>>> specified by name. The erase is performed based on erase group size,
>>>> to avoid erasing other partitions. The start address and the size
>>>> is aligned to the erase group size for this.
>>>>
>>>> Currently only supports erasing from eMMC.
>>>>
>>>> Signed-off-by: Dileep Katta 
>>>> ---
>>>> Note: The changes are on top of oem command support added by
>>>> r...@kernel.org
>>>>
>>>>common/fb_mmc.c | 58 ++
>>>> +++
>>>>drivers/usb/gadget/f_fastboot.c | 23 
>>>>include/fb_mmc.h|  1 +
>>>>3 files changed, 82 insertions(+)
>>>>
>>>> diff --git a/common/fb_mmc.c b/common/fb_mmc.c
>>>> index 6ea3938..3911989 100644
>>>> --- a/common/fb_mmc.c
>>>> +++ b/common/fb_mmc.c
>>>> @@ -10,6 +10,7 @@
>>>>#include 
>>>>#include 
>>>>#include 
>>>> +#include 
>>>>
>>>>#ifndef CONFIG_FASTBOOT_GPT_NAME
>>>>#define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME
>>>> @@ -110,3 +111,60 @@ void fb_mmc_flash_write(const char *cmd, void
>>>> *download_buffer,
>>>>  write_raw_image(dev_desc, &info, cmd, download_buffer,
>>>>  download_bytes);
>>>>}
>>>> +
>>>> +void fb_mmc_erase(const char *cmd, char *response)
>>>> +{
>>>> +   int ret;
>>>> +   block_dev_desc_t *dev_desc;
>>>> +   disk_partition_t info;
>>>> +   lbaint_t blks, blks_start, blks_size, grp_size;
>>>> +   struct mmc *mmc = find_mmc_device(CONFIG_
>>>> FASTBOOT_FLASH_MMC_DEV);
>>>> +
>>>> +   if (mmc == NULL) {
>>>> +   error("invalid mmc device\n");
>>>>
>>>
>>> no newline with error()
>>>
>> Will remove
>>
>>>
>>>  +   fastboot_fail("invalid mmc device");
>>>> +   return;
>>>> +   }
>>>> +
>>>> +   /* initialize the response buffer */
>>>> +   response_str = response;
>>>> +
>>>> +   dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
>>>> +   if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
>>>> +   error("invalid mmc device\n");
>>>>
>>>
>>> no newline with error()
>>>
>> Will remove
>>
>>>
>>>
>>>  +   fastboot_fail("invalid mmc device");
>>>> +   return;
>>>> +   }
>>>> +
>>>> +   ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
>>>> +   if (ret) {
>>>> +   error("cannot find partition: '%s'\n", cmd);
>>>>
>>>
>>> no newline with error()
>>>
>> Will remove
>>
>>>
>>>  +   fastboot_fail("cannot find partition");
>>>> +   return;
>>>> +   }
>>>> +
>>>> +   puts("Erasing partition\n");
>>>> +
>>>> +   /* Align blocks to erase group size to avoid erasing other
>>>> partitions */
>>>> +   grp_size = mmc->erase_grp_size;
>>>> +   blks_start = (info.start + grp_size - 1) & ~(grp_size - 1);
>>>> +   if (info.size >= grp_size)
>>>> +   blks_size = (info.size - (blks_start - info.start)) &
>>>> +   (~(grp_size - 1));
>>>> +   else
>>>> +   blks_size = 0;
>>>>
>>>
>>>
>>> Is this logic correct??? Isn't the "erase_grp_size" in bytes? and the
>>> info.start & info.size in LBA's?
>>>
>> Yes, the math will take care o

[U-Boot] [PATCH v3 1/3] fastboot: OUT transaction length must be aligned to wMaxPacketSize

2015-02-16 Thread Dileep Katta
OUT transactions must be aligned to wMaxPacketSize for each transfer,
or else transfer will not complete successfully. This patch modifies
rx_bytes_expected to return a transfer length that is aligned to
wMaxPacketSize.

Note that the value of wMaxPacketSize and ep->maxpacket may not be
the same value, and it is the value of wMaxPacketSize that should be
used for alignment. wMaxPacketSize is passed depending on the speed of
connection.

Signed-off-by: Dileep Katta 
---
Changes in v2:
- Corrected source of wMaxPacketSize
Changes in v3:
- Corrected the logic to accomodate both HS and FS speeds

 drivers/usb/gadget/f_fastboot.c | 27 ++-
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index a8d8205..2793590 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -55,6 +55,7 @@ static inline struct f_fastboot *func_to_fastboot(struct 
usb_function *f)
 static struct f_fastboot *fastboot_func;
 static unsigned int download_size;
 static unsigned int download_bytes;
+static bool is_high_speed;
 
 static struct usb_endpoint_descriptor fs_ep_in = {
.bLength= USB_DT_ENDPOINT_SIZE,
@@ -219,10 +220,13 @@ static int fastboot_set_alt(struct usb_function *f,
  __func__, f->name, interface, alt);
 
/* make sure we don't enable the ep twice */
-   if (gadget->speed == USB_SPEED_HIGH)
+   if (gadget->speed == USB_SPEED_HIGH) {
ret = usb_ep_enable(f_fb->out_ep, &hs_ep_out);
-   else
+   is_high_speed = true;
+   } else {
ret = usb_ep_enable(f_fb->out_ep, &fs_ep_out);
+   is_high_speed = false;
+   }
if (ret) {
puts("failed to enable out ep\n");
return ret;
@@ -370,13 +374,20 @@ static void cb_getvar(struct usb_ep *ep, struct 
usb_request *req)
fastboot_tx_write_str(response);
 }
 
-static unsigned int rx_bytes_expected(void)
+static unsigned int rx_bytes_expected(unsigned int maxpacket)
 {
int rx_remain = download_size - download_bytes;
+   int rem = 0;
if (rx_remain < 0)
return 0;
if (rx_remain > EP_BUFFER_SIZE)
return EP_BUFFER_SIZE;
+   if (rx_remain < maxpacket) {
+   rx_remain = maxpacket;
+   } else if (rx_remain % maxpacket != 0) {
+   rem = rx_remain % maxpacket;
+   rx_remain = rx_remain + (maxpacket - rem);
+   }
return rx_remain;
 }
 
@@ -388,6 +399,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct 
usb_request *req)
const unsigned char *buffer = req->buf;
unsigned int buffer_size = req->actual;
unsigned int pre_dot_num, now_dot_num;
+   unsigned int max;
 
if (req->status != 0) {
printf("Bad status: %d\n", req->status);
@@ -425,7 +437,9 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct 
usb_request *req)
 
printf("\ndownloading of %d bytes finished\n", download_bytes);
} else {
-   req->length = rx_bytes_expected();
+   max = is_high_speed ? hs_ep_out.wMaxPacketSize :
+   fs_ep_out.wMaxPacketSize;
+   req->length = rx_bytes_expected(max);
if (req->length < ep->maxpacket)
req->length = ep->maxpacket;
}
@@ -438,6 +452,7 @@ static void cb_download(struct usb_ep *ep, struct 
usb_request *req)
 {
char *cmd = req->buf;
char response[RESPONSE_LEN];
+   unsigned int max;
 
strsep(&cmd, ":");
download_size = simple_strtoul(cmd, NULL, 16);
@@ -453,7 +468,9 @@ static void cb_download(struct usb_ep *ep, struct 
usb_request *req)
} else {
sprintf(response, "DATA%08x", download_size);
req->complete = rx_handler_dl_image;
-   req->length = rx_bytes_expected();
+   max = is_high_speed ? hs_ep_out.wMaxPacketSize :
+   fs_ep_out.wMaxPacketSize;
+   req->length = rx_bytes_expected(max);
if (req->length < ep->maxpacket)
req->length = ep->maxpacket;
}
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/3] fastboot: OUT transaction length must be aligned to wMaxPacketSize

2015-02-13 Thread Dileep Katta
OUT transactions must be aligned to wMaxPacketSize for each transfer,
or else transfer will not complete successfully. This patch modifies
rx_bytes_expected to return a transfer length that is aligned to
wMaxPacketSize.

Note that the value of wMaxPacketSize and ep->maxpacket may not be
the same value, and it is the value of wMaxPacketSize that should be
used for alignment.

Signed-off-by: Dileep Katta 
---
Changes from v1:
- Corrected source of wMaxPacketSize
 drivers/usb/gadget/f_fastboot.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index a8d8205..b18452e 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -370,13 +370,20 @@ static void cb_getvar(struct usb_ep *ep, struct 
usb_request *req)
fastboot_tx_write_str(response);
 }
 
-static unsigned int rx_bytes_expected(void)
+static unsigned int rx_bytes_expected(unsigned maxpacket)
 {
int rx_remain = download_size - download_bytes;
+   int rem = 0;
if (rx_remain < 0)
return 0;
if (rx_remain > EP_BUFFER_SIZE)
return EP_BUFFER_SIZE;
+   if (rx_remain < maxpacket) {
+   rx_remain = maxpacket;
+   } else if (rx_remain % maxpacket != 0) {
+   rem = rx_remain % maxpacket;
+   rx_remain = rx_remain + (maxpacket - rem);
+   }
return rx_remain;
 }
 
@@ -425,7 +432,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct 
usb_request *req)
 
printf("\ndownloading of %d bytes finished\n", download_bytes);
} else {
-   req->length = rx_bytes_expected();
+   req->length = rx_bytes_expected(fs_ep_out.wMaxPacketSize);
if (req->length < ep->maxpacket)
req->length = ep->maxpacket;
}
@@ -453,7 +460,7 @@ static void cb_download(struct usb_ep *ep, struct 
usb_request *req)
} else {
sprintf(response, "DATA%08x", download_size);
req->complete = rx_handler_dl_image;
-   req->length = rx_bytes_expected();
+   req->length = rx_bytes_expected(fs_ep_out.wMaxPacketSize);
if (req->length < ep->maxpacket)
req->length = ep->maxpacket;
}
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 2/3] fastboot: Correct fastboot_fail and fastboot_okay strings

2015-02-12 Thread Dileep Katta
If the string is copied without NULL termination using strncpy(),
then strncat() on the next line, may concatenate the string after
some stale (or random) data, if the response string was not
zero-initialized.

Signed-off-by: Dileep Katta 
---
 common/fb_mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index 3911989..73055cc 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -23,13 +23,13 @@ static char *response_str;
 
 void fastboot_fail(const char *s)
 {
-   strncpy(response_str, "FAIL", 4);
+   strncpy(response_str, "FAIL\0", 5);
strncat(response_str, s, RESPONSE_LEN - 4 - 1);
 }
 
 void fastboot_okay(const char *s)
 {
-   strncpy(response_str, "OKAY", 4);
+   strncpy(response_str, "OKAY\0", 5);
strncat(response_str, s, RESPONSE_LEN - 4 - 1);
 }
 
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 3/3] usb: gadget: fastboot: Set the Serial Number for Fastboot Gadget

2015-02-12 Thread Dileep Katta
Configure the serial number using the serial# environment variable
during the fastboot bind.

This enables "fastboot devices" to return the serial number for
the attached devices.

Signed-off-by: Dileep Katta 
---
 drivers/usb/gadget/f_fastboot.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 0d53a61..d114c07 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -136,6 +136,7 @@ static int fastboot_bind(struct usb_configuration *c, 
struct usb_function *f)
int id;
struct usb_gadget *gadget = c->cdev->gadget;
struct f_fastboot *f_fb = func_to_fastboot(f);
+   const char *s;
 
/* DYNAMIC interface numbers assignments */
id = usb_interface_id(c, f);
@@ -161,6 +162,10 @@ static int fastboot_bind(struct usb_configuration *c, 
struct usb_function *f)
 
hs_ep_out.bEndpointAddress = fs_ep_out.bEndpointAddress;
 
+   s = getenv("serial#");
+   if (s)
+   g_dnl_set_serialnumber((char *)s);
+
return 0;
 }
 
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 1/3] fastboot: OUT transaction length must be aligned to wMaxPacketSize

2015-02-12 Thread Dileep Katta
OUT transactions must be aligned to wMaxPacketSize for each transfer,
or else transfer will not complete successfully. This patch modifies
rx_bytes_expected to return a transfer length that is aligned to
wMaxPacketSize.

Note that the value of ep->desc->wMaxPacketSize and ep->maxpacket
may not be the same value, and it is the value of ep->desc->wMaxPacketSize
that should be used for alignment.

Signed-off-by: Dileep Katta 
---
 drivers/usb/gadget/f_fastboot.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index a8d8205..0d53a61 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -370,13 +370,20 @@ static void cb_getvar(struct usb_ep *ep, struct 
usb_request *req)
fastboot_tx_write_str(response);
 }
 
-static unsigned int rx_bytes_expected(void)
+static unsigned int rx_bytes_expected(unsigned maxpacket)
 {
int rx_remain = download_size - download_bytes;
+   int rem = 0;
if (rx_remain < 0)
return 0;
if (rx_remain > EP_BUFFER_SIZE)
return EP_BUFFER_SIZE;
+   if (rx_remain < maxpacket) {
+   rx_remain = maxpacket;
+   } else if (rx_remain % maxpacket != 0) {
+   rem = rx_remain % maxpacket;
+   rx_remain = rx_remain + (maxpacket - rem);
+   }
return rx_remain;
 }
 
@@ -425,7 +432,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct 
usb_request *req)
 
printf("\ndownloading of %d bytes finished\n", download_bytes);
} else {
-   req->length = rx_bytes_expected();
+   req->length = rx_bytes_expected(ep->desc->wMaxPacketSize);
if (req->length < ep->maxpacket)
req->length = ep->maxpacket;
}
@@ -453,7 +460,7 @@ static void cb_download(struct usb_ep *ep, struct 
usb_request *req)
} else {
sprintf(response, "DATA%08x", download_size);
req->complete = rx_handler_dl_image;
-   req->length = rx_bytes_expected();
+   req->length = rx_bytes_expected(ep->desc->wMaxPacketSize);
if (req->length < ep->maxpacket)
req->length = ep->maxpacket;
}
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v1 1/1] usb: gadget: fastboot: Add fastboot erase

2015-02-12 Thread Dileep Katta
Hi Rob,

On 12 February 2015 at 14:35, Rob Herring  wrote:
> On Tue, Feb 10, 2015 at 2:49 AM, Dileep Katta  wrote:
>> Adds the fastboot erase functionality, to erase a partition
>> specified by name. The erase is performed based on erase group size,
>> to avoid erasing other partitions. The start address and the size
>> is aligned to the erase group size for this.
>>
>> Currently only supports erasing from eMMC.
>>
>> Signed-off-by: Dileep Katta 
>> ---
>> Note: The changes are on top of oem command support added by r...@kernel.org
>>
>>  common/fb_mmc.c | 58 
>> +
>>  drivers/usb/gadget/f_fastboot.c | 23 
>>  include/fb_mmc.h|  1 +
>>  3 files changed, 82 insertions(+)
>>
>> diff --git a/common/fb_mmc.c b/common/fb_mmc.c
>> index 6ea3938..3911989 100644
>> --- a/common/fb_mmc.c
>> +++ b/common/fb_mmc.c
>> @@ -10,6 +10,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  #ifndef CONFIG_FASTBOOT_GPT_NAME
>>  #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME
>> @@ -110,3 +111,60 @@ void fb_mmc_flash_write(const char *cmd, void 
>> *download_buffer,
>> write_raw_image(dev_desc, &info, cmd, download_buffer,
>> download_bytes);
>>  }
>> +
>> +void fb_mmc_erase(const char *cmd, char *response)
>> +{
>> +   int ret;
>> +   block_dev_desc_t *dev_desc;
>> +   disk_partition_t info;
>> +   lbaint_t blks, blks_start, blks_size, grp_size;
>> +   struct mmc *mmc = find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV);
>> +
>> +   if (mmc == NULL) {
>> +   error("invalid mmc device\n");
>> +   fastboot_fail("invalid mmc device");
>
> Perhaps fastboot_fail should also call error().
There is error() before every fastboot_fail(). You mean to move
error() inside fastboot_fail()? If yes, I will do it.
>
>> +   return;
>> +   }
>> +
>> +   /* initialize the response buffer */
>> +   response_str = response;
>> +
>> +   dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
>> +   if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
>> +   error("invalid mmc device\n");
>> +   fastboot_fail("invalid mmc device");
>> +   return;
>> +   }
>> +
>> +   ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
>> +   if (ret) {
>> +   error("cannot find partition: '%s'\n", cmd);
>> +   fastboot_fail("cannot find partition");
>> +   return;
>> +   }
>> +
>> +   puts("Erasing partition\n");
>
> This can probably be dropped since you have a print below.
Will remove.
>> +
>> +   /* Align blocks to erase group size to avoid erasing other 
>> partitions */
>
> The partitioning could should probably enforce optimal alignment, but
> I guess that's a separate patch.
Fine. Will do it as a separate patch.
>
>> +   grp_size = mmc->erase_grp_size;
>> +   blks_start = (info.start + grp_size - 1) & ~(grp_size - 1);
>> +   if (info.size >= grp_size)
>> +   blks_size = (info.size - (blks_start - info.start)) &
>> +   (~(grp_size - 1));
>> +   else
>> +   blks_size = 0;
>> +
>> +   printf("Erasing blocks " LBAFU " to " LBAFU " due to alignment\n",
>> +  blks_start, blks_start + blks_size);
>> +
>> +   blks = dev_desc->block_erase(dev_desc->dev, blks_start, blks_size);
>> +   if (blks != blks_size) {
>> +   error("failed erasing from device %d\n", dev_desc->dev);
>> +   fastboot_fail("failed erasing from device");
>> +   return;
>> +   }
>> +
>> +   printf(" erased " LBAFU " bytes from '%s'\n",
>> +  blks_size * info.blksz, cmd);
>> +   fastboot_okay("");
>> +}
>> diff --git a/drivers/usb/gadget/f_fastboot.c 
>> b/drivers/usb/gadget/f_fastboot.c
>> index f7d84bf..a8d8205 100644
>> --- a/drivers/usb/gadget/f_fastboot.c
>> +++ b/drivers/usb/gadget/f_fastboot.c
>> @@ -535,6 +535,26 @@ static void cb_oem(struct usb_ep *ep, struct 
>> usb_request *req)

Re: [U-Boot] [PATCH v1 1/1] usb: gadget: fastboot: Add fastboot erase

2015-02-12 Thread Dileep Katta
Hi Steve,

On 11 February 2015 at 05:25, Steve Rae  wrote:
>
> Hi, Dileep
>
>
> On 15-02-10 12:49 AM, Dileep Katta wrote:
>>
>> Adds the fastboot erase functionality, to erase a partition
>> specified by name. The erase is performed based on erase group size,
>> to avoid erasing other partitions. The start address and the size
>> is aligned to the erase group size for this.
>>
>> Currently only supports erasing from eMMC.
>>
>> Signed-off-by: Dileep Katta 
>> ---
>> Note: The changes are on top of oem command support added by r...@kernel.org
>>
>>   common/fb_mmc.c | 58 
>> +
>>   drivers/usb/gadget/f_fastboot.c | 23 
>>   include/fb_mmc.h|  1 +
>>   3 files changed, 82 insertions(+)
>>
>> diff --git a/common/fb_mmc.c b/common/fb_mmc.c
>> index 6ea3938..3911989 100644
>> --- a/common/fb_mmc.c
>> +++ b/common/fb_mmc.c
>> @@ -10,6 +10,7 @@
>>   #include 
>>   #include 
>>   #include 
>> +#include 
>>
>>   #ifndef CONFIG_FASTBOOT_GPT_NAME
>>   #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME
>> @@ -110,3 +111,60 @@ void fb_mmc_flash_write(const char *cmd, void 
>> *download_buffer,
>> write_raw_image(dev_desc, &info, cmd, download_buffer,
>> download_bytes);
>>   }
>> +
>> +void fb_mmc_erase(const char *cmd, char *response)
>> +{
>> +   int ret;
>> +   block_dev_desc_t *dev_desc;
>> +   disk_partition_t info;
>> +   lbaint_t blks, blks_start, blks_size, grp_size;
>> +   struct mmc *mmc = find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV);
>> +
>> +   if (mmc == NULL) {
>> +   error("invalid mmc device\n");
>
> no newline with error()
Will remove
>
>> +   fastboot_fail("invalid mmc device");
>> +   return;
>> +   }
>> +
>> +   /* initialize the response buffer */
>> +   response_str = response;
>> +
>> +   dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
>> +   if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
>> +   error("invalid mmc device\n");
>
> no newline with error()
Will remove
>
>
>> +   fastboot_fail("invalid mmc device");
>> +   return;
>> +   }
>> +
>> +   ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
>> +   if (ret) {
>> +   error("cannot find partition: '%s'\n", cmd);
>
> no newline with error()
Will remove
>
>> +   fastboot_fail("cannot find partition");
>> +   return;
>> +   }
>> +
>> +   puts("Erasing partition\n");
>> +
>> +   /* Align blocks to erase group size to avoid erasing other 
>> partitions */
>> +   grp_size = mmc->erase_grp_size;
>> +   blks_start = (info.start + grp_size - 1) & ~(grp_size - 1);
>> +   if (info.size >= grp_size)
>> +   blks_size = (info.size - (blks_start - info.start)) &
>> +   (~(grp_size - 1));
>> +   else
>> +   blks_size = 0;
>
>
> Is this logic correct??? Isn't the "erase_grp_size" in bytes? and the 
> info.start & info.size in LBA's?
Yes, the math will take care of it. Ref: mmc_berase()
>
>
>> +
>> +   printf("Erasing blocks " LBAFU " to " LBAFU " due to alignment\n",
>> +  blks_start, blks_start + blks_size);
>> +
>> +   blks = dev_desc->block_erase(dev_desc->dev, blks_start, blks_size);
>> +   if (blks != blks_size) {
>> +   error("failed erasing from device %d\n", dev_desc->dev);
>
> no newline with error()
Will remove
>
>> +   fastboot_fail("failed erasing from device");
>> +   return;
>> +   }
>> +
>> +   printf(" erased " LBAFU " bytes from '%s'\n",
>> +  blks_size * info.blksz, cmd);
>> +   fastboot_okay("");
>> +}
>> diff --git a/drivers/usb/gadget/f_fastboot.c 
>> b/drivers/usb/gadget/f_fastboot.c
>> index f7d84bf..a8d8205 100644
>> --- a/drivers/usb/gadget/f_fastboot.c
>> +++ b/drivers/usb/gadget/f_fastboot.c
>> @@ -535,6 +535,26 @@ static void cb_oem(s

[U-Boot] [PATCH v1 1/1] usb: gadget: fastboot: Add fastboot erase

2015-02-10 Thread Dileep Katta
Adds the fastboot erase functionality, to erase a partition
specified by name. The erase is performed based on erase group size,
to avoid erasing other partitions. The start address and the size
is aligned to the erase group size for this.

Currently only supports erasing from eMMC.

Signed-off-by: Dileep Katta 
---
Note: The changes are on top of oem command support added by r...@kernel.org

 common/fb_mmc.c | 58 +
 drivers/usb/gadget/f_fastboot.c | 23 
 include/fb_mmc.h|  1 +
 3 files changed, 82 insertions(+)

diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index 6ea3938..3911989 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifndef CONFIG_FASTBOOT_GPT_NAME
 #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME
@@ -110,3 +111,60 @@ void fb_mmc_flash_write(const char *cmd, void 
*download_buffer,
write_raw_image(dev_desc, &info, cmd, download_buffer,
download_bytes);
 }
+
+void fb_mmc_erase(const char *cmd, char *response)
+{
+   int ret;
+   block_dev_desc_t *dev_desc;
+   disk_partition_t info;
+   lbaint_t blks, blks_start, blks_size, grp_size;
+   struct mmc *mmc = find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV);
+
+   if (mmc == NULL) {
+   error("invalid mmc device\n");
+   fastboot_fail("invalid mmc device");
+   return;
+   }
+
+   /* initialize the response buffer */
+   response_str = response;
+
+   dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
+   if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
+   error("invalid mmc device\n");
+   fastboot_fail("invalid mmc device");
+   return;
+   }
+
+   ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
+   if (ret) {
+   error("cannot find partition: '%s'\n", cmd);
+   fastboot_fail("cannot find partition");
+   return;
+   }
+
+   puts("Erasing partition\n");
+
+   /* Align blocks to erase group size to avoid erasing other partitions */
+   grp_size = mmc->erase_grp_size;
+   blks_start = (info.start + grp_size - 1) & ~(grp_size - 1);
+   if (info.size >= grp_size)
+   blks_size = (info.size - (blks_start - info.start)) &
+   (~(grp_size - 1));
+   else
+   blks_size = 0;
+
+   printf("Erasing blocks " LBAFU " to " LBAFU " due to alignment\n",
+  blks_start, blks_start + blks_size);
+
+   blks = dev_desc->block_erase(dev_desc->dev, blks_start, blks_size);
+   if (blks != blks_size) {
+   error("failed erasing from device %d\n", dev_desc->dev);
+   fastboot_fail("failed erasing from device");
+   return;
+   }
+
+   printf(" erased " LBAFU " bytes from '%s'\n",
+  blks_size * info.blksz, cmd);
+   fastboot_okay("");
+}
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index f7d84bf..a8d8205 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -535,6 +535,26 @@ static void cb_oem(struct usb_ep *ep, struct usb_request 
*req)
}
 }
 
+static void cb_erase(struct usb_ep *ep, struct usb_request *req)
+{
+   char *cmd = req->buf;
+   char response[RESPONSE_LEN];
+
+   strsep(&cmd, ":");
+   if (!cmd) {
+   error("missing partition name\n");
+   fastboot_tx_write_str("FAILmissing partition name");
+   return;
+   }
+
+   strcpy(response, "FAILno flash device defined");
+
+#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+   fb_mmc_erase(cmd, response);
+#endif
+   fastboot_tx_write_str(response);
+}
+
 struct cmd_dispatch_info {
char *cmd;
void (*cb)(struct usb_ep *ep, struct usb_request *req);
@@ -566,6 +586,9 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = 
{
{
.cmd = "oem",
.cb = cb_oem,
+   }, {
+   .cmd = "erase",
+   .cb = cb_erase,
},
 };
 
diff --git a/include/fb_mmc.h b/include/fb_mmc.h
index 1ad1d13..402ba9b 100644
--- a/include/fb_mmc.h
+++ b/include/fb_mmc.h
@@ -6,3 +6,4 @@
 
 void fb_mmc_flash_write(const char *cmd, void *download_buffer,
unsigned int download_bytes, char *response);
+void fb_mmc_erase(const char *cmd, char *response);
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v1 1/1] fastboot: oem format command implementation

2015-02-09 Thread Dileep Katta
On 30 January 2015 at 22:27, Lukasz Majewski  wrote:

> Hi Dileep,
>
> > This is the Modified version of
> > http://patchwork.ozlabs.org/patch/388084/
> >  - As flash support is already in mainline, it is removed
> >  - 'oem' command support is present
> >  - 'oem format' command is implemented
> >  - Handled review comments of the original patch
> >
> > Signed-off-by: Dileep Katta 
> > ---
> >  common/cmd_fastboot.c   |   4 +
> >  common/cmd_mmc.c|   2 +-
> >  disk/Makefile   |   1 +
> >  disk/part_fastboot.c| 363
> > 
> > doc/README.android-fastboot |   5 +-
> > drivers/usb/gadget/f_fastboot.c |  85 ++
> > include/usb/fastboot.h  | 108  7 files changed,
> > 564 insertions(+), 4 deletions(-) create mode 100644
> > disk/part_fastboot.c create mode 100644 include/usb/fastboot.h
> >
> > diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
> > index b72f4f3..efdf461 100644
> > --- a/common/cmd_fastboot.c
> > +++ b/common/cmd_fastboot.c
> > @@ -10,12 +10,16 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char
> > *const argv[]) {
> >   int ret;
> >
> >   g_dnl_clear_detach();
> > +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
> > + board_partition_init();
> > +#endif
> >   ret = g_dnl_register("usb_dnl_fastboot");
> >   if (ret)
> >   return ret;
> > diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> > index 4e28c9d..0ce747b 100644
> > --- a/common/cmd_mmc.c
> > +++ b/common/cmd_mmc.c
> > @@ -809,7 +809,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;
> >
> > diff --git a/disk/Makefile b/disk/Makefile
> > index 6970cec..4969656 100644
> > --- a/disk/Makefile
> > +++ b/disk/Makefile
> > @@ -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_FASTBOOT_FLASH_MMC_DEV) +=part_fastboot.o
> > diff --git a/disk/part_fastboot.c b/disk/part_fastboot.c
> > new file mode 100644
> > index 000..adf37af
> > --- /dev/null
> > +++ b/disk/part_fastboot.c
> > @@ -0,0 +1,363 @@
> > +/*
> > + * Copyright (C) 2013 Texas Instruments
> > + *
> > + * Author : Pankaj Bharadiya 
> > + *
> > + * Tom Rix  and Sitara 2011 u-boot by
> > + * Mohammed Afzal M A 
> > + *
> > + * Copyright (C) 2008 The Android Open Source Project
> > + * All rights reserved.
> > + *
> > + * Copyright 2014 Linaro, Ltd.
> > + * Dileep Katta 
> > + *
> > + * SPDX-License-Identifier:  GPL-2.0+
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define EFI_VERSION 0x0001
> > +#define EFI_ENTRIES 128
> > +#define EFI_NAMELEN 36
> > +
> > +struct partition_emmc {
> > + const char *name;
> > + unsigned size_kb;
> > +};
> > +
> > +/* eMMC partition layout (All sizes are in kB)
> > + * Modify the below partition table to change the GPT configuration.
> > + * The entry for each partition can be modified as per the
> > requirement.
> > + */
> > +static struct partition_emmc partitions[] = {
>
> Defining mmc partitions as a static struct in the code IMHO is not
> flexible.
>
> > + { "-", 128 },   /* Master Boot Record and GUID
> > Partition Table */
> > + { "spl", 128 }, /* First stage bootloader */
> > + { "bootloader", 512 },  /* Second stage bootloader */
> > + { "misc", 128 },/* Rserved for internal
> > purpose */
> > + { "-", 128 },   /* Reserved */
> > + { "recovery", 8*1024 }, /* Recovery partition  */
> > + { "boot", 8*1024 }, /* Partition contains kernel +
> > ramdisk ima

[U-Boot] [PATCH v1 1/1] fastboot: oem format command implementation

2015-01-30 Thread Dileep Katta
This is the Modified version of http://patchwork.ozlabs.org/patch/388084/
 - As flash support is already in mainline, it is removed
 - 'oem' command support is present
 - 'oem format' command is implemented
 - Handled review comments of the original patch

Signed-off-by: Dileep Katta 
---
 common/cmd_fastboot.c   |   4 +
 common/cmd_mmc.c|   2 +-
 disk/Makefile   |   1 +
 disk/part_fastboot.c| 363 
 doc/README.android-fastboot |   5 +-
 drivers/usb/gadget/f_fastboot.c |  85 ++
 include/usb/fastboot.h  | 108 
 7 files changed, 564 insertions(+), 4 deletions(-)
 create mode 100644 disk/part_fastboot.c
 create mode 100644 include/usb/fastboot.h

diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
index b72f4f3..efdf461 100644
--- a/common/cmd_fastboot.c
+++ b/common/cmd_fastboot.c
@@ -10,12 +10,16 @@
 #include 
 #include 
 #include 
+#include 
 
 static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const 
argv[])
 {
int ret;
 
g_dnl_clear_detach();
+#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+   board_partition_init();
+#endif
ret = g_dnl_register("usb_dnl_fastboot");
if (ret)
return ret;
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 4e28c9d..0ce747b 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -809,7 +809,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;
 
diff --git a/disk/Makefile b/disk/Makefile
index 6970cec..4969656 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -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_FASTBOOT_FLASH_MMC_DEV)   +=part_fastboot.o
diff --git a/disk/part_fastboot.c b/disk/part_fastboot.c
new file mode 100644
index 000..adf37af
--- /dev/null
+++ b/disk/part_fastboot.c
@@ -0,0 +1,363 @@
+/*
+ * Copyright (C) 2013 Texas Instruments
+ *
+ * Author : Pankaj Bharadiya 
+ *
+ * Tom Rix  and Sitara 2011 u-boot by
+ * Mohammed Afzal M A 
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Copyright 2014 Linaro, Ltd.
+ * Dileep Katta 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define EFI_VERSION 0x0001
+#define EFI_ENTRIES 128
+#define EFI_NAMELEN 36
+
+struct partition_emmc {
+   const char *name;
+   unsigned size_kb;
+};
+
+/* eMMC partition layout (All sizes are in kB)
+ * Modify the below partition table to change the GPT configuration.
+ * The entry for each partition can be modified as per the requirement.
+ */
+static struct partition_emmc partitions[] = {
+   { "-", 128 },   /* Master Boot Record and GUID Partition Table */
+   { "spl", 128 }, /* First stage bootloader */
+   { "bootloader", 512 },  /* Second stage bootloader */
+   { "misc", 128 },/* Rserved for internal purpose */
+   { "-", 128 },   /* Reserved */
+   { "recovery", 8*1024 }, /* Recovery partition  */
+   { "boot", 8*1024 }, /* Partition contains kernel + ramdisk images */
+   { "system", 256*1024 }, /* Android file system */
+   { "cache", 256*1024 },  /* Store Application Cache */
+   { "userdata", 256*1024 },   /* User data */
+   { "media", 0 }, /* Media files */
+   { 0, 0 },
+};
+
+
+static const u8 partition_type[16] = {
+   0xa2, 0xa0, 0xd0, 0xeb, 0xe5, 0xb9, 0x33, 0x44,
+   0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7,
+};
+
+static const u8 random_uuid[16] = {
+   0xff, 0x1f, 0xf2, 0xf9, 0xd4, 0xa8, 0x0e, 0x5f,
+   0x97, 0x46, 0x59, 0x48, 0x69, 0xae, 0xc3, 0x4e,
+};
+
+struct efi_entry {
+   u8 type_uuid[16];
+   u8 uniq_uuid[16];
+   u64 first_lba;
+   u64 last_lba;
+   u64 attr;
+   u16 name[EFI_NAMELEN];
+};
+
+struct efi_header {
+   u8 magic[8];
+
+   u32 version;
+   u32 header_sz;
+
+   u32 crc32;
+   u32 reserved;
+
+   u64 header_lba;
+   u64 backup_lba;
+   u64 first_lba;
+   u64 last_lba;
+
+   u8 volume_uuid[16];
+
+   u64 entries_lba;
+
+   u32 entries_count;
+   u32 entries_size;
+   u32 entries_crc32;
+} __packed;
+
+struct ptable {
+   u8 mbr[512];
+   union {
+   struct efi_header header;
+   u8 block[512];
+   };

[U-Boot] [PATCH v5 1/1] Enable Android Fastboot support on am335x_evm board

2014-10-28 Thread Dileep Katta
Signed-off-by: Dileep Katta 
---
Changes in v2:
- None
Changes in v3:
- None
Changes in v4:
- None
- Fastboot flash command changes by Steve Rae are in mainline
- This enables the code for BeagleBone Black
- Not submitting the changes made for flash command
Changes in v5:
- Verified eth gadget with new VID/PID
- Changed the code to use new VID/PID always
- Added spaces as required

 include/configs/am335x_evm.h | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 1ec783d..7c83e3b 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -314,6 +314,12 @@
 #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   0x0700
+
 #ifdef CONFIG_MUSB_HOST
 #define CONFIG_CMD_USB
 #define CONFIG_USB_STORAGE
@@ -324,9 +330,13 @@
 #define CONFIG_USB_ETH_RNDIS
 #define CONFIG_USBNET_HOST_ADDR"de:ad:be:af:00:00"
 
+/*To support eMMC booting*/
+#define CONFIG_STORAGE_EMMC
+#define CONFIG_FASTBOOT_FLASH_MMC_DEV   1
+
 /* USB TI's IDs */
-#define CONFIG_G_DNL_VENDOR_NUM 0x0403
-#define CONFIG_G_DNL_PRODUCT_NUM 0xBD00
+#define CONFIG_G_DNL_VENDOR_NUM 0x0451
+#define CONFIG_G_DNL_PRODUCT_NUM 0xD022
 #define CONFIG_G_DNL_MANUFACTURER "Texas Instruments"
 #endif /* CONFIG_MUSB_GADGET */
 
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 1/1] Enable Android Fastboot support on am335x_evm board

2014-10-13 Thread Dileep Katta
Signed-off-by: Dileep Katta 
---
Changes in v2:
-None
Changes in v3:
-None
Changes in v4:
-None
-Fastboot flash command changes by Steve Rae are in mainline
  This enables the code for BeagleBone Black
  Not submitting the changes made for flash command
 include/configs/am335x_evm.h | 13 +
 1 file changed, 13 insertions(+)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 476430d..73c3153 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -313,6 +313,11 @@
 #define CONFIG_AM335X_USB0_MODEMUSB_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   0x0700
 
 #ifdef CONFIG_MUSB_HOST
 #define CONFIG_CMD_USB
@@ -323,10 +328,18 @@
 #define CONFIG_USB_ETHER
 #define CONFIG_USB_ETH_RNDIS
 #define CONFIG_USBNET_HOST_ADDR"de:ad:be:af:00:00"
+#define CONFIG_FASTBOOT_FLASH_MMC_DEV   1
+/*To support eMMC booting*/
+#define CONFIG_STORAGE_EMMC
 
 /* 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 */
 
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, PATCH v3 2/2] fastboot: Flash command support

2014-09-17 Thread Dileep Katta
Thanks for the review comments. Working on the fix.

Regards,
Dileep

On 11 September 2014 13:42, Wolfgang Denk  wrote:
>
> Dear Dileep Katta,
>
> In message <1410417650-16522-2-git-send-email-dileep.ka...@linaro.org> you 
> wrote:
> > 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;
>
> > +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");
> > + 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?
>
> > + 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...
>
>
> > +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?
>
> > + n = crc32(n, (void *)ptbl->entry, sizeof(ptbl->entry));
> > + hdr->entries_crc32 = n;
> > +
> > + n = crc32(0, 0, 0);
>
> What exactly is this good for?
>
> > + n = crc32(0, (void *)&ptbl->header, sizeof(ptbl->header));
> > + hdr->crc32 = n;
> > +}
>
>
> > + for (n = 0; n < (128/4); n++) {
> > + /* read partition */
> > + source[0] = '\0';
> > +

Re: [U-Boot] [PATCH 2/2 v2] fastboot: Flash command support

2014-09-11 Thread Dileep Katta
On 12 August 2014 01:22, Steve Rae  wrote:

>
>
> On 14-08-10 06:59 PM, Dileep Katta wrote:
>
>> 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.
>>
>> Signed-off-by: Dileep Katta 
>> ---
>> Changes for v2:
>> - Fixed coding style issues
>>
>>   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
>>
>> diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
>> index 83fa7bd..6d0d0a4 100644
>> --- a/common/cmd_fastboot.c
>> +++ b/common/cmd_fastboot.c
>> @@ -10,11 +10,15 @@
>>   #include 
>>   #include 
>>   #include 
>> +#include 
>> +#include 
>>
>>   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;
>>   }
>>
>> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
>> index 1e40983..dd7170d 100644
>> --- a/common/cmd_mmc.c
>> +++ b/common/cmd_mmc.c
>> @@ -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;
>>
>> diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
>> index 855808c..a100109 100644
>> --- a/common/cmd_nvedit.c
>> +++ b/common/cmd_nvedit.c
>> @@ -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);
>> diff --git a/disk/Makefile b/disk/Makefile
>> index 6970cec..4b7a9ef 100644
>> --- a/disk/Makefile
>> +++ b/disk/Makefile
>> @@ -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
>> diff --git a/disk/part_fastboot.c b/disk/part_fastboot.c
>> new file mode 100644
>> index 000..4fa9f85
>> --- /dev/null
>> +++ b/disk/part_fastboot.c
>> @@ -0,0 +1,379 @@
>> +/*
>> + * Copyright (C) 2013 Texas Instruments
>> + *
>> + * Author : Pankaj Bharadiya 
>> + *
>> + * Tom Rix  and Sitara 2011 u-boot by
>> + * Mohammed Afzal M A 
>> + *
>> + * Copyright (C) 2008 The Android Open Source Project
>> + * All rights reserved.
>> + *
>> + * Copyright 2014 Linaro, Ltd.
>> + * Dileep Katta 
>> + *
>> + * SPDX-License-Identifier:GPL-2.0+
>> + */
>> +

[U-Boot] [U-Boot, PATCH v3 2/2] fastboot: Flash command support

2014-09-10 Thread Dileep Katta
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.


Signed-off-by: Dileep Katta 
---
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

diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
index 83fa7bd..6d0d0a4 100644
--- a/common/cmd_fastboot.c
+++ b/common/cmd_fastboot.c
@@ -10,11 +10,15 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 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;
 }
 
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 1e40983..dd7170d 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -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;
 
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 855808c..a100109 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -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);
diff --git a/disk/Makefile b/disk/Makefile
index 6970cec..4b7a9ef 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -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
diff --git a/disk/part_fastboot.c b/disk/part_fastboot.c
new file mode 100644
index 000..4fa9f85
--- /dev/null
+++ b/disk/part_fastboot.c
@@ -0,0 +1,379 @@
+/*
+ * Copyright (C) 2013 Texas Instruments
+ *
+ * Author : Pankaj Bharadiya 
+ *
+ * Tom Rix  and Sitara 2011 u-boot by
+ * Mohammed Afzal M A 
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Copyright 2014 Linaro, Ltd.
+ * Dileep Katta 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define EFI_VERSION 0x0001
+#define EFI_ENTRIES 128
+#define EFI_NAMELEN 36
+
+struct partition_emmc {
+   const char *name;
+   unsigned size_kb;
+};
+
+/* eMMC partition layout (All sizes are in kB)
+ * Modify the below partition table to change the GPT configuration.
+ * The entry for each partition can be modified as per the requirement.
+ */
+static struct partition_emmc partitions[] = {
+   { "-", 128 },   /* Master Boot Record and GUID Partition Table */
+   { "spl", 128 }, /* First stage bootloader */
+   { "bootloader", 512 },  /* Second stage bootloader */
+   { "misc", 128 },/* Rserved for internal purpose */
+   { "-", 128 },   /* Reserved */
+   { "recovery", 8*1024 }, /* Recovery partition  */
+   { "boot", 8*1024 }, /* Partition contains kernel + ramdisk images */
+   { "system", 256*1024 }, /* Android file system */
+   

[U-Boot] [U-Boot, PATCH v3 1/2] arm: BeagleBone Black: enable fastboot support

2014-09-10 Thread Dileep Katta
Enable Android Fastboot support on am335x_evm board

Signed-off-by: Dileep Katta 
---
Changes in v2:
-None
Changes in v3:
-None
 include/configs/am335x_evm.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 35ae0e6..3999405 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -291,6 +291,11 @@
 #define CONFIG_AM335X_USB0_MODEMUSB_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   0x0700
 
 #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 */
 
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/2 v2] fastboot: Flash command support

2014-08-10 Thread Dileep Katta
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.

Signed-off-by: Dileep Katta 
---
Changes for v2:
- Fixed coding style issues

 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

diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
index 83fa7bd..6d0d0a4 100644
--- a/common/cmd_fastboot.c
+++ b/common/cmd_fastboot.c
@@ -10,11 +10,15 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 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;
 }
 
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 1e40983..dd7170d 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -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;
 
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 855808c..a100109 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -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);
diff --git a/disk/Makefile b/disk/Makefile
index 6970cec..4b7a9ef 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -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
diff --git a/disk/part_fastboot.c b/disk/part_fastboot.c
new file mode 100644
index 000..4fa9f85
--- /dev/null
+++ b/disk/part_fastboot.c
@@ -0,0 +1,379 @@
+/*
+ * Copyright (C) 2013 Texas Instruments
+ *
+ * Author : Pankaj Bharadiya 
+ *
+ * Tom Rix  and Sitara 2011 u-boot by
+ * Mohammed Afzal M A 
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Copyright 2014 Linaro, Ltd.
+ * Dileep Katta 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define EFI_VERSION 0x0001
+#define EFI_ENTRIES 128
+#define EFI_NAMELEN 36
+
+struct partition_emmc {
+   const char *name;
+   unsigned size_kb;
+};
+
+/* eMMC partition layout (All sizes are in kB)
+ * Modify the below partition table to change the GPT configuration.
+ * The entry for each partition can be modified as per the requirement.
+ */
+static struct partition_emmc partitions[] = {
+   { "-", 128 },   /* Master Boot Record and GUID Partition Table */
+   { "spl", 128 }, /* First stage bootloader */
+   { "bootloader", 512 },  /* Second stage bootloader */
+   { "misc", 128 },/* Rserved for internal purpose */
+   { "-", 128 },   /* Reserved */
+   { "recovery", 8*1024 }, /* Recovery partition  */
+   { "boot", 8*1024 }, /* Partition contains kernel + ramdisk images */
+   { "system", 256*1024 }, /* Android file system */
+   { "cache", 256*1024 },  /* Store Application Cache */
+   

[U-Boot] [PATCH 1/2 v2] arm: BeagleBone Black: enable fastboot support

2014-08-10 Thread Dileep Katta
Enable Android Fastboot support on am335x_evm board

Signed-off-by: Dileep Katta 
---
Changes for v2:
-None
 include/configs/am335x_evm.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 35ae0e6..3999405 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -291,6 +291,11 @@
 #define CONFIG_AM335X_USB0_MODEMUSB_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   0x0700
 
 #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 */
 
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] fastboot: Flash command support

2014-08-02 Thread Dileep Katta
Hi Jeroen,


On 3 August 2014 02:43, Jeroen Hofstee  wrote:

> Hello Dileep,
>
>
> On 02-08-14 21:10, Jeroen Hofstee wrote:
>
>> Hello Dileep,
>>
>> On 02-08-14 20:30, Dileep Katta wrote:
>>
>>> Flash command 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.
>>>
>>> Signed-off-by: Dileep Katta 
>>> ---
>>>   common/cmd_fastboot.c   |   6 +
>>>   common/cmd_mmc.c|   2 +-
>>>   common/cmd_nvedit.c |   2 +-
>>>   disk/Makefile   |   1 +
>>>   disk/part_fastboot.c| 383 ++
>>> ++
>>>   doc/README.android-fastboot |  26 +++
>>>   drivers/usb/gadget/f_fastboot.c | 185 ++-
>>>   include/configs/am335x_evm.h|  23 ++-
>>>   include/configs/omap3_beagle.h  |  12 ++
>>>   include/usb/fastboot.h  | 175 ++
>>>   10 files changed, 803 insertions(+), 12 deletions(-)
>>>   create mode 100644 disk/part_fastboot.c
>>>   create mode 100644 include/usb/fastboot.h
>>>
>>>
>> I assume this is just a patch to be within the merge window
>> and you send a cleaned up version later, right?
>>
>>
>>  Just in case this is a serious submission, please check with
> checkpatch at least (which you are obligated to _before_
> sending patches in the first place):
>
> jeroen@yellow:~/software/u-boot$ ./scripts/checkpatch.pl
> U-Boot-2-2-fastboot-Flash-command-support.patch | wc
> 9123744   33293
>
> Regards,
> Jeroen
>

I will fix the errors and will send a cleaned up version. Please consider
the patches for the merge.

Regards,
Dileep
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/2] arm: BeagleBone Black: enable fastboot support

2014-08-02 Thread Dileep Katta
Enable Android Fastboot support on am335x_evm board

Signed-off-by: Dileep Katta 
---
 include/configs/am335x_evm.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 35ae0e6..3999405 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -291,6 +291,11 @@
 #define CONFIG_AM335X_USB0_MODEMUSB_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   0x0700
 
 #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 */
 
-- 
1.8.3.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/2] fastboot: Flash command support

2014-08-02 Thread Dileep Katta
Flash command 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.

Signed-off-by: Dileep Katta 
---
 common/cmd_fastboot.c   |   6 +
 common/cmd_mmc.c|   2 +-
 common/cmd_nvedit.c |   2 +-
 disk/Makefile   |   1 +
 disk/part_fastboot.c| 383 
 doc/README.android-fastboot |  26 +++
 drivers/usb/gadget/f_fastboot.c | 185 ++-
 include/configs/am335x_evm.h|  23 ++-
 include/configs/omap3_beagle.h  |  12 ++
 include/usb/fastboot.h  | 175 ++
 10 files changed, 803 insertions(+), 12 deletions(-)
 create mode 100644 disk/part_fastboot.c
 create mode 100644 include/usb/fastboot.h

diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
index 83fa7bd..7c91415 100644
--- a/common/cmd_fastboot.c
+++ b/common/cmd_fastboot.c
@@ -10,11 +10,16 @@
 #include 
 #include 
 #include 
+extern int board_partition_init(void);
+extern int dfu_init_env_entities(char *interface, int dev);
+extern void dfu_free_entities(void);
 
 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_MMC_FASTBOOT_DEV);
ret = g_dnl_register("usb_dnl_fastboot");
if (ret)
return ret;
@@ -26,6 +31,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;
 }
 
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 1e40983..dd7170d 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -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;
 
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 855808c..a100109 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -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);
diff --git a/disk/Makefile b/disk/Makefile
index 6970cec..4b7a9ef 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -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
diff --git a/disk/part_fastboot.c b/disk/part_fastboot.c
new file mode 100644
index 000..681f3da
--- /dev/null
+++ b/disk/part_fastboot.c
@@ -0,0 +1,383 @@
+/*
+ * Copyright (C) 2013 Texas Instruments
+ *
+ * Author : Pankaj Bharadiya 
+ *
+ * Tom Rix  and Sitara 2011 u-boot by
+ * Mohammed Afzal M A 
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Copyright 2014 Linaro, Ltd.
+ * Dileep Katta 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define EFI_VERSION 0x0001
+#define EFI_ENTRIES 128
+#define EFI_NAMELEN 36
+
+struct partition_emmc {
+   const char *name;
+   unsigned size_kb;
+};
+
+/* eMMC partition layout (All sizes are in kB)
+ * Modify the below partition table to change the GPT configuration.
+ * The entry for each partition can be modified as per the requirement.
+ */
+static struct partition_emmc partitions[] = {
+   { "-", 128 },   /* Master Boot Record and GUID 
Partition Table */
+   { "spl", 128 }, /* First stage bootloader */
+   { "bootloader", 512 },  /* Second stage bootloader */
+   { "misc", 128 },/* Rserved for internal purpose */
+   { "-", 128 },   /* Reserved */
+   { "recovery", 8*1024 }, /* Recovery partition  */
+   { "boot", 8*1024 }, /* Partition contains kernel + ramdisk 
images */
+   { "system", 256*1024 }, /* An