Skip to contentSkip to conversation

Fix SPL build without CONFIG_SPL_SERIAL_SUPPORT

PATCH New Alex Kiernan 2 participants 17 messages Apr 19, 2018 – Apr 29, 2018

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v2 cover Fix SPL build without CONFIG_SPL_SERIAL_SUPPORT

Attempting to build SPL without CONFIG_SPL_SERIAL_SUPPORT defined fails in assorted ways. This series fixes up those failures.

Green Travis build:

https://travis-ci.org/akiernan/u-boot/builds/368288275

Changes in v2:
- Rebase against master
- Update Travis build URL
- Introduce default y PRINTF/SPRINTF/STRTO symbol so CONFIG_IS_ENABLED works without any additional ifdefs
- Remove ifdef dance with SPL/TPL now PRINTF exists as its own symbol
- Guard select if SPL/TPL_{SPRINTF,STRTO} symbols with SPL/TPL

Alex Kiernan (8):
Cleanup CONFIG_SPL_SERIAL_SUPPORT migration
spl: ti: Avoid preloader_console_init if !CONFIG_SPL_SERIAL_SUPPORT
spl: Add dependency on serial to Ymodem
spl: ti: Avoid serial calls when serial support is disabled
spl: Split sprintf, strto* from SPL serial in Kconfig
spl: Disable printf if not required
Consolidate __assert_failed into one implementation
spl: disk: usb: Add dependencies to sprintf/strto*

 arch/arm/mach-omap2/boot-common.c               |  3 ++-
 board/ti/am335x/board.c                         |  2 ++
 common/spl/Kconfig                              |  6 +++++
 common/spl/spl.c                                |  2 ++
 configs/controlcenterdc_defconfig               |  1 +
 configs/ls1021aiot_sdcard_defconfig             |  1 +
 configs/ls1046aqds_nand_defconfig               |  1 +
 configs/ls1046aqds_sdcard_ifc_defconfig         |  1 +
 configs/ls1046aqds_sdcard_qspi_defconfig        |  1 +
 configs/ls1046ardb_emmc_defconfig               |  1 +
 configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig |  1 +
 configs/ls1046ardb_sdcard_defconfig             |  1 +
 disk/Kconfig                                    |  4 +++
 drivers/usb/musb-new/Kconfig                    |  4 +++
 include/configs/controlcenterdc.h               |  1 -
 include/configs/ls1021aiot.h                    |  1 -
 include/configs/ls1046a_common.h                |  2 --
 lib/Kconfig                                     | 34 +++++++++++++++++++++++++
 lib/Makefile                                    | 15 +++++------
 lib/panic.c                                     | 10 ++++++++
 lib/tiny-printf.c                               | 21 +++++----------
 lib/vsprintf.c                                  | 11 ++------
 22 files changed, 87 insertions(+), 37 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/8 Cleanup CONFIG_SPL_SERIAL_SUPPORT migration

CONFIG_SPL_SERIAL_SUPPORT had already been migrated to Kconfig, but existed in some include files; fix those up here.

---

Changes in v2:
- Rebase against master
- Update Travis build URL

 configs/controlcenterdc_defconfig               | 1 +
 configs/ls1021aiot_sdcard_defconfig             | 1 +
 configs/ls1046aqds_nand_defconfig               | 1 +
 configs/ls1046aqds_sdcard_ifc_defconfig         | 1 +
 configs/ls1046aqds_sdcard_qspi_defconfig        | 1 +
 configs/ls1046ardb_emmc_defconfig               | 1 +
 configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig | 1 +
 configs/ls1046ardb_sdcard_defconfig             | 1 +
 include/configs/controlcenterdc.h               | 1 -
 include/configs/ls1021aiot.h                    | 1 -
 include/configs/ls1046a_common.h                | 2 --
 11 files changed, 8 insertions(+), 4 deletions(-)
configs/controlcenterdc_defconfig +1 -0
index 5fe18c6..92d289e 100644
@@ -4,6 +4,7 @@ CONFIG_SYS_TEXT_BASE=0x00800000
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_TARGET_CONTROLCENTERDC=y
+CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_SPL=y
configs/ls1021aiot_sdcard_defconfig +1 -0
index 59592db..a34cb52 100644
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_TARGET_LS1021AIOT=y
 CONFIG_SYS_TEXT_BASE=0x82000000
+CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="ls1021a-iot-duart"
 CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT_PBL,SPL_FSL_PBL,SD_BOOT,SD_BOOT_QSPI"
configs/ls1046aqds_nand_defconfig +1 -0
index 1d40a14..3a5c001 100644
@@ -2,6 +2,7 @@ CONFIG_ARM=y
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_FSL_LS_PPA=y
+CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1046a-qds-duart"
 CONFIG_DISTRO_DEFAULTS=y
configs/ls1046aqds_sdcard_ifc_defconfig +1 -0
index 4d0907c..2c5a9e9 100644
@@ -2,6 +2,7 @@ CONFIG_ARM=y
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_FSL_LS_PPA=y
+CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1046a-qds-duart"
 CONFIG_DISTRO_DEFAULTS=y
configs/ls1046aqds_sdcard_qspi_defconfig +1 -0
index 8467148..66ddc35 100644
@@ -2,6 +2,7 @@ CONFIG_ARM=y
 CONFIG_TARGET_LS1046AQDS=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_FSL_LS_PPA=y
+CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1046a-qds-duart"
 CONFIG_DISTRO_DEFAULTS=y
configs/ls1046ardb_emmc_defconfig +1 -0
index 3ca8f16..97de7b1 100644
@@ -2,6 +2,7 @@ CONFIG_ARM=y
 CONFIG_TARGET_LS1046ARDB=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_FSL_LS_PPA=y
+CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1046a-rdb"
 CONFIG_DISTRO_DEFAULTS=y
configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig +1 -0
index ee6320f..dfa0f01 100644
@@ -3,6 +3,7 @@ CONFIG_TARGET_LS1046ARDB=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_SECURE_BOOT=y
 CONFIG_FSL_LS_PPA=y
+CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1046a-rdb"
 CONFIG_DISTRO_DEFAULTS=y
configs/ls1046ardb_sdcard_defconfig +1 -0
index 0fa6fa4..5a33dc6 100644
@@ -2,6 +2,7 @@ CONFIG_ARM=y
 CONFIG_TARGET_LS1046ARDB=y
 CONFIG_SYS_TEXT_BASE=0x82000000
 CONFIG_FSL_LS_PPA=y
+CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1046a-rdb"
 CONFIG_DISTRO_DEFAULTS=y
include/configs/controlcenterdc.h +0 -1
index b6d15f6..89e57301 100644
@@ -112,7 +112,6 @@
 
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBGENERIC_SUPPORT
-#define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
 
 #if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SPI_NOR_FLASH
include/configs/ls1021aiot.h +0 -1
index f2a6837..dc1206f 100644
@@ -67,7 +67,6 @@
 #define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
 #define CONFIG_SPL_WATCHDOG_SUPPORT
-#define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	0xe8
 
include/configs/ls1046a_common.h +0 -2
index b9424e6..2851c84 100644
@@ -67,7 +67,6 @@
 #define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
 #define CONFIG_SPL_WATCHDOG_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
-#define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_DRIVERS_MISC_SUPPORT
 
 #define CONFIG_SPL_MMC_SUPPORT
@@ -104,7 +103,6 @@
 #define CONFIG_SPL_ENV_SUPPORT
 #define CONFIG_SPL_WATCHDOG_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
-#define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
 
 #define CONFIG_SPL_NAND_SUPPORT
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/8 Cleanup CONFIG_SPL_SERIAL_SUPPORT migration

Quoted 4 lines · Alex Kiernan

CONFIG_SPL_SERIAL_SUPPORT had already been migrated to Kconfig, but existed in some include files; fix those up here.

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: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180429/4639accc/attachment.sig>
#3 lore raw

PATCH v2 2/8 spl: ti: Avoid preloader_console_init if !CONFIG_SPL_SERIAL_SUPPORT

In reply to Alex Kiernan

If CONFIG_SPL_SERIAL_SUPPORT is disabled then the build fails because serial_init is undefined. Guard preloader_console_init() appropriately to fix this.

---

Changes in v2: None

 arch/arm/mach-omap2/boot-common.c | 3 ++-
 common/spl/spl.c                  | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
arch/arm/mach-omap2/boot-common.c +2 -1
index db68a9d..f9ab5da 100644
@@ -196,9 +196,10 @@ u32 spl_boot_mode(const u32 boot_device)
 
 void spl_board_init(void)
 {
+#ifdef CONFIG_SPL_SERIAL_SUPPORT
 	/* Prepare console output */
 	preloader_console_init();
-
+#endif
 #if defined(CONFIG_SPL_NAND_SUPPORT) || defined(CONFIG_SPL_ONENAND_SUPPORT)
 	gpmc_init();
 #endif
common/spl/spl.c +2 -0
index 61d3071..794dbd0 100644
@@ -471,6 +471,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	jump_to_image_no_args(&spl_image);
 }
 
