spl: dfu: misc fixes and reduce MLO foot print
v3 cover spl: dfu: misc fixes and reduce MLO foot print
The patch series spl-dfu fixes includes
- select spl-dfu only spl-ram supported
- ignore the dfu-reset for spl-dfu
- reduce the spl-dfu MLO foot print
buildman ran for arm targets
Change history:
v1:
- Kconfig fix for dfu-reset for SPL-DFU
- compile out CONFIG_DFU_MMC for SPL-DFU
v2: - added Kconfig option CONFIG_SPL_DFU_MMC
and use of CONFIG_IS_ENABLED(DFU_MMC).
- compile out cli_hush. and use of
cli_simple_run_command() instead of
run_command().
- SPL size reduced by ~4K.
Ravi Babu (3):
spl: Kconfig: dfu: spl-dfu depends on SPL_RAM_SUPPORT
common: dfu: ignore reset for spl-dfu
spl: dfu: reduce spl-dfu MLO size
common/Makefile | 1 - common/dfu.c | 2 +- common/spl/Kconfig | 5 +++++ drivers/dfu/Kconfig | 5 +++++ drivers/dfu/Makefile | 3 +++ drivers/dfu/dfu.c | 4 ++++ drivers/dfu/dfu_mmc.c | 3 ++- include/dfu.h | 2 +- 8 files changed, 21 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1
PATCH v3 1/3 spl: Kconfig: dfu: spl-dfu depends on SPL_RAM_SUPPORT
Since SPL_DFU_SUPPORT is depends on SPL_RAM_SUPPORT, hence select SPL_DFU_SUPPORT only when SPL_RAM_SUPPORT is chosen.
--- common/spl/Kconfig | 1 + 1 file changed, 1 insertion(+)
common/spl/Kconfig +1 -0
@@ -646,6 +646,7 @@ config SPL_USBETH_SUPPORT config SPL_DFU_SUPPORT bool "Support DFU (Device Firmware Upgarde)" select SPL_HASH_SUPPORT + depends on SPL_RAM_SUPPORT help This feature enables the DFU (Device Firmware Upgarde) in SPL with RAM memory device support. The ROM code will load and execute
Signature · 1 line
1.9.1
PATCH v3 1/3 spl: Kconfig: dfu: spl-dfu depends on SPL_RAM_SUPPORT
Quoted 6 lines · Ravi
Since
SPL_DFU_SUPPORTis depends onSPL_RAM_SUPPORT, hence selectSPL_DFU_SUPPORTonly whenSPL_RAM_SUPPORTis chosen.Signed-off-by Ravi Babu <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170512/4ab5f056/attachment.sig>
PATCH v2 2/3 common: dfu: ignore reset for spl-dfu
In reply to Ravi BabuThe SPL-DFU feature enable to load and
execute u-boot from RAM over usb from
PC using dfu-util.
Hence dfu-reset should not be issued
when dfu-util -R switch is issued.
--- common/dfu.c | 2 +- common/spl/Kconfig | 4 ++++ drivers/dfu/dfu.c | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-)
common/dfu.c +1 -1
@@ -88,7 +88,7 @@ exit:board_usb_cleanup (usbctrl_index,USB_INIT_DEVICE );if (dfu_reset) -run_command ("reset" ,0 ); +do_reset (NULL ,0 ,0 ,NULL );g_dnl_clear_detach ();
common/spl/Kconfig +4 -0
@@ -6,6 +6,9 @@ config SUPPORT_SPL config SUPPORT_TPL bool +config SPL_DFU_NO_RESET + bool + config SPL bool depends on SUPPORT_SPL
@@ -646,6 +649,7 @@ config SPL_USBETH_SUPPORT config SPL_DFU_SUPPORT bool "Support DFU (Device Firmware Upgarde)" select SPL_HASH_SUPPORT + select SPL_DFU_NO_RESET depends on SPL_RAM_SUPPORT help This feature enables the DFU (Device Firmware Upgarde) in SPL with
drivers/dfu/dfu.c +4 -0
@@ -35,7 +35,11 @@ static struct hash_algo *dfu_hash_algo;*/ __weak bool dfu_usb_get_reset (void ) { +#ifdef CONFIG_SPL_DFU_NO_RESET +return false; +#else return true; +#endif }static int dfu_find_alt_num (const char *s)
Signature · 1 line
1.9.1
PATCH v2 2/3 common: dfu: ignore reset for spl-dfu
Quoted 7 lines · Ravi
The SPL-DFU feature enable to load and
execute u-boot from RAM over usb from
PC using dfu-util.
Hence dfu-reset should not be issued
when dfu-util -R switch is issued.Signed-off-by Ravi Babu <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170512/75fcc4d7/attachment.sig>
PATCH v3 3/3 spl: dfu: reduce spl-dfu MLO size
In reply to Ravi Babucompile out cli_hush.c for spl/dfu and
use cli_simple_run_command for dfu to
reduce the spl-dfu memory foot print.
Adding CONFIG_SPL_DFU_MMC to Kconfig and
use CONFIG_IS_ENABLED(DFU_MMC).
---
--- common/Makefile | 1 - drivers/dfu/Kconfig | 5 +++++ drivers/dfu/Makefile | 3 +++ drivers/dfu/dfu_mmc.c | 5 +++++ include/dfu.h | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-)
common/Makefile +0 -1
@@ -90,7 +90,6 @@ endif # !CONFIG_SPL_BUILD ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o -obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
drivers/dfu/Kconfig +5 -0
@@ -17,6 +17,11 @@ config DFU_MMC help This option enables using DFU to read and write to MMC based storage. +config SPL_DFU_MMC + bool "MMC back end for SPL-DFU" + help + This option enables DFU for SPL to read and write to MMC based storage. + config DFU_NAND bool "NAND back end for DFU" help
drivers/dfu/Makefile +3 -0
@@ -6,7 +6,10 @@ # obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o +ifndef CONFIG_SPL_BUILD obj-$(CONFIG_DFU_MMC) += dfu_mmc.o +endif +obj-$(CONFIG_SPL_DFU_MMC) += dfu_mmc.o obj-$(CONFIG_DFU_NAND) += dfu_nand.o obj-$(CONFIG_DFU_RAM) += dfu_ram.o obj-$(CONFIG_DFU_SF) += dfu_sf.o
drivers/dfu/dfu_mmc.c +5 -0
@@ -15,6 +15,7 @@#include <ext4fs.h> #include <fat.h> #include <mmc.h> +#include <cli.h> static unsigned char *dfu_file_buf;static long dfu_file_buf_len;
@@ -154,7 +155,11 @@ static int mmc_file_op(enum dfu_op op, struct dfu_entity *dfu,debug ("%s: %s 0x%p\n" , __func__, cmd_buf, cmd_buf); +#if CONFIG_IS_ENABLED (DFU_MMC ) + ret =cli_simple_run_command (cmd_buf,0 ); +#else ret =run_command (cmd_buf,0 ); +#endif if (ret) {puts ("dfu: Read error!\n" );return ret;
include/dfu.h +1 -1
@@ -203,7 +203,7 @@ static inline void dfu_set_defer_flush(struct dfu_entity *dfu)int dfu_write_from_mem_addr (struct dfu_entity *dfu,void *buf,int size);/* Device specific */ -#ifdef CONFIG_DFU_MMC +#if CONFIG_IS_ENABLED (DFU_MMC )extern int dfu_fill_entity_mmc (struct dfu_entity *dfu,char *devstr,char *s);#else static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr,
Signature · 1 line
1.9.1
PATCH v3 3/3 spl: dfu: reduce spl-dfu MLO size
Quoted 8 lines · Ravi Babu
compile out
cli_hush.cfor spl/dfu and
usecli_simple_run_commandfor dfu to
reduce the spl-dfu memory foot print.Adding
CONFIG_SPL_DFU_MMCtoKconfigand
useCONFIG_IS_ENABLED(DFU_MMC).Signed-off-by Ravi Babu <[email protected]>
[snip]
drivers/dfu/Makefile line 12
Quoted 12 lines
drivers/dfu/Makefile +3
-0@@ -6,7 +6,10 @@ # obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o +ifndef CONFIG_SPL_BUILD obj-$(CONFIG_DFU_MMC) += dfu_mmc.o +endif +obj-$(CONFIG_SPL_DFU_MMC) += dfu_mmc.o
This becomes obj-$(CONFIG_$(SPL_)DFU_MMC) += dfu_mmc.o
Quoted 4 lines
drivers/dfu/dfu_mmc.c +0
-0
[snip]
drivers/dfu/dfu_mmc.c static int mmc_file_op(enum dfu_op op, struct dfu_entity *dfu, · line 162
Quoted 9 lines
drivers/dfu/dfu_mmc.c +4
-0@@ -154,7 +155,11 @@ static int mmc_file_op(enum dfu_op op, struct dfu_entity *dfu,debug ("%s: %s 0x%p\n" , __func__, cmd_buf, cmd_buf); +#if CONFIG_IS_ENABLED (DFU_MMC ) + ret =cli_simple_run_command (cmd_buf,0 ); +#else ret =run_command (cmd_buf,0 ); +#endif
This doesn't make sense. CONFIG_IS_ENABLED(DFU_MMC) is true for CONFIG_DFU_MMC or CONFIG_SPL_DFU_MMC. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170504/7b818017/attachment.sig>
B
PATCH v3 3/3 spl: dfu: reduce spl-dfu MLO size
Hi Tom
Sorry for late response, some how missed this mail.
Quoted 17 lines
Review
Quoted 6 lines
obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o
(quoted diff) +3
-0+ifndef CONFIG_SPL_BUILD obj-$(CONFIG_DFU_MMC) += dfu_mmc.o +endif +obj-$(CONFIG_SPL_DFU_MMC) += dfu_mmc.oThis becomes obj-$(CONFIG_$(SPL_)DFU_MMC) += dfu_mmc.o
Quoted 4 lines
drivers/dfu/dfu_mmc.c index renamed from drivers/dfu/dfu_mmc.c +0
-0926ccbd..ba509db 100644
drivers/dfu/dfu_mmc.c +0
-0[snip]
Quoted 3 lines
drivers/dfu/dfu_mmc.c +0
-0@@ -154,7 +155,11 @@ static int mmc_file_op(enum dfu_op op, struct dfu_entity *dfu,
Quoted 8 lines
drivers/dfu/dfu_mmc.c static int mmc_file_op(enum dfu_op op, struct · line 162
Quoted 6 lines
drivers/dfu/dfu_mmc.c +3
-0debug ("%s: %s 0x%p\n" , __func__, cmd_buf, cmd_buf); +#if CONFIG_IS_ENABLED (DFU_MMC ) + ret =cli_simple_run_command (cmd_buf,0 );#else ret =run_command (cmd_buf,0 ); +#endif This doesn't make sense.
CONFIG_IS_ENABLED(DFU_MMC)is true forCONFIG_DFU_MMCorCONFIG_SPL_DFU_MMC. Thanks!
True, My bad, I realized it lately after posting the patch.
I will use run_command() only, which abstrace use of both simple_cli_xx() and hush_parser.
Since cli_hush.c is compile out for SPL to reduce the size. SPL must use simple_cli_xx().
Since by default CONFIG_HUSH_PARSER is defined for both SPL/U-BOOT, this leads to compile error. I need to fix this way.
common/cli.c +1 -1
@@ -28,7 +28,7 @@ DECLARE_GLOBAL_DATA_PTR;*/ int run_command (const char *cmd,int flag) { -#ifndef CONFIG_HUSH_PARSER +#if !defined(CONFIG_HUSH_PARSER ) || defined(CONFIG_SPL_BUILD )/* * cli_run_command can return 0 or 1 for success, so clean up * its result.
Is it ok, any other option ?
Regards
Ravi
PATCH v3 3/3 spl: dfu: reduce spl-dfu MLO size
Quoted 32 lines · Ravi
Hi Tom
Sorry for late response, some how missed this mail.
Quoted 17 lines
Review
Quoted 6 lines
obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o
(quoted diff) +3
-0+ifndef CONFIG_SPL_BUILD obj-$(CONFIG_DFU_MMC) += dfu_mmc.o +endif +obj-$(CONFIG_SPL_DFU_MMC) += dfu_mmc.oThis becomes obj-$(CONFIG_$(SPL_)DFU_MMC) += dfu_mmc.o
Quoted 4 lines
drivers/dfu/dfu_mmc.c index renamed from drivers/dfu/dfu_mmc.c +0
-0926ccbd..ba509db 100644
drivers/dfu/dfu_mmc.c +0
-0[snip]
Quoted 3 lines
drivers/dfu/dfu_mmc.c +0
-0@@ -154,7 +155,11 @@ static int mmc_file_op(enum dfu_op op, struct dfu_entity *dfu,Quoted 8 lines
drivers/dfu/dfu_mmc.c static int mmc_file_op(enum dfu_op op, struct · line 162
Quoted 6 lines
drivers/dfu/dfu_mmc.c +3
-0debug ("%s: %s 0x%p\n" , __func__, cmd_buf, cmd_buf); +#if CONFIG_IS_ENABLED (DFU_MMC ) + ret =cli_simple_run_command (cmd_buf,0 );#else ret =run_command (cmd_buf,0 ); +#endif This doesn't make sense.
CONFIG_IS_ENABLED(DFU_MMC)is true forCONFIG_DFU_MMCorCONFIG_SPL_DFU_MMC. Thanks!True, My bad, I realized it lately after posting the patch.
Quoted 7 lines
I will use
run_command()only, which abstrace use of bothsimple_cli_xx()andhush_parser.Since
cli_hush.cis compile out for SPL to reduce the size. SPL must usesimple_cli_xx().
Since by defaultCONFIG_HUSH_PARSERis defined for both SPL/U-BOOT, this leads to compile error. I need to fix this way.
We keep running into problems due to trying to whack in what to do in DFU via command rather than via API. Can you make an attempt to convert things over, in both SPL and not SPL, in DFU to using ABI instead, to see if we can get the size reduction here still, and not have to try and put fragile to other use cases ifdefs in common code? Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170513/ecd7dfcb/attachment.sig>
B
PATCH v3 3/3 spl: dfu: reduce spl-dfu MLO size
Hi Tom
Quoted 30 lines
Quoted 30 lines
Quoted 16 lines
Review
Quoted 5 lines
obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o
(quoted diff) +3
-0+ifndef CONFIG_SPL_BUILD obj-$(CONFIG_DFU_MMC) += dfu_mmc.o +endif +obj-$(CONFIG_SPL_DFU_MMC) += dfu_mmc.oThis becomes obj-$(CONFIG_$(SPL_)DFU_MMC) += dfu_mmc.o
Quoted 4 lines
drivers/dfu/dfu_mmc.c index renamed from drivers/dfu/dfu_mmc.c +0
-0926ccbd..ba509db 100644
drivers/dfu/dfu_mmc.c +0
-0[snip]
Quoted 3 lines
drivers/dfu/dfu_mmc.c +0
-0@@ -154,7 +155,11 @@ static int mmc_file_op(enum dfu_op op, struct dfu_entity *dfu,Quoted 8 lines
drivers/dfu/dfu_mmc.c static int mmc_file_op(enum dfu_op op, struct · line 162
Quoted 6 lines
drivers/dfu/dfu_mmc.c +3
-0debug ("%s: %s 0x%p\n" , __func__, cmd_buf, cmd_buf); +#if CONFIG_IS_ENABLED (DFU_MMC ) + ret =cli_simple_run_command (cmd_buf,0 );#else ret =run_command (cmd_buf,0 ); +#endif This doesn't make sense.
CONFIG_IS_ENABLED(DFU_MMC)is true forCONFIG_DFU_MMCorCONFIG_SPL_DFU_MMC. Thanks!True, My bad, I realized it lately after posting the patch.
I will use
run_command()only, which abstrace use of bothsimple_cli_xx()andhush_parser.
Quoted 6 lines
Quoted 4 lines
Since
cli_hush.cis compile out for SPL to reduce the size. SPL must usesimple_cli_xx().
Since by defaultCONFIG_HUSH_PARSERis defined for both SPL/U-BOOT, this leads to compile error. I need to fix this way.We keep running into problems due to trying to whack in what to do in DFU via command rather than via API. Can you make an attempt to convert things over, in both SPL and not SPL, in DFU to using ABI instead, to see if we can get the size reduction here still, and >not have to try and put fragile to other use cases ifdefs in common code? Thanks!
Use of direct mmc read/write API instead of using the run_command() is not feasible in this case. As the DFU does read/write to mmc through fat/ext4 files system, uses "fatload/fatwrite" or "ext4load/ext4write" command to perform read/write to specific partition of mmc device. I think use of run_command() is more appropriate.
Regards
Ravi
PATCH v3 3/3 spl: dfu: reduce spl-dfu MLO size
Quoted 32 lines · Ravi
Hi Tom
Quoted 30 lines
Quoted 30 lines
Quoted 16 lines
Review
Quoted 5 lines
obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o
(quoted diff) +3
-0+ifndef CONFIG_SPL_BUILD obj-$(CONFIG_DFU_MMC) += dfu_mmc.o +endif +obj-$(CONFIG_SPL_DFU_MMC) += dfu_mmc.oThis becomes obj-$(CONFIG_$(SPL_)DFU_MMC) += dfu_mmc.o
Quoted 4 lines
drivers/dfu/dfu_mmc.c index renamed from drivers/dfu/dfu_mmc.c +0
-0926ccbd..ba509db 100644
drivers/dfu/dfu_mmc.c +0
-0[snip]
Quoted 3 lines
drivers/dfu/dfu_mmc.c +0
-0@@ -154,7 +155,11 @@ static int mmc_file_op(enum dfu_op op, struct dfu_entity *dfu,Quoted 8 lines
drivers/dfu/dfu_mmc.c static int mmc_file_op(enum dfu_op op, struct · line 162
Quoted 6 lines
drivers/dfu/dfu_mmc.c +3
-0debug ("%s: %s 0x%p\n" , __func__, cmd_buf, cmd_buf); +#if CONFIG_IS_ENABLED (DFU_MMC ) + ret =cli_simple_run_command (cmd_buf,0 );#else ret =run_command (cmd_buf,0 ); +#endif This doesn't make sense.
CONFIG_IS_ENABLED(DFU_MMC)is true forCONFIG_DFU_MMCorCONFIG_SPL_DFU_MMC. Thanks!True, My bad, I realized it lately after posting the patch.
I will use
run_command()only, which abstrace use of bothsimple_cli_xx()andhush_parser.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Since
cli_hush.cis compile out for SPL to reduce the size. SPL must usesimple_cli_xx().
Since by defaultCONFIG_HUSH_PARSERis defined for both SPL/U-BOOT, this leads to compile error. I need to fix this way.We keep running into problems due to trying to whack in what to do in DFU via command rather than via API. Can you make an attempt to convert things over, in both SPL and not SPL, in DFU to using ABI instead, to see if we can get the size reduction here still, and >not have to try and put fragile to other use cases ifdefs in common code? Thanks!
Use of direct mmc read/write API instead of using the
run_command()is not feasible in this case. As the DFU does read/write to mmc through fat/ext4 files system, uses "fatload/fatwrite" or "ext4load/ext4write" command to perform read/write to specific partition of mmc device. I think use ofrun_command()is more appropriate.
OK. Can you go back to https://patchwork.ozlabs.org/patch/758485/ and clean that up as I was saying? We should be able to call cli_simple_run_command in all cases and then not need cli_hush.c, yes? And we can then move common/cli.c into being compiled only in the non-SPL case I think (but use travis-ci to confirm). Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170524/9a99105b/attachment.sig>
B
PATCH v3 3/3 spl: dfu: reduce spl-dfu MLO size
Hi Tom
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 1 line
This doesn't make sense.
CONFIG_IS_ENABLED(DFU_MMC)is true forCONFIG_DFU_MMCorCONFIG_SPL_DFU_MMC. Thanks!True, My bad, I realized it lately after posting the patch.
I will use
run_command()only, which abstrace use of bothsimple_cli_xx()andhush_parser.Since
cli_hush.cis compile out for SPL to reduce the size. SPL must usesimple_cli_xx().
Since by defaultCONFIG_HUSH_PARSERis defined for both SPL/U-BOOT, this leads to compile error. I need to fix this way.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
We keep running into problems due to trying to whack in what to do in DFU via command rather than via API. Can you make an attempt to convert things over, in both SPL and not SPL, in DFU to using ABI instead, to see if we can get the size reduction here still, >and >not have to try and put fragile to other use cases ifdefs in common code? Thanks!
Use of direct mmc read/write API instead of using the
run_command()is not feasible in this case. As the DFU does read/write to mmc through fat/ext4 files system, uses "fatload/fatwrite" or "ext4load/ext4write" command to perform read/write to specific >partition of mmc device. I think use ofrun_command()is more appropriate.OK. Can you go back to https://patchwork.ozlabs.org/patch/758485/ and clean that up as I was saying? We should be able to call
cli_simple_run_commandin all cases and then not needcli_hush.c, yes? And we can then movecommon/cli.cinto being compiled only in the non-SPL case I think (but use travis-ci to confirm). Thanks!
Ok, will do. Thanks.
In latest mainline, dfu has broken due to commit 1a9a5f7a: usb: host: xhci-omap: fix double weak board_usb_init functions. Due to this DFU gadget mode fails, due to weak board_usb_init() gets called which does not initialize the usb controller. I will fix this as well and send the patch.
Regards
Ravi