Compile USBIP drivers into kernel

  1. Create a new directory named usbip in "$(KERNELSOURCE)/drivers/usb/" directory, copy all driver files into that directory. The directory file list below:
    |usbip
    |---- stub.h
    |---- stub_tx.c
    |---- stub_rx.c
    |---- stub_dev.c
    |---- stub_main.c
    |---- usbip_common.h
    |---- usbip_common.c
    |---- usbip_event.c
    |---- vhci.h
    |---- vhci_hcd.c
    |---- vhci_rx.c
    |---- vhci_tx.c
    |---- vhci_sysfs.c
  2. Create a Kconfig file in "usbip" directory with contents below:
    #
    # USBIP driver configuration
    #
    comment "Usbip Driver"
    config USBIP
    bool "USBIP support"
    config USBIP_STUB
    tristate "Usbip stub driver"
    depends on USBIP
    config USBIP_VHCI
    tristate "Usbip vhci driver"
    depends on USBIP
  3. Modify the Kconfig file of its parent directory "usb", add contents:
    source "drivers/usb/usbip/Kconfig"
    Then we can find a item named "USBIP" in "Device Driver->USB devices support" when we use "make menuconfig/xconfig".
  4. Create a Makefile file in "usbip" directory with contents below:
    KSOURCE ?= /lib/modules/$(shell uname -r)/build
    HCD_HEADER:=$(KSOURCE)/drivers/usb/core/hcd.h
    usbip_common_mod-objs    := usbip_common.o usbip_event.o
    usbip-objs         := stub_dev.o stub_main.o stub_rx.o stub_tx.o
    vhci-hcd-objs          := vhci_sysfs.o vhci_tx.o vhci_rx.o vhci_hcd.o
    obj-$(CONFIG_USBIP)    += usbip_common_mod.o
    obj-$(CONFIG_USBIP_STUB)+= usbip.o
    obj-$(CONFIG_USBIP_VHCI)+= vhci-hcd.o
    EXTRA_CFLAGS += -DHCD_HEADER=/"$(HCD_HEADER)/"
  5. Modify the Makefile file of its parent directory "usb", add contents:
    obj-$(CONFIG_USBIP)    += usbip/
    All things done!

你可能感兴趣的:(shell,list,header,File,makefile)