All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/3] Raspberry Pi4: add support for DFU over USB
       [not found] <CGME20190916122430eucas1p164f3467e5ad5981c01bde6376ec51a27@eucas1p1.samsung.com>
@ 2019-09-16 12:24 ` Marek Szyprowski
       [not found]   ` <CGME20190916122430eucas1p19918617895f7d0d57c3f58218adc85ae@eucas1p1.samsung.com>
                     ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Marek Szyprowski @ 2019-09-16 12:24 UTC (permalink / raw)
  To: u-boot

Hi All

This patchset enables support for DFU over USB protocol on Raspberry Pi4
board. The board has DWC2 UDC controller connected to the USB-C power
connector. Enabling DFU on it, make the u-boot development much more
convenient, as one no longer needs to swap SD-card between RPi4 board and
host machine to update the u-boot binary.

Patches are based on current 'master' u-boot branch. They were tested on
the 2019-07-10-raspbian-buster-lite.img sd-card image with the following
lines added to config.txt:
dtoverlay=dwc2,dr_mode=peripheral
dtparam=i2c_arm=on
dtparam=spi=on
enable_uart=1
uart_2ndstage=1
kernel=u-boot.bin

To enable DFU, one has to enter follwing command:
# dfu 0 mmc 0

During the development of this feature I've encountered a serious bug in
FAT write code. Over-writing discontiguous files always caused serious
filesystem corruption. This was especially anoying, because the system
environment is kept on FAT volume in uboot.env file, so 'saveenv'
basically corrupted the boot partiting on the second call.

I hope that my fix for FAT code will be helpful for non-RPi users too.

Best regards
Marek Szyprowski
Samsung R&D Institute Poland


Patch summary:

Marek Szyprowski (3):
  fat: write: fix broken write to fragmented files
  usb: dwc2_udc_otg: add bcm2835 SoC (Raspberry Pi4) support
  config: enable DFU over USB on Raspberry Pi4 boards

 configs/rpi_4_32b_defconfig                | 11 +++++++++++
 drivers/usb/gadget/dwc2_udc_otg.c          |  2 ++
 drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 12 ++++++------
 fs/fat/fat_write.c                         |  6 +++---
 include/configs/rpi.h                      | 10 ++++++++++
 5 files changed, 32 insertions(+), 9 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 1/3] fat: write: fix broken write to fragmented files
       [not found]   ` <CGME20190916122430eucas1p19918617895f7d0d57c3f58218adc85ae@eucas1p1.samsung.com>
@ 2019-09-16 12:24     ` Marek Szyprowski
  2019-09-16 13:18       ` Oleksandr Suvorov
  2019-09-16 21:38       ` Lukasz Majewski
  0 siblings, 2 replies; 12+ messages in thread
From: Marek Szyprowski @ 2019-09-16 12:24 UTC (permalink / raw)
  To: u-boot

The code for handing file overwrite incorrectly assumed that the file on
disk is always contiguous. This resulted in corrupting disk structure
every time when write to existing fragmented file happened. Fix this
by adding proper check for cluster discontinuity and adjust chunk size
on each partial write.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 fs/fat/fat_write.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index 729cf39630d..6cfa5b45652 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -794,6 +794,8 @@ set_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, __u8 *buffer,
 
 			newclust = get_fatent(mydata, endclust);
 
