2011-07-21

[DM368][RTL8191] Porting RTL8191S to DM368/IPNC

The target is to install RTL8191SU, USB dongle, to davinci DM368.

Steps:
1. get official device driver from Realtek

2. in the software package, there are some documentation we would like to read first.
I suggest
HowTo support more VidPids.doc - check if VID/PID is included in code (os_intf/linux/usb_intf.c)
HowTo support new platform(including Android).doc - change Makefile 
In Makefile, I added a new platform CONFIG_PLATFORM_DM368 so the following lines were added
###
CONFIG_PLATFORM_DM368 = y
ifeq ($(CONFIG_PLATFORM_DM368), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
ARCH := arm
CROSS_COMPILE = arm_v5t_le-
KSRC := [YOUR KERNEL SRC]/ipnc/ti-davinci
endif
###
3. No problem after above change, we got 8712u.ko. However, when inserting module "insmod 8712u.ko", some error messages were prompted.


# insmod 8712u.ko
8712u: Unknown symbol strcasecmp
insmod: cannot insert `8712u.ko': Unknown symbol in module (-1): No such file or directory

It's apparently that the function "strcasecmp" is not included in the C library in DM368/IPNC. I confirmed it by checking include/linux/string.h (as well as asm/string.h). I decided not to modify lib but change rtl871x_ioctl_linux.c instead.

in rtl871x_ioctl_linux.c, there are couple lines of code using "strcasecmp". I use "strcmp" with small characters instead. for example

// if(0 == strcasecmp(ext,"RSSI")){
if(0 == strcmp(ext,"rssi")){

4. After all the change, the module can successfully be installed and "wlan0" can be find by "ifconfig -a"

2011-07-20

[DM368][RT73] Enabling Wireless Dongle

Reference information

Davinci USB WLan


in case USB is not configured to OTG or host:
I was using D-link DWA-110, Ralink RT-73 NIC
Steps:
1. download serialmonkey's driver source since it is recommended by TI wiki Davinci USB WLan.

there was not too much trouble to make it by following the wiki. I got rt73.ko and copied it to (target)/opt/ipnc. I also copied rt73.bin to (target)/lib/firmware

However, when issuing "insmod rt73.ko", the result was always -

rt73: init
rt73: idVendor = 0x7d1, idProduct = 0x3c03
rt73: Failed to request_firmware. Check your firmware file location
rt73: Failed to load Firmware.
apparently the firmware "rt73.ko" was not found.  I am not too familiar with the procedure after the driver is installed (such as what script will be called , etc). I searched web for quick solution, some useful sites are listed below:
in short, the search failed, even I place rt73.bin to various location, the firmware simply didn't get loaded.

2. Change to official Ralink driver

After reading TI's forum post "Trouble with USB WLAN driver on IPNC DM368", I decided to give up serialmonkey and go official way.

To make the official driver needs a little more effort. There was some kind of kernel inconstant with IPNC release (probably 2.0.26 or something like that). 

I got rt73_drv1.1.0.5 from ralink's download section. To make module, you have to
- modify Makefile: change LINUX_SRC
the first make resulted in missing sturct member get_wireless_stats error in rtmp_main.c, function usb_rtusb_probe()

#if (WIRELESS_EXT >= 12) 
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
netdev->get_wireless_stats = rt73_get_wireless_stats;
#endif
netdev->wireless_handlers = (struct iw_handler_def *) &rt73_iw_handler_def;
#endif
I believe that my IPNC_DM036 release is of kernel 2.6.18, but the include/linux/netdevice.h, the member  get_wireless_stats doesn't exist. not sure if appro or montavista patched it and I didn't check official kernel tree.

Anyway, I changed the #if statement to KERNEL_VERSION(2,6,18) and the module can be compiled.

3. the new rt73.ko works fine, and I also found that rt73.bin is not required.




2011-07-18

[Linux][kernel][DM368] Cannot Change Kernel Config Variable

After changing variables in the (default)config file, davinci_dm368_ipnc_defconfig, "make sys" generates .config but the .config file doesn't match the changes in davinci_dm368_ipnc_defconfig.

turning on USB_STORAGE at defconfig for example

# may also be needed; see USB_STORAGE Help for more information
#
# CONFIG_USB_STORAGE is not set
# CONFIG_USB_LIBUSUAL is not set
CONFIG_USB_STORAGE=m
CONFIG_USB_LIBUSUAL=y 
the .config will be still
# CONFIG_USB_STORAGE is not set
# CONFIG_USB_LIBUSUAL is not set
check steps:
1. track what's performed after executing "make sysall"  (make -n)
make sysall -> make lspall -> make lspclean, make lsp
make lsp -> make lspcfg
make lspcfg->
make lspbuild MAKE_TARGET=davinci_dm368_ipnc_defconfig => make ARCH=arm davinci_dm368_ipnc_defconfig   <==== I after this, .config is generated with incorrect config variables
make lspbuild MAKE_TARGET=checksetconfig

2.  locate potential trouble maker:
"make ARCH=arm davinci_dm368_ipnc_defconfig" executes "scripts/kconfig/conf -D arch/arm/configs/davinci_dm368_ipnc_defconfig arch/arm/Kconfig" to generate .config

suspicious screen output
arch/arm/configs/davinci_dm368_ipnc_defconfig:1037:warning: trying to reassign symbol USB_STORAGE
arch/arm/configs/davinci_dm368_ipnc_defconfig:1038:warning: trying to reassign symbol USB_LIBUSUAL
3. first, check if the variable USB_STORAGE has dependency problem.
the variable is defined at driver/usb/storage/Kconfig
config USB_STORAGE
    tristate "USB Mass Storage support"
    depends on USB
    select SCSI
but I am sure that CONFIG_USB is enabled in the generated .config file.

4. find more information about making kernel.

kernel 移植笔记(从omap linux-02.01.03.11 到 fred 版本kernel 学习)

史上最经典的Linux内核学习方法论

 "make ${PLATFORM}_defconfig"
     Create a ./.config file by using the default
     symbol values from
     arch/$ARCH/configs/${PLATFORM}_defconfig.
     Use "make help" to get a list of all available
     platforms of your architecture.

however, it seems not to have any problem. even I wasted couple hour to compare with the latest kernel.... no luck though

  5. back to fundamental, why "scripts/kconfig/conf -D arch/arm/configs/davinci_dm368_ipnc_defconfig arch/arm/Kconfig" outputs incorrect value.

[PATCH] Allow kconfig to accept overrides - Kernel

inspired me. so trace confdata.c
at conf_read_simple( )
    while (fgets(line, sizeof(line), in)) {
        conf_lineno++;
        sym = NULL;
        switch (line[0]) {
        case '#':
            if (memcmp(line + 2, "CONFIG_", 7))
                continue;
            p = strchr(line + 9, ' ');
            if (!p)
                continue;
            *p++ = 0;
            if (strncmp(p, "is not set", 10))
                continue;
it is surprised me that the line starting with "#" is not a comment !!

Solution
use double hash (##) as comment to "CONFIG_xxx is not set"


## CONFIG_USB_STORAGE is not set
## CONFIG_USB_LIBUSUAL is not set
CONFIG_USB_STORAGE=m
CONFIG_USB_LIBUSUAL=y  



Followups
in montavista releases, there is "Base Configuration for MontaVista Linux" file (scripts/kconfig/baseconfig), which will be compared with .config generated by make xxx_defconfig. The rules are

# If an option is marked as "m", the .config will only
# be modified if the option is turned off.
#
# If an option is marked as "y", the .config will be modified
# if the options in the "m" or the off states.
#
# If an option is marked as "n", the .config will be modified
# if the option is in the "m" or "y" states.
It could influence the final .config for making kernel.