Building Gadget USB Module

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(Kernel recompilation for Debian/Ubuntu)
Line 30: Line 30:
 
  sudo insmod ./dummy_hcd.ko
 
  sudo insmod ./dummy_hcd.ko
 
  sudo insmod ./gadgetfs.ko default_uid=`id -u`
 
  sudo insmod ./gadgetfs.ko default_uid=`id -u`
 +
 +
== Debian/Ubuntu - full kernel recompilation using make-kpkg ==
 +
 +
Gain root priviledges
 +
  sudo su -
 +
 +
Prepare your environment by installing some packages:
 +
  apt-get install kernel-package linux-source libncurses5-dev
 +
 +
Optionally, edit '''/etc/kernel-pkg.conf''' and fill in ''email'' and ''maintener'' fields.
 +
 +
Untar the kernel sources, and enter them
 +
  tar -C /usr/src -xjf /usr/src/linux-source-2.6.##.tar.bz2
 +
  cd /usr/src/linux-source.2.6.##
 +
 +
Prepare your kernel tree: copy the current kernel configuration and start kernel configuration
 +
  cp /boot/config-`uname -r` .config
 +
  make menuconfig
 +
 +
Find and enable all the necessary modules by following [[OpenMoko_under_QEMU#Setting_up_USB_connection|these instructions]].
 +
 +
It's now time to compile your kernel. Type:
 +
  make-kpkg -us -uc kernel_image kernel_headers
 +
 +
If all goes well, install your freshly created kernel:
 +
  dpkg -i /usr/src/linux-{image,headers}-2.6.XX.XXXXXXXXXXXXXX.deb
 +
 +
Update the boot loader configuration if necessary, and reboot using the created kernel.
  
 
[[Category:Categories]]
 
[[Category:Categories]]
 
[[Category:Guides]]
 
[[Category:Guides]]

Revision as of 12:38, 22 August 2007

General Comments

The guide is currently valid for Debian-based distros. Feel free to add instructions for others as well.

You will most likely need kernel version 2.6.20 or higher.

Debian GNU/Linux Lenny and Ubuntu Feisty Fawn 7.04

To prepare your environment run the following:

sudo apt-get install linux-source linux-headers-`uname -r`

Create and enter working dir (e.g. ~/gadgetfs)

mkdir $WD
cd $WD

Uncompress /usr/src/linux-source-2.6.##.tar.gz (or .bz2)

tar xf /usr/src/linux-source-2.6.##.tar.gz

Then run the following:

mkdir usb_module_dir
cd usb_module_dir
cp -r /usr/src/linux-source-2.6.##/drivers/usb/* .
cd gadget
echo "KDIR := /lib/modules/`uname -r`/build" >> Makefile
echo "PWD := `pwd`" >> Makefile
echo "obj-m := dummy_hcd.o gadgetfs.o" >> Makefile
echo "default: " >> Makefile
echo -e "\t\$(MAKE) -C \$(KDIR) SUBDIRS=\$(PWD) modules" >> Makefile
make

If everything went fine you will find dummy_hcd.ko and gadgetfs.o along with other files in the current directory. Load the modules whenever you need them by issuing

sudo insmod ./dummy_hcd.ko
sudo insmod ./gadgetfs.ko default_uid=`id -u`

Debian/Ubuntu - full kernel recompilation using make-kpkg

Gain root priviledges

 sudo su -

Prepare your environment by installing some packages:

 apt-get install kernel-package linux-source libncurses5-dev

Optionally, edit /etc/kernel-pkg.conf and fill in email and maintener fields.

Untar the kernel sources, and enter them

 tar -C /usr/src -xjf /usr/src/linux-source-2.6.##.tar.bz2
 cd /usr/src/linux-source.2.6.##

Prepare your kernel tree: copy the current kernel configuration and start kernel configuration

 cp /boot/config-`uname -r` .config
 make menuconfig

Find and enable all the necessary modules by following these instructions.

It's now time to compile your kernel. Type:

 make-kpkg -us -uc kernel_image kernel_headers

If all goes well, install your freshly created kernel:

 dpkg -i /usr/src/linux-{image,headers}-2.6.XX.XXXXXXXXXXXXXX.deb

Update the boot loader configuration if necessary, and reboot using the created kernel.

Personal tools

General Comments

The guide is currently valid for Debian-based distros. Feel free to add instructions for others as well.

You will most likely need kernel version 2.6.20 or higher.

Debian GNU/Linux Lenny and Ubuntu Feisty Fawn 7.04

To prepare your environment run the following:

sudo apt-get install linux-source linux-headers-`uname -r`

Create and enter working dir (e.g. ~/gadgetfs)

mkdir $WD
cd $WD

Uncompress /usr/src/linux-source-2.6.##.tar.gz (or .bz2)

tar xf /usr/src/linux-source-2.6.##.tar.gz

Then run the following:

mkdir usb_module_dir
cd usb_module_dir
cp -r /usr/src/linux-source-2.6.##/drivers/usb/* .
cd gadget
echo "KDIR := /lib/modules/`uname -r`/build" >> Makefile
echo "PWD := `pwd`" >> Makefile
echo "obj-m := dummy_hcd.o gadgetfs.o" >> Makefile
echo "default: " >> Makefile
echo -e "\t\$(MAKE) -C \$(KDIR) SUBDIRS=\$(PWD) modules" >> Makefile
make

If everything went fine you will find dummy_hcd.ko and gadgetfs.o along with other files in the current directory. Load the modules whenever you need them by issuing

sudo insmod ./dummy_hcd.ko
sudo insmod ./gadgetfs.ko default_uid=`id -u`