dfu: Fix up the Kconfig mess
Subsystems (2)
PATCH v2 1/3 dfu: Fix up the Kconfig mess
Clean up the screaming mess of configuration options that DFU is. It was impossible to configure DFU such that TFTP is enabled and USB is not, this patch fixes that and assures that DFU TFTP and DFU USB can be enabled separatelly and that the correct pieces of code are compiled in.
---
V2: Do not imply TFTP if net, we do not want this turned on by default.
--- cmd/Kconfig | 2 +- cmd/dfu.c | 18 +++++++++++++----- common/Makefile | 6 ++++-- drivers/dfu/Kconfig | 12 +++++++++++- drivers/dfu/Makefile | 2 +- 5 files changed, 30 insertions(+), 10 deletions(-)
cmd/Kconfig +1 -1
@@ -582,7 +582,7 @@ config CMD_DEMO config CMD_DFU bool "dfu" - select USB_FUNCTION_DFU + select DFU help Enables the command "dfu" which is used to have U-Boot create a DFU class device via USB. This command requires that the "dfu_alt_info"
cmd/dfu.c +13 -5
@@ -25,12 +25,14 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <4 )return CMD_RET_USAGE ; +#ifdef CONFIG_USB_FUNCTION_DFU char *usb_controller = argv[1 ]; +#endif char *interface = argv[2 ];char *devstring = argv[3 ]; -int ret; -#ifdef CONFIG_DFU_TFTP +int ret =0 ; +#ifdef CONFIG_TFTP_FUNCTION_DFU unsigned long addr =0 ;if (!strcmp (argv[1 ],"tftp" )) {if (argc ==5 )
@@ -39,7 +41,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return update_tftp(addr, interface, devstring); }#endif - +#ifdef CONFIG_USB_FUNCTION_DFU ret =dfu_init_env_entities (interface, devstring);if (ret) goto done;
@@ -56,18 +58,24 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) done:dfu_free_entities (); +#endif return ret; }U_BOOT_CMD (dfu,CONFIG_SYS_MAXARGS ,1 , do_dfu,"Device Firmware Upgrade" , +#ifdef CONFIG_USB_FUNCTION_DFU "<USB_controller> <interface> <dev> [list]\n" " - device firmware upgrade via <USB_controller>\n" " on device <dev>, attached to interface\n" " <interface>\n" " [list] - list available alt settings\n" -#ifdef CONFIG_DFU_TFTP -"dfu tftp <interface> <dev> [<addr>]\n" +#endif +#ifdef CONFIG_TFTP_FUNCTION_DFU +#ifdef CONFIG_USB_FUNCTION_DFU + "dfu " +#endif +"tftp <interface> <dev> [<addr>]\n" " - device firmware upgrade via TFTP\n" " on device <dev>, attached to interface\n" " <interface>\n"
common/Makefile +4 -2
@@ -66,7 +66,9 @@ endif # !CONFIG_SPL_BUILD obj-$(CONFIG_$(SPL_TPL_)BOOTSTAGE) += bootstage.o ifdef CONFIG_SPL_BUILD -obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o +ifdef CONFIG_SPL_DFU_SUPPORT +obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o +endif obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
@@ -128,7 +130,7 @@ endif obj-y += cli.o obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_simple.o cli_readline.o -obj-$(CONFIG_CMD_DFU) += dfu.o +obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o obj-y += command.o obj-$(CONFIG_$(SPL_)LOG) += log.o obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o
drivers/dfu/Kconfig +11 -1
@@ -1,12 +1,22 @@ menu "DFU support" +config DFU + bool + imply USB_FUNCTION_DFU if USB_GADGET + config USB_FUNCTION_DFU bool select HASH + depends on USB_GADGET + +config TFTP_FUNCTION_DFU + bool + depends on NET -if CMD_DFU +if DFU config DFU_TFTP bool "DFU via TFTP" + select TFTP_FUNCTION_DFU help This option allows performing update of DFU-managed medium with data sent via TFTP boot.
drivers/dfu/Makefile +1 -1
@@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o +obj-$(CONFIG_DFU) += dfu.o obj-$(CONFIG_DFU_MMC) += dfu_mmc.o obj-$(CONFIG_DFU_NAND) += dfu_nand.o obj-$(CONFIG_DFU_RAM) += dfu_ram.o
Signature · 1 line
2.15.1
PATCH 2/3 dfu: Rename _FUNCTION_DFU to DFU_OVER_
Do the following to make the symbol names less confusing.
sed -i "s/\([TU][^_]\+\)_FUNCTION_DFU/DFU_OVER_\1/g" \
git grep _FUNCTION_DFU | cut -d ":" -f 1 | sort -u
--- README | 2 +- board/siemens/common/factoryset.c | 4 ++-- cmd/dfu.c | 12 ++++++------ common/Makefile | 4 ++-- drivers/dfu/Kconfig | 8 ++++---- drivers/usb/gadget/Makefile | 2 +- include/configs/tegra-common-post.h | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-)
README +1 -1
@@ -1203,7 +1203,7 @@ The following options need to be configured: key for the Replay Protection Memory Block partition in eMMC. - USB Device Firmware Update (DFU) class support: - CONFIG_USB_FUNCTION_DFU + CONFIG_DFU_OVER_USB This enables the USB portion of the DFU USB class CONFIG_DFU_MMC
board/siemens/common/factoryset.c +2 -2
@@ -144,7 +144,7 @@ int factoryset_read_eeprom(int i2c_addr)unsigned char eeprom_buf[0x3c00 ], hdr[4 ], buf[MAX_STRING_LENGTH ];unsigned char *cp, *cp1; -#if defined(CONFIG_USB_FUNCTION_DFU ) +#if defined(CONFIG_DFU_OVER_USB ) factory_dat.usb_vendor_id =CONFIG_USB_GADGET_VENDOR_NUM ; factory_dat.usb_product_id =CONFIG_USB_GADGET_PRODUCT_NUM ;#endif
@@ -202,7 +202,7 @@ int factoryset_read_eeprom(int i2c_addr) cp1 +=3 ; } -#if defined(CONFIG_USB_FUNCTION_DFU ) +#if defined(CONFIG_DFU_OVER_USB )/* read vid and pid for dfu mode */ if (0 <= get_factory_record_val(cp, size, (uchar *)"USBD1", (uchar *)"vid", buf,
cmd/dfu.c +6 -6
@@ -25,14 +25,14 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <4 )return CMD_RET_USAGE ; -#ifdef CONFIG_USB_FUNCTION_DFU +#ifdef CONFIG_DFU_OVER_USB char *usb_controller = argv[1 ];#endif char *interface = argv[2 ];char *devstring = argv[3 ];int ret =0 ; -#ifdef CONFIG_TFTP_FUNCTION_DFU +#ifdef CONFIG_DFU_OVER_TFTP unsigned long addr =0 ;if (!strcmp (argv[1 ],"tftp" )) {if (argc ==5 )
@@ -41,7 +41,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return update_tftp(addr, interface, devstring); }#endif -#ifdef CONFIG_USB_FUNCTION_DFU +#ifdef CONFIG_DFU_OVER_USB ret =dfu_init_env_entities (interface, devstring);if (ret) goto done;
@@ -64,15 +64,15 @@ done:U_BOOT_CMD (dfu,CONFIG_SYS_MAXARGS ,1 , do_dfu,"Device Firmware Upgrade" , -#ifdef CONFIG_USB_FUNCTION_DFU +#ifdef CONFIG_DFU_OVER_USB "<USB_controller> <interface> <dev> [list]\n" " - device firmware upgrade via <USB_controller>\n" " on device <dev>, attached to interface\n" " <interface>\n" " [list] - list available alt settings\n" #endif -#ifdef CONFIG_TFTP_FUNCTION_DFU -#ifdef CONFIG_USB_FUNCTION_DFU +#ifdef CONFIG_DFU_OVER_TFTP +#ifdef CONFIG_DFU_OVER_USB "dfu " #endif "tftp <interface> <dev> [<addr>]\n"
common/Makefile +2 -2
@@ -67,7 +67,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTAGE) += bootstage.o ifdef CONFIG_SPL_BUILD ifdef CONFIG_SPL_DFU_SUPPORT -obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o +obj-$(CONFIG_DFU_OVER_USB) += dfu.o endif obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
@@ -130,7 +130,7 @@ endif obj-y += cli.o obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_simple.o cli_readline.o -obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o +obj-$(CONFIG_DFU_OVER_USB) += dfu.o obj-y += command.o obj-$(CONFIG_$(SPL_)LOG) += log.o obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o
drivers/dfu/Kconfig +4 -4
@@ -2,21 +2,21 @@ menu "DFU support" config DFU bool - imply USB_FUNCTION_DFU if USB_GADGET + imply DFU_OVER_USB if USB_GADGET -config USB_FUNCTION_DFU +config DFU_OVER_USB bool select HASH depends on USB_GADGET -config TFTP_FUNCTION_DFU +config DFU_OVER_TFTP bool depends on NET if DFU config DFU_TFTP bool "DFU via TFTP" - select TFTP_FUNCTION_DFU + select DFU_OVER_TFTP help This option allows performing update of DFU-managed medium with data sent via TFTP boot.
drivers/usb/gadget/Makefile +1 -1
@@ -26,7 +26,7 @@ obj-$(CONFIG_CI_UDC) += ci_udc.o ifndef CONFIG_SPL_BUILD obj-$(CONFIG_USB_GADGET_DOWNLOAD) += g_dnl.o obj-$(CONFIG_USB_FUNCTION_THOR) += f_thor.o -obj-$(CONFIG_USB_FUNCTION_DFU) += f_dfu.o +obj-$(CONFIG_DFU_OVER_USB) += f_dfu.o obj-$(CONFIG_USB_FUNCTION_MASS_STORAGE) += f_mass_storage.o obj-$(CONFIG_USB_FUNCTION_FASTBOOT) += f_fastboot.o obj-$(CONFIG_USB_FUNCTION_SDP) += f_sdp.o
include/configs/tegra-common-post.h +1 -1
@@ -11,7 +11,7 @@/* * Size of malloc() pool */ -#ifdef CONFIG_USB_FUNCTION_DFU +#ifdef CONFIG_DFU_OVER_USB #define CONFIG_SYS_MALLOC_LEN (SZ_4M + \ CONFIG_SYS_DFU_DATA_BUF_SIZE + \ CONFIG_SYS_DFU_MAX_FILE_SIZE)
Signature · 1 line
2.15.1
PATCH 3/3 dfu: tftp: Fix arm64 build warnings
In reply to Marek VasutFix two build warnings when building for arm64:
drivers/dfu/dfu_tftp.c: In function ‘dfu_tftp_write’:drivers/dfu/dfu_tftp.c:59:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
ret = dfu_write_from_mem_addr(dfu, (void *)addr, len);
^and
drivers/dfu/dfu_tftp.c: In function ‘dfu_tftp_write’:drivers/dfu/dfu_tftp.c:41:8: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘__kernel_size_t {aka long unsigned int}’ [-Wformat=]
debug("%s: image name: %s strlen: %u\n", __func__, sb, strlen(sb));
^--- drivers/dfu/dfu_tftp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dfu/dfu_tftp.c +2 -2
@@ -38,7 +38,7 @@ int dfu_tftp_write(char *dfu_entity_name, unsigned int addr, unsigned int len, }strsep (&s,"@" ); -debug ("%s: image name: %s strlen: %d\n" , __func__, sb,strlen (sb)); +debug ("%s: image name: %s strlen: %zd\n" , __func__, sb,strlen (sb)); alt_setting_num =dfu_get_alt (sb);free (sb);
@@ -56,7 +56,7 @@ int dfu_tftp_write(char *dfu_entity_name, unsigned int addr, unsigned int len, goto done; } - ret =dfu_write_from_mem_addr (dfu, (void *)addr, len); + ret =dfu_write_from_mem_addr (dfu, (void *)(uintptr_t )addr, len); done:dfu_free_entities ();
Signature · 1 line
2.15.1
PATCH v2 1/3 dfu: Fix up the Kconfig mess
In reply to Marek VasutHi Marek,
Quoted 8 lines
Clean up the screaming mess of configuration options that DFU is. It was impossible to configure DFU such that TFTP is enabled and USB is not, this patch fixes that and assures that DFU TFTP and DFU USB can be enabled separatelly and that the correct pieces of code are compiled in.
Signed-off-by Marek Vasut <[email protected]>Cc Lukasz Majewski <[email protected]>
Test HW: Beagle Bone Black
Quoted 137 lines
---
V2: Do not imply TFTP if net, we do not want this turned on by default. ---cmd/Kconfig | 2 +- cmd/dfu.c | 18 +++++++++++++----- common/Makefile | 6 ++++-- drivers/dfu/Kconfig | 12 +++++++++++- drivers/dfu/Makefile | 2 +- 5 files changed, 30 insertions(+), 10 deletions(-)cmd/Kconfig +1
-1@@ -582,7 +582,7 @@ config CMD_DEMO config CMD_DFU bool "dfu" - select USB_FUNCTION_DFU + select DFU help Enables the command "dfu" which is used to have U-Bootcreate a DFU class device via USB. This command requires that the "
dfu_alt_info" diff --gita/cmd/dfu.cb/cmd/dfu.c
index04291f6c08..76b89ca5ed100644cmd/dfu.c +13
-5@@ -25,12 +25,14 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 4)return CMD_RET_USAGE ; +#ifdef CONFIG_USB_FUNCTION_DFU char *usb_controller = argv[1 ]; +#endif char *interface = argv[2 ];char *devstring = argv[3 ]; -int ret; -#ifdef CONFIG_DFU_TFTP +int ret =0 ; +#ifdef CONFIG_TFTP_FUNCTION_DFU unsigned long addr =0 ;if (!strcmp (argv[1 ],"tftp" )) {if (argc ==5 )@@ -39,7 +41,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return update_tftp(addr, interface, devstring); } #endif - +#ifdef CONFIG_USB_FUNCTION_DFU ret = dfu_init_env_entities(interface, devstring);if (ret) goto done;@@ -56,18 +58,24 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) done: dfu_free_entities(); +#endif return ret; }U_BOOT_CMD (dfu,CONFIG_SYS_MAXARGS ,1 , do_dfu,"Device Firmware Upgrade" , +#ifdef CONFIG_USB_FUNCTION_DFU "<USB_controller> <interface> <dev> [list]\n" " - device firmware upgrade via <USB_controller>\n" " on device <dev>, attached to interface\n" " <interface>\n" " [list] - list available alt settings\n" -#ifdef CONFIG_DFU_TFTP -"dfu tftp <interface> <dev> [<addr>]\n" +#endif +#ifdef CONFIG_TFTP_FUNCTION_DFU +#ifdef CONFIG_USB_FUNCTION_DFU + "dfu " +#endif +"tftp <interface> <dev> [<addr>]\n" " - device firmware upgrade via TFTP\n" " on device <dev>, attached to interface\n" " <interface>\n"common/Makefile +4
-2@@ -66,7 +66,9 @@ endif # !CONFIG_SPL_BUILD obj-$(CONFIG_$(SPL_TPL_)BOOTSTAGE) += bootstage.o ifdef CONFIG_SPL_BUILD -obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o +ifdef CONFIG_SPL_DFU_SUPPORT +obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o +endif obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o@@ -128,7 +130,7 @@ endif obj-y += cli.o obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_simple.o cli_readline.o -obj-$(CONFIG_CMD_DFU) += dfu.o +obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o obj-y += command.o obj-$(CONFIG_$(SPL_)LOG) += log.o obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.odrivers/dfu/Kconfig +11
-1@@ -1,12 +1,22 @@ menu "DFU support" +config DFU + bool + imply USB_FUNCTION_DFU if USB_GADGET + config USB_FUNCTION_DFU bool select HASH + depends on USB_GADGET + +config TFTP_FUNCTION_DFU + bool + depends on NET -if CMD_DFU +if DFU config DFU_TFTP bool "DFU via TFTP" + select TFTP_FUNCTION_DFU help This option allows performing update of DFU-managed mediumwith data sent via TFTP boot.
drivers/dfu/Makefile +0
-0
drivers/dfu/Makefile line 11
Quoted 8 lines
drivers/dfu/Makefile +1
-1@@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o +obj-$(CONFIG_DFU) += dfu.o obj-$(CONFIG_DFU_MMC) += dfu_mmc.o obj-$(CONFIG_DFU_NAND) += dfu_nand.o obj-$(CONFIG_DFU_RAM) += dfu_ram.o
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-10 Fax: (+49)-8142-66989-80 Email: wd 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/20180219/2fdcb292/attachment.sig>