QSPI的flash烧录参考

#!/bin/sh

# the purpose of this script is to flash u-boot, Linux, 
# and the Linux ramdisk to QSPI flash

path=$1
BOOT_FILE="boot.bin"
BOOT_PART="/dev/mtd0"
BOOT_ENV_PART="/dev/mtd1"
BIT_PART="/dev/mtd2"
KERNEL_FILE="uImage"
KERNEL_PART="/dev/mtd3"
DT_FILE="devicetree.dtb"
DT_PART="/dev/mtd4"
RD_FILE="uramdisk.image.gz"
RD_PART="/dev/mtd5"


if [ $# -ne 1 ] ; then
        echo "usage: update_system.sh <path to images>"
        exit
fi

check_cmd()
{
        $1

        if [ $? -ne 0 ];then
            echo "FAILED!!!"
            echo
            exit 1
        fi
}


printf "\nWriting ${BOOT_FILE} Image To QSPI Flash @${BOOT_PART}\n"
check_cmd "flashcp -v $path/${BOOT_FILE} ${BOOT_PART}"

printf "\nerase bootenv @${BOOT_ENV_PART}\n"
flash_eraseall ${BOOT_ENV_PART}

if dmesg | grep "7z010" > /dev/null; then
	printf "\nWriting 7z010.bit to QSPI Flash ${BIT_PART}\n"
	printf "0: %.8x" `stat -c %s $path/7z010.bit` | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 > /tmp/bitstream
	cat $path/7z010.bit >> /tmp/bitstream	
	check_cmd "flashcp -v /tmp/bitstream ${BIT_PART}"
else
	printf "\nWriting 7z020.bit to QSPI Flash ${BIT_PART}\n"
	printf "0: %.8x" `stat -c %s $path/7z020.bit` | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 > /tmp/bitstream
	cat $path/7z020.bit >> /tmp/bitstream
	check_cmd "flashcp -v /tmp/bitstream ${BIT_PART}"
fi
	
printf "\nWriting ${KERNEL_FILE} To QSPI Flash @${KERNEL_PART}\n"
check_cmd "flashcp -v $path/${KERNEL_FILE} ${KERNEL_PART}"

printf "\nWriting ${DT_FILE} To QSPI Flash @${DT_PART}\n"
check_cmd "flashcp -v $path/${DT_FILE} ${DT_PART}"

printf "\nWriting ${RD_FILE} To QSPI Flash @${RD_PART}\n"
check_cmd "flashcp -v $path/${RD_FILE} ${RD_PART}"

echo "QSPI flash update successfully!"
echo

  • 10
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值