LinkIt Smart 7688 Knowledge Base¶
Contents:
Authors¶
- Leonid Polyakov
C/C++ Programming¶
Cross compilation¶
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
Unpack:
sudo tar -xvjf SDK.tar.bz2
Node.js native addons cross-compilation¶
Fork the module repo
Clone and edit unnecessary dependencies like nan
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
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
Remove /build from .gitignore, commit and push.
Install directly from GitHub, e.g.:
npm install https://github.com/Voxiferus/node-spi.git --global
First Steps¶
Getting started¶
- By default the module is in AP mode.
- Connect to the Linkit_Smart_xxx network and go to mylinkit.local URL
- Set password and login to the web configurator
- Select “Network” tab, switch to “Station mode” and connect the device to the local Wi-Fi network
Factory reset¶
- Boot up the board and wait for the WiFi LED to go off.
- Press and hold the WiFi button for at least 20 seconds then release.
- The WiFi LED will blink fast for 1 second, and then reboot to perform a factory reset.
Update the firmware with a USB drive¶
- Download the latest .. _LinkIt Smart 7688 Firmware: https://docs.labs.mediatek.com/resource/linkit-smart-7688/en/downloads
- Unzip and copy the image lks7688.img file to the root directory of a FAT32 USB drive.
- Attach the USB drive to the HOST port of the board with an OTG cable.
- Press and hold the on-board WiFi button.
- Press the MPU reset button once while holding the WiFi button.
- 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.
- The WiFi LED blinks fast for about 3 minutes.
- 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¶
Enable ext4 support:
# opkg update # opkg install block-mount kmod-fs-ext4 kmod-usb-storage-extras e2fsprogs fdisk
Format SD card:
# mkfs.ext4 /dev/mmcblk0p1
Copy root fs to SD:
# mount /dev/mmcblk0p1 /mnt # tar -C /overlay -cvf - . | tar -C /mnt -xf - # umount /mnt
Generate fstab (file system partitions table) from the current fs configuration:
# block detect > /etc/config/fstab
Edit fstab:
config 'mount' option target '/overlay' ... option enabled '1'
Reboot
Peripheral¶
Pinmux¶
List pin groups:
mt7688_pinmux get
Reassign pin group:
mt7688_pinmux set <group> <function>
SPI over GPIO¶
Install SPI-GPIO drivers:
# opkg update # opkg install kmod-spi-gpio # opkg install kmod-spi-dev # opkg install kmod-spi-gpio-custom
Use mt7688_pinmux to make sure devoted pins are in GPIO state. Probably, reboot needed ???
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 |