Monday, March 17, 2014

Cross compile Raspberry Pi kernel to inslude tsc2007.ko

As tsc2007 is included in the source tree of Raspberry Pi source, this post show how to download (git clone) Raspberry Pi source and cross-compile on another host PC running Ubuntu. Setup .config to include tsc2007 module with menuconfig option in make.


Please note:


Create our working directory, raspberrypi:
  • $ mkdir raspberrypi
  • cd raspberrypi
Before start our works, install the necessary tools and source code of Raspberry Pi linux:
  • $ git clone https://github.com/raspberrypi/tools.git
  • $ git clone https://github.com/raspberrypi/linux.git
  • $ cd linux
(For default setup) Prepare the .config file from pre-packaged config, bcmrpi_cutdown_defconfig:
  • $ make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- bcmrpi_cutdown_defconfig
To generate .config with tsc2007 menu, run with menuconfig option:
  • $ make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig
You can find the following code will be added in the generated .config.

CONFIG_TOUCHSCREEN_TSC2007=m



Build kernel:
  • $ make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-
  • $ mkdir ../modules
  • $ make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/
  • $ cd ../tools/mkimage/
  • $ ./imagetool-uncompressed.py ../../linux/arch/arm/boot/Image


Now insert a Raspbian installed SD Card, and run the command:
  • $ sudo rm /media/<boot-partition>/kernel.img
  • $ sudo mv kernel.img /media/<boot-partition>/
  • $ sudo rm -rf /media/<rootfs-partition>/lib/modules/
  • $ sudo rm -rf /media/<rootfs-partition>/lib/firmware/
  • $ cd ../../modules/
  • $ sudo cp -a lib/modules/ /media/<rootfs-partition>/lib/
  • $ sudo cp -a lib/firmware/ /media/<rootfs-partition>/lib/
  • $ sync



Now you can run Raspberry Pi with this new build Image. tsc2007.ko is included, but not yet run. The following steps set it run in power up. Because tsc2007 is controlled with i2c bus, so it will be enabled also.

By default, i2c is disabled in Raspbian. To run tsc2007 and i2c modules, follow the step:
  • $ sudo nano /etc/modules
    add the lines:
    i2c-bcm2708
    i2c-dev
    tsc2007

  • $ sudo nano /etc/modprobe.d/raspi-blacklist.conf
    comment the line of
    #blacklist i2c-bcm2708
  • install i2c-tools for testing
    $ sudo apt-get install i2c-tools
  • reboot
  • After reboot, run i2c-tools to test
    run the command with -1 option for rev 2 board, or -0 for rev 1 board.
    $ sudo i2cdetect -y 1
    sudo i2cdetect -y 0





You can verify tsc2007 is running by lsmod command. But I don't know any more is needed to make the touch part of "Tontec 2.4-inch TFT LCD 240x320 RGB Pixels Touch Screen Display Monitor" to work!

2 comments:

Dhruv Vyas said...

Hi, Really a nice tutorial.

Though, after doing as per you described in here, Green LED (ACT) stopped blinking at all. Any idea why so ?

JIGNESH PATEL said...

Nice tutorial..
How can i create image? So i can install linux on rasberrypi using Win32 Disk imager.