Building Gadget USB Module

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (Debian GNU/Linux Lenny and Ubuntu Feisty Fawn 7.04)
m (Category: -Software (non-openmoko), +Debian)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{Todo|Please add a description of what this is.}}
 +
 
== General Comments ==
 
== General Comments ==
 +
 
The guide is currently valid for Debian-based distros. Feel free to add instructions for others as well.
 
The guide is currently valid for Debian-based distros. Feel free to add instructions for others as well.
  
Line 60: Line 63:
 
   make menuconfig
 
   make menuconfig
  
Find and enable all the necessary modules by following [[OpenMoko_under_QEMU#Setting_up_USB_connection|these instructions]].
+
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:
 
It's now time to compile your kernel. Type:
Line 75: Line 78:
  
 
This is a hack, but works for me.
 
This is a hack, but works for me.
[[Category:Technical]]
+
[[Category:Debian]]
[[Category:Software (non openmoko)]]
+
[[Category:Documentation]]
+

Latest revision as of 20:58, 14 September 2008

TODO: Please add a description of what this is. (See: To-Do List)

[edit] 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.

[edit] Debian GNU/Linux Lenny and Ubuntu Feisty Fawn 7.04 / Hardy 8.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 the kernel source (pick one and adjust the minor version number):

tar xfz /usr/src/linux-source-2.6.##.tar.gz
tar xfj /usr/src/linux-source-2.6.##.tar.bz2

Note: This will place the source in the current working directory.

Then run the following:

mkdir usb_module_dir
cd usb_module_dir
cp -r ../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`

If you get the following error (happens for example on Ubunutu 8.04 - 2.6.24-19-generic)

insmod: error inserting './dummy_hcd.ko': -1 Invalid module format

try to unload the net2280 module, because it might blocking the dummy_hcd.ko module

sudo rmmod net2280

after that try it again

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

[edit] 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 --initrd kernel_image kernel_headers

If all goes well, install your freshly created kernel:

 dpkg -i /usr/src/linux-{image,headers}-VERSION_XXXXX_ARCH.deb

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

NOTE: Before installing the kernel, you should also prepare the firmware directory by creating a link to the current kernel firmware directory:

 ln -s /lib/firmware/`uname -r` /lib/firmware/VERSION

where VERSION is the full version of the created kernel (e.g. 2.6.20.3-ubuntu1)

This is a hack, but works for me.

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 / Hardy 8.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 the kernel source (pick one and adjust the minor version number):

tar xfz /usr/src/linux-source-2.6.##.tar.gz
tar xfj /usr/src/linux-source-2.6.##.tar.bz2

Note: This will place the source in the current working directory.

Then run the following:

mkdir usb_module_dir
cd usb_module_dir
cp -r ../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`

If you get the following error (happens for example on Ubunutu 8.04 - 2.6.24-19-generic)

insmod: error inserting './dummy_hcd.ko': -1 Invalid module format

try to unload the net2280 module, because it might blocking the dummy_hcd.ko module

sudo rmmod net2280

after that try it again

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 --initrd kernel_image kernel_headers

If all goes well, install your freshly created kernel:

 dpkg -i /usr/src/linux-{image,headers}-VERSION_XXXXX_ARCH.deb

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

NOTE: Before installing the kernel, you should also prepare the firmware directory by creating a link to the current kernel firmware directory:

 ln -s /lib/firmware/`uname -r` /lib/firmware/VERSION

where VERSION is the full version of the created kernel (e.g. 2.6.20.3-ubuntu1)

This is a hack, but works for me.