#!/bin/sh #An spi flash M25P80 connect to keystone-evm cpu by spi bus, so the method #is to read/write spi flash to verify whether the spi bus driver worked #or not. MTD_CHAR_DEVICE="/dev/mtd4" MTD_BLOCK_DEVICE="/dev/mtdblock4" if [ ! -e $MTD_CHAR_DEVICE ]; then echo "FAIL: spi flash device $MTD_CHAR_DEVICE does not exist" exit 1 else echo "PASS: spi flash device $MTD_CHAR_DEVICE exists" fi if [ ! -e $MTD_BLOCK_DEVICE ]; then echo "FAIL: spi flash device $MTD_BLOCK_DEVICE does not exist" exit 1 else echo "PASS: spi flash device $MTD_BLOCK_DEVICE exists" fi /usr/sbin/flash_erase -j $MTD_CHAR_DEVICE 0 0 if [ $? -ne 0 ]; then echo "FAIL: format spi flash device $MTD_BLOCK_DEVICE fail" exit 1 else mkdir -p /mnt/spi mount -t jffs2 $MTD_BLOCK_DEVICE /mnt/spi if [ $? -ne 0 ]; then echo "FAIL: mount spi flash device $MTD_BLOCK_DEVICE fail" exit 1 else cp /bin/busybox /mnt/spi ls /mnt/spi |grep busybox if [ $? -ne 0 ]; then echo "FAIL: read or write spi flash device $MTD_BLOCK_DEVICE fail" exit 1 else umount $MTD_BLOCK_DEVICE echo "PASS: read or write spi flash device $MTD_BLOCK_DEVICE success" fi fi fi echo "PASS: spi bus test passed" exit 0