7 Replies Latest reply on Mar 24, 2016 6:19 PM by CMata_Intel

    USB Host Mode Compilation problem

    rden3

      Hello,

       

      I have an Edison Arduino board (the big one that takes shields and has a full size type A USB port on it).

       

      I am trying to use the Type A USB socket in Host mode, for a WiFi dongle, but I'm having difficulty compiling the kernel - I hope somebody here may be able to help please.

       

      Edison Source from here:

      wget http://downloadmirror.intel.com/25028/eng/edison-src-ww25.5-15.tgz

       

      Kernel Source from here:

      wget https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.10.17.tar.bz2

       

      Then I unpack each of those and added the patch:

      cd linux-3.10.17

      patch -p1 < ../edison-src/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/files/upstream_to_edison.patch

       

      I used the supplied defconfig:

      cp ../edison-src/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/files/defconfig .config

       

      I have to copy some files

      cp ./drivers/tty/serial/mfd_trace.h include/trace/

      cp ./sound/soc/intel/sst/sst_trace.h include/trace

       

      at this point if I make the kernel, all is good.

       

      However, in menuconfig the "DWC3 Mode Selection" is "Gadget only mode"

      Is it the case that I should change that to enable host mode?

       

      When I make that change to Host only mode (dual mode has the same end results), .config changes as follows:

      < CONFIG_USB_DWC3_HOST=y

      < # CONFIG_USB_DWC3_GADGET is not set

      ---

      > # CONFIG_USB_DWC3_HOST is not set

      > CONFIG_USB_DWC3_GADGET=y

       

      The problem is then that when I try to compile I get errors that I don't understand:

       

      make -j8
      
      scripts/kconfig/conf --silentoldconfig Kconfig
      make[1]: Nothing to be done for 'all'.
        CHK     include/generated/uapi/linux/version.h
      make[1]: Nothing to be done for 'relocs'.
        CHK     include/generated/utsrelease.h
        CC      scripts/mod/devicetable-offsets.s
        GEN     scripts/mod/devicetable-offsets.h
        HOSTCC  scripts/mod/file2alias.o
        CALL    scripts/checksyscalls.sh
        HOSTLD  scripts/mod/modpost
        CHK     include/generated/compile.h
        PASYMS  arch/x86/realmode/rm/pasyms.h
        LDS     arch/x86/realmode/rm/realmode.lds
        LD      arch/x86/realmode/rm/realmode.elf
        RELOCS  arch/x86/realmode/rm/realmode.relocs
        OBJCOPY arch/x86/realmode/rm/realmode.bin
        VDSOSYM arch/x86/vdso/vdso32-sysenter-syms.lds
        VDSOSYM arch/x86/vdso/vdso32-int80-syms.lds
        AS      arch/x86/realmode/rmpiggy.o
        VDSOSYM arch/x86/vdso/vdso32-syms.lds
        LD      arch/x86/vdso/built-in.o
        LD      arch/x86/realmode/built-in.o
        LD      arch/x86/built-in.o
      WARNING: arch/x86/built-in.o(.text+0x354ae): Section mismatch in reference from the function penwell_arch_setup() to the function .init.text:mfld_calibrate_tsc()
      The function penwell_arch_setup() references
      the function __init mfld_calibrate_tsc().
      This is often because penwell_arch_setup lacks a __init 
      annotation or the annotation of mfld_calibrate_tsc is wrong.
      
        CC      drivers/misc/stm.o
      drivers/misc/stm.c: In function ‘stm_dev_init’:
      drivers/misc/stm.c:388:2: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
        pr_info("stm add %x\n", stm->stm_addr);
        ^
        CC      drivers/usb/dwc3/dwc3-device-intel.o
        LD      drivers/misc/built-in.o
        CC [M]  drivers/usb/gadget/epautoconf.o
        CC      drivers/usb/dwc3/debugfs.o
        CC      drivers/usb/host/xhci-plat.o
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:35:0:
      drivers/usb/dwc3/gadget.c:3117:5: error: redefinition of ‘dwc3_gadget_init’
       int dwc3_gadget_init(struct dwc3 *dwc)
           ^
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:26:0:
      drivers/usb/dwc3/core.h:977:19: note: previous definition of ‘dwc3_gadget_init’ was here
       static inline int dwc3_gadget_init(struct dwc3 *dwc)
                         ^
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:35:0:
      drivers/usb/dwc3/gadget.c:3237:6: error: redefinition of ‘dwc3_gadget_exit’
       void dwc3_gadget_exit(struct dwc3 *dwc)
            ^
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:26:0:
      drivers/usb/dwc3/core.h:979:20: note: previous definition of ‘dwc3_gadget_exit’ was here
       static inline void dwc3_gadget_exit(struct dwc3 *dwc)
                          ^
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:35:0:
      drivers/usb/dwc3/gadget.c:3262:5: error: redefinition of ‘dwc3_gadget_prepare’
       int dwc3_gadget_prepare(struct dwc3 *dwc)
           ^
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:26:0:
      drivers/usb/dwc3/core.h:990:19: note: previous definition of ‘dwc3_gadget_prepare’ was here
       static inline int dwc3_gadget_prepare(struct dwc3 *dwc)
                         ^
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:35:0:
      drivers/usb/dwc3/gadget.c:3270:6: error: redefinition of ‘dwc3_gadget_complete’
       void dwc3_gadget_complete(struct dwc3 *dwc)
            ^
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:26:0:
      drivers/usb/dwc3/core.h:995:20: note: previous definition of ‘dwc3_gadget_complete’ was here
       static inline void dwc3_gadget_complete(struct dwc3 *dwc)
                          ^
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:35:0:
      drivers/usb/dwc3/gadget.c:3278:5: error: redefinition of ‘dwc3_gadget_suspend’
       int dwc3_gadget_suspend(struct dwc3 *dwc)
           ^
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:26:0:
      drivers/usb/dwc3/core.h:999:19: note: previous definition of ‘dwc3_gadget_suspend’ was here
       static inline int dwc3_gadget_suspend(struct dwc3 *dwc)
                         ^
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:35:0:
      drivers/usb/dwc3/gadget.c:3288:5: error: redefinition of ‘dwc3_gadget_resume’
       int dwc3_gadget_resume(struct dwc3 *dwc)
           ^
      In file included from drivers/usb/dwc3/dwc3-device-intel.c:26:0:
      drivers/usb/dwc3/core.h:1004:19: note: previous definition of ‘dwc3_gadget_resume’ was here
       static inline int dwc3_gadget_resume(struct dwc3 *dwc)
                         ^
        LD [M]  drivers/usb/gadget/libcomposite.o
        LD [M]  drivers/usb/gadget/usb_f_acm.o
      drivers/usb/dwc3/dwc3-device-intel.c: In function ‘dwc3_quirks_process_event_buf’:
      drivers/usb/dwc3/dwc3-device-intel.c:161:6: warning: unused variable ‘reg’ [-Wunused-variable]
        u32 reg;
            ^
        LD [M]  drivers/usb/gadget/g_multi.o
      WARNING: drivers/usb/gadget/g_multi.o(.text+0x203f): Section mismatch in reference from the function rndis_config_register() to the function .init.text:rndis_do_config()
      The function rndis_config_register() references
      the function __init rndis_do_config().
      This is often because rndis_config_register lacks a __init 
      annotation or the annotation of rndis_do_config is wrong.
      
      WARNING: drivers/usb/gadget/g_multi.o(.text+0x207f): Section mismatch in reference from the function cdc_config_register() to the function .init.text:cdc_do_config()
      The function cdc_config_register() references
      the function __init cdc_do_config().
      This is often because cdc_config_register lacks a __init 
      annotation or the annotation of cdc_do_config is wrong.
      
      scripts/Makefile.build:308: recipe for target 'drivers/usb/dwc3/dwc3-device-intel.o' failed
      make[3]: *** [drivers/usb/dwc3/dwc3-device-intel.o] Error 1
      scripts/Makefile.build:455: recipe for target 'drivers/usb/dwc3' failed
      make[2]: *** [drivers/usb/dwc3] Error 2
      make[2]: *** Waiting for unfinished jobs....
        LD      drivers/usb/host/xhci-hcd.o
        LD      drivers/usb/host/built-in.o
      scripts/Makefile.build:455: recipe for target 'drivers/usb' failed
      make[1]: *** [drivers/usb] Error 2
      Makefile:795: recipe for target 'drivers' failed
      make: *** [drivers] Error 2
      

       

       

       

      I find that if I go through that same process, but do not apply the upstream_to_edison.patch to the kernel, then it is possible to make the change to Host mode without any compilation problem.

       

       

      Should I be making some other change to the selected modules?

      Am I trying to enable host mode in the right way?

       

       

      Any help or pointers in the right direction would be appreciated.

       

      Thanks,

       

      Rob.

        • 1. Re: USB Host Mode Compilation problem
          CMata_Intel

          Hi Rob,

           

          Which is the dongle you want to use with the board? Are you sure you are including all the drivers required for it?

          You said that when you do not apply the upstream_to_edison.patch you are able to compile without problems, have you tested this image with the dongle? Is it working?

           

          You should be able to use the board and connect devices as host with the USB A port just by moving the switch SW1 in order to point this port.

           

          Regards,

          Charlie

          • 2. Re: USB Host Mode Compilation problem
            rden3

            Hi Charlie,

             

            I have tried many different WiFi dongles and host devices, and I'm quite sure that is unrelated to the issue.

             

            When using the 3.10.17 + upstream_to_edison.patch + supplied defconfig, I get the failed to initialize libusb -99 error as well. I can see the switch and have of course tried all manner of booting with a device in place, having the switch set, using a decent 12V external supply - these are not the issue, it is a problem with software.

             

            I have flashed Ubilinux onto the board, conncted external 12V supply, set the switch, and connected any dongle I like and they all "just work" - this is not a hardware problem.

            I have tried adding many different kernel modules to my kernel build, and none of them enable me to see any USB devices, or even the USB root hub - everything just gives the failed to initialize -99 issue. With the exception of adding the USB dummy hub, but that is by its very nature not going to help me.

             

            What is clear is that patching the kernel with the patch supplied by Intel, that is supposed to support Edison, actually breaks compilation.

            There must be a solution to this, Ubilinux creators have found and implemented it, and either I cannot find the solution that they managed to find, or they have written the solution and not shared it.

             

            Regards,

             

            Rob

            • 3. Re: USB Host Mode Compilation problem
              CMata_Intel

              Hi Rob,

               

              The upstream_to_edison.patch is intended to be used on the Yocto source files and not in the kernel files from www.kernel.org. If you want to build your image with the kernel source files you would need to make the kernel files compatible with Yocto and then run the patch you were using.

              I suggest you to use the BSP file for Edison, you will see all the steps for building an image, and then you can enable all the modules you need with the menuconfig or with the defconfig file. This BSP fetch all the source files for the kernel with the required modifications in order to work with Yocto on the Module.

               

              Regards,

              Charlie

              • 4. Re: USB Host Mode Compilation problem
                CMata_Intel

                Hi Rob,

                 

                Do you have updates on this? I would like to know if you have started to create your own image with the required changes you need

                 

                Regards,

                Charlie

                • 5. Re: USB Host Mode Compilation problem
                  CMata_Intel

                  Hi,

                   

                  Using the “Edimax EW-7811Un 150Mbps 11n Wi-Fi USB Adapter” you can enable the WiFi-USB driver by doing the following:

                   

                  1. Follow the Intel® Edison Board Support Package User Guide and stop after step 4 in the 2nd section “Build an Intel® Edison Image using bitbake”.

                  2. Edit the file <edison-src>/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/files/defconfig and add this line:

                  CONFIG_RTL8192CU=y
                  CONFIG_RTLWIFI=y
                  
                  
                  
                  
                  

                  3. Edit the file <edison-src>/meta-intel-edison/meta-intel-edison-distro/recipes-core/images/edison-image.bb and add this line:

                  IMAGE_INSTALL += "linux-firmware-rtl8192cu"
                  
                  
                  
                  
                  

                  4. Continue from step 5, build the image and flash the board with the new image

                  5. Startup Edison, plug in the Wi-Fi USB into Edison USB type-A connector and make sure the micro switch pointing to USB type-A connector

                  6. Login to Edison Linux console and type the command dmesg | tail -30, you should see the following:

                  [  130.906664] usb 1-1: new high-speed USB device number 2 using dwc3-host

                  [  130.930176] usb 1-1: New USB device found, idVendor=7392, idProduct=7811

                  [  130.930207] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3

                  [  130.930229] usb 1-1: Product: 802.11n WLAN Adapter

                  [  130.930247] usb 1-1: Manufacturer: Realtek

                  [  130.930265] usb 1-1: SerialNumber: 00e04c000001

                  [  130.932641] rtl8192cu: Chip version 0x10

                  [  130.999544] rtl8192cu: MAC address: 74:da:38:42:1d:65

                  [  130.999572] rtl8192cu: Board Type 0

                  [  130.999731] rtlwifi: rx_max_size 15360, rx_urb_num 8, in_ep 1

                  [  130.999884] rtl8192cu: Loading firmware rtlwifi/rtl8192cufw.bin

                  [  131.000786] ieee80211 phy2: Selected rate control algorithm 'rtl_rc'

                  [  131.016639] rtlwifi: wireless switch is on

                  [  131.076912] systemd-udevd[451]: renamed network interface wlan1 to wlp0s17u1

                  7. Configure the network for the new device wlp0s17u1 with ifconfig wlp0s17u1 up

                  8. Running ifconfig should show:

                  wlp0s17u1     Link encap:Ethernet  HWaddr 74:da:38:42:1d:65

                                      UP BROADCAST MULTICAST MTU:1500  Metric:1

                                      RX packets:0 errors:0 dropped:0 overruns:0 frame:0

                                      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

                                      collisions:0 txqueuelen:1000

                                      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

                  iwlist wlp0s17u1 scan should show the available WiFi networks.

                   

                  Kind regards,

                  • 6. Re: USB Host Mode Compilation problem
                    lernerbot

                    I've gotten this to compile and I see the new adapter in ifconfig. How does one get this new adapter to connect to a network using wpa_cli? It keeps selecting wlan0 for me.

                    • 7. Re: USB Host Mode Compilation problem
                      CMata_Intel

                      Hi lernerbot,

                       

                      Have you tried to configure the interface with connman?

                       

                      Regards,

                      Charlie