Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. Show all posts

4 September 2008

Getting Aztech UM-3100 USB Modem to work on CentOS 5

Our old Hylafax external modems decided to kick the bucket over the weekend, and it was an opportunity to refresh the hardware. They lasted a good 9 years (or more!) and I dont think they make them anymore.

Additionally they had to be powered by large adaptors, which took up way too much room. So a good solution would be to use some USB modems; small, cheap, USB powered and easily replaceable.

We chose Aztech UM-3100 USB Modem. Relatively cheap at about RM70, we thought it would be a great solution. So I plugged it into the machine, and this was the dmesg output:

usb 1-2: new full speed USB device using uhci_hcd and address 2
usb 1-2: device descriptor read/64, error -71
usb 1-2: device descriptor read/64, error -71
usb 1-2: new full speed USB device using uhci_hcd and address 3
usb 1-2: device descriptor read/64, error -71
usb 1-2: device descriptor read/64, error -71
usb 1-2: new full speed USB device using uhci_hcd and address 4
usb 1-2: device not accepting address 4, error -71
usb 1-2: new full speed USB device using uhci_hcd and address 5
usb 1-2: configuration #1 chosen from 2 choices
drivers/usb/class/cdc-acm.c: Zero length descriptor references

cdc_acm: probe of 1-2:1.0 failed with error -22
usbcore: registered new driver cdc_acm
drivers/usb/class/cdc-acm.c: v0.25:USB Abstract Control Model driver for USB modems and ISDN adapters


So not very good news to start off the day. This usb-modem isn't supported out of the box, fortunately it isn't too much a problem, but it does require a recompilation of the cdc-acm (USB Communication Device Class definition - Abstract Control Module). Here is a brief lowdown on how to get the Aztech modem recognised in CentOS 5.0.

Prepping the system for module compilation

First, we need to bring down the linux kernel source.

# wget -c ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/kernel-2.6.18-8.1.8.el5.src.rpm
Length: 48176889 (46M)
8% [==> ] 4,018,200 124.1K/s eta 7m 27s

It took only about 7 minutes to download. A "rpm -hiv" extracted the sources in /usr/src/redhat. You will then need to extract the source from redhats patches by doing this:

# rpmbuild -bp --target=$(uname -m) /usr/src/redhat/SPECS/kernel-2.6.spec

which should recreate the kernel source in /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i686. Copy your config from the /boot directory to this directory

# cp /boot/config-`uname -r` ./.config

Now you are ready to compile the entire kernel ... if you want to. For me, I just want to compile the usb modem module, and not need to wait for the entire compilation process. But first, the modifications.

Adding support for the modem.

This ubuntu forum post "Shiro/Conexant (Rockwell) RD02-D400/Aztech UM3100 USB 56K Modem" provides the information to add support for the Aztech modem. First of all, we need to make sure that the ID as reported by lsusb is matches our modifications. To do so, type this:

# lsusb
Bus 001 Device 009: ID 0572:1328 Conexant Systems (Rockwell), Inc.


You will see that its 0x0572, 0x1328. This is what we will use in our modification. Modify the cdc-acm.c file:

# nano drivers/usb/class/cdc-acm.c

