1. 程式人生 > >一點一滴分析LinkIt Smart 7688 問題彙總

一點一滴分析LinkIt Smart 7688 問題彙總

定義

$ - 指定Ubuntu系統下命令

# - Openwrt下命令

1. 系統編譯

1.1 .config檔案

openwrt中,make menuconfig生成.config檔案後,我們如何對.config中自定義的差異內容進行進行備份,方便移植到其它的系統中,這是一個問題。當然,有人說有很多簡單的方法。但是這些都不是Openwrt開發著所希望看到的。對於Openwrt,開發團隊建立了簡單的工具scripts/diffconfig.sh`。我們可以採用這個工具進行配置儲存工作。

有一個簡單的方法,生成diff檔案,然後通過git進行操作,這樣我們可以對我們自己的openwrt進行定製備份了。

1.1.1 如何建立config diff檔案

  $./scripts/diffconfig.sh > config.diff

1.1.2 如何使用config diff檔案

  $cp config.diff .config
  $make defconfig

或者

  $cat config.diff >> .config
  $make defconfig

1.1.3 make meunconfig

  $make menuconfig

1.1.3 make kernel_menuconfig

$ make kernel_menuconfig

1.2 編譯

系統編譯很簡單,直接在系統目錄下執行make命令就可以了,如果想檢視輸出資訊,可以在make後面增加V=s/V=99。如果是多核系統,可以在後面再增加j=2或其它數字,這代表同時有多個執行緒同時執行。這樣可以提高編譯速度。我的系統是單核的,我驗證了一下沒有任何改善。多核系統可以測試一下。

 $ make V=99

1.2.1 linux核心編譯

如果我們僅僅是想對linux核心包進行編譯,可以採用下面的命令來進行。

 $ make target/linux/{clean,prepare} V=s QUILT=1

1.2.2 package編譯(以Madplay為例)

全新編譯madplay

  $ make package/feeds/packages/madplay/{clean,compile,install} V=s
  $ make package/feeds/packages/madplay/{compile,install} V=s

重新編譯madplay

$ make package/feeds/packages/madplay/compile V=s

1.2.3 package安裝(以Madplay為例)

madplay安裝

複製ipk檔案到openwrt系統(採用scp命令),然後通過opkg進行安裝。

  $ scp bin/ramips/packages/packages/madplay-alsa_0.15.2b-4_ramips_24kec.ipk root@192.168.1.168:/tmp

安裝madplay到openwrt

  # root@mylinkit:/tmp# opkg install madplay-alsa_0.15.2b-4_ramips_24kec.ipk
    Installing madplay-alsa (0.15.2b-4) to root...
    Configuring madplay-alsa.

MadPay原始碼修改

$ wget ftp://ftp.mars.org/pub/mpeg/madplay-0.15.2b.tar.gz

得到madplay原始碼,修改player.c,採用FIFO控制方式,然後編譯madplay.

$ make package/feeds/packages/madplay/{compile,install} V=s
$ scp bin/ramips/packages/packages/madplay-alsa_0.15.2b-4_ramips_24kec.ipk root@192.168.1.168:/tmp

# opkg install madplay-alsa_0.15.2b-4_ramips_24kec.ipk
# madplay /Media/USB-A1/*.mp3
# echo f > /tmp/.madplayFIFO

建立madplayCon.c檔案

# make package/feeds/packages/gogoo/ethMOH/{clean,compile,install} V=s
  KEY_PAUSE    = 'p', 
  KEY_STOP     = 's',
  KEY_FORWARD  = 'f',
  KEY_BACK     = 'b',
  KEY_TIME     = 't',
  KEY_QUIT     = 'q',
  KEY_INFO     = 'i',
  KEY_GAINDECR = '-',
  KEY_GAININCR = '+',
  KEY_GAINZERO = '_',
  KEY_GAININFO = '='

1.3 dts檔案修改

1.3.1 按鈕相關修改

MT7688按鈕一組為32個,所以GPIO0組對應GPIO0-PIO32,GPIO1組對應GPIO32以上的引腳。

    gpio-keys-polled {
        compatible = "gpio-keys-polled";
        #address-cells = <1>;
        #size-cells = <0>;
        poll-interval = <20>;
        wps {
            label = "wps";
            gpios = <&gpio1 6 1>;     // GPIO38 wifi button
            linux,code = <0x211>;
        };
        key_playpause {
            label = "key_playpause";
            gpios = <&gpio0 15 1>;      // GPIO15-KEY_PLAY/Pause(S5)
            linux,code = <164>;
        };
        key_volumeup {
            label = "key_volumeup";
            gpios = <&gpio0 17 1>;      //GPIO17-KEY_VOL+(S7)
            linux,code = <115>;
        };
        key_volumedown {
            label = "key_volumedown";
            gpios = <&gpio0 18 1>;      //GPIO18-KEY_VOL-(S8)
            linux,code = <114>;
        };
        key_next {
            label = "key_next";
            gpios = <&gpio0 16 1>;      //GPIO16-KEY_NEXT(S6)
            linux,code = <0x197>;
        };
        key_previous {
            label = "key_previous";
            gpios = <&gpio0 14 1>;      //GPIO14-KEY_PRE(S4)
            linux,code = <0x19c>;
        };
    };

尖括號中的內容為標準按鍵程式碼,可以在linux/include/uapi/linux/input.h中查詢到。

1.3.2 SD卡檢測引腳電平修改

LinkIt smart7688的SD卡檢測,預設是高電平。但是普通的SD卡是低電平。所以,要對dts進行修改。使用下面命令:

$ vi target/linux/ramips/dts/LINKIT7688.dts

修改前:

    [email protected]10130000 {
        status = "okay";
        mediatek,cd-high;
//      mediatek,cd-poll;
    };

修改後:

        [email protected]10130000 {
        status = "okay";
        mediatek,cd-low;
//      mediatek,cd-poll;
    };

1.4 package建立

package的Makefile

  • PKG_NAME - The name of the package, as seen via menuconfig and ipkg
  • PKG_VERSION - The upstream version number that we’re downloading
  • PKG_RELEASE - The version of this package Makefile
  • PKG_LICENSE - The license(s) the package is available under, SPDX form.
  • PKG_LICENSE_FILE- file containing the license text
  • PKG_BUILD_DIR - Where to compile the package
  • PKG_SOURCE - The filename of the original sources
  • PKG_SOURCE_URL - Where to download the sources from (directory)
  • PKG_MD5SUM - A checksum to validate the download
  • PKG_CAT - How to decompress the sources (zcat, bzcat, unzip)
  • PKG_BUILD_DEPENDS - Packages that need to be built before this package, but are not required at runtime. Uses the same syntax as DEPENDS below.
  • PKG_INSTALL - Setting it to “1” will call the package’s original “make install” with prefix set to PKG_INSTALL_DIR
  • PKG_INSTALL_DIR - Where “make install” copies the compiled files
  • PKG_FIXUP - See below
  • PKG_SOURCE_PROTO - the protocol to use for fetching the sources (git, svn)
  • PKG_REV - the svn revision to use, must be specified if proto is “svn”
  • PKG_SOURCE_SUBDIR - must be specified if proto is “svn” or “git”, e.g. “PKG_SOURCE_SUBDIR:=(PKG_NAME)(PKG_VERSION)”
  • PKG_SOURCE_VERSION - must be specified if proto is “git”, the commit hash to check out
  • PKG_CONFIG_DEPENDS - specifies which config options depend on this package being selected
  • SECTION - The type of package (currently unused) //包的型別
  • CATEGORY - Which menu it appears in menuconfig //menuconfig的哪一個選單顯示
  • TITLE - A short description of the package //包的簡短描述
  • DESCRIPTION - (deprecated) A long description of the package //報的一個長描述
  • URL - Where to find the original software // 那裡找到源軟體
  • MAINTAINER - (required for new packages) Who to contact concerning the package // 包的聯絡
  • DEPENDS - (optional) Which packages must be built/installed before this package. See below for the syntax. // 哪些包需要必須先編譯/安裝
  • PKGARCH - (optional) Set this to “all” to produce a package with “Architecture: all”
  • USERID - (optional) a username:groupname pair to create at package installation time.

1.5 JFFS2-Journalling Flash File System Version2

JFFS2全名是 Journalling Flash File System Version2,是Redhat公司開發的快閃記憶體檔案系統[1],其前身是JFFS, 最早只支援NOR Flash, 自2.6版以後開始支援NAND Flash, 極適合使用於嵌入式系統。https://zh.wikipedia.org/wiki/JFFS2

1.5 如何建立自己的板子支援

增加mt7688支援
參考CC程式碼:(CC-2015/10/19 18:19:18-SHA-1: 3d98b29a3d0aa854fad712a92ace42ad06e92d6b)
* 修改target\linux\ramips\Makefile檔案,增加mt7688支援
* 修改target\linux\ramips\modules.mk檔案,增加TARGET_ramips_mt7688支援
* 建立target\linux\ramips\mt7688\config-3.18檔案
* 建立target\linux\ramips\mt7688\profiles\00-default.mk檔案
* 建立target\linux\ramips\mt7688\target.mk檔案

增加LinkIt Smart7688支援
參考CC程式碼:(CC-2015/10/19 18:19:22-SHA-1: 8829dee8871e45c675a4bd4036c188c6d0f5645b)
* 在package\boot\uboot-envtools\files\ramips新增linkits7688板名支援
* 在target\linux\ramips\base-files\etc\board.d\02_network新增linkits7688支援
* 在target\linux\ramips\base-files\lib\ramips.sh中新增linkits7688支援
* 在target\linux\ramips\base-files\lib\upgrade\platform.sh中新增linkits7688支援
* 增加target\linux\ramips\dts\LINKIT7688.dts檔案
* 修改target\linux\ramips\image\Makefile檔案
* 增加target\linux\ramips\mt7688\profiles\01-mediatek.mk檔案

參考windora
* 修改target\linux\ramips\base-files\etc\board.d\02_network
* 修改target\linux\ramips\base-files\lib\ramips.sh
* 修改target\linux\ramips\base-files\lib\upgrade\platform.sh
* 修改target\linux\ramips\image\Makefile
* 建立一個*.mk檔案到target\linux\ramips\mt7688\profiles\目錄下
* 建立一個example.dts檔案到target\linux\ramips\dts\目錄下

root@mylinkit:~# cat /proc/cpuinfo
system type             : MediaTek MT7688 ver:1 eco:2
machine                 : MediaTek LinkIt Smart 7688
processor               : 0
cpu model               : MIPS 24KEc V5.5
BogoMIPS                : 385.84
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 32
extra interrupt vector  : yes
hardware watchpoint     : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa                     : mips1 mips2 mips32r1 mips32r2
ASEs implemented        : mips16 dsp
shadow register sets    : 1
kscratch registers      : 0
package                 : 0
core                    : 0
VCED exceptions         : not available
VCEI exceptions         : not available

1.6 rpcd - (OpenWrt ubus RPC backend server)

1.7 patch

$ quilt --help
用法:quilt [--trace[=verbose]] [--quiltrc=XX] command [-h] ...
       quilt --version
命令是:
        add       fold    new       remove    top
        annotate  fork    next      rename    unapplied
        applied   graph   patches   revert    upgrade
        delete    grep    pop       series
        diff      header  previous  setup
        edit      import  push      shell
        files     mail    refresh   snapshot

Global options:

--trace
        Runs the command in bash trace mode (-x). For internal debugging.

--quiltrc file
        Use the specified configuration file instead of ~/.quiltrc (or
        /etc/quilt.quiltrc if ~/.quiltrc does not exist).  See the pdf
        documentation for details about its possible contents.  The
        special value "-" causes quilt not to read any configuration
        file.

--version
        Print the version number and exit immediately.

1.7.1 準備quilt配置

$ cd ~
cat > ~/.quiltrc <<EOF
QUILT_DIFF_ARGS="--no-timestamps --no-index -p ab --color=auto"
QUILT_REFRESH_ARGS="--no-timestamps --no-index -p ab"
QUILT_PATCH_OPTS="--unified"
QUILT_DIFF_OPTS="-p"
EDITOR="nano"
EOF

**1.7.2

$ cd ~/openwrt/openwrt_ethMOH/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7688/linux-3.18.29/
$ quilt series
$ quilt new platform/502-alsa.patch
$ quilt edit sound/soc/codecs/wm8960.c
$ quilt diff
$ quilt refresh
$ cd ../../../../
$ make target/linux/update package/index V=s

修改存在的patch

$ quilt push platform/502-alsa.patch
$ quilt edit sound/soc/codecs/wm8960.c
$ quilt diff
$ quilt refresh
$ cd ../../../../

$ make target/linux/update V=s  //民間更新patch到target/linux/ramips/patches-xxx方法
/$ make target/linux/update package/index V=s //官方更新patch到target/linux/ramips/patches-xxx方法

$ make target/linux/{clean,prepare} V=s QUILT=1

1.8 Makefile

$? - 當前目標所依賴的檔案列表中比當前目標檔案還要新的檔案
[email protected] - 當前目標名字
$< - 當前依賴檔案的名字
$* - 不包括字尾名的當前依賴檔案的名字

1.9 WM8960音效卡

Linkit的預設的音效卡是WM8960,該音效卡為I2S介面。Linkit預設WM8960使用的為外部晶振提供時鐘頻率。所以如果我們希望採用MT7688的REF_CLK0訊號作為WM8960的時鐘訊號的話,我們就需要對MTK的配置檔案進行一些修改。
具體的修改可以參考https://github.com/hnhkj/CC15.05.git的程式碼。

1.10 USB音效卡CM108

1.11 wps 功能 (don’t support)

1.12 init.d/rc.d開機自動執行

啟動方法:
1,建立指令碼到 init.d(具體參考原來文件)。
2,開機自動執行./etc/init.d/example enable。
3, 使能自動執行可以在/etc/rc.d/ 下查詢到連線

1.13 eclipse

2. 系統配置

2.1 MTD

[email protected]:~# mtd
Usage: mtd [<options> ...] <command> [<arguments> ...] <device>[:<device>...]

The device is in the format of mtdX (eg: mtd4) or its label.
mtd recognizes these commands:
        unlock                  unlock the device
        refresh                 refresh mtd partition
        erase                   erase all data on device
        verify <imagefile>|-    verify <imagefile> (use - for stdin) to device
        write <imagefile>|-     write <imagefile> (use - for stdin) to device
        jffs2write <file>       append <file> to the jffs2 partition on the device
        fixseama                fix the checksum in a seama header on first boot
Following options are available:
        -q                      quiet mode (once: no [w] on writing,
                                           twice: no status messages)
        -n                      write without first erasing the blocks
        -r                      reboot after successful command
        -f                      force write without trx checks
        -e <device>             erase <device> before executing the command
        -d <name>               directory for jffs2write, defaults to "tmp"
        -j <name>               integrate <file> into jffs2 data when writing an image
        -s <number>             skip the first n bytes when appending data to the jffs2 partiton, defaults to "0"
        -p                      write beginning at partition offset
        -l <length>             the length of data that we want to dump

Example: To write linux.trx to mtd4 labeled as linux and reboot afterwards
         mtd -r write linux.trx linux
  • 2.1.1 如何顯示MTD狀態
  root@mylinkit:/tmp# cat /proc/mtd
  dev:    size   erasesize  name
  mtd0: 00030000 00010000 "u-boot"
  mtd1: 00010000 00010000 "u-boot-env"
  mtd2: 00010000 00010000 "factory"
  mtd3: 00fb0000 00010000 "firmware"
  mtd4: 0011a791 00010000 "kernel"
  mtd5: 00e9586f 00010000 "rootfs"
  mtd6: 00100000 00010000 "rootfs_data"
  • 2.1.2 dd命令:/bin/dd
    讀取mtd2內的資料內容,mac地址
  # dd bs=1 skip=3 count=6 if=/dev/mtd2 2>/dev/null | hexdump

參考文件:linkit-smart-7688-feed\mtk-linkit\files\etc\uci-defaults\51_linkit_config - Line30:

MAC=$(dd bs=1 skip=7 count=3 if=/dev/mtd2 2>/dev/null | hexdump -v -n 3 -e '3/1 "%02X"'
  • 2.1.3 入如何寫firmware到flash.
   # cd /tmp
   # wget http://www.example.org/original_firmware.bin
   # mtd -r write /tmp/original_firmware.bin firmware
  • 2.1.4 備份MTD2/factory資訊
  # dd if=/dev/mtd2 of=/tmp/factory.bin
  • 2.1.5 寫factory.bin到mtd2
  # mtd -r write /tmp/factory.bin factory

注意:如果命令返回不能寫入MTD2,可能是由於你的系統設定了禁止寫該區域的許可權。我們可以通過修改target/linux/ramips/dts/LINKIT7688.dts,登出禁止程式碼。這樣就可以將資料寫入到MTD2區域了。

I know that we can modify LINKIT7688 file to allow mtd command modify mtd2's data.

/target/linux/ramips/dts/LINKIT7688
line82-86:
factory: [email protected]40000 {
label = "factory";
reg = <0x40000 0x10000>;
read-only;
};
delete read-only.
  • fw_printenv命令:/usr/sbin/fw_printenv

參考文件:linkit-smart-7688-feed\mtk-linkit\files\etc\init.d\linkit

Line15:

SEQ=fw_printenv -n wifi_seq

2.2 用SD卡擴充套件空間(未驗證)

Yes!you can mount tf card as overlay
1.install block-mount e2fsprogs kmod-fs-ext4
2.mkfs.ext4 /dev/mmcblk0
3.block detect > /etc/config/fstab
4.vi etc/config/fstab
modify option 'target' '/overlay'
modify option 'enable' '1'
5.reboot,use df -h check

2.3 ifconfig 相關引數

狀態:Ethernet0 連線PC,Wifi連線Router (狀態非常好)

ifconfig
apcli0    Link encap:Ethernet  HWaddr 9E:65:F9:0B:18:55
          inet addr:192.168.1.104  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::9c65:f9ff:fe0b:1855/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

br-lan    Link encap:Ethernet  HWaddr 9C:65:F9:1B:10:27
          inet addr:192.168.100.1  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::9e65:f9ff:fe1b:1027/64 Scope:Link
          inet6 addr: fdef:dd3c:f1e1::1/60 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:478 errors:0 dropped:0 overruns:0 frame:0
          TX packets:340 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:45279 (44.2 KiB)  TX bytes:46562 (45.4 KiB)

eth0      Link encap:Ethernet  HWaddr 9C:65:F9:1B:10:27
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:525 errors:0 dropped:0 overruns:0 frame:0
          TX packets:307 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:70666 (69.0 KiB)  TX bytes:46599 (45.5 KiB)
          Interrupt:5

eth0.1    Link encap:Ethernet  HWaddr 9C:65:F9:1B:10:27
          inet6 addr: fe80::9e65:f9ff:fe1b:1027/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:5911 (5.7 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1269 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1269 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:88230 (86.1 KiB)  TX bytes:88230 (86.1 KiB)

ra0       Link encap:Ethernet  HWaddr 9C:65:F9:1B:18:55
          inet6 addr: fe80::9e65:f9ff:fe1b:1855/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11176 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2457 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2248608 (2.1 MiB)  TX bytes:42335 (41.3 KiB)
          Interrupt:6

2.4 network 配置

config interface 'loopback'
    option ifname 'lo'
    option proto 'static'
    option ipaddr '127.0.0.1'
    option netmask '255.0.0.0'

config globals 'globals'
    option ula_prefix 'fd01:80d1:1f98::/48'

config interface 'lan'
    option ifname 'eth0'
    option force_link '1'
    option type 'bridge'
    option proto 'static'
    option netmask '255.255.255.0'
    option ip6assign '60'
    option ipaddr '192.168.100.1'
    option macaddr '00:0c:43:e1:76:2a'

config switch
    option name 'switch0'
    option reset '1'
    option enable_vlan '0'

config interface 'wan'
    option proto 'dhcp'

2.5 eeprom配置

eepromn內容可以在/lib/firmware/mt7628.eeprom中。

  • 2.1 - Chip ID(0x00h)
  • 2.2 - Layout Revision ID(0x02)
  • 2.3 - WIFI MAC Address (0x04)
  • 2.4 - WIFI MAC Address (0x28)
  • 2.5 - WIFI MAC Address (0x2E)
  • 2.6 - NIC Configuration 0 (0x34)
  • 2.7 - NIC Configuration 1 (0x36)
  • 2.8 - Country Region Code for 2.4G band (0x39)
  • 2.9 - LED Mode (0x3B)
  • 2.10 - NIC COnfiguration 2 (0x42)
  • 2.11 - RSSI Offset for 2.4G band (0x46)
  • 2.12 - 20M/40M BW Power Delta for 2.4G band (0x50)
  • 2.13 - Temp. Sensor Calibation (0x55)
  • 2.14 - 2.4G Tx0 Power Slope/offset (0x56~0x57)
  • 2.15 - 2.4G Tx0 Target Power (0x58)
  • 2.16 - 2.4G Tx0 Power Low/Middle/High Channel (0x59)
  • 2.17 - 2.4G Tx1 Power Slope/Offset (0x5C~0x5D)
  • 2.18 - 2.4G Tx1 Target Power (0x5E)
  • 2.19 - 2.4G Tx1 Power Offset Low/Middle/High Channel (0x5F~0x61)
  • 2.20 - 2.4G Tx rate power configuration (0xA0~0xBF)
  • 2.21 - External LNA (0xC0)
  • 2.22 - 2.4GHz Step Number (0xC6)
  • 2.23 - Frequency offset (0xF4~0xF6)
  • 2.24 - Reserved for Customer (0x140~0x1EF)

2.6 Sysupgrade

與opkg, mtd 等相比, sysupgrade 僅僅是個shell指令碼: /sbin/sysupgrade 詣在更容易的實現系統更新.

timezone //時區

時區設定儲存在/tmp/TZ中。

root@mylinkit:/tmp# cat TZ
UTC

2.7 uhttpd

2.8 修改Linkit_Smart_7688預設的SSID

mtk-linkit\files\etc\uci-defaults\51\_linkit\_config檔案中,預設是讀取wifi MAC address的後3個位元組,載入到字串LiniIt_Smart_7688_的後面,根據MAC地址的唯一性,形成一個唯一的SSID地址。如果我們想修改該SSID的話,可以在這個檔案中進行修改。又或者配置SSID到uboot環境變數中,形成自己的SSID。這部分實現可以參考lks7688.cfg部分。如果系統在uboot中設定了SSID的話,系統將顯示該SSID。如果沒有設定的話,系統將設定該檔案配置的SSID。

[ -n "${SSID}" ] || { \
  MAC=$(dd bs=1 skip=7 count=3 if=/dev/mtd2 2>/dev/null | hexdump -v -n 3 -e '3/1 "%02X"')
  SSID=LinkIt_Smart_7688_${MAC}
}

2.9 修改Linkit_Smart_7688的版本號

Linkit_Smart_7688預設擁有自己的版本號,該版本號定義在mtk-linkit\files\etc\uci-defaults\54_linkit_version檔案中。

uci set system[email protected]system[0].firmware_version=v0.9.3

2.10 修改Linkit_Smart_7688的主機名

Linkit_Smart_7688的主機名在mtk-linkit\files\etc\uci-defaults\51_linkit_config檔案中定義,你可以通過修改這個檔案來修改主機名。

uci set system[email protected]system[-1].hostname="mylinkIt"

2.11 獲得Linkit_Smart_7688的MAC地址

對於如何獲取MAC地址,OpenWrt提供了詳細的程式介面。可以參考\openwrt\package\base-files\files\lib\functions\system.sh檔案,該檔案包含的mac的操作函式。在很多的sh文件中都包含的對該檔案的引用。

例如:mtk-linkit\files\etc\uci-defaults\51_linkit_config檔案中的wan_mac獲取。

wan_mac=$(mtd_get_mac_binary factory 4)

獲取ap_mac地址(源自:mtk-linkit\files\etc\rc.button\wps
檔案):

iwinfo ra0 info | grep Access | awk '{print $3}')

2.12 Linkit_Smart_7688預設模組的新增和刪除

Linkit_Smart_7688預設添加了很多的模組,例如:python,node.js等。我們如何對預設的模組進行修改,新增或刪除想要的模組呢。其實很簡單,我們就是需要修改mtk-linkit\Makefile,在該檔案中修改想要或不想要的模組。然後feed install它就可以了。當然,你會發現已經安裝過的模組,在檔案中刪除後,編譯後仍然會在firmware中,這是怎麼回事呢?這是因為,在編譯預設的Makefile的時候,系統通過feed已經將原來預設的模組新增進了.config。如果要刪除它們,需要同feed來刪除它們。然後,編譯以後就不會出現了。

define Package/mtk-linkit
  TITLE:=MTK LinkIt Smart board support package
  HIDDEN:=1
  DEPENDS:[email protected]_ramips_mt7688_LinkIt7688 \
    +gdbserver +curl +strace +coreutils +coreutils-stty \
    +avahi-nodbus-daemon +mountd +mjpg-streamer \
  +uhttpd +rpcd +rpcd-mod-iwinfo +git +git-http +samba36-server \
  +python +python-pyserial +python-pip +hidapi \
  +libmraa +libupm +node +node-hid +node-cylon-firmata +yunbridge \
  +luci +luci-theme-openwrt +luci-app-mjpg-streamer +luci-app-samba +luci-lib-json \
  +rpcd-mod-rpcsys +cgi-io +avrdude +spi-tools +uboot-envtools \
  +kmod-fs-vfat +kmod-fs-exfat +kmod-i2c-core +kmod-i2c-ralink \
  +kmod-nls-base +kmod-nls-cp437 +kmod-nls-iso8859-1 \
  +kmod-nls-iso8859-15 +kmod-nls-iso8859-2 +kmod-nls-utf8 \
  +kmod-sdhci-mt7620 +kmod-usb-storage \
  +kmod-video-core +kmod-video-uvc \
  +kmod-sound-core +kmod-sound-mtk +madplay-alsa +alsa-utils \
  +mtk-linkit-webui +mtk-sdk-wifi +tcpdump-mini

  CATEGORY:=Base system
  DEFAULT:=y
endef

2.13 如果修改Linkit_Smart_7688預設opkg連線地址

[email protected]-System-Name:~/openwrt/openwrt_ethMOH$ cat feeds.conf.default
src-git packages https://github.com/openwrt/packages.git;for-15.05
src-git luci https://github.com/openwrt/luci.git;for-15.05
src-git routing https://github.com/openwrt-routing/packages.git;for-15.05
src-git telephony https://github.com/openwrt/telephony.git;for-15.05
src-git management https://github.com/openwrt-management/packages.git;for-15.05
#src-git targets https://github.com/openwrt/targets.git
#src-git oldpackages http://git.openwrt.org/packages.git
#src-svn xwrt http://x-wrt.googlecode.com/svn/trunk/package
#src-svn phone svn://svn.openwrt.org/openwrt/feeds/phone
#src-svn efl svn://svn.openwrt.org/openwrt/feeds/efl
#src-svn xorg svn://svn.openwrt.org/openwrt/feeds/xorg
#src-svn desktop svn://svn.openwrt.org/openwrt/feeds/desktop
#src-svn xfce svn://svn.openwrt.org/openwrt/feeds/xfce
#src-svn lxde svn://svn.openwrt.org/openwrt/feeds/lxde
#src-link custom /usr/src/openwrt/custom-feed

該連線地址的修改主要修改一個檔案mtk-linkit\files\etc\opkg\linkit.conf。我們可以通過修改這個檔案中的檔案指向你的opkg連線地址,然後編譯。編譯後出的OS就可以通過opkg install連線你的伺服器了。當然,如果你不想使用Linkit_Smart_7688預設的opkg連線地址的話,你可以在mtk-linkit\files\etc\init.d\linkit檔案中刪除對linkit.conf的初始化部分,這樣在OpenWrt啟動的時候就不會講linit.conf新增/etc/opkg/distfeeds.conf

當然,如果你不想修改系統,只是在OpenWrt中修改opkg連線地址的話,那也很簡單。你只要用vi命令修改/etc/opkg/distfeeds.conf檔案就可以了。這也很簡單。

2.14 如果修改Linkit_Smart_7688預設lan ipaddress.

預設的Lan IPAddress在OpenWrt的/etc/config/network檔案中設定,如果想修改ip地址。可以在linkit-smart-7688-feed\mtk-linkit\files\etc\uci-defaults\51_linkit_config檔案中進行修改。linkit-smart-7688-feed預設的Lan ipaddr192.168.100.1

2.15 如果修改Linkit_Smart_7688的GPIO11.

Linkit_Smart_7688的GPIO11引腳,預設用來鎖定CL245A晶片的。該晶片是一個鎖存器,用來提升MT7688的引腳輸出功率和保護MT7688的引腳功能。但是,如果你不需要這個功能,希望將GPIO11引腳釋放出來的話。你可以對原始碼進行一些修改或者刪除。MTK在linux中增加了一個驅動,用來驅動GPIO11引腳的。詳細內容可以參考target\linux\ramips\patches-3.18\0200-linkit_bootstrap.patch檔案。

2.16 aplay多音效卡的使用

2.16.1 aplay查詢有效音效卡 aplay -l

[email protected]:/# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: I2S [MTK APSoC I2S], device 0: WMserious PCM wm8960-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

2.16.2 用指定的音效卡播放 aplay -Dhw:x (x=0,x=1)

root@mylinkit:/# aplay -Dhw:1 /Media/SD-P1/*.wav
Playing WAVE '/Media/SD-P1/1.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

2.16.3 aply -h

[email protected]:/# aplay -h
Usage: aplay [OPTION]... [FILE]...

-h, --help              help