+			if ((newclust - 1) != endclust)
+				break;
 			if (IS_LAST_CLUST(newclust, mydata->fatsize))
 				break;
 			if (CHECK_CLUST(newclust, mydata->fatsize)) {
@@ -811,7 +813,7 @@ set_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, __u8 *buffer,
 			offset = 0;
 		else
 			offset = pos - cur_pos;
-		wsize = min(cur_pos + actsize, filesize) - pos;
+		wsize = min_t(unsigned long long, actsize, filesize - cur_pos);
 		if (get_set_cluster(mydata, curclust, offset,
 				    buffer, wsize, &actsize)) {
 			printf("Error get-and-setting cluster\n");
@@ -824,8 +826,6 @@ set_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, __u8 *buffer,
 		if (filesize <= cur_pos)
 			break;
 
-		/* CHECK: newclust = get_fatent(mydata, endclust); */
-
 		if (IS_LAST_CLUST(newclust, mydata->fatsize))
 			/* no more clusters */
 			break;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 2/3] usb: dwc2_udc_otg: add bcm2835 SoC (Raspberry Pi4) support
       [not found]   ` <CGME20190916122430eucas1p2dc270f6d0b8ee4da5521fe63d6df072f@eucas1p2.samsung.com>
@ 2019-09-16 12:24     ` Marek Szyprowski
  2019-09-16 21:40       ` Lukasz Majewski
  0 siblings, 1 reply; 12+ messages in thread
From: Marek Szyprowski @ 2019-09-16 12:24 UTC (permalink / raw)
  To: u-boot

Broadcom 2835 SoC requires special conversion of physical memory addresses
for DMA purpose, so add needed wrappers to dwc2_udc_otg driver. Also extend
the list of compatible devices with 'brcm,bcm2835-usb' entry. This allows
to use USB gadget drivers (i.e. DFU) on Raspberry Pi4 boards.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/usb/gadget/dwc2_udc_otg.c          |  2 ++
 drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 12 ++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index 35f4147840e..49f342eb211 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -31,6 +31,7 @@
 #include <linux/usb/otg.h>
 #include <linux/usb/gadget.h>
 
+#include <phys2bus.h>
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
 #include <asm/io.h>
@@ -1213,6 +1214,7 @@ static int dwc2_udc_otg_remove(struct udevice *dev)
 
 static const struct udevice_id dwc2_udc_otg_ids[] = {
 	{ .compatible = "snps,dwc2" },
+	{ .compatible = "brcm,bcm2835-usb" },
 	{ .compatible = "st,stm32mp1-hsotg",
 	  .data = (ulong)dwc2_set_stm32mp1_hsotg_params },
 	{},
diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
index 7eb632d3b14..5e695b4ff2a 100644
--- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
@@ -28,7 +28,7 @@ static inline void dwc2_udc_ep0_zlp(struct dwc2_udc *dev)
 {
 	u32 ep_ctrl;
 
-	writel(usb_ctrl_dma_addr, &reg->in_endp[EP0_CON].diepdma);
+	writel(phys_to_bus((unsigned long)usb_ctrl_dma_addr), &reg->in_endp[EP0_CON].diepdma);
 	writel(DIEPT_SIZ_PKT_CNT(1), &reg->in_endp[EP0_CON].dieptsiz);
 
 	ep_ctrl = readl(&reg->in_endp[EP0_CON].diepctl);
@@ -49,7 +49,7 @@ static void dwc2_udc_pre_setup(void)
 
 	writel(DOEPT_SIZ_PKT_CNT(1) | sizeof(struct usb_ctrlrequest),
 	       &reg->out_endp[EP0_CON].doeptsiz);
-	writel(usb_ctrl_dma_addr, &reg->out_endp[EP0_CON].doepdma);
+	writel(phys_to_bus((unsigned long)usb_ctrl_dma_addr), &reg->out_endp[EP0_CON].doepdma);
 
 	ep_ctrl = readl(&reg->out_endp[EP0_CON].doepctl);
 	writel(ep_ctrl|DEPCTL_EPENA, &reg->out_endp[EP0_CON].doepctl);
@@ -75,7 +75,7 @@ static inline void dwc2_ep0_complete_out(void)
 
 	writel(DOEPT_SIZ_PKT_CNT(1) | sizeof(struct usb_ctrlrequest),
 	       &reg->out_endp[EP0_CON].doeptsiz);
-	writel(usb_ctrl_dma_addr, &reg->out_endp[EP0_CON].doepdma);
+	writel(phys_to_bus((unsigned long)usb_ctrl_dma_addr), &reg->out_endp[EP0_CON].doepdma);
 
 	ep_ctrl = readl(&reg->out_endp[EP0_CON].doepctl);
 	writel(ep_ctrl|DEPCTL_EPENA|DEPCTL_CNAK,
@@ -113,7 +113,7 @@ static int setdma_rx(struct dwc2_ep *ep, struct dwc2_request *req)
 				(unsigned long) ep->dma_buf +
 				ROUND(ep->len, CONFIG_SYS_CACHELINE_SIZE));
 
-	writel((unsigned long) ep->dma_buf, &reg->out_endp[ep_num].doepdma);
+	writel(phys_to_bus((unsigned long)ep->dma_buf), &reg->out_endp[ep_num].doepdma);
 	writel(DOEPT_SIZ_PKT_CNT(pktcnt) | DOEPT_SIZ_XFER_SIZE(length),
 	       &reg->out_endp[ep_num].doeptsiz);
 	writel(DEPCTL_EPENA|DEPCTL_CNAK|ctrl, &reg->out_endp[ep_num].doepctl);
@@ -161,7 +161,7 @@ static int setdma_tx(struct dwc2_ep *ep, struct dwc2_request *req)
 	while (readl(&reg->grstctl) & TX_FIFO_FLUSH)
 		;
 
-	writel((unsigned long) ep->dma_buf, &reg->in_endp[ep_num].diepdma);
+	writel(phys_to_bus((unsigned long)ep->dma_buf), &reg->in_endp[ep_num].diepdma);
 	writel(DIEPT_SIZ_PKT_CNT(pktcnt) | DIEPT_SIZ_XFER_SIZE(length),
 	       &reg->in_endp[ep_num].dieptsiz);
 
@@ -921,7 +921,7 @@ static int dwc2_udc_get_status(struct dwc2_udc *dev,
 			   (unsigned long) usb_ctrl +
 			   ROUND(sizeof(g_status), CONFIG_SYS_CACHELINE_SIZE));
 
-	writel(usb_ctrl_dma_addr, &reg->in_endp[EP0_CON].diepdma);
+	writel(phys_to_bus(usb_ctrl_dma_addr), &reg->in_endp[EP0_CON].diepdma);
 	writel(DIEPT_SIZ_PKT_CNT(1) | DIEPT_SIZ_XFER_SIZE(2),
 	       &reg->in_endp[EP0_CON].dieptsiz);
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 3/3] config: enable DFU over USB on Raspberry Pi4 boards
       [not found]   ` <CGME20190916122431eucas1p206a5a96f594baef702cd94b81c4917b1@eucas1p2.samsung.com>
@ 2019-09-16 12:24     ` Marek Szyprowski
  2019-09-16 12:45       ` Matthias Brugger
  2019-09-16 21:41       ` Lukasz Majewski
  0 siblings, 2 replies; 12+ messages in thread
From: Marek Szyprowski @ 2019-09-16 12:24 UTC (permalink / raw)
  To: u-boot

Enable support for DFU over USB. This requires to enable USB gadget,
DWC2 UDC OTG driver and DFU command. DFU entities are defined for the
following firmware objects: u-boot.bin, uboot.env and zImage.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 configs/rpi_4_32b_defconfig | 11 +++++++++++
 include/configs/rpi.h       | 10 ++++++++++
 2 files changed, 21 insertions(+)

diff --git a/configs/rpi_4_32b_defconfig b/configs/rpi_4_32b_defconfig
index a31a617a5fb..0a375b97369 100644
--- a/configs/rpi_4_32b_defconfig
+++ b/configs/rpi_4_32b_defconfig
@@ -12,6 +12,7 @@ CONFIG_MISC_INIT_R=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_SYS_PROMPT="U-Boot> "
+CONFIG_CMD_DFU=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_MMC=y
@@ -19,6 +20,7 @@ CONFIG_CMD_FS_UUID=y
 CONFIG_ENV_FAT_INTERFACE="mmc"
 CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_DFU_MMC=y
 CONFIG_DM_KEYBOARD=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
@@ -26,6 +28,15 @@ CONFIG_MMC_SDHCI_BCM2835=y
 CONFIG_PINCTRL=y
 # CONFIG_PINCTRL_GENERIC is not set
 # CONFIG_REQUIRE_SERIAL_CONSOLE is not set
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="FSL"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0525
+CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_DM_VIDEO=y
 CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_CONSOLE_SCROLL_LINES=10
diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index 77d2d5458a1..f502915ad53 100644
--- a/include/configs/rpi.h
+++ b/include/configs/rpi.h
@@ -70,9 +70,18 @@
 #define CONFIG_TFTP_TSIZE
 #endif
 
+/* DFU over USB/UDC */
+#ifdef CONFIG_CMD_DFU
+#define CONFIG_SYS_DFU_DATA_BUF_SIZE	SZ_1M
+#define CONFIG_SYS_DFU_MAX_FILE_SIZE	SZ_2M
+#define ENV_DFU_SETTINGS \
+	"dfu_alt_info=u-boot.bin fat 0 1;uboot.env fat 0 1;zImage fat 0 1"
+#endif
+
 /* Console configuration */
 #define CONFIG_SYS_CBSIZE		1024
 
+
 /* Environment */
 #define CONFIG_ENV_SIZE			SZ_16K
 #define CONFIG_SYS_LOAD_ADDR		0x1000000
@@ -185,6 +194,7 @@
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \
 	ENV_DEVICE_SETTINGS \
+	ENV_DFU_SETTINGS \
 	ENV_MEM_LAYOUT_SETTINGS \
 	BOOTENV
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 3/3] config: enable DFU over USB on Raspberry Pi4 boards
  2019-09-16 12:24     ` [U-Boot] [PATCH 3/3] config: enable DFU over USB on Raspberry Pi4 boards Marek Szyprowski
@ 2019-09-16 12:45       ` Matthias Brugger
  2019-09-16 12:53         ` Marek Szyprowski
  2019-09-16 21:41       ` Lukasz Majewski
  1 sibling, 1 reply; 12+ messages in thread
From: Matthias Brugger @ 2019-09-16 12:45 UTC (permalink / raw)
  To: u-boot



On 16/09/2019 14:24, Marek Szyprowski wrote:
> Enable support for DFU over USB. This requires to enable USB gadget,
> DWC2 UDC OTG driver and DFU command. DFU entities are defined for the
> following firmware objects: u-boot.bin, uboot.env and zImage.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  configs/rpi_4_32b_defconfig | 11 +++++++++++
>  include/configs/rpi.h       | 10 ++++++++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/configs/rpi_4_32b_defconfig b/configs/rpi_4_32b_defconfig
> index a31a617a5fb..0a375b97369 100644
> --- a/configs/rpi_4_32b_defconfig
> +++ b/configs/rpi_4_32b_defconfig
> @@ -12,6 +12,7 @@ CONFIG_MISC_INIT_R=y
>  # CONFIG_DISPLAY_CPUINFO is not set
>  # CONFIG_DISPLAY_BOARDINFO is not set
>  CONFIG_SYS_PROMPT="U-Boot> "
> +CONFIG_CMD_DFU=y
>  # CONFIG_CMD_FLASH is not set
>  CONFIG_CMD_GPIO=y
>  CONFIG_CMD_MMC=y
> @@ -19,6 +20,7 @@ CONFIG_CMD_FS_UUID=y
>  CONFIG_ENV_FAT_INTERFACE="mmc"
>  CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
>  CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
> +CONFIG_DFU_MMC=y
>  CONFIG_DM_KEYBOARD=y
>  CONFIG_DM_MMC=y
>  CONFIG_MMC_SDHCI=y
> @@ -26,6 +28,15 @@ CONFIG_MMC_SDHCI_BCM2835=y
>  CONFIG_PINCTRL=y
>  # CONFIG_PINCTRL_GENERIC is not set
>  # CONFIG_REQUIRE_SERIAL_CONSOLE is not set
> +CONFIG_USB=y
> +CONFIG_DM_USB=y
> +CONFIG_DM_USB_GADGET=y
> +CONFIG_USB_GADGET=y
> +CONFIG_USB_GADGET_MANUFACTURER="FSL"
> +CONFIG_USB_GADGET_VENDOR_NUM=0x0525
> +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
> +CONFIG_USB_GADGET_DWC2_OTG=y
> +CONFIG_USB_GADGET_DOWNLOAD=y

Does this only work on RPi4? It seems to me that this should also be working on
the other RPi's. Do you have such HW to test?

>  CONFIG_DM_VIDEO=y
>  CONFIG_SYS_WHITE_ON_BLACK=y
>  CONFIG_CONSOLE_SCROLL_LINES=10
> diff --git a/include/configs/rpi.h b/include/configs/rpi.h
> index 77d2d5458a1..f502915ad53 100644
> --- a/include/configs/rpi.h
> +++ b/include/configs/rpi.h
> @@ -70,9 +70,18 @@
>  #define CONFIG_TFTP_TSIZE
>  #endif
>  
> +/* DFU over USB/UDC */
> +#ifdef CONFIG_CMD_DFU
> +#define CONFIG_SYS_DFU_DATA_BUF_SIZE	SZ_1M
> +#define CONFIG_SYS_DFU_MAX_FILE_SIZE	SZ_2M
> +#define ENV_DFU_SETTINGS \
> +	"dfu_alt_info=u-boot.bin fat 0 1;uboot.env fat 0 1;zImage fat 0 1"
> +#endif
> +
>  /* Console configuration */
>  #define CONFIG_SYS_CBSIZE		1024
>  
> +

New line sneaked in.

Regards,
Matthias

>  /* Environment */
>  #define CONFIG_ENV_SIZE			SZ_16K
>  #define CONFIG_SYS_LOAD_ADDR		0x1000000
> @@ -185,6 +194,7 @@
>  #define CONFIG_EXTRA_ENV_SETTINGS \
>  	"dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \
>  	ENV_DEVICE_SETTINGS \
> +	ENV_DFU_SETTINGS \
>  	ENV_MEM_LAYOUT_SETTINGS \
>  	BOOTENV
>  
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 3/3] config: enable DFU over USB on Raspberry Pi4 boards
  2019-09-16 12:45       ` Matthias Brugger
@ 2019-09-16 12:53         ` Marek Szyprowski
  2019-09-16 16:18           ` Jonathan Gray
  0 siblings, 1 reply; 12+ messages in thread
From: Marek Szyprowski @ 2019-09-16 12:53 UTC (permalink / raw)
  To: u-boot

Hi Matthias,

On 16.09.2019 14:45, Matthias Brugger wrote:
> On 16/09/2019 14:24, Marek Szyprowski wrote:
>> Enable support for DFU over USB. This requires to enable USB gadget,
>> DWC2 UDC OTG driver and DFU command. DFU entities are defined for the
>> following firmware objects: u-boot.bin, uboot.env and zImage.
>>
>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>> ---
>>   configs/rpi_4_32b_defconfig | 11 +++++++++++
>>   include/configs/rpi.h       | 10 ++++++++++
>>   2 files changed, 21 insertions(+)
>>
>> diff --git a/configs/rpi_4_32b_defconfig b/configs/rpi_4_32b_defconfig
>> index a31a617a5fb..0a375b97369 100644
>> --- a/configs/rpi_4_32b_defconfig
>> +++ b/configs/rpi_4_32b_defconfig
>> @@ -12,6 +12,7 @@ CONFIG_MISC_INIT_R=y
>>   # CONFIG_DISPLAY_CPUINFO is not set
>>   # CONFIG_DISPLAY_BOARDINFO is not set
>>   CONFIG_SYS_PROMPT="U-Boot> "
>> +CONFIG_CMD_DFU=y
>>   # CONFIG_CMD_FLASH is not set
>>   CONFIG_CMD_GPIO=y
>>   CONFIG_CMD_MMC=y
>> @@ -19,6 +20,7 @@ CONFIG_CMD_FS_UUID=y
>>   CONFIG_ENV_FAT_INTERFACE="mmc"
>>   CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
>>   CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
>> +CONFIG_DFU_MMC=y
>>   CONFIG_DM_KEYBOARD=y
>>   CONFIG_DM_MMC=y
>>   CONFIG_MMC_SDHCI=y
>> @@ -26,6 +28,15 @@ CONFIG_MMC_SDHCI_BCM2835=y
>>   CONFIG_PINCTRL=y
>>   # CONFIG_PINCTRL_GENERIC is not set
>>   # CONFIG_REQUIRE_SERIAL_CONSOLE is not set
>> +CONFIG_USB=y
>> +CONFIG_DM_USB=y
>> +CONFIG_DM_USB_GADGET=y
>> +CONFIG_USB_GADGET=y
>> +CONFIG_USB_GADGET_MANUFACTURER="FSL"
>> +CONFIG_USB_GADGET_VENDOR_NUM=0x0525
>> +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
>> +CONFIG_USB_GADGET_DWC2_OTG=y
>> +CONFIG_USB_GADGET_DOWNLOAD=y
> Does this only work on RPi4? It seems to me that this should also be working on
> the other RPi's. Do you have such HW to test?

It should work on any RPi with USB device controller available on the 
micro-usb/c-usb connector. AFAIK, besides RPi4, only some RPi0 has USB 
device mode available. Other RPi's have USB hub connected to DWC2 
controller, so switching DWC2 to device mode is not enough to make it 
working.

However I have access only to RPi3 and RPi4.

>>   CONFIG_DM_VIDEO=y
>>   CONFIG_SYS_WHITE_ON_BLACK=y
>>   CONFIG_CONSOLE_SCROLL_LINES=10
>> diff --git a/include/configs/rpi.h b/include/configs/rpi.h
>> index 77d2d5458a1..f502915ad53 100644
>> --- a/include/configs/rpi.h
>> +++ b/include/configs/rpi.h
>> @@ -70,9 +70,18 @@
>>   #define CONFIG_TFTP_TSIZE
>>   #endif
>>   
>> +/* DFU over USB/UDC */
>> +#ifdef CONFIG_CMD_DFU
>> +#define CONFIG_SYS_DFU_DATA_BUF_SIZE	SZ_1M
>> +#define CONFIG_SYS_DFU_MAX_FILE_SIZE	SZ_2M
>> +#define ENV_DFU_SETTINGS \
>> +	"dfu_alt_info=u-boot.bin fat 0 1;uboot.env fat 0 1;zImage fat 0 1"
>> +#endif
>> +
>>   /* Console configuration */
>>   #define CONFIG_SYS_CBSIZE		1024
>>   
>> +
> New line sneaked in.
>
> Regards,
> Matthias
>
>>   /* Environment */
>>   #define CONFIG_ENV_SIZE			SZ_16K
>>   #define CONFIG_SYS_LOAD_ADDR		0x1000000
>> @@ -185,6 +194,7 @@
>>   #define CONFIG_EXTRA_ENV_SETTINGS \
>>   	"dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \
>>   	ENV_DEVICE_SETTINGS \
>> +	ENV_DFU_SETTINGS \
>>   	ENV_MEM_LAYOUT_SETTINGS \
>>   	BOOTENV
>>   
>>
>
Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 1/3] fat: write: fix broken write to fragmented files
  2019-09-16 12:24     ` [U-Boot] [PATCH 1/3] fat: write: fix broken write to fragmented files Marek Szyprowski
@ 2019-09-16 13:18       ` Oleksandr Suvorov
  2019-09-16 21:38       ` Lukasz Majewski
  1 sibling, 0 replies; 12+ messages in thread
From: Oleksandr Suvorov @ 2019-09-16 13:18 UTC (permalink / raw)
  To: u-boot

On Mon, Sep 16, 2019 at 3:25 PM Marek Szyprowski
<m.szyprowski@samsung.com> wrote:
>
> The code for handing file overwrite incorrectly assumed that the file on
> disk is always contiguous. This resulted in corrupting disk structure
> every time when write to existing fragmented file happened. Fix this
> by adding proper check for cluster discontinuity and adjust chunk size
> on each partial write.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>

> ---
>  fs/fat/fat_write.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
> index 729cf39630d..6cfa5b45652 100644
> --- a/fs/fat/fat_write.c
> +++ b/fs/fat/fat_write.c
> @@ -794,6 +794,8 @@ set_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, __u8 *buffer,
>
>                         newclust = get_fatent(mydata, endclust);
>
> +                       if ((newclust - 1) != endclust)
> +                               break;
>                         if (IS_LAST_CLUST(newclust, mydata->fatsize))
>                                 break;
>                         if (CHECK_CLUST(newclust, mydata->fatsize)) {
> @@ -811,7 +813,7 @@ set_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, __u8 *buffer,
>                         offset = 0;
>                 else
>                         offset = pos - cur_pos;
> -               wsize = min(cur_pos + actsize, filesize) - pos;
> +               wsize = min_t(unsigned long long, actsize, filesize - cur_pos);
>                 if (get_set_cluster(mydata, curclust, offset,
>                                     buffer, wsize, &actsize)) {
>                         printf("Error get-and-setting cluster\n");
> @@ -824,8 +826,6 @@ set_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, __u8 *buffer,
>                 if (filesize <= cur_pos)
>                         break;
>
> -               /* CHECK: newclust = get_fatent(mydata, endclust); */
> -
>                 if (IS_LAST_CLUST(newclust, mydata->fatsize))
>                         /* no more clusters */
>                         break;
> --
> 2.17.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot



-- 
Best regards

Oleksandr Suvorov
cryosay at gmail.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 3/3] config: enable DFU over USB on Raspberry Pi4 boards
  2019-09-16 12:53         ` Marek Szyprowski
