Copy from:
http://www.absolutelytech.com/2010/04/18/solved-unable-to-enumerate-usb-device-disabling-ehci_hcd/
Some hardware just don’t work with ehci_hcd on Karmic Koala. My memory stick from transcend refused to work no matter what I did. After plugging the device nothing happened, doing dmesg showed me the following error:
Apr 18 10:59:04 dpac-laptop kernel: [73668.388060] usb 1-2: new high speed USB device using ehci_hcd and address 5
Apr 18 10:59:04 dpac-laptop kernel: [73668.473034] hub 1-0:1.0: unable to enumerate USB device on port 2
After searching a lot, I came to a conclusion that my device doesn’t work with USB 2.0. So I disabled the ehci_hcd to make it work.
Since Karmic doesn’t use ehci_hcd as a module, modprobe -r ehci_hcd no longer works. The module is compiled into kernel. To disable it execute the following commands in terminal:
cd /sys/bus/pci/drivers/ehci_hcd
ls
You will see a file with 0000:00:xx.x format. Execute the following command:
sudo sh -c 'echo -n "0000:00:xx.x" > unbind'
Replace the xx.x with the numbers displayed on your file. It should disable the ehci_hcd.
I plugged in my memory stick, and it worked.
Please note that you’ll have to do all this each time you restart.
UPDATE
You can now use the following script to disable ehci_hcd. It is far more simpler since it just needs you copy pasting the commands instead of a manual action. Here it goes:
cd /sys/bus/pci/drivers/ehci_hcd/
sudo sh -c 'find ./ -name "0000:00:*" -print| sed "s/\.\///">unbind'
Cheers!
Friday, April 1, 2011
Wednesday, November 3, 2010
How to: Compile Linux kernel modules
How to: Compile Linux kernel modules
by LinuxTitli
(Link http://www.cyberciti.biz/tips/compiling-linux-kernel-module.html)
This is one the essential and important task. Many time we upgrade our kernel and some recompiled drivers won't work with Linux. Especially if you have weird hardware; then vendor may send you driver code aka C files to compile. Or even you can write your own Linux kernel driver. Compiling kernel driver is easy. Kernel 2.6.xx makes it even much more easier. Following steps are required to compile driver as module:
1) You need running kernel source code; if you don't have a source code download it from kernel.org. Untar kernel source code (tar ball) in /usr/src using tar command:
$ tar -zxvf kernel* -C /usr/src
To be frank kernel headers are more than sufficient to compile kernel modules / drivers. See how to install kernel headers under Debian / Ubuntu Linux or RHEL / CentOS / Fedora Linux.
2) Next go to your kernel module source code directory and simply create the Makefile file as follows (assuming your kernel module name is foo):
$ vi Makefile
3) Add following text to it:
obj-m = foo.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
4) Compile module using make command (module build can be done by any user) :
$ make
It will finally creates the foo.ko module in current directory. You can see all actual compile command stored in .foo* files in same directory.
5) Once module compiled successfully, load it using insmod or modprobe command. You need to be root user or privileged user to run insmod:
# insmod foo.ko
Example: hello.c module
1) hello.c C source code. Copy following code and save to hello.c
$ mkdir demo; cd demo
$ vi hello.c
2)Add following c source code to it:
#include /* Needed by all modules */
#include /* Needed for KERN_INFO */
#include /* Needed for the macros */
static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}
static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}
module_init(hello_start);
module_exit(hello_end);
This is an example modified from original source for demonstration purpose.
3) Save the file. Create new Makefile as follows:
$ vi Makefile
Append following make commands:
obj-m = hello.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
4) Save and close the file.
5) Compile hello.c module:
$ make
6) Become a root user (use su or sudo) and load the module:
$ su -
# insmod hello.ko
Note you can see message on screen if you are logged in as root under run level 3.
7) Verify that module loaded:
# lsmod | less
8) See message in /var/log/message file:
# tail -f /var/log/message
9) Unload the module:
# rmmod hello
10) Load module when Linux system comes up. File /etc/modules use to load kernel boot time. This file should contain the names of kernel modules that are to be loaded at boot time, one per line. First copy your module to /lib/modules/$(uname -r)/kernel/drivers. Following are suggested steps:
(a) Create directory for hello module:
# mkdir -p /lib/modules/$(uname -r)/kernel/drivers/hello
(b) Copy module:
# cp hello.ko /lib/modules/$(uname -r)/kernel/drivers/hello/
(c) Edit /etc/modules file under Debian Linux:
# vi /etc/modules
(d) Add following line to it:
hello
(e) Reboot to see changes. Use lsmod or dmesg command to verify module loaded or not.
# cat /proc/modules
OR
# lsmod | less
by LinuxTitli
(Link http://www.cyberciti.biz/tips/compiling-linux-kernel-module.html)
This is one the essential and important task. Many time we upgrade our kernel and some recompiled drivers won't work with Linux. Especially if you have weird hardware; then vendor may send you driver code aka C files to compile. Or even you can write your own Linux kernel driver. Compiling kernel driver is easy. Kernel 2.6.xx makes it even much more easier. Following steps are required to compile driver as module:
1) You need running kernel source code; if you don't have a source code download it from kernel.org. Untar kernel source code (tar ball) in /usr/src using tar command:
$ tar -zxvf kernel* -C /usr/src
To be frank kernel headers are more than sufficient to compile kernel modules / drivers. See how to install kernel headers under Debian / Ubuntu Linux or RHEL / CentOS / Fedora Linux.
2) Next go to your kernel module source code directory and simply create the Makefile file as follows (assuming your kernel module name is foo):
$ vi Makefile
3) Add following text to it:
obj-m = foo.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
4) Compile module using make command (module build can be done by any user) :
$ make
It will finally creates the foo.ko module in current directory. You can see all actual compile command stored in .foo* files in same directory.
5) Once module compiled successfully, load it using insmod or modprobe command. You need to be root user or privileged user to run insmod:
# insmod foo.ko
Example: hello.c module
1) hello.c C source code. Copy following code and save to hello.c
$ mkdir demo; cd demo
$ vi hello.c
2)Add following c source code to it:
#include
#include
#include
static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}
static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}
module_init(hello_start);
module_exit(hello_end);
This is an example modified from original source for demonstration purpose.
3) Save the file. Create new Makefile as follows:
$ vi Makefile
Append following make commands:
obj-m = hello.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
4) Save and close the file.
5) Compile hello.c module:
$ make
6) Become a root user (use su or sudo) and load the module:
$ su -
# insmod hello.ko
Note you can see message on screen if you are logged in as root under run level 3.
7) Verify that module loaded:
# lsmod | less
8) See message in /var/log/message file:
# tail -f /var/log/message
9) Unload the module:
# rmmod hello
10) Load module when Linux system comes up. File /etc/modules use to load kernel boot time. This file should contain the names of kernel modules that are to be loaded at boot time, one per line. First copy your module to /lib/modules/$(uname -r)/kernel/drivers. Following are suggested steps:
(a) Create directory for hello module:
# mkdir -p /lib/modules/$(uname -r)/kernel/drivers/hello
(b) Copy module:
# cp hello.ko /lib/modules/$(uname -r)/kernel/drivers/hello/
(c) Edit /etc/modules file under Debian Linux:
# vi /etc/modules
(d) Add following line to it:
hello
(e) Reboot to see changes. Use lsmod or dmesg command to verify module loaded or not.
# cat /proc/modules
OR
# lsmod | less
Saturday, July 24, 2010
Cài đặt MySQL Server 5 trên Ubuntu
Cài mysql server:
#sudo apt-get install mysql-server
Cài module PHP cho mysql nếu dùng php:
#sudo apt-get install php5-mysql
Kiểm tra thử tạo mới 1 database dùng mysqladmin:
#mysqladmin create < databasename >
Cài đặt Apache web server:
#sudo apt-get install apache2
Cài đặt PHP 5
#sudo apt-get install php5
#sudo apt-get install libapache2-mod-php5
Restart apache server:
sudo /etc/init.d/apache2 restart
MYSQL:
Start MySql server:
#/etc/init.d/mysql start
Stop MySql server:
#/etc/init.d/mysql stop
Restart MySql server:
#/etc/init.d/mysql restart
Kiểm tra trạng thái của MySql server:
#/etc/init.d/mysql status
Monday, July 5, 2010
Sunday, July 4, 2010
Ubuntu Server
1. Install SSH:
Type the following two command to install both ssh client and server:
#sudo apt-get install openssh-server openssh-client
Start SSH Server:
# sudo /etc/init.d/ssh start
Stop SSH Server:
# sudo /etc/init.d/ssh stop
Restart SSH Server:
# sudo /etc/init.d/ssh restart
2. Installing and setting TFTPD in Ubuntu
- Install tftpd and related packages.
$ sudo apt-get install xinetd tftpd tftp
- Create /etc/xinetd.d/tftp and put this entry:
service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /tftpboot
disable = no
}
- Make /tftpboot directory
$ sudo mkdir /tftpboot
$ sudo chmod -R 777 /tftpboot
$ sudo chown -R nobody /tftpboot
- Start tftpd through xinetd
$ sudo /etc/init.d/xinetd start
Or
$ sudo /etc/init.d/xinetd restart
3. NFS Server
- In order to set NFS server you need to install the following packages:
=> nfs-kernel-server - Linux NFS Server
=> nfs-common - NFS Common programs
=> portmap - The RPC portmapper
- Use apt-get command to install all required packages:
$ sudo apt-get install nfs-kernel-server portmap nfs-common
- Sharing directory with /etc/exports
$ sudo vi /etc/exports
To export /data directory to 192.168.1.0/24 network enter the following
in /etc/exports file:
/data 192.168.1.0/24(rw,rsync)
To export /sales to hostname tom and jerry, enter:
/sales tom(ro,sync) jerry(ro,sync)
To export /users to 192.168.1.0/24 in read write format, enter:
/users 192.168.1.0/24(ro,sync) jerry(rw,fsid=0,insecure,no_subtree_check,async)
/AMCC/ppc_4xx *(rw,no_root_squash,no_all_squash,sync,no_subtree_check)
Where,
* rw : Allow clients to read as well as write access
* ro : Read only access
* insecure : Tells the NFS server to use unpriveledged ports (ports > 1024).
* no_subtree_check : If the entire volume (/users) is exported, disabling
this check will speed up transfers.
* async : async will speed up transfers.
Save and close the file. Just restart nfs-server:
$ sudo /etc/init.d/nfs-kernel-server restart
Now your NFS sever is sharing /sales and /data directories.
Saturday, July 3, 2010
Ubuntu (TT)
4. Grub2
Cài đặt:
$ sudo apt-get install grub2
Link
5. Phầm mềm chỉnh sửa & ghi CD & DVD:
- Phần mềm chỉnh sửa đĩa ISO: ISO Master. Có thể cài đặt bằng cách vô
Ubuntu Software Center gõ ISO Master or bằng lệnh sau:
sudo apt-get install isomaster
- Phần mềm ghi đĩa: K3B, Brasero, GnomeBaker ... & google :D
Cách cài thì tương tự như trên.
Wednesday, June 30, 2010
Ubuntu ...
1. Dùng alias để tạo lệnh mới trên Ubuntu:
Thêm vào dòng lệnh alias vào file ~/.bashrc.
Ví dụ:
alias ls='ls --color=auto -hF'
alias ll='ls --color=auto -lhF'
alias la='ls --color=auto -lahF'
alias grep='grep --color=auto'
alias diff='diff -rBNup'
Sau đó tắt terminal đi, mở lại. Bây giờ ta có thể dùng lệnh la tương đương
với gõ ls --color=auto -lahF,
or grep thì tương đương với gõ grep --color=auto, ...
2. Tăng tốc cho Ubuntu:
2.1 Disable IPV6 Ubuntu:
Cách 1: Thay đổi nội dung file aliases
sudo vi /etc/modprobe.d/aliases
Tìm dòng alias net-pf-10 ipv6
Sau đó đổi thành alias net-pf-10 off (Or aliases net-pf-10 off ipv6)
Save file and reboot.
Cách 2: Disable trên Firefox
Vào thành address bar: Gõ about:config search từ network.dns.disableIPv6,
sau đó nhấn chuột phải đổi thành TRUE
Cách 3: Thay đổi file /etc/default/grub
sudo vi /etc/default/grub
Tìm
GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”
Sau đó đổi thành
GRUB_CMDLINE_LINUX_DEFAULT=”ipv6.disable=1 quiet splash”
Save lại.
Sau đó update grub
sudo update-grub
2.2 Tăng tốc quá trình khởi động:
Code:
sudo vi /etc/init.d/rc
Sửa dòng CONCURRENCY=none thành CONCURRENCY=shell là hoàn tất.
Nhớ lưu file lại & reboot
2.3 Đẩy dữ liệu lên RAM
Thủ thuật này đặc biệt hiệu quả khi bạn có nhiều RAM (tầm 512MB trở lên).
Thủ thuật này sẽ giảm số lần ghi dữ liệu tạm lên ổ cứng, thay vì vậy sẽ
ghi dữ liệu tạm vào ram càng nhiều càng tốt.
Bạn chạy lệnh:
Code:
sudo gedit /etc/sysctl.conf
Sau đó thêm dòng vm.swappiness=10 vào cuối file rồi lưu lại.
Từ lần khởi động sau thiệt lập sẽ được thực hiện mặc định.
Khi không có dòng này thì giá trị mặc định là 60, bạn có thể thay
bằng 5 nếu có nhiều hơn 1GB ram, và đặt về 0 nếu thích, khi đặt về 0
thì Linux sẽ giảm thiểu tối đa việc sử dụng đĩa cứng lưu dữ liệu tạm.
3. Cài đặt Ubuntu từ đĩa USB di động:
Link
(Còn nữa).
Subscribe to:
Posts (Atom)