Hands on LinkIt Smart 7688 Duo without Arduino IDE

arduinomk
7688
linkit7688

#1

This Topic is about troubleshooting and investigation the LinkIt Smart Duo 7688, its (mis-)behaviour and troubles if working with an alternative development Environment Arduino.mk without Arduino-IDE.


Programming the AVR on LinkIt Smart 7688 Duo without Arduino-IDE

I am working on a Archlinux, which is usually fresh like supermarket.

AVRDude version 6.3
Arduino Version = 182
Arduino Makefile Version = 1.5
CC Version = 6.3.0 (avr-gcc)

The 7688 seemed to be even fresher than my OS and therefore i needed to add the Target to AVRDudes board.txt. The content can be found from MediaTek-Labs boards.txt, with a variation of the smart7688.build.variant. If this is defined as =smart7688 as supposed i am getting this error:

/usr/bin/avr-g++ -x c++ -include Arduino.h -MMD -c -mmcu=atmega32u4 -DF_CPU=8000000L -DARDUINO=182 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/archlinux-arduino/avr/cores/arduino -I/usr/share/arduino/hardware/archlinux-arduino/avr/variants/smart7688    -Wall -ffunction-sections -fdata-sections -Os -DUSB_VID=0x0E8D -DUSB_PID=0xAB01 -pedantic -Wall -Wextra -fno-use-cxa-atexit  -fno-threadsafe-statics -fdiagnostics-color -fpermissive -fno-exceptions -std=gnu++11 -DHE_ROLE=gateway7688 -DCUSTOM_CONFIG=config_gateway7688.h serial.ino -o ../bin/7688_serial_test/smart7688/serial.ino.o
In file included from <command-line>:0:0:
/usr/share/arduino/hardware/archlinux-arduino/avr/cores/arduino/Arduino.h:257:26: fatal error: pins_arduino.h: No such file or directory
 #include "pins_arduino.h"
                          ^
compilation terminated.

–If i am changing this to smart7688.build.variant=yun i can at least compile the sketch–

This is the working boards.txt.

smart7688.name=LinkIt Smart 7688 Duo
smart7688.upload.via_ssh=true
smart7688.vid.0=0x0E8D
smart7688.pid.0=0xAB00
smart7688.vid.1=0x0E8D
smart7688.pid.1=0xAB01

smart7688.upload.tool=avrdude
smart7688.upload.protocol=avr109
smart7688.upload.maximum_size=28672
smart7688.upload.speed=57600
smart7688.upload.disable_flushing=true
smart7688.upload.use_1200bps_touch=true
smart7688.upload.wait_for_upload_port=true

smart7688.bootloader.tool=avrdude
smart7688.bootloader.low_fuses=0xff
smart7688.bootloader.high_fuses=0xd8
smart7688.bootloader.extended_fuses=0xce
smart7688.bootloader.file=caterina/Caterina-smart7688.hex
smart7688.bootloader.unlock_bits=0x3F
smart7688.bootloader.lock_bits=0x2F

smart7688.build.board=AVR_LINKITSMART7688
smart7688.build.mcu=atmega32u4
smart7688.build.f_cpu=8000000L
smart7688.build.vid=0x0E8D
smart7688.build.pid=0xAB01
smart7688.build.usb_product="LinkIt Smart 7688 Duo"
smart7688.build.usb_manufacturer="MediaTek Labs"
smart7688.build.variant=smart7688
#smart7688.build.variant=yun
smart7688.build.extra_flags={build.usb_flags}

To make smart7688.build.variant=smart7688 work we need to provide the pins_arduino.h file for this target and place it in the $ARDUINO_CORE_PATH/hardware/arduino/avr/variants/smart7688 folder. /usr/share/arduino/hardware/archlinux-arduino/avr/variants/smart7688 in my case Archlinux and make it readable (775) for everyone.

Next I need to flash the .hex to the AVR from within the 7688 Duo, with AVRDude.

I copied it to the 7688 via scp. Make sure, to that the SPI pins are free.

$ scp bin/7688_serial_test/smart7688/7688_serial_test.hex root@he_gateway.lan:/tmp/
$ ssh root@he_gateway.lan
$ cd /tmp
$ avrdude -p m32u4 -c linuxgpio -v -e -U flash:w:7688_serial_test.hex
$ opkg update && opkg install picocom

I am not getting any output here, which is because the default serial port in the avr is called mapped to Serial1. If you don’t want replace Serial.print() with Serial1.print() you can use the much more ugly but convenient SERIAL_PORT_HARDWARE directive, see: pins_arduino.h. (SERIAL_PORT_HARDWARE.print() …).

Unbricking LinkIt Smart 7688 Duo

Thanks to cnx-software.com blog there is a documented way to debrick the device.

Requirements


  1. Unzip the image and put lks7688.img to the toplevel directory of the USB stick.
  2. The Stick with the OTG cable going into the USB host port. The other port powers the device.
  3. Press wifi-Button and keep pressed. Press MPU-Button for 3-5 secs.
  4. When the red LED starts blinking, reveal the wifi-Button. After 2-3 Minutes the update should be done.

It is easier when have UART connected:

DDR Calibration DQS reg = 00008989


U-Boot 1.1.3 (Sep 10 2015 - 05:56:31)

Board: Ralink APSoC DRAM:  128 MB
relocate_code Pointer at: 87f68000
flash manufacture id: c2, device id 20 19
find flash: MX25L25635E
*** Warning - bad CRC, using default environment

============================================ 
Ralink UBoot Version: 4.3.0.0
-------------------------------------------- 
ASIC 7628_MP (Port5<->None)
DRAM component: 1024 Mbits DDR, width 16
DRAM bus: 16 bit
Total memory: 128 MBytes
Flash component: SPI Flash
Date:Sep 10 2015  Time:05:56:31
============================================ 
icache: sets:512, ways:4, linesz:32 ,total:65536
dcache: sets:256, ways:4, linesz:32 ,total:32768 

 ##### The CPU freq = 580 MHZ #### 
 estimate memory size =128 Mbytes
RESET MT7628 PHY!!!!!!
GPIOMODE --> 50054404

GPIOMODE2 --> 5540551


RESET BUTTON PRESSED
button pressed for 13 s

Please choose the operation: 
   1: Load system code to SDRAM via TFTP. 
   2: Load system code then write to Flash via TFTP. 
   3: Boot system code via Flash (default).
   4: Entr boot command line interface.
   7: Load Boot Loader code then write to Flash via Serial. 
   9: Load Boot Loader code then write to Flash via TFTP. 



5: System Load Linux then write to Flash via USB Storage. 
(Re)start USB...
USB0:   *********ehci_hcd_init**********
Mediatek/Ralink USB EHCI host init hccr b01c0000 and hcor b01c0010 hc_length 16
 6. u2phydcr0(0xb0120860)=0x00aaaa02
 FM_OUT value: u4FmOut = 0(0x00000000)
 FM_OUT value: u4FmOut = 131(0x00000083)
 FM detection done! loop = 1
 SR calibration value u1SrCalVal = 6


Register 1111 NbrPorts 1
USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
       scanning bus for storage devices... 1 Storage Device(s) found
reading lks7688.img
...........................................................................................................................................................................................................................................................................................................................................................................................................

22282244 bytes read
writing lks7688.img to flash
....................................................................................................................................................................................................................................................................................................................................................
....................................................................................................................................................................................................................................................................................................................................................
.
.
Done!
     [04040D07][04040C0F]

LinkIt Smart 7688 Duo as RFM95 to Wifi-BERadio gateway
Welcome, einsiedlerkrebs!
LinkIt Smart 7688 Duo