How to install NVMe device driver into linux kernel

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to install NVMe device driver into linux kernel

Jump to solution
19,757 Views
thomasculverhou
Contributor III


I am working through the freescale yocto project quick start guide for the LS2080ardb. I need to enable the NVME device driver in my kernel build so that Linux recognises a PCIE HDD I have attached to the PCIE slot on the RDB when the kernel boots.

According to the documentation, I want something like:

bitbake -c menuconfig virtual/kernel           <=== at this point, I navigate to and enable the NVME device driver option

bitbake -c compile -f virtual/kernel

bitbake virtual/kernel

I'm then doing

bitbake fsl-image-kernelitb

to produce an itb file that I then tftp onto the LS2080 board. However, when I do

lsmod

or

lspci

I don't see any PCIE HDD and the nvme module has not been loaded. There is also nothing in dmesg to suggest the HDD was recognised; the only PCIE devices I can see are the Freescale Semiconductor PCI bridge. Finally, there is no /sys/modules directory at all (the default directory for device drivers).

I tried compiling the nvme device driver into a .ko, scp'd it to the LS2080, and did

insmod nvme.ko

The device driver gets loaded without fault and appears when I do lsmod. I tried to rescan the PCIE bus for the PCIE HDD with

echo "1" > /sys/bus/pci/rescan

but the PCIE HDD was still not recognised.

Can anyone help?

Labels (1)
0 Kudos
Reply
1 Solution
12,113 Views
thomasculverhou
Contributor III

I finally found a solution - there are two parts to it.

I was doing this, which is incorrect:

1) bitbake -c menuconfig virtual/kernel           <=== at this point, I navigate to and enable the NVME device driver option

2) bitbake -c compile -f virtual/kernel

3) bitbake virtual/kernel                                   <=== this step builds the kernel but destroys the .config file created in step 1).

I didn't realise step 3) destroyed the .config file created by step 1) in the tmp/ directory. Thus, when I subsequently did

bitbake fsl-image-kernelitb

a default .config file was used which didn't have my NVMe modifications. I'm still not sure where the default .config file comes from, and how to change it so that NVMe is enabled by default.

The correct procedure is:

1) bitbake -c menuconfig virtual/kernel           <=== at this point, I navigate to and enable the NVME device driver option

2) bitbake fsl-image-kernelitb

Step 1) creates a .config file with the NVME device driver option enabled, and step 2) creates the kernel image with NVMe enabled. The .config file created by step 1) in tmp/ is destroyed. A closer inspection of fsl-image-kernelitb.bb shows a line

do_deply[depends] += "u-boot-mkimage-native:do_build virtual/kernel:do_build ${ROOTFS_IMAGE}:do_build"

Note the bold-font command above - this is the command that actually builds the kernel which is inserted into the .itb file that I load onto the board.

However, this didn't solve the problem of why there was no /lib/modules directory in my new .itb image. To fix this, you have to insert the following line into the the .bb file of the rootfs image to be built into the .itb file. In my case, I am using fsl-image-minimal.bb:

IMAGE_INSTALL_append += " kernel_modules"

When I build the .itb and load it onto the LS2080A RDB, I can now see the full /lib/modules directory, and as a result modprobe works as expected.

View solution in original post

0 Kudos
Reply
3 Replies
12,113 Views
thomasculverhou
Contributor III

It turns out that despite getting the kernel modules correctly installed on the LS2080A, I still can't get an NVMe PCIe hard disk recognised by the kernel. I have tested my PCIe card with the hard disk on a desktop linux PC and it works fine.

I think I am missing some other module dependencies in the kernel, but I have no idea what they might be (running menuconfig and selecting the NVMe driver should cause all dependencies to be added to the kernel build).

Any help much appreciated.

0 Kudos
Reply
12,114 Views
thomasculverhou
Contributor III

I finally found a solution - there are two parts to it.

I was doing this, which is incorrect:

1) bitbake -c menuconfig virtual/kernel           <=== at this point, I navigate to and enable the NVME device driver option

2) bitbake -c compile -f virtual/kernel

3) bitbake virtual/kernel                                   <=== this step builds the kernel but destroys the .config file created in step 1).

I didn't realise step 3) destroyed the .config file created by step 1) in the tmp/ directory. Thus, when I subsequently did

bitbake fsl-image-kernelitb

a default .config file was used which didn't have my NVMe modifications. I'm still not sure where the default .config file comes from, and how to change it so that NVMe is enabled by default.

The correct procedure is:

1) bitbake -c menuconfig virtual/kernel           <=== at this point, I navigate to and enable the NVME device driver option

2) bitbake fsl-image-kernelitb

Step 1) creates a .config file with the NVME device driver option enabled, and step 2) creates the kernel image with NVMe enabled. The .config file created by step 1) in tmp/ is destroyed. A closer inspection of fsl-image-kernelitb.bb shows a line

do_deply[depends] += "u-boot-mkimage-native:do_build virtual/kernel:do_build ${ROOTFS_IMAGE}:do_build"

Note the bold-font command above - this is the command that actually builds the kernel which is inserted into the .itb file that I load onto the board.

However, this didn't solve the problem of why there was no /lib/modules directory in my new .itb image. To fix this, you have to insert the following line into the the .bb file of the rootfs image to be built into the .itb file. In my case, I am using fsl-image-minimal.bb:

IMAGE_INSTALL_append += " kernel_modules"

When I build the .itb and load it onto the LS2080A RDB, I can now see the full /lib/modules directory, and as a result modprobe works as expected.

0 Kudos
Reply
12,113 Views
thomasculverhou
Contributor III

Further notes:

Examining the output of

bitbake fsl-image-kernelitb

it looks like an rpm is being created for the nvme kernel module, but this is never integrated into the kernel.itb file.

What is the correct method to alter the kernel configuration and then deploy it in the itb file?

Can someone please help?

0 Kudos
Reply