Monday, December 9, 2013

Compat wireless driver on mini2440

Compat wireless driver on mini2440

Continuing my post on Debian squeeze in mini2440 board , the default wireless driver included in kernel 2.6.32.2 are limited and most of them were discontinued.
As posted before, get the toolchains from debian squeeze distribution and kernel source for mini2440 whith 2.6.32.2 version.
Get the latest compat wireless driver from linuk backports.
I use the compat-drivers-3.7.6-1.tar.bz2 from http://mirror.anl.gov/pub/linux/kernel/projects/backports/stable/v3.7.6/compat-drivers-3.7.6-1.tar.bz2

From the latest post we got working kernel and debian root file system from debootstrap process.
Since my purposes is to update existing nand flash, i'm using empty root file system. But the one that filled with debian file system can also be used if you fish to include them with the whole filesystem.

Create empty rootfs
> mkdir rootfs
install modules from precompiled kernel
> sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=../rootfs modules_install

extract compat driver
> tar xjvf compat-drivers-3.7.6-1.tar.bz2
get on compat-driver path
> cd compat-drivers-3.7.6-1

make changes to compile as follow:
Makefile :
> vi Makefile
...
export KMODDIR?=       updates
KMODDIR_ARG:=   "INSTALL_MOD_DIR=$(KMODDIR)"
ifneq ($(origin KLIB), undefined)
KMODPATH_ARG:=  "INSTALL_MOD_PATH=$(KLIB)"
else
#export KLIB:=          /lib/modules/$(shell uname -r)
export KLIB:=          ../rootfs/lib/modules/2.6.32.2-FriendlyARM
endif
#export KLIB_BUILD ?=   $(KLIB)/build
export KLIB_BUILD ?=    ../linux-2.6.32.2-FriendlyARM

export MAKE

#DESTDIR?=
export DESTDIR?=        ../rootfs
export KERNELNAME?=     2.6.32.2-FriendlyARM
...
        @# Udev stuff needed for the new compat_firmware_class.
        @./compat/scripts/compat_firmware_install
        @#/sbin/depmod -a
        @/sbin/depmod -a -b $(DESTDIR) $(KERNELNAME)
....


compat/Makefile :
> vi compat/Makefile
...
#compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o
#compat-$(CONFIG_COMPAT_KERNEL_3_1) += compat-3.1.o
#compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o
#compat-$(CONFIG_COMPAT_KERNEL_3_3) += \
        compat-3.3.o
#compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o
#compat-$(CONFIG_COMPAT_KERNEL_3_5) += \
#       compat-3.5.o \
#       user_namespace.o
#compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o
....


compat/script/compat_firmware_install:
> vi compat/script/compat_firmware_install
#!/bin/sh

if [ -f /usr/bin/lsb_release ]; then
        LSB_RED_ID=$($DESTDIR/usr/bin/lsb_release -i -s)
else
        LSB_RED_ID="Unknown"
fi

case $LSB_RED_ID in
"Ubuntu")
        mkdir -p $DESTDIR/lib/udev/ $DESTDIR/lib/udev/rules.d/
        cp udev/ubuntu/compat_firmware.sh $DESTDIR/lib/udev/
        cp udev/50-compat_firmware.rules $DESTDIR/lib/udev/rules.d/
        ;;
*)
        mkdir -p $DESTDIR/lib/udev/ $DESTDIR/lib/udev/rules.d/
        cp udev/compat_firmware.sh $DESTDIR/lib/udev/
        cp udev/50-compat_firmware.rules $DESTDIR/lib/udev/rules.d/
        ;;
esac


Compile
To compile the compat-driver do the following:
> make clean
> ./script/driver_select restore
The driver_select are the main control of the compat-driver, so if you want to build specific driver, select them from available choice given by driver_select or simply put the restore to get the default driver selection. Now compiled it

> make ARCH=arm CROOS_COMPILE=arm-linux-gnueabi-
The make will build linked to linux-2.6.32.2-FriendlyARM source code and /rootfs/lib/modules/2.6.32.2-FriendlyARM. You may change the source code location and installed module path.
After finish with no error do install them to your rootfs folder using:

> make ARCH=arm CROOS_COMPILE=arm-linux-gnueabi- install_modules install_scripts 

Go to rootfs folder, compress the content, (which in my case only content by kernel modules), put them on the sdcard and extract them on the mini2400 board overwrite existing ones. Reboot the board and plug the usb wifi dongle.

Tested to work with these usb wifi dongle:
TL-WN321-G
TL-WN422G
TL-WN721N
TL-WN722N
TL-WN727N
TL-WN821N

Cheers!

1 comment: