使用 Arduino IDE 在 Linkit Smart 7688 Duo 开发 Arduino 程序

Linkit Smart 7688 Duo 有两颗芯片,一个是装了 OpenWrt 的 MT7688, 还有是兼容 Arduino 的 Atmega32U4 芯片,因此 Linkit Smart 也是可以使用 Arduino IDE 开发的。

首先从 Arduino 官方网站下载 Arduino IDE,安装好,装完之后需要在 Arduino IDE 中添加 Linkit Smart 的开发扩展,打开 文件 -> 首选项菜单,在"附加开发板管理器网址"中添加网址: http://download.labs.mediatek.com/package_mtk_linkit_smart_7688_index.json
如图所示:

arduino_preview

打开开发板管理器,搜索 Linkit Smart,就能看到列出了 Linkit Smart 开发插件,点击安装。安装需要耗费一点时间,有点时候还会失败,需要一点耐心。

接下来就是要安装驱动了,打开首选项菜单,在面板下面首选项配置文件所在的目录,如图:

driver

依次进入目录下的 packages ->Linkit -> hardware -> avr -> 0.1.8 -> driver ,在 driver 目录下能看到一个 linkit_smart_7688.inf 的驱动文件,右键安装。在 Windows 10 下会报错,驱动没有通过验证,只要在网上搜索 " windows 10 禁用驱动强制验证" ,按操作禁用即可。

接下来就要试着用 Arduino IDE 写程序,然后写入到 Linkit Smart 了,打开示例文件 Blink:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(3000);                       // wait for a second
}

在"工具" 菜单栏下开发板选择 linkit Smart 7688 Duo,端口为网络端口 mylinkit at 192.168...,这跟普通 Arduino 有点不同,一般为 COM 端口。

保存文件之后就可以直接上传了,第一次上传会弹出密码输入框,输入 Linkit Smart 的密码,看到如下类似输出就表示上传成功了:

set pinmux spi_s -> gpio

avrdude: Version 6.1, compiled on Sep 27 2016 at 08:17:47
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/root/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : unknown
         Using Programmer              : linuxgpio
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : linuxgpio
         Description     : Use sysfs interface to bitbang GPIO lines
         Pin assignment  : /sys/class/gpio/gpio{n}
           RESET   =  3
           SCK     =  15
           MOSI    =  16
           MISO    =  17

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9587
avrdude: erasing chip
avrdude: reading input file "/tmp/sketch.hex"
avrdude: input file /tmp/sketch.hex auto detected as Intel Hex
avrdude: writing flash (32758 bytes):

Writing | ################################################## | 100% 4.61s

avrdude: 32758 bytes of flash written
avrdude: verifying flash memory against /tmp/sketch.hex:
avrdude: load data flash data from input file /tmp/sketch.hex:
avrdude: input file /tmp/sketch.hex auto detected as Intel Hex
avrdude: input file /tmp/sketch.hex contains 32758 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 4.26s

avrdude: verifying ...
avrdude: 32758 bytes of flash verified

avrdude done.  Thank you.

此时就应该能看到 D13 的 LED 灯闪烁了。