[PATCH v2] xyz-modem: Select CRC16

Daniel Palmer daniel at thingy.jp
Mon Jun 8 15:06:06 CEST 2026


- CONFIG_LOADB causes the xyzModem code to get built and that code depends
  on CONFIG_CRC16. If you don't have something else that selects CONFIG_CRC16
  you can unselect it and then the final link will fail:

  LD      u-boot
/usr/bin/m68k-linux-gnu-ld.bfd: common/xyzModem.o: in function `xyzModem_get_hdr':
u-boot/common/xyzModem.c:388:(.text.xyzModem_get_hdr+0x17a): undefined reference to `crc16_ccitt'

- Add CONFIG_YMODEM_SUPPORT, make that select CONFIG_CRC16 and make
  CONFIG_LOADB select CONFIG_YMODEM_SUPPORT.

- SPL/TPL already have Kconfig symbols for ymodem support but the spl
  ymodem code has issues building in the TPL phase and doesn't seem to
  be used:

/usr/bin/aarch64-linux-gnu-ld.bfd: common/spl/spl_ymodem.o: in function `spl_ymodem_load_image':
u-boot/common/spl/spl_ymodem.c:138:(.text.spl_ymodem_load_image+0xdc): undefined reference to `spl_load_simple_fit'
u-boot/common/spl/spl_ymodem.c:138:(.text.spl_ymodem_load_image+0xdc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `spl_load_simple_fit'
make[1]: *** [scripts/Makefile.xpl:546: tpl/u-boot-tpl] Error 1

- Remove the ymodem symbol entirely for TPL.

- Select CONFIG_SPL_CRC16 for SPL.

- Finally, since everyone is now using the ymodem support symbols remove
  the special rule for loadb in the makefile.

Signed-off-by: Daniel Palmer <daniel at thingy.jp>
---

v2: Fix the SPL/TPL stuff as brought up by Tom. This opened a can of
    worms when I tested if the TPL builds or not so I decided to just
    remove the TPL ymodem stuff. It didn't seem to be used in any
    defconfig and there isn't a CONFIG_TPL_CRC16 to enable the needed
    crc16 code anyhow so maybe it hasn't been used for a while?

 cmd/Kconfig            |  1 +
 common/Kconfig         |  4 ++++
 common/Makefile        |  1 -
 common/spl/Kconfig     |  1 +
 common/spl/Kconfig.tpl | 11 +----------
 5 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index c71c6824a196..503fc51f6bb4 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1412,6 +1412,7 @@ config CMD_W1
 config CMD_LOADB
 	bool "loadb"
 	default y
+	select YMODEM_SUPPORT
 	help
 	  Load a binary file over serial line.
 
diff --git a/common/Kconfig b/common/Kconfig
index 8e8c733aa295..0db74aa580e4 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1274,3 +1274,7 @@ config IO_TRACE
 	  confirm that the driver behaves the same way before and after a code
 	  change. To add support for your architecture, add '#include
 	  <iotrace.h>' to the bottom of arch/<arch>/include/asm/io.h and test.
+
+config YMODEM_SUPPORT
+	bool
+	select CRC16
diff --git a/common/Makefile b/common/Makefile
index d62ea34599ed..6c39c422f980 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -99,7 +99,6 @@ obj-$(CONFIG_$(PHASE_)LOG) += log.o
 obj-$(CONFIG_$(PHASE_)LOG_CONSOLE) += log_console.o
 obj-$(CONFIG_$(PHASE_)LOG_SYSLOG) += log_syslog.o
 obj-y += s_record.o
-obj-$(CONFIG_CMD_LOADB) += xyzModem.o
 obj-$(CONFIG_$(PHASE_)YMODEM_SUPPORT) += xyzModem.o
 
 obj-$(CONFIG_$(PHASE_)AVB_VERIFY) += avb_verify.o
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 5fa94098e498..25f3867f991c 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1655,6 +1655,7 @@ config SPL_WATCHDOG
 config SPL_YMODEM_SUPPORT
 	bool "Support loading using Ymodem"
 	depends on SPL_SERIAL
+	select SPL_CRC16
 	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
diff --git a/common/spl/Kconfig.tpl b/common/spl/Kconfig.tpl
index a535b61ecd35..ea238afbf188 100644
--- a/common/spl/Kconfig.tpl
+++ b/common/spl/Kconfig.tpl
@@ -38,7 +38,7 @@ config TPL_FRAMEWORK
 	default y if SPL_FRAMEWORK
 	help
 	  Enable the SPL framework under common/spl/ for TPL builds.
-	  This framework supports MMC, NAND and YMODEM and other methods
+	  This framework supports MMC, NAND and other methods
 	  loading of U-Boot's SPL stage. If unsure, say Y.
 
 config TPL_BANNER_PRINT
@@ -333,13 +333,4 @@ config TPL_DM_SPI_FLASH
 	help
 	  Enable support for SPI DM flash drivers in TPL.
 
-config TPL_YMODEM_SUPPORT
-	bool "Support loading using Ymodem"
-	depends on TPL_SERIAL
-	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
-	  means of transmitting U-Boot over a serial line for using in TPL,
-	  with a checksum to ensure correctness.
-
 endmenu
-- 
2.53.0



More information about the U-Boot mailing list