Building Gadget USB Module

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(General Comments)
(Ubuntu Feisty 7.0.4)
Line 6: Line 6:
 
== Ubuntu Feisty 7.0.4 ==
 
== Ubuntu Feisty 7.0.4 ==
 
To prepare your environment run the following:
 
To prepare your environment run the following:
<pre>
+
sudo apt-get install linux-source linux-headers-`uname -r`
sudo apt-get install linux-source linux-headers-`uname -r`
+
</pre>
+
  
 
Uncompress /usr/src/linux-source-2.6.##.tar.gz (or .bz2)
 
Uncompress /usr/src/linux-source-2.6.##.tar.gz (or .bz2)
<pre>
+
cd /usr/src/
cd /usr/src/
+
 
sudo tar -xvf /usr/src/linux-source-2.6.##.tar.gz
 
sudo tar -xvf /usr/src/linux-source-2.6.##.tar.gz
</pre>
+
 
 
link it to /usr/src/linux
 
link it to /usr/src/linux
<pre>
+
sudo ln -s /usr/src/linux-source-2.6.## /usr/src/linux
sudo ln -s /usr/src/linux-source-2.6.## /usr/src/linux
+
 
</pre>
+
 
ensure /lib/modules/`uname -r`/build exists,  
 
ensure /lib/modules/`uname -r`/build exists,  
<pre>
+
ls /lib/modules/`uname -r`/build
ls /lib/modules/`uname -r`/build
+
 
</pre>
+
 
then run the following:
 
then run the following:
<pre>
+
mkdir usb_module_dir
mkdir usb_module_dir
+
cd usb_module_dir
cd usb_module_dir
+
cp -r /usr/src/linux/drivers/usb/* .
cp -r /usr/src/linux/drivers/usb/* .
+
cd gadget
cd gadget
+
echo "KDIR := /lib/modules/`uname -r`/build" >> Makefile
echo "KDIR := /lib/modules/`uname -r`/build" >> Makefile
+
echo "PWD := `pwd`" >> Makefile
echo "PWD := `pwd`" >> Makefile
+
echo "obj-m := dummy_hcd.o gadgetfs.o" >> Makefile
echo "obj-m := dummy_hcd.o gadgetfs.o" >> Makefile
+
echo "default: " >> Makefile
echo "default: " >> Makefile
+
echo -e "\t\$(MAKE) -C \$(KDIR) SUBDIRS=\$(PWD) modules" >> Makefile
echo -e "\t\$(MAKE) -C \$(KDIR) SUBDIRS=\$(PWD) modules" >> Makefile
+
make
make
+
</pre>
+
  
 
Once the kernel modules ( dummy_hcd.ko and gadgetfs.ko ) are built, you must remove (or move) the gadgetfs and net2280 as follows:
 
Once the kernel modules ( dummy_hcd.ko and gadgetfs.ko ) are built, you must remove (or move) the gadgetfs and net2280 as follows:
<pre>
+
sudo mv /lib/modules/`uname -r`/kernel/drivers/usb/gadget/net2280.ko ./original_net2280.ko
sudo mv /lib/modules/`uname -r`/kernel/drivers/usb/gadget/net2280.ko ./original_net2280.ko
+
sudo mv /lib/modules/`uname -r`/kernel/drivers/usb/gadget/gadget.ko ./original_gadgetfs.ko
sudo mv /lib/modules/`uname -r`/kernel/drivers/usb/gadget/gadget.ko ./original_gadgetfs.ko
+
</pre>
+
  
 
and replace them with the new modules:
 
and replace them with the new modules:
<pre>
+
sudo cp dummy_hcd.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/
sudo cp dummy_hcd.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/
+
sudo cp gadgetfs.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/
sudo cp gadgetfs.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/
+
sudo depmod
sudo depmod
+
</pre>
+
  
 
The net2280 module provides conflicting symbols and causes interference with the dummy_hcd module.
 
The net2280 module provides conflicting symbols and causes interference with the dummy_hcd module.

Revision as of 15:34, 30 July 2007

General Comments

You will most likely need kernel version 2.6.20 or higher

This procedure works on Debian GNU/Linux as well.

Ubuntu Feisty 7.0.4

To prepare your environment run the following:

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

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

cd /usr/src/

sudo tar -xvf /usr/src/linux-source-2.6.##.tar.gz

link it to /usr/src/linux

sudo ln -s /usr/src/linux-source-2.6.## /usr/src/linux

ensure /lib/modules/`uname -r`/build exists,

ls /lib/modules/`uname -r`/build

then run the following:

mkdir usb_module_dir
cd usb_module_dir
cp -r /usr/src/linux/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

Once the kernel modules ( dummy_hcd.ko and gadgetfs.ko ) are built, you must remove (or move) the gadgetfs and net2280 as follows:

sudo mv /lib/modules/`uname -r`/kernel/drivers/usb/gadget/net2280.ko ./original_net2280.ko
sudo mv /lib/modules/`uname -r`/kernel/drivers/usb/gadget/gadget.ko ./original_gadgetfs.ko

and replace them with the new modules:

sudo cp dummy_hcd.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/
sudo cp gadgetfs.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/
sudo depmod

The net2280 module provides conflicting symbols and causes interference with the dummy_hcd module.

Personal tools

General Comments

You will most likely need kernel version 2.6.20 or higher

This procedure works on Debian GNU/Linux as well.

Ubuntu Feisty 7.0.4

To prepare your environment run the following:

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

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

cd /usr/src/
sudo tar -xvf /usr/src/linux-source-2.6.##.tar.gz

link it to /usr/src/linux

sudo ln -s /usr/src/linux-source-2.6.## /usr/src/linux

ensure /lib/modules/`uname -r`/build exists,

ls /lib/modules/`uname -r`/build

then run the following:

mkdir usb_module_dir
cd usb_module_dir
cp -r /usr/src/linux/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

Once the kernel modules ( dummy_hcd.ko and gadgetfs.ko ) are built, you must remove (or move) the gadgetfs and net2280 as follows:

sudo mv /lib/modules/`uname -r`/kernel/drivers/usb/gadget/net2280.ko ./original_net2280.ko
sudo mv /lib/modules/`uname -r`/kernel/drivers/usb/gadget/gadget.ko ./original_gadgetfs.ko

and replace them with the new modules:

sudo cp dummy_hcd.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/
sudo cp gadgetfs.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/
sudo depmod

The net2280 module provides conflicting symbols and causes interference with the dummy_hcd module.