Skip to content

Commit 323f48d

Browse files
committed
usb: gadget: f_fastboot: make EP buffer size configurable
Introduce CONFIG_USB_FUNCTION_FASTBOOT_EP_BUFFER_SIZE to allow customization of the endpoint buffer size used for fastboot transfers. The EP_BUFFER_SIZE must always be an integral multiple of the maxpacket size (64, 512, or 1024 bytes depending on USB speed), as controllers like DWC3 expect bulk OUT requests to be divisible by maxpacket size. On DWC3 controllers operating in SuperSpeed mode, increasing the endpoint buffer size from the default value significantly improves download throughput - from approximately 50 MB/s to over 170 MB/s. This is particularly beneficial for flashing large images during development or production. The configurable buffer size allows board maintainers to tune the trade-off between memory usage and transfer performance based on their specific requirements and available resources. Signed-off-by: Anton Burticica <mouse@ya.ru>
1 parent 2296adf commit 323f48d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

drivers/fastboot/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ config USB_FUNCTION_FASTBOOT
2626
help
2727
This enables the USB part of the fastboot gadget.
2828

29+
config USB_FUNCTION_FASTBOOT_EP_BUFFER_SIZE
30+
hex "USB fastboot endpoint buffer size"
31+
depends on USB_FUNCTION_FASTBOOT
32+
default 0x1000
33+
help
34+
The buffer size used for USB endpoint transfers in fastboot.
35+
This must always be an integral multiple of the maxpacket size
36+
(64 or 512 or 1024), otherwise transfers may fail on certain
37+
controllers like DWC3 that expect bulk OUT requests to be
38+
divisible by maxpacket size.
39+
The default value is 0x1000 (4096 bytes).
40+
2941
config UDP_FUNCTION_FASTBOOT
3042
depends on NET
3143
select FASTBOOT

drivers/usb/gadget/f_fastboot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#define RX_ENDPOINT_MAXIMUM_PACKET_SIZE_1_1 (0x0040)
3232
#define TX_ENDPOINT_MAXIMUM_PACKET_SIZE (0x0040)
3333

34-
#define EP_BUFFER_SIZE 4096
34+
#define EP_BUFFER_SIZE (CONFIG_USB_FUNCTION_FASTBOOT_EP_BUFFER_SIZE)
3535
/*
3636
* EP_BUFFER_SIZE must always be an integral multiple of maxpacket size
3737
* (64 or 512 or 1024), else we break on certain controllers like DWC3

0 commit comments

Comments
 (0)