[U-Boot-Users] [PATCH] make y-modem a separate config option

Anders Larsen al at alarsen.net
Thu Jul 6 17:16:34 CEST 2006


Hi,

the loady command (which was introduced this april) bloats the size of
U-Boot by almost 4K on my at91 board.
The patch below introduces a new option CFG_CMD_LOADY, which can be
disabled separately from CFG_CMD_LOADB to save precious space
(loadb + loady together take up about 2.5 times as much code space as
loadb alone).

Perhaps CFG_CMD_LOADY should even be added to CFG_CMD_NONSTD for this
reason?

Cheers
 Anders

Signed-off-by: Anders Larsen <al at alarsen.net>

CHANGELOG:
  Optionally disable the y-modem protocol
  Patch by Anders Larsen <al at alarsen.net>, 6 Jul 2006
---

 common/cmd_load.c      |   28 +++++++++++++++-------------
 include/cmd_confdefs.h |    1 +
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/common/cmd_load.c b/common/cmd_load.c
index f63b8e8..5f06129 100644
--- a/common/cmd_load.c
+++ b/common/cmd_load.c
@@ -33,7 +33,7 @@ #include <xyzModem.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if (CONFIG_COMMANDS & CFG_CMD_LOADB)
+#if (CONFIG_COMMANDS & CFG_CMD_LOADY)
 static ulong load_serial_ymodem (ulong offset);
 #endif
 
@@ -404,7 +404,7 @@ # endif /* CFG_CMD_SAVES */
 #endif	/* CFG_CMD_LOADS */
 
 
-#if (CONFIG_COMMANDS & CFG_CMD_LOADB)  /* loadb command (load binary) included */
+#if (CONFIG_COMMANDS & (CFG_CMD_LOADB | CFG_CMD_LOADY))  /* loadb command (load binary) included */
 
 #define XON_CHAR        17
 #define XOFF_CHAR       19
@@ -476,16 +476,7 @@ int do_load_serial_bin (cmd_tbl_t *cmdtp
 		}
 	}
 
-	if (strcmp(argv[0],"loady")==0) {
-		printf ("## Ready for binary (ymodem) download "
-			"to 0x%08lX at %d bps...\n",
-			offset,
-			load_baudrate);
-
-		addr = load_serial_ymodem (offset);
-
-	} else {
-
+	if (strcmp(argv[0],"loadb")==0) {
 		printf ("## Ready for binary (kermit) download "
 			"to 0x%08lX at %d bps...\n",
 			offset,
@@ -500,6 +491,15 @@ int do_load_serial_bin (cmd_tbl_t *cmdtp
 			printf ("## Start Addr      = 0x%08lX\n", addr);
 			load_addr = addr;
 		}
+#if (CONFIG_COMMANDS & CFG_CMD_LOADY)
+	} else {
+		printf ("## Ready for binary (ymodem) download "
+			"to 0x%08lX at %d bps...\n",
+			offset,
+			load_baudrate);
+
+		addr = load_serial_ymodem (offset);
+#endif
 	}
 	if (load_baudrate != current_baudrate) {
 		printf ("## Switch baudrate to %d bps and press ESC ...\n",
@@ -1086,7 +1086,7 @@ #endif	/* CFG_CMD_SAVES */
 #endif	/* CFG_CMD_LOADS */
 
 
-#if (CONFIG_COMMANDS & CFG_CMD_LOADB)
+#if (CONFIG_COMMANDS & (CFG_CMD_LOADB | CFG_CMD_LOADY))
 U_BOOT_CMD(
 	loadb, 3, 0,	do_load_serial_bin,
 	"loadb   - load binary file over serial line (kermit mode)\n",
@@ -1095,6 +1095,7 @@ U_BOOT_CMD(
 	" with offset 'off' and baudrate 'baud'\n"
 );
 
+#if (CONFIG_COMMANDS & CFG_CMD_LOADY)
 U_BOOT_CMD(
 	loady, 3, 0,	do_load_serial_bin,
 	"loady   - load binary file over serial line (ymodem mode)\n",
@@ -1102,6 +1103,7 @@ U_BOOT_CMD(
 	"    - load binary file over serial line"
 	" with offset 'off' and baudrate 'baud'\n"
 );
+#endif	/* CFG_CMD_LOADY */
 
 #endif	/* CFG_CMD_LOADB */
 
diff --git a/include/cmd_confdefs.h b/include/cmd_confdefs.h
index cf36583..ab596cd 100644
--- a/include/cmd_confdefs.h
+++ b/include/cmd_confdefs.h
@@ -75,6 +75,7 @@ #define CFG_CMD_DIAG	0x0000008000000000U
 #define CFG_CMD_FPGA	0x0000010000000000ULL	/* FPGA configuration Support	*/
 #define CFG_CMD_HWFLOW	0x0000020000000000ULL	/* RTS/CTS hw flow control	*/
 #define CFG_CMD_SAVES	0x0000040000000000ULL	/* save S record dump		*/
+#define CFG_CMD_LOADY	0x0000080000000000ULL	/* loady (implies loadb)	*/
 #define CFG_CMD_SPI	0x0000100000000000ULL	/* SPI utility			*/
 #define CFG_CMD_FDOS	0x0000200000000000ULL	/* Floppy DOS support		*/
 #define CFG_CMD_VFD	0x0000400000000000ULL	/* VFD support (TRAB)		*/






More information about the U-Boot mailing list