@ 2019-09-16 16:18           ` Jonathan Gray
  2019-09-17  5:41             ` Marek Szyprowski
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Gray @ 2019-09-16 16:18 UTC (permalink / raw)
  To: u-boot

On Mon, Sep 16, 2019 at 02:53:30PM +0200, Marek Szyprowski wrote:
> Hi Matthias,
> 
> On 16.09.2019 14:45, Matthias Brugger wrote:
> > On 16/09/2019 14:24, Marek Szyprowski wrote:
> >> Enable support for DFU over USB. This requires to enable USB gadget,
> >> DWC2 UDC OTG driver and DFU command. DFU entities are defined for the
> >> following firmware objects: u-boot.bin, uboot.env and zImage.
> >>
> >> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> >> ---
> >>   configs/rpi_4_32b_defconfig | 11 +++++++++++
> >>   include/configs/rpi.h       | 10 ++++++++++
> >>   2 files changed, 21 insertions(+)
> >>
> >> diff --git a/configs/rpi_4_32b_defconfig b/configs/rpi_4_32b_defconfig
> >> index a31a617a5fb..0a375b97369 100644
> >> --- a/configs/rpi_4_32b_defconfig
> >> +++ b/configs/rpi_4_32b_defconfig
> >> @@ -12,6 +12,7 @@ CONFIG_MISC_INIT_R=y
> >>   # CONFIG_DISPLAY_CPUINFO is not set
> >>   # CONFIG_DISPLAY_BOARDINFO is not set
> >>   CONFIG_SYS_PROMPT="U-Boot> "
> >> +CONFIG_CMD_DFU=y
> >>   # CONFIG_CMD_FLASH is not set
> >>   CONFIG_CMD_GPIO=y
> >>   CONFIG_CMD_MMC=y
> >> @@ -19,6 +20,7 @@ CONFIG_CMD_FS_UUID=y
> >>   CONFIG_ENV_FAT_INTERFACE="mmc"
> >>   CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
> >>   CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
> >> +CONFIG_DFU_MMC=y
> >>   CONFIG_DM_KEYBOARD=y
> >>   CONFIG_DM_MMC=y
> >>   CONFIG_MMC_SDHCI=y
> >> @@ -26,6 +28,15 @@ CONFIG_MMC_SDHCI_BCM2835=y
> >>   CONFIG_PINCTRL=y
> >>   # CONFIG_PINCTRL_GENERIC is not set
> >>   # CONFIG_REQUIRE_SERIAL_CONSOLE is not set
> >> +CONFIG_USB=y
> >> +CONFIG_DM_USB=y
> >> +CONFIG_DM_USB_GADGET=y
> >> +CONFIG_USB_GADGET=y
> >> +CONFIG_USB_GADGET_MANUFACTURER="FSL"
> >> +CONFIG_USB_GADGET_VENDOR_NUM=0x0525
> >> +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
> >> +CONFIG_USB_GADGET_DWC2_OTG=y
> >> +CONFIG_USB_GADGET_DOWNLOAD=y
> > Does this only work on RPi4? It seems to me that this should also be working on
> > the other RPi's. Do you have such HW to test?
> 
> It should work on any RPi with USB device controller available on the 
> micro-usb/c-usb connector. AFAIK, besides RPi4, only some RPi0 has USB 
> device mode available. Other RPi's have USB hub connected to DWC2 
> controller, so switching DWC2 to device mode is not enough to make it 
> working.
> 
> However I have access only to RPi3 and RPi4.

