#!/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
QSPI的flash烧录参考
最新推荐文章于 2024-07-20 18:38:43 发布