scroll down about 97%... put this in similar place, next to all the other devices
{ USB_DEVICE(0x0572, 0x1328), /* Aztech UM-3100 */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
Save, and that's all with the source code modification. No big deal.

Compiling the specific module.

Instead of having to build the kernel and all the modules, we can tell 'make' to build from specific directories. First, you will have to compile some scripts which are used for MODPOST, which is important to make the .ko module files.

# make SUBDIRS=scripts/mod/
WARNING: Symbol version dump /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i686/Module.symvers
is missing; modules will have no dependencies and modversions.

CC scripts/mod/empty.o
HOSTCC scripts/mod/mk_elfconfig
MKELF scripts/mod/elfconfig.h
HOSTCC scripts/mod/file2alias.o
HOSTCC scripts/mod/modpost.o
HOSTCC scripts/mod/sumversion.o
HOSTLD scripts/mod/modpost
Building modules, stage 2.
MODPOST


Then you can actually build the modules which are of particular interest to you, in this case "drivers/usb/class"

# make SUBDIRS=drivers/usb/class modules
WARNING: Symbol version dump /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i686/Module.symvers
is missing; modules will have no dependencies and modversions.
Building modules, stage 2.
MODPOST
CC drivers/usb/class/cdc-acm.mod.o
LD [M] drivers/usb/class/cdc-acm.ko
CC drivers/usb/class/usblp.mod.o
LD [M] drivers/usb/class/usblp.ko


The file which you need is drivers/usb/class/cdc-acm.ko so just copy this to the real modules directory of your running kernel.

# cp drivers/usb/class/cdc-acm.ko /lib/modules/2.6.18-8.el5/kernel/drivers/usb/class

Loading up the new module

Unload the module if it was loaded before:

# rmmod cdc_acm
ERROR: Module cdc_acm does not exist in /proc/modules


And load up the new one

# insmod cdc_acm

To check that its there:

# lsmod |grep cdc
cdc_acm 15136 0


And now, plug in the Aztech modem, and see what happens:

# dmesg
cdc_acm: no version for "struct_module" found: kernel tainted.
cdc_acm 1-2:1.0: ttyACM0: USB ACM device
usbcore: registered new driver cdc_acm
drivers/usb/class/cdc-acm.c: v0.25:USB Abstract Control Model driver for USB modems and ISDN adapters


Congratulations, it looks like its been recognised as ttyACM0

Testing the modem

Make sure you have the 'cu' utility installed. It usually comes in the 'uucp' package:
# yum install uucp
Once 'cu' is available, use '-l' to speak directly to the line.
# cu -l ttyACM0
Connected.
You can then reset the phone, and try to call out.
atz
OK
atdt9,012xxxxxxx
(9 is to get a dialtone from my PABX, and the comma is to wait).
Also test the modems ability to auto pickup after 1 ring with this command
ats0=1
However Hylafax controls the pickup process, so make sure this is not set. Reset the modem with this:
atz
And quit from 'cu' with this tilda command:
~.
Disconnected
Conclusion

Your Aztech modem should be recognised by the system even after a reboot (test it, its the only reboot you'll need to do). You can now plug in more USB modems to cater for your Fax server's needs.

yk.

31 July 2007

Little Tricks with Xen images from jailtime.org

Ive been busy setting up a CentOS server. After the successful installation of dspam on our FC5 Xen virtual machine, we have decided to move it from our development server (a frankenstein of a machine) to a proper host. Yes, Ive been testing it for over a year now!

Postfix with MySQL support in CentOS 5

So I downloaded a prebuilt CentOS image from jailtime and installed the necessary tools. A little trick I learnt was the inclusion of the extra repositories. dspam requires a postfix installation with MySQL support. To do this, you can either compile from source, but being the lazy git I am, I'd rather download the binaries.

To do this, you just need to enable the CentOSPlus repositories, which can be done via a command line switch:

# yum --enablerepo=centosplus upgrade postfix

Yum will then work out the requisites and download the stuff for you. Unfortunately it also brings down the postgresql binaries. So unless you are in dire need of hard disk space, don't do it this way.

We aren't in Kansas anymore, Toto

Another thing about the jailtime images is that the hwclock scripts are modified to return 0. This is because there is no hardware clock. It uses the host's (Dom0) time. So to get the correct time, make sure you change the zone information in /etc/localtime. For us users in Kuala Lumpur, I have to do this:

# ln -s /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime

Keeping it 32bits

My Xen host is a AMD 64 server. My Xen clients are i386 virtual machines. This is for "portability" reasons. My previous post about using yum to install i386 binaries can be improved. Now use setarch. To install:

# yum install setarch.i386

subsequently make sure you run it before yumming some more.

# setarch i386

If you forget and accidentally call yum, mixing i386 and x86_64 info, the downloaded headers will be "confused". You'd have to do a clean:

# yum clean all


yk.

9 February 2007

Yum, PHP and Xen running 32bits on a 64bit machine.

My host Xen server is an AMD 64bi machine. The little Xen VMs are based on CentOS 4.4 32bit, which I plan to keep it as such to allow easy migration. However it comes with abit of risk.

I managed to run 'yum install httpd mysql mysql-server' without any problems. But when I needed to install PHP, typing in 'yum install php' would result in a horrific set of errors which look like this:

Error: Missing Dependency: libgssapi_krb5.so.2()(64bit) is needed by package openssl
Error: Missing Dependency: libdl.so.2()(64bit) is needed by package openssl

etc...

which indicates that yum has detected the 64bit nature of the host arch, as 'uname' gives it away.

So how do I force yum to install only i386 binaries? Simple, RTFM! 'man yum' ... somewhere in the middle of the documentation, it states:
Specifying package names
A package can be referred to for install,update,list,remove etc with any of the following:

name
name.arch
name-ver
name-ver-rel
name-ver-rel.arch
name-epoch:ver-rel.arch
epoch:name-ver-rel.arch

For example: yum remove kernel-2.4.1-10.i686
So to get php to install nicely, just type:

yum install php.i386

and it works!

[Update: 5 minutes later.
It kinda worked. there was a problem at the end of the installation. Yum complained that 'package php-pear-4.3.9-3.22 is intended for a x86_64 architecture'. So "no problem," I thought, "I just apply what I learnt to php-pear by using 'yum install php-pear.i386'"
No. yum resolved that php needed more stuff like openssl, and decided to look for the 64 bit installation. I tried my luck and did this:

yum install php-pear.i386 php.i386

on the reasoning that I should also force yum to install only i386 archs for these two items. Surprisingly, it kept all the dependencies to i386, and it resolved it well.

So NOW it works.]

yk.

Xen and Centos 4.4

After finding it "difficult" to install extra stuff in a rPath installation, Im now trying to use the CentOS images from jailtime.org.
Got it running, and after getting the network up, I needed to install these basic administrative tools
  1. webmin
  2. vi
I got the latest rpm from webmin.com, and typed in 'rpm -hiv webmin.xx.noarch.rpm' It complained that it needed perl, so I had to do this

yum install perl

After downloading 12MB of stuff, rpm'ing webmin was successful. Joy.

The default editor provided by jailtime is 'nano'. Its a nice interactive editor, but I guess Im way to used to 'vi'. 'vi' is definitely primitive by anybodies standards, but I guess typing in the 'Esc-W-Q' has become ingrained in my fingers, that I can't help but to install it.

Unfortunately it is not straightforward, as 'yum install vi' does NOT work.
Googling for this is hopeless, as when you do a search for 'yum install vi', you just get instructions on how to edit yum repositories with vi, and its not very helpful.

However a 'which vi' on a system which has 'vi', gives a hint:

alias vi='vim'
'usr/bin/vim'

however a 'yum install vim' also does not work, as the proper command is actually

yum install vim-enhanced

This will do the necessary dependency checks, and will offer to download 4.5MB worth of stuff! I never knew a console based text editor would be so bulky.

Anyway, I shut down the Xen image, made a copy of it so that next time I need to prep up a virtual server, I already have one preprepared.


yk.