https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/device.md

	The following devices can boot using USB device boot mode:

	Pi Compute Module
	Pi Compute Module 3
	Pi Zero
	Pi Zero W
	Pi A
	Pi A+
	Pi 3A+

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 1/3] fat: write: fix broken write to fragmented files
  2019-09-16 12:24     ` [U-Boot] [PATCH 1/3] fat: write: fix broken write to fragmented files Marek Szyprowski
  2019-09-16 13:18       ` Oleksandr Suvorov
@ 2019-09-16 21:38       ` Lukasz Majewski
  1 sibling, 0 replies; 12+ messages in thread
From: Lukasz Majewski @ 2019-09-16 21:38 UTC (permalink / raw)
  To: u-boot

Hi Marek,

> The code for handing file overwrite incorrectly assumed that the file
> on disk is always contiguous. This resulted in corrupting disk
> structure every time when write to existing fragmented file happened.
> Fix this by adding proper check for cluster discontinuity and adjust
> chunk size on each partial write.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  fs/fat/fat_write.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
> index 729cf39630d..6cfa5b45652 100644
> --- a/fs/fat/fat_write.c
> +++ b/fs/fat/fat_write.c
> @@ -794,6 +794,8 @@ set_contents(fsdata *mydata, dir_entry *dentptr,
> loff_t pos, __u8 *buffer, 
>  			newclust = get_fatent(mydata, endclust);
>  
> +			if ((newclust - 1) != endclust)
> +				break;
>  			if (IS_LAST_CLUST(newclust, mydata->fatsize))
>  				break;
>  			if (CHECK_CLUST(newclust, mydata->fatsize)) {
> @@ -811,7 +813,7 @@ set_contents(fsdata *mydata, dir_entry *dentptr,
> loff_t pos, __u8 *buffer, offset = 0;
>  		else
>  			offset = pos - cur_pos;
> -		wsize = min(cur_pos + actsize, filesize) - pos;
> +		wsize = min_t(unsigned long long, actsize, filesize
> - cur_pos); if (get_set_cluster(mydata, curclust, offset,
>  				    buffer, wsize, &actsize)) {
>  			printf("Error get-and-setting cluster\n");
> @@ -824,8 +826,6 @@ set_contents(fsdata *mydata, dir_entry *dentptr,
> loff_t pos, __u8 *buffer, if (filesize <= cur_pos)
>  			break;
>  
> -		/* CHECK: newclust = get_fatent(mydata, endclust); */
> -
>  		if (IS_LAST_CLUST(newclust, mydata->fatsize))
>  			/* no more clusters */
>  			break;

Reviewed-by: Lukasz Majewski <lukma@denx.de>

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190916/9542053b/attachment.sig>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 2/3] usb: dwc2_udc_otg: add bcm2835 SoC (Raspberry Pi4) support
  2019-09-16 12:24     ` [U-Boot] [PATCH 2/3] usb: dwc2_udc_otg: add bcm2835 SoC (Raspberry Pi4) support Marek Szyprowski
