[U-Boot] USB ethernet support broken with device-model?

Simon Glass sjg at chromium.org
Tue Jun 16 20:37:26 CEST 2015


+Joe (Network maintainer)

Hi,

On 14 June 2015 at 08:08, Karsten Merker <merker at debian.org> wrote:
> Hello,
>
> I am trying to build current u-boot master for the (sunxi-based)
> MSI_Primo81 target with support for an ASIX AX88772B USB ethernet
> adapter. Setting
>
> CONFIG_SYS_EXTRA_OPTIONS="USB_HOST_ETHER,USB_ETHER_ASIX"
>
> via make menuconfig results in the following build error:
>
> [...]
>   CC      common/main.o
>   CC      common/board_f.o
>   CC      common/cmd_version.o
>   LD      common/built-in.o
>   CC      drivers/video/cfb_console.o
>   LD      drivers/video/built-in.o
>   LD      drivers/built-in.o
>   CC      drivers/usb/eth/usb_ether.o
> In file included from drivers/usb/eth/usb_ether.c:12:0:
> include/usb_ether.h:24:20: error: field 'eth_dev' has incomplete type
>   struct eth_device eth_dev;  /* used with eth_register */
>                     ^
> drivers/usb/eth/usb_ether.c: In function 'is_eth_dev_on_usb_host':
> drivers/usb/eth/usb_ether.c:68:27: warning: initialization from incompatible pointer type
>   struct eth_device *dev = eth_get_dev();
>                            ^
> drivers/usb/eth/usb_ether.c: In function 'probe_valid_drivers':
> drivers/usb/eth/usb_ether.c:106:4: warning: implicit declaration of function 'eth_register' [-Wimplicit-function-declaration]
>     eth_register(eth);
>     ^
> drivers/usb/eth/usb_ether.c:107:4: warning: implicit declaration of function 'eth_write_hwaddr' [-Wimplicit-function-declaration]
>     if (eth_write_hwaddr(eth, "usbeth",
>     ^
> drivers/usb/eth/usb_ether.c: In function 'usb_host_eth_scan':
> drivers/usb/eth/usb_ether.c:131:3: warning: implicit declaration of function 'eth_unregister' [-Wimplicit-function-declaration]
>    eth_unregister(&usb_eth[i].eth_dev);
>    ^
> scripts/Makefile.build:276: recipe for target 'drivers/usb/eth/usb_ether.o' failed
> make[1]: *** [drivers/usb/eth/usb_ether.o] Error 1
> Makefile:1158: recipe for target 'drivers/usb/eth' failed
> make: *** [drivers/usb/eth] Error 2
>
> This appears to be a device-model related issue. With the default
> configuration, which includes CONFIG_DM_ETH=y, the above error
> occurs, but with CONFIG_DM_ETH unset, the build succeeds.  The
> problem seems to be with the definition of struct eth_device in
> include/net.h, which is bracketed by an #ifndef CONFIG_DM_ETH /
> #endif (lines 147-214).  I know about nothing about how
> device-model works in u-boot, so I am stuck here.  Simon, could
> you perhaps take a look at the issue?

Yes, USB Ethernet does not support driver model for Ethernet /
CONFIG_DM_ETH yet.

It would be great to add this if you'd like to give it a crack.

Some hints:

- declare a USB_DEVICE() in asix.c with the appropriate vendor/device
IDs using usb_device_id (see usb_storage.c for how the storage driver
does it). You'll want to take the IDs from asix_dongles[] and use the
USB_DEVICE_ID_MATCH_VENDOR and USB_DEVICE_ID_MATCH_PRODUCT flags
- add a U_BOOT_DRIVER() in asix.c which defines the
start/send/recv/stop methods (see sunxi_emac.c for an example)
- don't compile in usb_ether.c if CONFIG_DM_ETH is set (the USB
subsystem should automatically scan and find your driver as it does
with storage)
- skip calling usb_host_eth_scan() from cmd_usb.c if CONFIG_DM_ETH is set
- hack up asix.c to remove asix_eth_probe() and asix_eth_get_info()
when CONFIG_DM_ETH is set

I'm happy to review and test.

[snip]

Regards,
Simon


More information about the U-Boot mailing list