Difference between revisions of "CI20-SGX kernel module"

From eLinux.org
Jump to: navigation, search
(added UM binaries link)
(Update SGX driver info)
Line 1: Line 1:
 
{{TOC right}}
 
{{TOC right}}
  
The graphics driver for the CI20 is an out-of-tree kernel module. The way kernel modules work is that they have to be recompiled if the base kernel is modified. This is kernel feature. Modules are only allowed to be loaded when they have been compiled based on the exact source tree and options that the running kernel is.
+
The graphics driver for the CI20 is an out-of-tree kernel module. Kernel modules must be recompiled if the base kernel is modified. Modules are only allowed to be loaded when they have been compiled using the exact source tree and kernel configuration as that of the running kernel.
  
As the default xorg driver also uses the GPU for running X window system, it would seem that debian gui fails to load when you recompile the kernel from sources. The only thing that needs doing, is to recompile the kernel module for the GPU. And copy that module onto the filesystem.
+
As the default Xorg driver also uses the GPU for running the X window system, it would seem that Debian GUI fails to load when you recompile the kernel from sources. The only thing that needs doing, is to recompile the kernel module for the GPU and then copy that module onto the filesystem.
  
If GPU functionality is not required by whatever task you wish to do with the CI20, you could just disable the module. You will still be able to use the Debian GUI. This just disables hardware 3D acceleration, OpenGL etc. Instructions for disabling the GPU are available [[CI20-SGX_kernel_module#Disabling_the_GPU_module|here]]
+
It's also possible to disable the GPU, if you don't need it for any specific task. You will still be able to use the Debian GUI (with a tweak to your xorg.conf), but hardware 3D acceleration and OpenGL will be disabled. Instructions for disabling the GPU are available [[CI20-SGX_kernel_module#Disabling_the_GPU_module|here]]
 +
 
 +
It is important that your kernel module and user module version match, else the SGX driver will fail to load. The following table details this:
 +
{| class="wikitable"
 +
|-
 +
! Kernel Version !! Kernel Module Version !! User Module Version
 +
|-
 +
| 3.0.8 || [http://mipscreator.imgtec.com/CI20/sgx/ci20-sgx-km-1.13.3341330_3.0.8.tgz 1.13.3341330] || [http://mipscreator.imgtec.com/CI20/sgx/UM_Binaries.1.13.3341330.2015-06-25_10_09_21_withXSGX.tar 1.13.3341330]
 +
|-
 +
| 3.18 || [http://mipscreator.imgtec.com/CI20/sgx/SGX_DDK_Linux_XOrg_MAIN%403759903_source_km.tgz 1.14.3759903] || [http://mipscreator.imgtec.com/CI20/sgx/SGX_DDK_Linux_XOrg_ES1_ES2_OGL_MAIN%403759903_binary_um.tar 1.14.3759903]
 +
|}
  
 
== Compiling the module ==
 
== Compiling the module ==
The kernel part of the GPU driver must be built to generate a kernel module which is then loaded and interacts with the SGX hardware and the userland portions of the driver. The sources for the module are available for the 3.0.8 version of the GPU driver.
+
The kernel part of the GPU driver must be built to generate a kernel module which is then loaded and interacts with the SGX hardware and the userland portions of the driver. The sources for the module are available for the 3.18 version of the GPU driver.
 
 
You may build the module using the following instructions:
 
 
 
Check the UM libraries version on your CI20
 
 
 
root@ci20-3110:~# ls -al /usr/lib/libpvr*
 
lrwxrwxrwx 1 root root    24 Jun  9  2014 /usr/lib/libpvr2d.so -> libpvr2d.so.1.11.2580795
 
-rwxr-xr-x 1 root root 29668 Jun  9  2014 /usr/lib/libpvr2d.so.1.11.2580795
 
 
 
OR
 
 
 
root@ci20:~# ls -al /usr/lib/libpvr*
 
lrwxrwxrwx 1 root root    24 Feb  2 12:05 /usr/lib/libpvr2d.so -> libpvr2d.so.1.13.3341330
 
lrwxrwxrwx 1 root root    24 Feb  2 12:05 /usr/lib/libpvr2d.so.1 -> libpvr2d.so.1.13.3341330
 
 
 
If you have libpvr2d.so -> libpvr2d.so.1.11.2580795, you are running the older version of the NAND image. It is highly recommended to upgrade to a newer version. [http://elinux.org/CI20_Distros]
 
The exact tarball is ci20-sgx-km-6f3b77c686de27ef260beb92b7fe30e7da9671a5.tar.gz from [https://github.com/MIPS/CI20_collateral here]
 
 
 
If you have libpvr2d.so -> libpvr2d.so.1.13.3341330 or newer, you can see the exact tarball from [https://github.com/MIPS/CI20_collateral here]. The file name should correspond to the UM libraries you have and the kernel version.. e.g. ci20-sgx-km-1.13.3341330_3.0.8
 
 
 
Inside the directory, run the following
 
  
  CROSS_COMPILE=$CROSS_COMPILE ARCH=mips KERNELDIR=/home/user/ci20/linux_kernel_repo_dir make -C eurasiacon/build/linux2/jz4780_linux
+
Download and extract the latest kernel module. Change into the extracted directory and run the following (ensuring that CROSS_COMPILE is correctly set):
  
You will need to adjust KERNELDIR to the appropriate path to where the source code for your ci20 kernel is located.
+
CROSS_COMPILE=$CROSS_COMPILE ARCH=mips KERNELDIR=/home/user/ci20/linux_kernel_repo_dir make -C eurasiacon/build/linux2/jz4780_linux
And the CROSS_COMPILE path to your cross compiler.
 
  
 
This will generate the pvrsrvkm.ko module file. This needs to be placed in the following path
 
This will generate the pvrsrvkm.ko module file. This needs to be placed in the following path
  
  /lib/modules/3.0.8-xxxxx-xxxxxxxxx/kernel/drivers/gpu/pvrsrvkm.ko
+
  cp eurasicon/binary2_jz4780_linux_release/target/pvrsrvkm.ko /lib/modules/`uname -r`/extra/
 
 
The folder name should match the kernel version you are running. You can check using
 
 
 
uname -a
 
 
 
== Downloading the usermode binaries ==
 
 
 
The binaries are available for download at the following links. These are for use with Debian 7 and Kernel 3.0.8.
 
http://mipscreator.imgtec.com/CI20/sgx/UM_Binaries.1.13.3341330.2015-06-25_10_09_21_withXSGX.tar
 
http://mipscreator.imgtec.com/CI20/sgx/UM_Binaries.1.13.3341330.2015-06-25_10_09_21.tar
 
  
 
== Disabling the GPU module ==
 
== Disabling the GPU module ==
You can set xorg to default to using the fbdev driver instead of the GPU if you don't need the GPU. i.e. Hardware 3D acceleration / opengl processing etc.
+
You can set Xorg to default to using the fbdev driver instead of the GPU. If you do so, the Debian GUI will still run.
 
 
The Debian GUI will still run.
 
  
 
The only thing you need to do is apply the following xorg.conf in /etc/X11/xorg.conf
 
The only thing you need to do is apply the following xorg.conf in /etc/X11/xorg.conf
Line 75: Line 51:
 
  EndSection
 
  EndSection
  
== HACK for advanced users ==
+
== Hack for advanced users ==
  
You can bypass the module version checking feature. But you should know what you are doing. Because changes to kernel options can easily tweak
+
If you know what you're doing, it is possible to bypass the kernel module version checking. However, changes to kernel options can easily tweak something minor that cause bad things to happen.
something minor that causes bad things to happen.
 
  
 
To do this, modify the kernel version string in the .config file to exactly match the one the original pvr module was built with.  
 
To do this, modify the kernel version string in the .config file to exactly match the one the original pvr module was built with.  
You can check that by checking your old /lib/modules/3.0.8-xxx directory numbers. or uname -a
+
You can check that by checking your old /lib/modules/3.18.3-ci20-x directory numbers or uname -r.
  
 
{{CI20}}
 
{{CI20}}
 
[[Category:CI20|SGX Kernel Module]]
 
[[Category:CI20|SGX Kernel Module]]

Revision as of 06:41, 15 October 2015

The graphics driver for the CI20 is an out-of-tree kernel module. Kernel modules must be recompiled if the base kernel is modified. Modules are only allowed to be loaded when they have been compiled using the exact source tree and kernel configuration as that of the running kernel.

As the default Xorg driver also uses the GPU for running the X window system, it would seem that Debian GUI fails to load when you recompile the kernel from sources. The only thing that needs doing, is to recompile the kernel module for the GPU and then copy that module onto the filesystem.

It's also possible to disable the GPU, if you don't need it for any specific task. You will still be able to use the Debian GUI (with a tweak to your xorg.conf), but hardware 3D acceleration and OpenGL will be disabled. Instructions for disabling the GPU are available here

It is important that your kernel module and user module version match, else the SGX driver will fail to load. The following table details this:

Kernel Version Kernel Module Version User Module Version
3.0.8 1.13.3341330 1.13.3341330
3.18 1.14.3759903 1.14.3759903

Compiling the module

The kernel part of the GPU driver must be built to generate a kernel module which is then loaded and interacts with the SGX hardware and the userland portions of the driver. The sources for the module are available for the 3.18 version of the GPU driver.

Download and extract the latest kernel module. Change into the extracted directory and run the following (ensuring that CROSS_COMPILE is correctly set):

CROSS_COMPILE=$CROSS_COMPILE ARCH=mips KERNELDIR=/home/user/ci20/linux_kernel_repo_dir make -C eurasiacon/build/linux2/jz4780_linux

This will generate the pvrsrvkm.ko module file. This needs to be placed in the following path

cp eurasicon/binary2_jz4780_linux_release/target/pvrsrvkm.ko /lib/modules/`uname -r`/extra/

Disabling the GPU module

You can set Xorg to default to using the fbdev driver instead of the GPU. If you do so, the Debian GUI will still run.

The only thing you need to do is apply the following xorg.conf in /etc/X11/xorg.conf

# X.Org X server configuration file for CI20

Section "Device"
        Identifier      "Device0"
        Driver          "fbdev"
EndSection

Section "Monitor"
        Identifier      "Monitor"
EndSection

Section "Screen"
        Identifier      "Screen0"
        Monitor         "Monitor"
        Device          "Device0"
        DefaultFbBpp    32
EndSection

Hack for advanced users

If you know what you're doing, it is possible to bypass the kernel module version checking. However, changes to kernel options can easily tweak something minor that cause bad things to happen.

To do this, modify the kernel version string in the .config file to exactly match the one the original pvr module was built with. You can check that by checking your old /lib/modules/3.18.3-ci20-x directory numbers or uname -r.