@ 2019-09-16 21:40       ` Lukasz Majewski
  0 siblings, 0 replies; 12+ messages in thread
From: Lukasz Majewski @ 2019-09-16 21:40 UTC (permalink / raw)
  To: u-boot

Hi Marek,

> Broadcom 2835 SoC requires special conversion of physical memory
> addresses for DMA purpose, so add needed wrappers to dwc2_udc_otg
> driver. Also extend the list of compatible devices with
> 'brcm,bcm2835-usb' entry. This allows to use USB gadget drivers (i.e.
> DFU) on Raspberry Pi4 boards.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  drivers/usb/gadget/dwc2_udc_otg.c          |  2 ++
>  drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 12 ++++++------
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c
> b/drivers/usb/gadget/dwc2_udc_otg.c index 35f4147840e..49f342eb211
> 100644 --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -31,6 +31,7 @@
>  #include <linux/usb/otg.h>
>  #include <linux/usb/gadget.h>
>  
> +#include <phys2bus.h>
>  #include <asm/byteorder.h>
>  #include <asm/unaligned.h>
>  #include <asm/io.h>
> @@ -1213,6 +1214,7 @@ static int dwc2_udc_otg_remove(struct udevice
> *dev) 
>  static const struct udevice_id dwc2_udc_otg_ids[] = {
>  	{ .compatible = "snps,dwc2" },
> +	{ .compatible = "brcm,bcm2835-usb" },
>  	{ .compatible = "st,stm32mp1-hsotg",
>  	  .data = (ulong)dwc2_set_stm32mp1_hsotg_params },
>  	{},
> diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
> b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c index
> 7eb632d3b14..5e695b4ff2a 100644 ---
> a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +++
> b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c @@ -28,7 +28,7 @@ static
> inline void dwc2_udc_ep0_zlp(struct dwc2_udc *dev) {
>  	u32 ep_ctrl;
>  
> -	writel(usb_ctrl_dma_addr, &reg->in_endp[EP0_CON].diepdma);
> +	writel(phys_to_bus((unsigned long)usb_ctrl_dma_addr),
> &reg->in_endp[EP0_CON].diepdma); writel(DIEPT_SIZ_PKT_CNT(1),
> &reg->in_endp[EP0_CON].dieptsiz); 
>  	ep_ctrl = readl(&reg->in_endp[EP0_CON].diepctl);
> @@ -49,7 +49,7 @@ static void dwc2_udc_pre_setup(void)
>  
>  	writel(DOEPT_SIZ_PKT_CNT(1) | sizeof(struct usb_ctrlrequest),
>  	       &reg->out_endp[EP0_CON].doeptsiz);
> -	writel(usb_ctrl_dma_addr, &reg->out_endp[EP0_CON].doepdma);
> +	writel(phys_to_bus((unsigned long)usb_ctrl_dma_addr),
> &reg->out_endp[EP0_CON].doepdma); 
>  	ep_ctrl = readl(&reg->out_endp[EP0_CON].doepctl);
>  	writel(ep_ctrl|DEPCTL_EPENA,
> &reg->out_endp[EP0_CON].doepctl); @@ -75,7 +75,7 @@ static inline
> void dwc2_ep0_complete_out(void) 
>  	writel(DOEPT_SIZ_PKT_CNT(1) | sizeof(struct usb_ctrlrequest),
>  	       &reg->out_endp[EP0_CON].doeptsiz);
> -	writel(usb_ctrl_dma_addr, &reg->out_endp[EP0_CON].doepdma);
> +	writel(phys_to_bus((unsigned long)usb_ctrl_dma_addr),
> &reg->out_endp[EP0_CON].doepdma); 
>  	ep_ctrl = readl(&reg->out_endp[EP0_CON].doepctl);
>  	writel(ep_ctrl|DEPCTL_EPENA|DEPCTL_CNAK,
> @@ -113,7 +113,7 @@ static int setdma_rx(struct dwc2_ep *ep, struct
> dwc2_request *req) (unsigned long) ep->dma_buf +
>  				ROUND(ep->len,
> CONFIG_SYS_CACHELINE_SIZE)); 
> -	writel((unsigned long) ep->dma_buf,
> &reg->out_endp[ep_num].doepdma);
> +	writel(phys_to_bus((unsigned long)ep->dma_buf),
> &reg->out_endp[ep_num].doepdma); writel(DOEPT_SIZ_PKT_CNT(pktcnt) |
> DOEPT_SIZ_XFER_SIZE(length), &reg->out_endp[ep_num].doeptsiz);
>  	writel(DEPCTL_EPENA|DEPCTL_CNAK|ctrl,
> &reg->out_endp[ep_num].doepctl); @@ -161,7 +161,7 @@ static int
> setdma_tx(struct dwc2_ep *ep, struct dwc2_request *req) while
> (readl(&reg->grstctl) & TX_FIFO_FLUSH) ;
>  
> -	writel((unsigned long) ep->dma_buf,
> &reg->in_endp[ep_num].diepdma);
> +	writel(phys_to_bus((unsigned long)ep->dma_buf),
> &reg->in_endp[ep_num].diepdma); writel(DIEPT_SIZ_PKT_CNT(pktcnt) |
> DIEPT_SIZ_XFER_SIZE(length), &reg->in_endp[ep_num].dieptsiz);
>  
> @@ -921,7 +921,7 @@ static int dwc2_udc_get_status(struct dwc2_udc
> *dev, (unsigned long) usb_ctrl +
>  			   ROUND(sizeof(g_status),
> CONFIG_SYS_CACHELINE_SIZE)); 
> -	writel(usb_ctrl_dma_addr, &reg->in_endp[EP0_CON].diepdma);
> +	writel(phys_to_bus(usb_ctrl_dma_addr),
> &reg->in_endp[EP0_CON].diepdma); writel(DIEPT_SIZ_PKT_CNT(1) |
> DIEPT_SIZ_XFER_SIZE(2), &reg->in_endp[EP0_CON].dieptsiz);
>  

Reviewed-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190916/1a9e3a65/attachment.sig>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 3/3] config: enable DFU over USB on Raspberry Pi4 boards
  2019-09-16 12:24     ` [U-Boot] [PATCH 3/3] config: enable DFU over USB on Raspberry Pi4 boards Marek Szyprowski
  2019-09-16 12:45       ` Matthias Brugger
@ 2019-09-16 21:41       ` Lukasz Majewski
  1 sibling, 0 replies; 12+ messages in thread