+#ifdef CONFIG_SPL_SERIAL_SUPPORT
 /*
  * This requires UART clocks to be enabled.  In order for this to work the
  * caller must ensure that the gd pointer is valid.
@@ -491,6 +492,7 @@ void preloader_console_init(void)
 	spl_display_print();
 #endif
 }
+#endif
 
 /**
  * spl_relocate_stack_gd() - Relocate stack ready for board_init_r() execution
Signature · 1 line
2.7.4
#4 lore raw

PATCH v2 2/8 spl: ti: Avoid preloader_console_init if !CONFIG_SPL_SERIAL_SUPPORT

Quoted 5 lines · Alex Kiernan

If CONFIG_SPL_SERIAL_SUPPORT is disabled then the build fails because serial_init is undefined. Guard preloader_console_init() appropriately to fix this.

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: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180429/09b06f21/attachment.sig>
#5 lore raw

PATCH v2 3/8 spl: Add dependency on serial to Ymodem

In reply to Alex Kiernan

Building with Ymodem support requires serial in SPL/TPL, add that dependency here.

---

Changes in v2: None

 common/spl/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
common/spl/Kconfig +2 -0
index 4d27565..c5d4b5e 100644
@@ -751,6 +751,7 @@ config SPL_WATCHDOG_SUPPORT
 
 config SPL_YMODEM_SUPPORT
 	bool "Support loading using Ymodem"
+	depends on SPL_SERIAL_SUPPORT
 	help
 	  While loading from serial is slow it can be a useful backup when
 	  there is no other option. The Ymodem protocol provides a reliable
@@ -951,6 +952,7 @@ config TPL_SPI_SUPPORT
 
 config TPL_YMODEM_SUPPORT
 	bool "Support loading using Ymodem"
+	depends on TPL_SERIAL_SUPPORT
 	help
 	  While loading from serial is slow it can be a useful backup when
 	  there is no other option. The Ymodem protocol provides a reliable
Signature · 1 line
2.7.4
#6 lore raw

PATCH v2 3/8 spl: Add dependency on serial to Ymodem

Quoted 4 lines · Alex Kiernan

Building with Ymodem support requires serial in SPL/TPL, add that dependency here.

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: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180429/33a0a980/attachment.sig>
#7 lore raw

PATCH v2 4/8 spl: ti: Avoid serial calls when serial support is disabled

In reply to Alex Kiernan

If CONFIG_SPL_SERIAL_SUPPORT is not set, then the build will fail:

board/ti/am335x/built-in.o: In function `spl_start_uboot':
board/ti/am335x/board.c:247: undefined reference to serial_tstc' board/ti/am335x/board.c:247: undefined reference to serial_getc'

Avoid the calls to the serial functions in that case.

---

Changes in v2: None

 board/ti/am335x/board.c | 2 ++
 1 file changed, 2 insertions(+)
board/ti/am335x/board.c +2 -0
index c33bf58..896b9b6 100644
@@ -243,9 +243,11 @@ static struct emif_regs ddr3_icev2_emif_reg_data = {
 #ifdef CONFIG_SPL_OS_BOOT
 int spl_start_uboot(void)
 {
+#ifdef CONFIG_SPL_SERIAL_SUPPORT
 	/* break into full u-boot on 'c' */
 	if (serial_tstc() && serial_getc() == 'c')
 		return 1;
+#endif
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
Signature · 1 line
2.7.4
#8 lore raw

PATCH v2 4/8 spl: ti: Avoid serial calls when serial support is disabled

Quoted 9 lines · Alex Kiernan

If CONFIG_SPL_SERIAL_SUPPORT is not set, then the build will fail:

board/ti/am335x/built-in.o: In function `spl_start_uboot':
board/ti/am335x/board.c:247: undefined reference to serial_tstc' board/ti/am335x/board.c:247: undefined reference to serial_getc'

Avoid the calls to the serial functions in that case.

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: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180429/ba65c593/attachment.sig>
#9 lore raw

PATCH v2 5/8 spl: Split sprintf, strto* from SPL serial in Kconfig

In reply to Alex Kiernan

When SPL serial is disabled, callers who need sprintf or strtoul fail because their inclusion is guarded by CONFIG_SPL_SERIAL_SUPPORT/ CONFIG_TPL_SERIAL_SUPPORT.

Split printf, sprintf and strto into their own entries and then select all of them if SERIAL_SUPPORT is enabled to match the current behaviour.

Include panic.o unconditionally as it can be called from anywhere which uses BUG_ON().

---

Changes in v2:
- Introduce default y PRINTF/SPRINTF/STRTO symbol so CONFIG_IS_ENABLED works without any additional ifdefs

 common/spl/Kconfig |  4 ++++
 lib/Kconfig        | 34 ++++++++++++++++++++++++++++++++++
 lib/Makefile       | 15 ++++++---------
 3 files changed, 44 insertions(+), 9 deletions(-)
common/spl/Kconfig +4 -0
index c5d4b5e..259f966 100644
@@ -626,6 +626,8 @@ config SPL_SATA_SUPPORT
 
 config SPL_SERIAL_SUPPORT
 	bool "Support serial"
+	select SPL_PRINTF
+	select SPL_STRTO
 	help
 	  Enable support for serial in SPL. This allows use of a serial UART
 	  for displaying messages while SPL is running. It also brings in
@@ -927,6 +929,8 @@ config TPL_RAM_DEVICE
 
 config TPL_SERIAL_SUPPORT
 	bool "Support serial"
+	select TPL_PRINTF
+	select TPL_STRTO
 	help
 	  Enable support for serial in TPL. See SPL_SERIAL_SUPPORT for
 	  details.
lib/Kconfig +34 -0
index 436b90f..33fb067 100644
@@ -27,6 +27,40 @@ config HAVE_PRIVATE_LIBGCC
 config LIB_UUID
 	bool
 
+config PRINTF
+	bool
+	default y
+
+config SPL_PRINTF
+	bool
+	select SPL_SPRINTF
+	select SPL_STRTO if !USE_TINY_PRINTF
+
+config TPL_PRINTF
+	bool
+	select TPL_SPRINTF
+	select TPL_STRTO if !USE_TINY_PRINTF
+
+config SPRINTF
+	bool
+	default y
+
+config SPL_SPRINTF
+	bool
+
+config TPL_SPRINTF
+	bool
+
+config STRTO
+	bool
+	default y
+
+config SPL_STRTO
+	bool
+
+config TPL_STRTO
+	bool
+
 config USE_PRIVATE_LIBGCC
 	bool "Use private libgcc"
 	depends on HAVE_PRIVATE_LIBGCC
lib/Makefile +6 -9
index 35da570..13be8f4 100644
@@ -88,22 +88,19 @@ obj-y += time.o
 obj-$(CONFIG_TRACE) += trace.o
 obj-$(CONFIG_LIB_UUID) += uuid.o
 obj-$(CONFIG_LIB_RAND) += rand.o
+obj-y += panic.o
 
-ifdef CONFIG_SPL_BUILD
-ifdef CONFIG_TPL_BUILD
-SERIAL_SUPPORT := $(CONFIG_TPL_SERIAL_SUPPORT)
-else
-SERIAL_SUPPORT := $(CONFIG_SPL_SERIAL_SUPPORT)
-endif
+ifeq ($(CONFIG_$(SPL_TPL_)BUILD),y)
 # SPL U-Boot may use full-printf, tiny-printf or none at all
 ifdef CONFIG_USE_TINY_PRINTF
-obj-$(SERIAL_SUPPORT) += tiny-printf.o panic.o strto.o
+obj-$(CONFIG_$(SPL_TPL_)SPRINTF) += tiny-printf.o
 else
-obj-$(SERIAL_SUPPORT) += vsprintf.o panic.o strto.o strmhz.o
+obj-$(CONFIG_$(SPL_TPL_)SPRINTF) += vsprintf.o strmhz.o
 endif
+obj-$(CONFIG_$(SPL_TPL_)STRTO) += strto.o
 else
 # Main U-Boot always uses the full printf support
-obj-y += vsprintf.o panic.o strto.o strmhz.o
+obj-y += vsprintf.o strto.o strmhz.o
 endif
 
 subdir-ccflags-$(CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED) += -O2
Signature · 1 line
2.7.4
#10 lore raw

PATCH v2 5/8 spl: Split sprintf, strto* from SPL serial in Kconfig

Quoted 11 lines · Alex Kiernan

When SPL serial is disabled, callers who need sprintf or strtoul fail because their inclusion is guarded by CONFIG_SPL_SERIAL_SUPPORT/ CONFIG_TPL_SERIAL_SUPPORT.

Split printf, sprintf and strto into their own entries and then select all of them if SERIAL_SUPPORT is enabled to match the current behaviour.

Include panic.o unconditionally as it can be called from anywhere which uses BUG_ON().

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: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180429/8f5129ed/attachment.sig>
#11 lore raw

PATCH v2 6/8 spl: Disable printf if not required

In reply to Alex Kiernan

Now we have a guard for printf, disable it in the build if it's not selected.

---

Changes in v2:
- Remove ifdef dance with SPL/TPL now PRINTF exists as its own symbol

 lib/panic.c       |  2 ++
 lib/tiny-printf.c | 12 +++++++-----
 lib/vsprintf.c    |  3 ++-
 3 files changed, 11 insertions(+), 6 deletions(-)
lib/panic.c +2 -0
index e2b8b74..0efa134 100644
@@ -37,9 +37,11 @@ void panic_str(const char *str)
 
 void panic(const char *fmt, ...)
 {
+#if CONFIG_IS_ENABLED(PRINTF)
 	va_list args;
 	va_start(args, fmt);
 	vprintf(fmt, args);
 	va_end(args);
+#endif
 	panic_finish();
 }
lib/tiny-printf.c +7 -5
index 0b04813..e29377e 100644
@@ -23,11 +23,6 @@ struct printf_info {
 	void (*putc)(struct printf_info *info, char ch);
 };
 
-static void putc_normal(struct printf_info *info, char ch)
-{
-	putc(ch);
-}
-
 static void out(struct printf_info *info, char c)
 {
 	*info->bf++ = c;
@@ -321,6 +316,12 @@ abort:
 	return 0;
 }
 
+#if CONFIG_IS_ENABLED(PRINTF)
+static void putc_normal(struct printf_info *info, char ch)
+{
+	putc(ch);
+}
+
 int vprintf(const char *fmt, va_list va)
 {
 	struct printf_info info;
@@ -343,6 +344,7 @@ int printf(const char *fmt, ...)
 
 	return ret;
 }
+#endif
 
 static void putc_outstr(struct printf_info *info, char ch)
 {
lib/vsprintf.c +2 -1
index 5f7a5f1..9f0ce8a 100644
@@ -783,6 +783,7 @@ int sprintf(char *buf, const char *fmt, ...)
 	return i;
 }
 
+#if CONFIG_IS_ENABLED(PRINTF)
 int printf(const char *fmt, ...)
 {
 	va_list args;
@@ -824,7 +825,7 @@ int vprintf(const char *fmt, va_list args)
 	puts(printbuffer);
 	return i;
 }
-
+#endif
 
 void __assert_fail(const char *assertion, const char *file, unsigned line,
 		   const char *function)
Signature · 1 line
2.7.4
#12 lore raw

PATCH v2 6/8 spl: Disable printf if not required

Quoted 4 lines · Alex Kiernan

Now we have a guard for printf, disable it in the build if it's not selected.

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: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180429/3a3e33a5/attachment.sig>
#13 lore raw

PATCH v2 7/8 Consolidate __assert_failed into one implementation

In reply to Alex Kiernan

We had two implementations of __assert_failed which were almost identical, combine them into one.

---

Changes in v2: None

 lib/panic.c       | 8 ++++++++
 lib/tiny-printf.c | 9 ---------
 lib/vsprintf.c    | 8 --------
 3 files changed, 8 insertions(+), 17 deletions(-)
lib/panic.c +8 -0
index 0efa134..bae8a35 100644
@@ -45,3 +45,11 @@ void panic(const char *fmt, ...)
 #endif
 	panic_finish();
 }
+
+void __assert_fail(const char *assertion, const char *file, unsigned int line,
+		   const char *function)
+{
+	/* This will not return */
+	panic("%s:%u: %s: Assertion `%s' failed.", file, line, function,
+	      assertion);
+}
lib/tiny-printf.c +0 -9
index e29377e..5f7e27d 100644
@@ -383,12 +383,3 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
 
 	return ret;
 }
-
-void __assert_fail(const char *assertion, const char *file, unsigned line,
-		   const char *function)
-{
-	/* This will not return */
-	printf("%s:%u: %s: Assertion `%s' failed.", file, line, function,
-	       assertion);
-	hang();
-}
lib/vsprintf.c +0 -8
index 9f0ce8a..8514f50 100644
@@ -827,14 +827,6 @@ int vprintf(const char *fmt, va_list args)
 }
 #endif
 
-void __assert_fail(const char *assertion, const char *file, unsigned line,
-		   const char *function)
-{
-	/* This will not return */
-	panic("%s:%u: %s: Assertion `%s' failed.", file, line, function,
-	      assertion);
-}
-
 char *simple_itoa(ulong i)
 {
 	/* 21 digits plus null terminator, good for 64-bit or smaller ints */
Signature · 1 line
2.7.4
#14 lore raw

PATCH v2 7/8 Consolidate __assert_failed into one implementation

Quoted 4 lines · Alex Kiernan

We had two implementations of __assert_failed which were almost identical, combine them into one.

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: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180429/e876b341/attachment.sig>
#15 lore raw

PATCH v2 8/8 spl: disk: usb: Add dependencies to sprintf/strto*

In reply to Alex Kiernan

If SPL serial support is disabled nothing brings in sprintf, snprintf or simple_strtoul:

env/built-in.o: In function `regex_callback':
env/attr.c:128: undefined reference to sprintf' disk/built-in.o: In function blk_get_device_by_str':
disk/part.c:386: undefined reference to simple_strtoul' disk/part.c:395: undefined reference to simple_strtoul' disk/built-in.o: In function `blk_get_device_part_str':
disk/part.c:522: undefined reference to simple_strtoul' disk/built-in.o: In function part_set_generic_name':
disk/part.c:704: undefined reference to sprintf' drivers/built-in.o: In function init_peripheral_ep':
drivers/usb/musb-new/musb_gadget.c:1826: undefined reference to sprintf' drivers/built-in.o: In function musb_core_init':
drivers/usb/musb-new/musb_core.c:1451: undefined reference to `snprintf'

Add those dependencies here.

---

Changes in v2:
- Guard select if SPL/TPL_{SPRINTF,STRTO} symbols with SPL/TPL

 disk/Kconfig                 | 4 ++++
 drivers/usb/musb-new/Kconfig | 4 ++++
 2 files changed, 8 insertions(+)
disk/Kconfig +4 -0
index 8af2a95..28fb81c 100644
@@ -4,6 +4,10 @@ menu "Partition Types"
 config PARTITIONS
 	bool "Enable Partition Labels (disklabels) support"
 	default y
+	select SPL_SPRINTF if SPL
+	select TPL_SPRINTF if TPL
+	select SPL_STRTO if SPL
+	select TPL_STRTO if TPL
 	help
 	  Partition Labels (disklabels) Supported:
 	  Zero or more of the following:
drivers/usb/musb-new/Kconfig +4 -0
index ea5bae2..f8f2205 100644
@@ -5,12 +5,16 @@ comment "MUSB Controller Driver"
 
 config USB_MUSB_HOST
 	bool "MUSB host mode support"
+	select SPL_SPRINTF if SPL
+	select TPL_SPRINTF if TPL
 	help
 	  Enables the MUSB USB dual-role controller in host mode.
 
 config USB_MUSB_GADGET
 	bool "MUSB gadget mode support"
 	select USB_GADGET_DUALSPEED
+	select SPL_SPRINTF if SPL
+	select TPL_SPRINTF if TPL
 	help
 	  Enables the MUSB USB dual-role controller in gadget mode.
 
Signature · 1 line
2.7.4
#16 lore raw

PATCH v2 8/8 spl: disk: usb: Add dependencies to sprintf/strto*

Quoted 17 lines · Alex Kiernan

If SPL serial support is disabled nothing brings in sprintf, snprintf or simple_strtoul:

env/built-in.o: In function `regex_callback':
env/attr.c:128: undefined reference to sprintf' disk/built-in.o: In function blk_get_device_by_str':
disk/part.c:386: undefined reference to simple_strtoul' disk/part.c:395: undefined reference to simple_strtoul' disk/built-in.o: In function `blk_get_device_part_str':
disk/part.c:522: undefined reference to simple_strtoul' disk/built-in.o: In function part_set_generic_name':
disk/part.c:704: undefined reference to sprintf' drivers/built-in.o: In function init_peripheral_ep':
drivers/usb/musb-new/musb_gadget.c:1826: undefined reference to sprintf' drivers/built-in.o: In function musb_core_init':
drivers/usb/musb-new/musb_core.c:1451: undefined reference to `snprintf'

Quoted 3 lines

Add those dependencies here.

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: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180429/e5bb2429/attachment.sig>