LoginSignup
5
5

More than 5 years have passed since last update.

カーネルモジュールのコンパイル - RTL8812AUとMT7610U (Raspberry Pi) [メモ]

Last updated at Posted at 2016-06-15

概要

環境

  • Raspberry Pi 3
  • 2016-05-27-raspbian-jessie-lite.img

手順

  1. sudo apt-get update; sudo apt-get upgrade -y
    いつもの
  2. sudo apt-get install curl build-essential bc git
    追加パッケージ
  3. rpi-updateで、ファームウェアとかアップデートして、再起動

    sudo apt-get install -y rpi-update
    sudo rpi-update
    #
    #2016-05-27のカーネルなら、このハッシュで取得
    # >Linux raspberrypi 4.4.11-v7+ #886 SMP Thu May 19 15:20:49 BST 2016 armv7l
    #sudo rpi-update 48cfa89779408ecd69db4eb793b846fb7fe40c4b
    #
    sudo reboot
    
  4. カーネルのソース取得とモジュールビルド環境の準備

    # ファームウエアのハッシュから、カーネルのハッシュを取得して、`Module7.symvers`とカーネルのソース取得
    #
    FIRMWARE_REV=`cat /boot/.firmware_revision`
    KERNEL_REV=`curl -L https://github.com/Hexxeh/rpi-firmware/raw/${FIRMWARE_REV}/git_hash`
    echo Firmware Rev: ${FIRMWARE_REV}
    echo kernel Rev  : ${KERNEL_REV}
    curl -L https://github.com/Hexxeh/rpi-firmware/raw/${FIRMWARE_REV}/Module.symvers >Module.symvers
    curl -L https://github.com/Hexxeh/rpi-firmware/raw/${FIRMWARE_REV}/Module7.symvers >Module7.symvers
    curl -L https://github.com/raspberrypi/linux/archive/${KERNEL_REV}.tar.gz >rpi-linux.tar.gz
    #
    # rootになる
    sudo -s
    #
    # カーネルソース展開 時間がかかるよ
    HOME=/home/pi
    cd /usr/src
    mkdir rpi-linux
    cd rpi-linux
    tar --strip-components 1 -xf ${HOME}/rpi-linux.tar.gz
    #
    # Module.symversと .configを取得して配置.
    modprobe configs
    gunzip -c /proc/config.gz >.config
    # cp $HOME/Module.symvers Module.symvers  ## RPi1 ????
    cp $HOME/Module7.symvers Module.symvers
    #
    # モジュールビルドの準備とリンク.
    time make modules_prepare
    ln -sv /usr/src/rpi-linux /lib/modules/$(uname -r)/build
    
  5. rtl8812AU_8821AU_linuxのソース取得・ビルド

    # rootじゃなかったら.
    sudo -s 
    #
    # ソース取得.
    cd /usr/src
    git clone https://github.com/abperiasamy/rtl8812AU_8821AU_linux.git
    cd rtl8812AU_8821AU_linux/
    #
    # Makefileのコンフィグをらずぱい向けにする - README.mdに書いてあった
    # > Edit Makefile and turn on ``CONFIG_PLATFORM_ARM_RPI``, turn off ``CONFIG_PLATFORM_I386_PC``
    sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/' Makefile
    sed -i 's/CONFIG_PLATFORM_ARM_RPI = n/CONFIG_PLATFORM_ARM_RPI = y/' Makefile
    #
    # ビルド
    make clean
    make
    make install
    modprobe -a 8812au
    
  6. うごいた

    pi@raspberrypi:~ $ lsusb | grep 8812
    Bus 001 Device 004: ID 0bda:8812 Realtek Semiconductor Corp. 
    pi@raspberrypi:~ $ lsmod | grep 8812au
    8812au                960323  0 
    cfg80211              427855  2 brcmfmac,8812au
    pi@raspberrypi:~ $ ifconfig wlan1 | grep "inet "
          inet addr:192.168.41.11  Bcast:192.168.41.255  Mask:255.255.255.0
    

(追記) MediaTek MT7610U (RT2860) - ID 0e8d:7610 MediaTek Inc.

  • https://github.com/xtknight/mt7610u-linksys-ae6000-wifi-fixes.git

    # rootじゃなかったら
    sudo -s 
    #
    # MediaTekのダウンロードサイトからもってくるアーカイブと、エラーになった
    ##  MT7610U USB     9/16/2013     V3.0.0.2
    ## wget http://s3.amazonaws.com/mtk.cfs/Downloads/linux/mt7610u_wifi_sta_v3002_dpo_20130916.tar.bz2
    ## tar xjf mt7610u_wifi_sta_v3002_dpo_20130916.tar.bz2
    ## cd mt7610u_wifi_sta_v3002_dpo_20130916
    #
    # ので、ビルドが通ったものをgit clone
    # git clone https://github.com/coolshou/mt7610u.git
    # cd mt7610u
    #したけど↑は、うまく設定できなかった。ので別のもの
    #
    cd /usr/src
    git clone https://github.com/xtknight/mt7610u-linksys-ae6000-wifi-fixes.git
    cd mt7610u-linksys-ae6000-wifi-fixes
    make
    make install
    #
    #
    #sed -i 's/SSID=11n-AP/SSID=/' /etc/Wireless/RT2870STA/RT2870STA.dat
    #sed -i 's/AuthMode=OPEN/AuthMode=WPA2PSK/' /etc/Wireless/RT2870STA/RT2870STA.dat
    #sed -i 's/EncrypType=NONE/EncrypType=AES/' /etc/Wireless/RT2870STA/RT2870STA.dat
    modprobe -a mt7610u_sta
    
    • sudo vi /etc/network/interfaces

      /etc/network/interfaces
      ...
      # 以下追加
      allow-hotplug ra0
      iface ra0 inet manual
      wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
      
    • 動いた

      pi@raspberrypi:~$ lsusb | grep 7610
      Bus 001 Device 005: ID 0e8d:7610 MediaTek Inc.
      pi@raspberrypi:~$ lsmod | grep 7610
      mt7610u_sta           876773  0
      cfg80211              427855  2 brcmfmac,mt7610u_sta
      pi@raspberrypi:~$ ifconfig ra0 | grep "inet "
        inet addr:192.168.41.13  Bcast:192.168.41.255  Mask:255.255.255.0
      

その他

  • (試していない) Raspberry Pi 1/Zero対応?
    cp $HOME/Module7.symvers Module.symvers のところの7をとる???
    => cp $HOME/Module.symvers Module.symvers

  • rpi-updateで取得すると、/boot/.firmware_revisionにファームのハッシュが入って、それを利用して、カーネルソースとか取得してる模様..

  • ↓のエラーは、sudo apt-get inatall bc をやる。

    include/linux/jiffies.h:10:33: fatal error: generated/timeconst.h: No such file or directory
    #include <generated/timeconst.h>
                                 ^
    compilation terminated.
    
  • テストするとき sudo wpa_supplicant -iwlan1 -c /etc/wpa_supplicant/wpa_supplicant.conf # -Bをつけるとデーモン化

  • 5GHzのとこにつなぐにはどうすれば..

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5