From: Lukasz Majewski @ 2019-09-16 21:41 UTC (permalink / raw)
  To: u-boot

Hi Marek,

> Enable support for DFU over USB. This requires to enable USB gadget,
> DWC2 UDC OTG driver and DFU command. DFU entities are defined for the
> following firmware objects: u-boot.bin, uboot.env and zImage.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  configs/rpi_4_32b_defconfig | 11 +++++++++++
>  include/configs/rpi.h       | 10 ++++++++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/configs/rpi_4_32b_defconfig b/configs/rpi_4_32b_defconfig
> index a31a617a5fb..0a375b97369 100644
> --- a/configs/rpi_4_32b_defconfig
> +++ b/configs/rpi_4_32b_defconfig
> @@ -12,6 +12,7 @@ CONFIG_MISC_INIT_R=y
>  # CONFIG_DISPLAY_CPUINFO is not set
>  # CONFIG_DISPLAY_BOARDINFO is not set
>  CONFIG_SYS_PROMPT="U-Boot> "
> +CONFIG_CMD_DFU=y
>  # CONFIG_CMD_FLASH is not set
>  CONFIG_CMD_GPIO=y
>  CONFIG_CMD_MMC=y
> @@ -19,6 +20,7 @@ CONFIG_CMD_FS_UUID=y
>  CONFIG_ENV_FAT_INTERFACE="mmc"
>  CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
>  CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
> +CONFIG_DFU_MMC=y
>  CONFIG_DM_KEYBOARD=y
>  CONFIG_DM_MMC=y
>  CONFIG_MMC_SDHCI=y
> @@ -26,6 +28,15 @@ CONFIG_MMC_SDHCI_BCM2835=y
>  CONFIG_PINCTRL=y
>  # CONFIG_PINCTRL_GENERIC is not set
>  # CONFIG_REQUIRE_SERIAL_CONSOLE is not set
> +CONFIG_USB=y
> +CONFIG_DM_USB=y
> +CONFIG_DM_USB_GADGET=y
> +CONFIG_USB_GADGET=y
> +CONFIG_USB_GADGET_MANUFACTURER="FSL"
> +CONFIG_USB_GADGET_VENDOR_NUM=0x0525
> +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
> +CONFIG_USB_GADGET_DWC2_OTG=y
> +CONFIG_USB_GADGET_DOWNLOAD=y
>  CONFIG_DM_VIDEO=y
>  CONFIG_SYS_WHITE_ON_BLACK=y
>  CONFIG_CONSOLE_SCROLL_LINES=10
> diff --git a/include/configs/rpi.h b/include/configs/rpi.h
> index 77d2d5458a1..f502915ad53 100644
> --- a/include/configs/rpi.h
> +++ b/include/configs/rpi.h
> @@ -70,9 +70,18 @@
>  #define CONFIG_TFTP_TSIZE
>  #endif
>  
> +/* DFU over USB/UDC */
> +#ifdef CONFIG_CMD_DFU
> +#define CONFIG_SYS_DFU_DATA_BUF_SIZE	SZ_1M
> +#define CONFIG_SYS_DFU_MAX_FILE_SIZE	SZ_2M
> +#define ENV_DFU_SETTINGS \
> +	"dfu_alt_info=u-boot.bin fat 0 1;uboot.env fat 0 1;zImage
> fat 0 1" +#endif
> +
>  /* Console configuration */
>  #define CONFIG_SYS_CBSIZE		1024
>  
> +
>  /* Environment */
>  #define CONFIG_ENV_SIZE			SZ_16K
>  #define CONFIG_SYS_LOAD_ADDR		0x1000000
> @@ -185,6 +194,7 @@
>  #define CONFIG_EXTRA_ENV_SETTINGS \
>  	"dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \
>  	ENV_DEVICE_SETTINGS \
> +	ENV_DFU_SETTINGS \
>  	ENV_MEM_LAYOUT_SETTINGS \
>  	BOOTENV
>  

