LinkIt Smart 7688 Knowledge Base

Contents:

Authors

  • Leonid Polyakov

C/C++ Programming

Cross compilation

  1. Download SKD from .. _Mediatek downloads page: https://docs.labs.mediatek.com/resource/linkit-smart-7688/en/downloads e.g.:

    wget https://labs.mediatek.com/en/download/AGSSkG38
    
  2. Unpack:

    sudo tar -xvjf SDK.tar.bz2
    

Node.js native addons cross-compilation

  1. Fork the module repo

  2. Clone and edit unnecessary dependencies like nan

  3. Deploy SKD if needed. Set $STAGING_DIR environment variable, e.g.:

    export STAGING_DIR=/sdk/OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir
    
  4. Run the following bash script in the module folder:

    set -e
    
    if [ ! -d "$STAGING_DIR" ]; then
        echo "STAGING_DIR needs to be set to your cross toolchain path";
        exit 1
    fi
    
    ARCH=${ARCH:-mipsel}
    NODE=${NODE:-0.12.7}
    
    TOOLCHAIN_DIR=$(ls -d "$STAGING_DIR/toolchain-"*)
    echo $TOOLCHAIN_DIR
    
    export SYSROOT=$(ls -d "$STAGING_DIR/target-"*)
    
    source $TOOLCHAIN_DIR/info.mk # almost a bash script
    
    echo "Cross-compiling for" $TARGET_CROSS
    
    export PATH=$TOOLCHAIN_DIR/bin:$PATH
    export CPPPATH=$TARGET_DIR/usr/include
    export LIBPATH=$TARGET_DIR/usr/lib
    
    #TODO: anything better than this hack?
    OPTS="-I $SYSROOT/usr/include -L $TOOLCHAIN_DIR/lib -L $SYSROOT/usr/lib"
    
    export CC="${TARGET_CROSS}gcc $OPTS"
    export CXX="${TARGET_CROSS}g++ $OPTS"
    export AR=${TARGET_CROSS}ar
    export RANLIB=${TARGET_CROSS}ranlib
    export LINK="${TARGET_CROSS}g++ $OPTS"
    export CPP="${TARGET_CROSS}gcc $OPTS -E"
    export STRIP=${TARGET_CROSS}strip
    export OBJCOPY=${TARGET_CROSS}objcopy
    export LD="${TARGET_CROSS}g++ $OPTS"
    export OBJDUMP=${TARGET_CROSS}objdump
    export NM=${TARGET_CROSS}nm
    export AS=${TARGET_CROSS}as
    
    export npm_config_arch=$ARCH
    node-gyp rebuild --target=$NODE -v
    
  5. Remove /build from .gitignore, commit and push.

  6. Install directly from GitHub, e.g.:

    npm install https://github.com/Voxiferus/node-spi.git --global
    

First Steps

Getting started

  1. By default the module is in AP mode.
  2. Connect to the Linkit_Smart_xxx network and go to mylinkit.local URL
  3. Set password and login to the web configurator
  4. Select “Network” tab, switch to “Station mode” and connect the device to the local Wi-Fi network

Factory reset

  1. Boot up the board and wait for the WiFi LED to go off.
  2. Press and hold the WiFi button for at least 20 seconds then release.
  3. The WiFi LED will blink fast for 1 second, and then reboot to perform a factory reset.

Update the firmware with a USB drive

  1. Download the latest .. _LinkIt Smart 7688 Firmware: https://docs.labs.mediatek.com/resource/linkit-smart-7688/en/downloads
  2. Unzip and copy the image lks7688.img file to the root directory of a FAT32 USB drive.
  3. Attach the USB drive to the HOST port of the board with an OTG cable.
  4. Press and hold the on-board WiFi button.
  5. Press the MPU reset button once while holding the WiFi button.
  6. Keep holding the WiFi button for about 5 seconds. Do not release until the orange LED for WiFi is off. DO NOT press the WiFi button longer than 20s or it will upgrade the bootloader.
  7. The WiFi LED blinks fast for about 3 minutes.
  8. The device will automatically reboot after firmware update is complete.

Enabling SFTP

# opkg update
# opkg install vsftpd openssh-sftp-server
# /etc/init.d/vsftpd enable
# /etc/init.d/vsftpd start

Mounting the root FS on an SD card

  1. Enable ext4 support:

    # opkg update
    # opkg install block-mount kmod-fs-ext4 kmod-usb-storage-extras e2fsprogs fdisk
    
  2. Format SD card:

    # mkfs.ext4 /dev/mmcblk0p1
    
  3. Copy root fs to SD:

    # mount /dev/mmcblk0p1 /mnt
    # tar -C /overlay -cvf - . | tar -C /mnt -xf -
    # umount /mnt
    
  4. Generate fstab (file system partitions table) from the current fs configuration:

    # block detect > /etc/config/fstab
    
  5. Edit fstab:

    config 'mount'
      option  target  '/overlay'
      ...
      option  enabled '1'
    
  6. Reboot

Peripheral

Pinmux

  1. List pin groups:

    mt7688_pinmux get
    
  2. Reassign pin group:

    mt7688_pinmux set <group> <function>
    

SPI over GPIO

  1. Install SPI-GPIO drivers:

    # opkg update
    # opkg install kmod-spi-gpio
    # opkg install kmod-spi-dev
    # opkg install kmod-spi-gpio-custom
    
  2. Use mt7688_pinmux to make sure devoted pins are in GPIO state. Probably, reboot needed ???

  1. Insert the module:

    insmod spi-gpio-custom bus<x=0...3>=<id>,<sck>,<mosi>,<miso>,<mode1>,<maxfreq1>,<cs1>
    

E.g.:

insmod spi-gpio-custom bus0=1,14,15,16,0,10000,17

Modes:

Mode# CPOL CPHA
0 0 0
1 0 1
2 1 0
3 1 1

Indices and tables