(arm + DSP development) how to load the driver without burning into the kernel by module in Linux

Time:2021-4-2

Because I need to connect a USB to serial device on the development board (omapl138-arm + Linux dual core), and the kernel has not been compiled into the relevant driver, so I can not identify the device. The chip of USB to serial cable is PL2303, and the PL2303 chip driver has been integrated into the Linux internal core source code, only arm linux If you cut it out, you need to recompile it into a kernel module and load it.

The loading process is as follows:

In the directory where the kernel is located:

cd omapl138/linux-3.3/
  • To configure the kernel:
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- da850_omapl138_tl_defconfig
  • Open the configuration interface:
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig

get into“Device Drivers”–>

SelectUSB support(*), enter into it — >

USB Serial Converter SurpportconfigureM, into which — >

SelectUSB Generic Serial Driver(*)

USB Prolific 2303 Single Port Serial DriverMatchingM

Save to exit.

Default y means to compile to the kernel by default. There are three options: y, m and N. m means to compile to the kernel module and N means not to compile.

  • Compiler module:
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- modules

After compiling, pl2303.ko file is generated in drivers / USB / serial. Download the file to any directory of the arm board and execute the command on the arm side

insmod pl2303.ko

Load the driver.

  • After loading the driver, you can
dmesg | grep usb

View the loaded USB driver information. When you see the following information:

usbcore: registered new interface driver usbserial

usbcore: registered new interface driver usbserial_generic

usbserial: USB Serial Driver Core

usbcore: registered new interface driver pl2303

usb 1-1: pl2303 converter now attached to ttyUSB0

Indicates that the driver is loaded correctly.

  • Or by command:
ls /sys/bus/usb-serial/drivers

Check whether the driver has been loaded. When you see the following information:

generic option1 pl2303

Indicates that the driver is loaded correctly.

  • You can use the following command:
ls -l /dev/ttyUSB0

To view port information, such as read / write permissions:

crw-rw—- 1 root dialout 188, 0 2015-09-02 11:18 /dev/ttyUSB0

Or by command:

dmesg | grep ttyUSB0

View information:

[ 20.956427] usb 3-2.3: pl2303 converter now attached to ttyUSB0

[ 28.412579] type=1503 audit(1441078763.210:19): operation=”open” pid=1874 parent=1852 profile=”/usr/sbin/cupsd” requested_mask=”w::” denied_mask=”w::” fsuid=0 ouid=0 name=”/dev/ttyUSB0″

[ 9994.613062] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0

[29474.242048] usb 3-2.3: pl2303 converter now attached to ttyUSB0

  • At the beginning, you need to determine which USB device is connected to the system
lsusb

Display the USB bus information in the system and connected to the system.

  • Can pass
Modinfo [module name]

View module information

  • adopt
Modinfo [module name] | grep depend

View module dependencies

  • adopt
cat /var/log/messages | tail

perhaps

dmesg | tail

View the system log.

  • Module compilation method:
make -C ${KERNELSRC} M=${PWD} modules

Kernelsrc is the kernel source code directory, which is generally

/usr/src/${shell uname -r}

M is the current directory of module source code

Other hardware drivers can be analogized.