Reviewed-by: Lukasz Majewski <lukma@denx.de>

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190916/20cdacd8/attachment.sig>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 3/3] config: enable DFU over USB on Raspberry Pi4 boards
  2019-09-16 16:18           ` Jonathan Gray
@ 2019-09-17  5:41             ` Marek Szyprowski
  0 siblings, 0 replies; 12+ messages in thread
From: Marek Szyprowski @ 2019-09-17  5:41 UTC (permalink / raw)
  To: u-boot

Hi Jonathan,

On 16.09.2019 18:18, Jonathan Gray wrote:
> On Mon, Sep 16, 2019 at 02:53:30PM +0200, Marek Szyprowski wrote:
>> Hi Matthias,
>>
>> On 16.09.2019 14:45, Matthias Brugger wrote:
>>> On 16/09/2019 14:24, Marek Szyprowski wrote:
>>>> Enable support for DFU over USB. This requires to enable USB gadget,
>>>> DWC2 UDC OTG driver and DFU command. DFU entities are defined for the
>>>> following firmware objects: u-boot.bin, uboot.env and zImage.
>>>>
>>>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>>>> ---
>>>>    configs/rpi_4_32b_defconfig | 11 +++++++++++
>>>>    include/configs/rpi.h       | 10 ++++++++++
>>>>    2 files changed, 21 insertions(+)
>>>>
>>>> diff --git a/configs/rpi_4_32b_defconfig b/configs/rpi_4_32b_defconfig
>>>> index a31a617a5fb..0a375b97369 100644
>>>> --- a/configs/rpi_4_32b_defconfig
>>>> +++ b/configs/rpi_4_32b_defconfig
>>>> @@ -12,6 +12,7 @@ CONFIG_MISC_INIT_R=y
>>>>    # CONFIG_DISPLAY_CPUINFO is not set
>>>>    # CONFIG_DISPLAY_BOARDINFO is not set
>>>>    CONFIG_SYS_PROMPT="U-Boot> "
>>>> +CONFIG_CMD_DFU=y
>>>>    # CONFIG_CMD_FLASH is not set
>>>>    CONFIG_CMD_GPIO=y
>>>>    CONFIG_CMD_MMC=y
>>>> @@ -19,6 +20,7 @@ CONFIG_CMD_FS_UUID=y
>>>>    CONFIG_ENV_FAT_INTERFACE="mmc"
>>>>    CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
>>>>    CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
>>>> +CONFIG_DFU_MMC=y
>>>>    CONFIG_DM_KEYBOARD=y
>>>>    CONFIG_DM_MMC=y
>>>>    CONFIG_MMC_SDHCI=y
>>>> @@ -26,6 +28,15 @@ CONFIG_MMC_SDHCI_BCM2835=y
>>>>    CONFIG_PINCTRL=y
>>>>    # CONFIG_PINCTRL_GENERIC is not set
>>>>    # CONFIG_REQUIRE_SERIAL_CONSOLE is not set
>>>> +CONFIG_USB=y
>>>> +CONFIG_DM_USB=y
>>>> +CONFIG_DM_USB_GADGET=y
>>>> +CONFIG_USB_GADGET=y
>>>> +CONFIG_USB_GADGET_MANUFACTURER="FSL"
>>>> +CONFIG_USB_GADGET_VENDOR_NUM=0x0525
>>>> +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
>>>> +CONFIG_USB_GADGET_DWC2_OTG=y
>>>> +CONFIG_USB_GADGET_DOWNLOAD=y
>>> Does this only work on RPi4? It seems to me that this should also be working on
>>> the other RPi's. Do you have such HW to test?
>> It should work on any RPi with USB device controller available on the
>> micro-usb/c-usb connector. AFAIK, besides RPi4, only some RPi0 has USB
>> device mode available. Other RPi's have USB hub connected to DWC2
>> controller, so switching DWC2 to device mode is not enough to make it
>> working.
>>
>> However I have access only to RPi3 and RPi4.
> https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/device.md
>
> 	The following devices can boot using USB device boot mode:
>
> 	Pi Compute Module
> 	Pi Compute Module 3
> 	Pi Zero
> 	Pi Zero W
> 	Pi A
> 	Pi A+
> 	Pi 3A+

