#!/bin/sh # This script is used to test spi flash functionality for bsc9131rdb. An spi # flash M25P80 connect to bsc9131 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/mtd8" MTD_BLOCK_DEVICE="/dev/mtdblock8" FLASH_ERASE=`which flash_erase` if [ "x$FLASH_ERASE" != "x" ]; then echo "PASS: flash_erase found" else echo "FAIL: flash_erase not found" exit 1 fi 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 $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 file_num=`ls /mnt/spi |grep -c 'busybox'` if [ $file_num -eq 1 ]; then rm /mnt/spi/busybox umount $MTD_BLOCK_DEVICE echo "PASS: read or write spi flash device $MTD_BLOCK_DEVICE success" else echo "FAIL: read or write spi flash device $MTD_BLOCK_DEVICE fail" exit 1 fi fi fi echo "PASS: spi bus test passed" exit 0