今日のメモ (無線 dongle のドライバと格闘の巻)

昨晩エントリにコメント頂戴してます。以下、材料との事。

別途内容精査して試験を予定。

今日は

無線 dongle 関連について色々試験など。カーネルのコンパイルで微妙にハマる。

ブランチどうするか

とりあえず armadillo500fx なパッチを branch 作ってアテてたんですが、このブランチで wireless なナニを一緒にしたくない、という事で更にここ発で branch 作成しなきゃ、なんですが commit しないと微妙な事に気づく。
最初は一つづつ git add/rm してたんですが大量なのに負けて git add -A しちゃいました。知らなかったんですが

  • git add -u は管理対象なもので modify/delete されているものをインデクスに反映
  • git add -A は新規追加なソレも含めてインデクス方面に反映

という事になっている模様。今までは規模が小さいナニしか経験無かったので不要だったんですが、これは便利ですな。

コンパイルの準備

で、commit ができたので branch をそこからさらに作成して手動で

  • CONFIG_WIRELESS_EXT=y
  • CONFIG_WIRELESS_EXT_SYSFS=y

を .config に盛り込んで make しようとしたら動作がおかしい。結局以下なコマンド実行してから

$ make ARCH=arm CROSS_COMPILE=../../prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- armadillo500fx_dev_android_defconfig

.config 方面にコンパイルスイッチな修正を盛り込んで (usbserial 関連含め

$ make ARCH=arm CROSS_COMPILE=../../prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- 

でコンパイルが完了。今から zImage を実機転送します。とりあえず dongle が認識されてりゃ成功ってコトで。

転送後

まだ続きがある事をようやく知りました。ちなみに正常に起動してます。起動前から dongle 差してたら起動時に以下なメセジがカーネルバッファに出力されている事を確認。

usb 2-1: new full speed USB device using fsl-ehci and address 2
usb 2-1: not running at top speed; connect to a high speed hub
usb 2-1: configuration #1 chosen from 1 choice

起動後、ifconfig しても何も出ず。よく考えたらドライバ入れてない。以下を確認しつつドライバのコンパイルに着手。

ええと make 時に以下なエラーが出ます。

cc1: error: unrecognized command line option "-m64"
cc1: error: unrecognized command line option "-mno-red-zone"
cc1: error: unrecognized command line option "-mcmodel=kernel"
cc1: error: unrecognized command line option "-maccumulate-outgoing-args"

なんか微妙なオプションだな、と思ってたらカーネルツリーの arch/x86/Makefile を include している模様。てっぺんの Makefile に以下なコメントがあった。

# When performing cross compilation for other architectures ARCH shall be set
# to the target architecture. (See arch/* for the possibilities).
# ARCH can be set during invocation of make:
# make ARCH=ia64
# Another way is to have ARCH set in the environment.
# The default ARCH is the host where make is executed.

# CROSS_COMPILE specify the prefix used for all executables used
# during compilation. Only gcc and related bin-utils executables
# are prefixed with $(CROSS_COMPILE).
# CROSS_COMPILE can be set on the command line
# make CROSS_COMPILE=ia64-linux-
# Alternatively CROSS_COMPILE can be set in the environment.
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile

コマンド投入時に ARCH な指定が必要な模様。ちなみに以下なナニが Makefile にあります。

include $(srctree)/arch/$(SRCARCH)/Makefile

で、以下でコンパイルがパスしました。

$ make ARCH=arm

diff を以下に残しておきます。

$ diff ./os/linux/config.mk ./os/linux/config.mk.org
309,312d308
< ifeq ($(PLATFORM),ARMADILLO)
< EXTRA_CFLAGS := $(WFLAGS) -I$(RT28xx_DIR)/include -O3
< endif
<
$ diff ./common/rtusb_dev_id.c ./common/rtusb_dev_id.c.org 
63d62
<       {USB_DEVICE(0x2019,0xED14)}, /* Planex GW-USMicroN */
$ diff ./Makefile ./Makefile.org
11c11
< #PLATFORM = PC
---
> PLATFORM = PC
41d40
< PLATFORM = ARMADILLO
43,47d41
< ifeq ($(PLATFORM),ARMADILLO)
< LINUX_SRC = /home/ojag/android/armadillo500fx-droid/kernel/common
< #ARCH = arm
< CROSS_COMPILE = /home/ojag/android/armadillo500fx-droid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
< endif
$

その後

実機方面に rt2870sta.ko と RT2870STA.dat をコピーして insmod したらデバイス認識しています。

# insmod rt2870sta.ko
Using rt2870sta.ko
rtusb init ---->


=== pAd = c8808000, size = 501464

<-- RTMPAllocTxRxRingMemory, Status=0
<-- RTMPAllocAdapterBlock, Status=0
usbcore: registerd new interface driver rt2870
#

ifconfig -a したら以下な出力。

ra0 Link encap:Ethernet  HWaddr 00:00:00:00:00:00
    BROADCAST MULTICAST  MTU:1500  Metric:1
    (以下略

何故に MAC アドレスがゼロなのかは別途確認します。しかしモジュールだと色々な意味で微妙だな。wpa_supplicant 云々も含め、明日以降で確認します。

追記

ドライバなソースは以下から取得しております。