[U-Boot] USB: ci_udc fails to link in SPL when DM is active

Hi,
I’m trying to build an SPL image for an iMX7 platform with the following options active:
CONFIG_SPL=y CONFIG_SPL_USB_GADGET_SUPPORT=y CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_CMD_USB=y CONFIG_USB=y CONFIG_DM_USB=y CONFIG_CI_UDC=y CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_FUNCTION_SDP=y
This leads to the SPL failing to link:
LD spl/u-boot-spl drivers/built-in.o: In function `usb_gadget_register_driver': /root/u-boot/drivers/usb/gadget/ci_udc.c:1019: undefined reference to `usb_setup_ehci_gadget' scripts/Makefile.spl:364: recipe for target 'spl/u-boot-spl' failed make[1]: *** [spl/u-boot-spl] Error 1 Makefile:1539: recipe for target 'spl/u-boot-spl' failed make: *** [spl/u-boot-spl] Error 2
Is DM_USB in SPL with this driver not supported or should I have configured something else? I’m using the current mainline master branch.
Thanks, Sven

Hi again.
I have tried some more and I thought I would write down my thoughts and findings. I also collected a couple of questions at the end of this email. First, the design goal: I’d like to use as much driver model as possible as well as SPL instead of the iMX plugin stuff. This is primarily for future proofing and keeping the board-specific code small.
Here’s the functionality that I need: - USB SDP from SPL: CONFIG_SPL_USB_SDP_SUPPORT, CONFIG_CI_UDC - MMC support in SPL and proper: CONFIG_SPL_MMC_SUPPORT, CONFIG_MMC, CONFIG_FSL_ESDHC - USB mass storage support in proper: CONFIG_USB_STORAGE
Everything seems to be working fine when driver model is inactive for USB and USB storage is inactive. When setting CONFIG_USB_STORAGE=y, there are compilation errors: CC common/usb_storage.o common/usb_storage.c: In function 'usb_stor_probe_device': common/usb_storage.c:206:32: error: 'struct usb_device' has no member named 'dev'; did you mean 'devnum'? common/usb_storage.c:216:34: error: 'struct usb_device' has no member named 'dev'; did you mean 'devnum’?
Those errors are caused by code that’s only compiled when CONFIG_BLK=y. Disabling that, however, makes my MMC not work anymore. That’s why I tried to set CONFIG_DM_USB=y. However, the build system doesn’t seem to support CONFIG_DM_USB only being active in proper and not SPL: CC spl/common/usb_storage.o common/usb_storage.c: In function 'usb_stor_info': common/usb_storage.c:142:7: warning: implicit declaration of function 'blk_first_device'; did you mean 'blk_list_devices'? [-Wimplicit-function-declaration] common/usb_storage.c:144:7: warning: implicit declaration of function 'blk_next_device'; did you mean 'blk_show_device'? [-Wimplicit-function-declaration] common/usb_storage.c: In function 'usb_stor_probe_device': common/usb_storage.c:216:9: warning: implicit declaration of function 'blk_create_devicef'; did you mean 'blk_list_devices'? [-Wimplicit-function-declaration] common/usb_storage.c:230:10: warning: implicit declaration of function 'blk_prepare_device'; did you mean 'usb_free_device'? [-Wimplicit-function-declaration] common/usb_storage.c: At top level: common/usb_storage.c:1546:21: error: variable 'usb_storage_ops' has initializer but incomplete type common/usb_storage.c:1547:3: error: 'const struct blk_ops' has no member named 'read' common/usb_storage.c:1547:10: warning: excess elements in struct initializer common/usb_storage.c:1547:10: note: (near initialization for 'usb_storage_ops') common/usb_storage.c:1548:3: error: 'const struct blk_ops' has no member named 'write' common/usb_storage.c:1548:11: warning: excess elements in struct initializer common/usb_storage.c:1548:11: note: (near initialization for 'usb_storage_ops') common/usb_storage.c:1546:29: error: storage size of 'usb_storage_ops' isn't known
The errors are again caused by CONFIG_BLK=y it seems. Getting desperate and trying to set CONFIG_SPL_DM=y leads to a too big SPL image and a bunch of undefined references to USB and FDT stuff when trying to link the SPL. Backing up a little and unsetting CONFIG_USB_STORAGE with CONFIG_DM_USB=y gives: LD spl/u-boot-spl drivers/built-in.o: In function `usb_child_post_bind': /home/sven/u-boot/drivers/usb/host/usb-uclass.c:715: undefined reference to `dev_get_parent_platdata' drivers/built-in.o: In function `dev_read_u32_default': /home/sven/u-boot/include/dm/read.h:467: undefined reference to `ofnode_read_u32_default' /home/sven/u-boot/include/dm/read.h:467: undefined reference to `ofnode_read_u32_default' drivers/built-in.o: In function `usb_setup_ehci_gadget': /home/sven/u-boot/drivers/usb/host/usb-uclass.c:388: undefined reference to `uclass_find_device_by_seq' /home/sven/u-boot/drivers/usb/host/usb-uclass.c:395: undefined reference to `dev_get_platdata' /home/sven/u-boot/drivers/usb/host/usb-uclass.c:397: undefined reference to `device_probe' /home/sven/u-boot/drivers/usb/host/usb-uclass.c:400: undefined reference to `dev_get_priv' drivers/built-in.o: In function `usb_get_bus': /home/sven/u-boot/drivers/usb/host/usb-uclass.c:740: undefined reference to `device_get_uclass_id' drivers/built-in.o: In function `usb_child_pre_probe': /home/sven/u-boot/drivers/usb/host/usb-uclass.c:753: undefined reference to `dev_get_parent_priv' /home/sven/u-boot/drivers/usb/host/usb-uclass.c:754: undefined reference to `dev_get_parent_platdata' /home/sven/u-boot/drivers/usb/host/usb-uclass.c:781: undefined reference to `usb_select_config' drivers/built-in.o: In function `ehci_get_ctrl': /home/sven/u-boot/drivers/usb/host/ehci-hcd.c:115: undefined reference to `dev_get_priv' drivers/built-in.o: In function `ehci_update_endpt2_dev_n_port': /home/sven/u-boot/drivers/usb/host/ehci-hcd.c:293: undefined reference to `usb_find_usb2_hub_address_port' drivers/built-in.o: In function `ehci_submit_async': /home/sven/u-boot/drivers/usb/host/ehci-hcd.c:408: undefined reference to `usb_maxpacket' drivers/built-in.o: In function `_ehci_create_int_queue': /home/sven/u-boot/drivers/usb/host/ehci-hcd.c:1251: undefined reference to `usb_maxpacket' /home/sven/u-boot/drivers/usb/host/ehci-hcd.c:1310: undefined reference to `usb_maxpacket' drivers/built-in.o: In function `ehci_register': /home/sven/u-boot/drivers/usb/host/ehci-hcd.c:1623: undefined reference to `dev_get_uclass_priv' /home/sven/u-boot/drivers/usb/host/ehci-hcd.c:1624: undefined reference to `dev_get_priv' drivers/built-in.o: In function `ehci_deregister': /home/sven/u-boot/drivers/usb/host/ehci-hcd.c:1667: undefined reference to `dev_get_priv' drivers/built-in.o: In function `ehci_usb_phy_mode': /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:435: undefined reference to `dev_get_platdata' /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:436: undefined reference to `devfdt_get_addr' /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:447: undefined reference to `fdtdec_lookup_phandle' /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:453: undefined reference to `fdtdec_get_addr' drivers/built-in.o: In function `ehci_usb_ofdata_to_platdata': /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:483: undefined reference to `dev_get_platdata' /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:486: undefined reference to `fdt_getprop' drivers/built-in.o: In function `ehci_usb_probe': /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:505: undefined reference to `dev_get_platdata' /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:506: undefined reference to `devfdt_get_addr' /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:507: undefined reference to `dev_get_priv' /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:517: undefined reference to `device_get_supply_regulator' /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:527: undefined reference to `regulator_set_enable' drivers/built-in.o: In function `mx6_init_after_reset': /home/sven/u-boot/drivers/usb/host/ehci-mx6.c:408: undefined reference to `regulator_set_enable' drivers/built-in.o:(.u_boot_list_2_uclass_2_usb+0x8): undefined reference to `dm_scan_fdt_dev’
OK, maybe I can disable the USB host drivers in SPL (CONFIG_SPL_USB_HOST_SUPPORT). No, that leads to my initial problem: LD spl/u-boot-spl drivers/built-in.o: In function `usb_gadget_register_driver': /home/sven/u-boot/drivers/usb/gadget/ci_udc.c:1019: undefined reference to `usb_setup_ehci_gadget'
Questions: 1. Can I enable USB driver model just for the proper build and have it disabled for the SPL build? 2. Is it possible to use the MMC (with CONFIG_DM_MMC=y) when CONFIG_BLK is not set? If so, how? 3. All of these dependencies seem to be missing from Kconfig. Is that intentional?
I am feeling a little lost here. I think, most of my problems are caused by wanting USB SDP I SPL. However, since I only have an eMMC on this board, that seems to be the only way to boot when the eMMC is blank/invalid.
Any remarks and suggestions on how to deal with this are appreciated :-)
Best regards, Sven
On 12 Nov 2018, at 08:31, Sven Schwermer sven@svenschwermer.de wrote:
Hi,
I’m trying to build an SPL image for an iMX7 platform with the following options active:
CONFIG_SPL=y CONFIG_SPL_USB_GADGET_SUPPORT=y CONFIG_SPL_USB_SDP_SUPPORT=y CONFIG_CMD_USB=y CONFIG_USB=y CONFIG_DM_USB=y CONFIG_CI_UDC=y CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_FUNCTION_SDP=y
This leads to the SPL failing to link:
LD spl/u-boot-spl drivers/built-in.o: In function `usb_gadget_register_driver': /root/u-boot/drivers/usb/gadget/ci_udc.c:1019: undefined reference to `usb_setup_ehci_gadget' scripts/Makefile.spl:364: recipe for target 'spl/u-boot-spl' failed make[1]: *** [spl/u-boot-spl] Error 1 Makefile:1539: recipe for target 'spl/u-boot-spl' failed make: *** [spl/u-boot-spl] Error 2
Is DM_USB in SPL with this driver not supported or should I have configured something else? I’m using the current mainline master branch.
Thanks, Sven
participants (1)
-
Sven Schwermer