Wow, I wasn't aware that there were so many variants of RPi board. 
Anyway, I have only RPi3 (B) and RPi4, so I have no other board to test.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-09-17  5:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20190916122430eucas1p164f3467e5ad5981c01bde6376ec51a27@eucas1p1.samsung.com>
2019-09-16 12:24 ` [U-Boot] [PATCH 0/3] Raspberry Pi4: add support for DFU over USB Marek Szyprowski
     [not found]   ` <CGME20190916122430eucas1p19918617895f7d0d57c3f58218adc85ae@eucas1p1.samsung.com>
2019-09-16 12:24     ` [U-Boot] [PATCH 1/3] fat: write: fix broken write to fragmented files Marek Szyprowski
2019-09-16 13:18       ` Oleksandr Suvorov
2019-09-16 21:38       ` Lukasz Majewski
     [not found]   ` <CGME20190916122430eucas1p2dc270f6d0b8ee4da5521fe63d6df072f@eucas1p2.samsung.com>
2019-09-16 12:24     ` [U-Boot] [PATCH 2/3] usb: dwc2_udc_otg: add bcm2835 SoC (Raspberry Pi4) support Marek Szyprowski
2019-09-16 21:40       ` Lukasz Majewski
     [not found]   ` <CGME20190916122431eucas1p206a5a96f594baef702cd94b81c4917b1@eucas1p2.samsung.com>
2019-09-16 12:24     ` [U-Boot] [PATCH 3/3] config: enable DFU over USB on Raspberry Pi4 boards Marek Szyprowski
2019-09-16 12:45       ` Matthias Brugger
2019-09-16 12:53         ` Marek Szyprowski
2019-09-16 16:18           ` Jonathan Gray
2019-09-17  5:41             ` Marek Szyprowski
2019-09-16 21:41       ` Lukasz Majewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.