Raspberry Pi4: add support for DFU over USB
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): CGME20190916122430eucas1p164f3467e5ad5981c01bde6376ec51a27@eucas1p1.samsung.com
cover Raspberry Pi4: add support for DFU over USB
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(-)
Signature · 1 line
2.17.1
PATCH 1/3 fat: write: fix broken write to fragmented files
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.
--- fs/fat/fat_write.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/fat/fat_write.c +3 -3
@@ -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 ;
Signature · 1 line
2.17.1
PATCH 1/3 fat: write: fix broken write to fragmented files
Quoted 8 lines · Marek Szyprowski
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 <[email protected]>
Quoted 42 lines
--- fs/fat/fat_write.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/fat/fat_write.c +3
-4@@ -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
Signature · 4 lines
Best regards Oleksandr Suvorov cryosay at gmail.com
PATCH 1/3 fat: write: fix broken write to fragmented files
In reply to Marek SzyprowskiHi Marek,
Quoted 34 lines
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 <[email protected]>--- fs/fat/fat_write.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/fat/fat_write.c +3
-2@@ -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" );
fs/fat/fat_write.c set_contents(fsdata *mydata, dir_entry *dentptr, · line 831
Quoted 8 lines
fs/fat/fat_write.c +0
-2@@ -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 ;
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>
PATCH 2/3 usb: dwc2_udc_otg: add bcm2835 SoC (Raspberry Pi4) support
In reply to Marek SzyprowskiBroadcom 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.
--- 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(-)
drivers/usb/gadget/dwc2_udc_otg.c +2 -0
@@ -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 }, {},
drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +6 -6
@@ -28,7 +28,7 @@ static inline void dwc2_udc_ep0_zlp(struct dwc2_udc *dev) {u32 ep_ctrl; -writel (usb_ctrl_dma_addr, ®->in_endp[EP0_CON ].diepdma); +writel (phys_to_bus ((unsigned long )usb_ctrl_dma_addr), ®->in_endp[EP0_CON ].diepdma);writel (DIEPT_SIZ_PKT_CNT (1 ), ®->in_endp[EP0_CON ].dieptsiz); ep_ctrl =readl (®->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 ), ®->out_endp[EP0_CON ].doeptsiz); -writel (usb_ctrl_dma_addr, ®->out_endp[EP0_CON ].doepdma); +writel (phys_to_bus ((unsigned long )usb_ctrl_dma_addr), ®->out_endp[EP0_CON ].doepdma); ep_ctrl =readl (®->out_endp[EP0_CON ].doepctl);writel (ep_ctrl|DEPCTL_EPENA , ®->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 ), ®->out_endp[EP0_CON ].doeptsiz); -writel (usb_ctrl_dma_addr, ®->out_endp[EP0_CON ].doepdma); +writel (phys_to_bus ((unsigned long )usb_ctrl_dma_addr), ®->out_endp[EP0_CON ].doepdma); ep_ctrl =readl (®->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, ®->out_endp[ep_num].doepdma); +writel (phys_to_bus ((unsigned long )ep->dma_buf), ®->out_endp[ep_num].doepdma);writel (DOEPT_SIZ_PKT_CNT (pktcnt) |DOEPT_SIZ_XFER_SIZE (length), ®->out_endp[ep_num].doeptsiz);writel (DEPCTL_EPENA |DEPCTL_CNAK |ctrl, ®->out_endp[ep_num].doepctl);
@@ -161,7 +161,7 @@ static int setdma_tx(struct dwc2_ep *ep, struct dwc2_request *req)while (readl (®->grstctl) &TX_FIFO_FLUSH ) ; -writel ((unsigned long ) ep->dma_buf, ®->in_endp[ep_num].diepdma); +writel (phys_to_bus ((unsigned long )ep->dma_buf), ®->in_endp[ep_num].diepdma);writel (DIEPT_SIZ_PKT_CNT (pktcnt) |DIEPT_SIZ_XFER_SIZE (length), ®->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, ®->in_endp[EP0_CON ].diepdma); +writel (phys_to_bus (usb_ctrl_dma_addr), ®->in_endp[EP0_CON ].diepdma);writel (DIEPT_SIZ_PKT_CNT (1 ) |DIEPT_SIZ_XFER_SIZE (2 ), ®->in_endp[EP0_CON ].dieptsiz);
Signature · 1 line
2.17.1
PATCH 2/3 usb: dwc2_udc_otg: add bcm2835 SoC (Raspberry Pi4) support
Hi Marek,
Quoted 89 lines
Broadcom 2835 SoC requires special conversion of physical memory addresses for DMA purpose, so add needed wrappers to
dwc2_udc_otgdriver. 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 <[email protected]>--- 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(-)(quoted diff) +0
-0
b/drivers/usb/gadget/dwc2_udc_otg.cindex35f4147840e..49f342eb211100644 ---a/drivers/usb/gadget/dwc2_udc_otg.c
+++b/drivers/usb/gadget/dwc2_udc_otg.cdrivers/usb/gadget/dwc2_udc_otg.c +2
-0@@ -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 }, {},(quoted diff) +0
-0
b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.cindex7eb632d3b14..5e695b4ff2a100644 ---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 voiddwc2_udc_ep0_zlp(struct dwc2_udc *dev){drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +1
-1u32 ep_ctrl; -writel (usb_ctrl_dma_addr, ®->in_endp[EP0_CON ].diepdma); + writel(phys_to_bus((unsigned long)usb_ctrl_dma_addr),®->in_endp[EP0_CON].diepdma);
writel(DIEPT_SIZ_PKT_CNT(1), ®->in_endp[EP0_CON].dieptsiz);drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +1
-1ep_ctrl =readl (®->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 ), ®->out_endp[EP0_CON ].doeptsiz); -writel (usb_ctrl_dma_addr, ®->out_endp[EP0_CON ].doepdma); +writel (phys_to_bus ((unsigned long )usb_ctrl_dma_addr), ®->out_endp[EP0_CON ].doepdma); ep_ctrl =readl (®->out_endp[EP0_CON ].doepctl); writel(ep_ctrl|DEPCTL_EPENA,®->out_endp[EP0_CON].doepctl); @@ -75,7 +75,7 @@ static inline void
dwc2_ep0_complete_out(void)drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +1
-1writel (DOEPT_SIZ_PKT_CNT (1 ) |sizeof (struct usb_ctrlrequest ), ®->out_endp[EP0_CON ].doeptsiz); -writel (usb_ctrl_dma_addr, ®->out_endp[EP0_CON ].doepdma); + writel(phys_to_bus((unsigned long)usb_ctrl_dma_addr),®->out_endp[EP0_CON].doepdma);
drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +0
-0ep_ctrl =readl (®->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));(quoted diff) +0
-1- writel((unsigned long) ep->dma_buf,®->out_endp[ep_num].doepdma);
(quoted diff) +1
-0+ writel(phys_to_bus((unsigned long)ep->dma_buf),®->out_endp[ep_num].doepdma);
writel(DOEPT_SIZ_PKT_CNT(pktcnt) | DOEPT_SIZ_XFER_SIZE(length), ®->out_endp[ep_num].doeptsiz);
writel(DEPCTL_EPENA|DEPCTL_CNAK|ctrl,
®->out_endp[ep_num].doepctl); @@ -161,7 +161,7 @@ static intsetdma_tx(struct dwc2_ep *ep, struct dwc2_request *req)while (readl(®->grstctl)&TX_FIFO_FLUSH) ;(quoted diff) +0
-1- writel((unsigned long) ep->dma_buf,®->in_endp[ep_num].diepdma);
(quoted diff) +1
-0+ writel(phys_to_bus((unsigned long)ep->dma_buf),®->in_endp[ep_num].diepdma);
writel(DIEPT_SIZ_PKT_CNT(pktcnt) | DIEPT_SIZ_XFER_SIZE(length), ®->in_endp[ep_num].dieptsiz);(quoted diff) +1
-1@@ -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, ®->in_endp[EP0_CON].diepdma); + writel(phys_to_bus(usb_ctrl_dma_addr),
Quoted 3 lines
®->in_endp[EP0_CON].diepdma);
writel(DIEPT_SIZ_PKT_CNT(1) | DIEPT_SIZ_XFER_SIZE(2), ®->in_endp[EP0_CON].dieptsiz);
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>
PATCH 3/3 config: enable DFU over USB on Raspberry Pi4 boards
In reply to Marek SzyprowskiEnable 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.
--- configs/rpi_4_32b_defconfig | 11 +++++++++++ include/configs/rpi.h | 10 ++++++++++ 2 files changed, 21 insertions(+)
configs/rpi_4_32b_defconfig +11 -0
@@ -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
include/configs/rpi.h +10 -0
@@ -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
Signature · 1 line
2.17.1
PATCH 3/3 config: enable DFU over USB on Raspberry Pi4 boards
Quoted 33 lines · Marek Szyprowski
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 <[email protected]>--- configs/rpi_4_32b_defconfig | 11 +++++++++++ include/configs/rpi.h | 10 ++++++++++ 2 files changed, 21 insertions(+)configs/rpi_4_32b_defconfig +2
-0@@ -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
configs/rpi_4_32b_defconfig CONFIG_MMC_SDHCI_BCM2835=y · line 39
Quoted 10 lines
configs/rpi_4_32b_defconfig +9
-0# 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?
Quoted 13 lines
configs/rpi_4_32b_defconfig +0
-0CONFIG_DM_VIDEO=y CONFIG_SYS_WHITE_ON_BLACK=y CONFIG_CONSOLE_SCROLL_LINES=10include/configs/rpi.h +2
-0@@ -70,9 +70,18 @@#define CONFIG_TFTP_TSIZE #endif +/* DFU over USB/UDC */ +#ifdef CONFIG_CMD_DFU
include/configs/rpi.h line 84
Quoted 10 lines
include/configs/rpi.h +7
-0+#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
Quoted 12 lines
include/configs/rpi.h +1
-0/* 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
PATCH 3/3 config: enable DFU over USB on Raspberry Pi4 boards
Hi Matthias,
Quoted 38 lines · Matthias Brugger
Quoted 37 lines · Marek Szyprowski
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 <[email protected]>--- configs/rpi_4_32b_defconfig | 11 +++++++++++ include/configs/rpi.h | 10 ++++++++++ 2 files changed, 21 insertions(+)configs/rpi_4_32b_defconfig +5
-0@@ -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
Quoted 8 lines
configs/rpi_4_32b_defconfig CONFIG_MMC_SDHCI_BCM2835=y · line 39
Quoted 6 lines
configs/rpi_4_32b_defconfig +6
-0+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=yDoes 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.
Quoted 28 lines
Quoted 13 lines
configs/rpi_4_32b_defconfig +0
-0CONFIG_DM_VIDEO=y CONFIG_SYS_WHITE_ON_BLACK=y CONFIG_CONSOLE_SCROLL_LINES=10include/configs/rpi.h +2
-0@@ -70,9 +70,18 @@#define CONFIG_TFTP_TSIZE #endif +/* DFU over USB/UDC */ +#ifdef CONFIG_CMD_DFU include/configs/rpi.h line 84
Quoted 10 lines
include/configs/rpi.h +7
-0+#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
Quoted 13 lines
include/configs/rpi.h line 200
Quoted 12 lines
include/configs/rpi.h +1
-0/* 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
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
PATCH 3/3 config: enable DFU over USB on Raspberry Pi4 boards
Quoted 50 lines · Marek Szyprowski
Hi Matthias,
Quoted 38 lines · Matthias Brugger
Quoted 37 lines · Marek Szyprowski
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 <[email protected]>--- configs/rpi_4_32b_defconfig | 11 +++++++++++ include/configs/rpi.h | 10 ++++++++++ 2 files changed, 21 insertions(+)configs/rpi_4_32b_defconfig +5
-0@@ -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=yQuoted 8 lines
configs/rpi_4_32b_defconfig CONFIG_MMC_SDHCI_BCM2835=y · line 39
Quoted 6 lines
configs/rpi_4_32b_defconfig +6
-0+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=yDoes 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?
Quoted 7 lines
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+
PATCH 3/3 config: enable DFU over USB on Raspberry Pi4 boards
Hi Jonathan,
Quoted 61 lines · Jonathan Gray
Quoted 49 lines · Marek Szyprowski
Hi Matthias,
Quoted 38 lines · Matthias Brugger
Quoted 37 lines · Marek Szyprowski
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 <[email protected]>--- configs/rpi_4_32b_defconfig | 11 +++++++++++ include/configs/rpi.h | 10 ++++++++++ 2 files changed, 21 insertions(+)configs/rpi_4_32b_defconfig +5
-0@@ -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=yQuoted 8 lines
configs/rpi_4_32b_defconfig CONFIG_MMC_SDHCI_BCM2835=y · line 39
Quoted 6 lines
configs/rpi_4_32b_defconfig +6
-0+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=yDoes 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?
Quoted 7 lines
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:
Quoted 7 lines
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
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
PATCH 3/3 config: enable DFU over USB on Raspberry Pi4 boards
In reply to Marek SzyprowskiHi Marek,
Quoted 70 lines
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 <[email protected]>--- configs/rpi_4_32b_defconfig | 11 +++++++++++ include/configs/rpi.h | 10 ++++++++++ 2 files changed, 21 insertions(+)configs/rpi_4_32b_defconfig +11
-0@@ -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=10include/configs/rpi.h +6
-0@@ -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;zImagefat 0 1" +#endif
include/configs/rpi.h +2
-0+/* Console configuration */ #define CONFIG_SYS_CBSIZE 1024 +/* Environment */ #define CONFIG_ENV_SIZE SZ_16K#define CONFIG_SYS_LOAD_ADDR 0x1000000
include/configs/rpi.h line 200
Quoted 7 lines
include/configs/rpi.h +1
-0@@ -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,
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>