1. AM335X启动配置
矿板SYSBOOT位配置信息,在矿板反面ANTMINER丝印上方,使用电阻焊接与否来替代拨码开关,矿板默认配置表如下
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 |
---|---|---|---|---|---|---|---|
R55 | R56 | R57 | R58 | R59 | R60 | R61 | R62 |
0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 |
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
R63 | R64 | R65 | R66 | R67 | R68 | R69 | R70 |
0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 |
然后参照AM335x Sitara Processors Technical Reference Manual得出矿板默认的启动优先级(截图有剪裁)
2. 擦除NAND上的镜像
从默认启动配置可以看出,nand flash启动优先级高于mmc0和uart0,正常情况下的矿板都是带程序的
如果能进uboot,可以使用以下指令擦除nand:nand erase.chip
如果不能中断uboot引导过程,或者上电不输出ccccc
(xmodem1K的标识),则可能是nand flash中的mlo或uboot损坏
可以通过短接nand flash上的相关引脚来干扰默认启动过程,进而跳到mmc0或者uart0启动
但首要前提,矿板PMIC(TPS65217C)各路电压都正常,晶振0.8V左右,核心1.1V都要有。
短接下图任一红色方框中,任意两个引脚,然后再通电启动即可破坏默认的NAND优先启动方式,跳转到mmc0或者uart0启动。
3. 格式化TF卡
我使用的windows系统,因此使用DiskGenius来格式化TF卡
首先删除TF卡内原有的分区(如果TF卡内有其他资料,需要提前备份),这里我使用的是一张拓容卡,所以请不要吐槽这个容量
新建一个FAT32分区,参数这里改不了,默认即可,然后点击保存更改
先不要格式化,右键刚才创建的分区
系统标识改成0B
最后格式化刚才创建的分区,拷入一级引导MLO
和uboot.img
将TF卡插入矿板卡槽,上电启动,完成。
如果是linux用户,挂在tf卡后直接执行下面的bash脚本即可,复制下面的脚本,存储为.sh文件
#!/bin/bash
# Authors:
# LT Thomas <ltjr@ti.com>
# Chase Maupin
# Franklin Cooper Jr.
#
# create-sdcard.sh v0.3
# Force locale language to be set to English. This avoids issues when doing
# text and string processing.
export LANG=C
# Determine the absolute path to the executable
# EXE will have the PWD removed so we can concatenate with the PWD safely
PWD=`pwd`
EXE=`echo $0 | sed s=$PWD==`
EXEPATH="$PWD"/"$EXE"
clear
cat << EOM
################################################################################
This script will create a bootable SD card from custom or pre-built binaries.
The script must be run with root permissions and from the bin directory of
the SDK
Example:
$ sudo ./create-sdcard.sh path/to/sdcard/files
Formatting can be skipped if the SD card is already formatted and
partitioned properly.
################################################################################
EOM
AMIROOT=`whoami | awk {‘print $1‘}`
if [ "$AMIROOT" != "root" ] ; then
echo " **** Error *** must run script with sudo"
echo ""
exit
fi
THEPWD=$EXEPATH
check_for_sdcards()
{
# find the avaible SD cards
ROOTDRIVE=`mount | grep ‘on / ‘ | awk {‘print $1‘} | cut -c6-8`
PARTITION_TEST=`cat /proc/partitions | grep -v $ROOTDRIVE | grep ‘\<sd.\>\|\<mmcblk.\>‘ | grep -n ‘‘`
if [ "$PARTITION_TEST" = "" ]; then
echo -e "Please insert a SD card to continue\n"
while [ "$PARTITION_TEST" = "" ]; do
read -p "Type ‘y‘ to re-detect the SD card or ‘n‘ to exit the script: " REPLY
if [ "$REPLY" = ‘n‘ ]; then
exit 1
fi
ROOTDRIVE=`mount | grep ‘on / ‘ | awk {‘print $1‘} | cut -c6-8`
PARTITION_TEST=`cat /proc/partitions | grep -v $ROOTDRIVE | grep ‘\<sd.\>\|\<mmcblk.\>‘ | grep -n ‘‘`
done
fi
}
# find the avaible SD cards
ROOTDRIVE=`mount | grep ‘on / ‘ | awk {‘print $1‘} | cut -c6-9`
if [ "$ROOTDRIVE" = "root" ]; then
ROOTDRIVE=`readlink /dev/root | cut -c1-3`
else
ROOTDRIVE=`echo $ROOTDRIVE | cut -c1-3`
fi
PARTITION_TEST=`cat /proc/partitions | grep -v $ROOTDRIVE | grep ‘\<sd.\>\|\<mmcblk.\>‘ | grep -n ‘‘`
# Check for available mounts
check_for_sdcards
echo -e "\nAvailable Drives to write images to: \n"
echo "# major minor size name "
cat /proc/partitions | grep -v $ROOTDRIVE | grep ‘\<sd.\>\|\<mmcblk.\>‘ | grep -n ‘‘
echo " "
DEVICEDRIVENUMBER=
while true;
do
read -p ‘Enter Device Number or ‘n‘ to exit: ‘ DEVICEDRIVENUMBER
echo " "
if [ "$DEVICEDRIVENUMBER" = ‘n‘ ]; then
exit 1
fi
if [ "$DEVICEDRIVENUMBER" = "" ]; then
# Check to see if there are any changes
check_for_sdcards
echo -e "These are the Drives available to write images to:"
echo "# major minor size name "
cat /proc/partitions | grep -v $ROOTDRIVE | grep ‘\<sd.\>\|\<mmcblk.\>‘ | grep -n ‘‘
echo " "
continue
fi
DEVICEDRIVENAME=`cat /proc/partitions | grep -v $ROOTDRIVE | grep ‘\<sd.\>\|\<mmcblk.\>‘ | grep -n ‘‘ | grep "${DEVICEDRIVENUMBER}:" | awk ‘{print $5}‘`
if [ -n "$DEVICEDRIVENAME" ]
then
DRIVE=/dev/$DEVICEDRIVENAME
DEVICESIZE=`cat /proc/partitions | grep -v $ROOTDRIVE | grep ‘\<sd.\>\|\<mmcblk.\>‘ | grep -n ‘‘ | grep "${DEVICEDRIVENUMBER}:" | awk ‘{print $4}‘`
break
else
echo -e "Invalid selection!"
# Check to see if there are any changes
check_for_sdcards
echo -e "These are the only Drives available to write images to: \n"
echo "# major minor size name "
cat /proc/partitions | grep -v $ROOTDRIVE | grep ‘\<sd.\>\|\<mmcblk.\>‘ | grep -n ‘‘
echo " "
fi
done
echo "$DEVICEDRIVENAME was selected"
#Check the size of disk to make sure its under 16GB
if [ $DEVICESIZE -gt 17000000 ] ; then
cat << EOM
################################################################################
**********WARNING**********
Selected Device is greater then 16GB
Continuing past this point will erase data from device
Double check that this is the correct SD Card
################################################################################
EOM
ENTERCORRECTLY=0
while [ $ENTERCORRECTLY -ne 1 ]
do
read -p ‘Would you like to continue [y/n] : ‘ SIZECHECK
echo ""
echo " "
ENTERCORRECTLY=1
case $SIZECHECK in
"y") ;;
"n") exit;;
*) echo "Please enter y or n";ENTERCORRECTLY=0;;
esac
echo ""
done
fi
echo ""
DRIVE=/dev/$DEVICEDRIVENAME
NUM_OF_DRIVES=`df | grep -c $DEVICEDRIVENAME`
# This if statement will determine if we have a mounted sdX or mmcblkX device.
# If it is mmcblkX, then we need to set an extra char in the partition names, ‘p‘,
# to account for /dev/mmcblkXpY labled partitions.
if [[ ${DEVICEDRIVENAME} =~ ^sd. ]]; then
echo "$DRIVE is an sdx device"
P=‘‘
else
echo "$DRIVE is an mmcblkx device"
P=‘p‘
fi
if [ "$NUM_OF_DRIVES" != "0" ]; then
echo "Unmounting the $DEVICEDRIVENAME drives"
for ((c=1; c<="$NUM_OF_DRIVES"; c++ ))
do
unmounted=`df | grep ‘\<‘$DEVICEDRIVENAME$P$c‘\>‘ | awk ‘{print $1}‘`
if [ -n "$unmounted" ]
then
echo " unmounted ${DRIVE}$P$c"
sudo umount -f ${DRIVE}$P$c
fi
done
echo " unmounted ${DRIVE}$P"
sudo umount -f ${DRIVE}$P
else
echo " unmounted ${DRIVE}$P"
sudo umount -f ${DRIVE}$P
fi
# Refresh this variable as the device may not be mounted at script instantiation time
# This will always return one more then needed
NUM_OF_PARTS=`cat /proc/partitions | grep -v $ROOTDRIVE | grep -c $DEVICEDRIVENAME`
for ((c=1; c<"$NUM_OF_PARTS"; c++ ))
do
SIZE=`cat /proc/partitions | grep -v $ROOTDRIVE | grep ‘\<‘$DEVICEDRIVENAME$P$c‘\>‘ | awk ‘{print $3}‘`
echo "Current size of $DEVICEDRIVENAME$P$c $SIZE bytes"
done
#Section for partitioning the drive
#create 1 partition
cat << EOM
################################################################################
Now erasing partition table
################################################################################
EOM
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
cat << EOM
################################################################################
Partitioning Boot
################################################################################
EOM
mkfs.vfat -I -F 32 -n "boot" ${DRIVE}${P}
#Add directories for images
export START_DIR=$PWD
export PATH_TO_SDBOOT=boot
echo " "
echo "Mount the partitions "
mkdir $PATH_TO_SDBOOT
sudo mount -t vfat ${DRIVE}${P} boot/
echo " "
echo "Emptying partitions "
echo " "
sudo rm -rf $PATH_TO_SDBOOT/*
echo ""
echo "Syncing...."
echo ""
sync
sync
sync
cat << EOM
################################################################################
Copying files now... will take minutes
################################################################################
Copying boot partition
EOM
echo ""
#copy boot files out of board support
if [ -f "$1/MLO" ] ; then
cp -f $1/* $PATH_TO_SDBOOT/
elif [ -f "$1/tiboot3.bin" ] ; then
cp -f $1/* $PATH_TO_SDBOOT/
else
cat << EOM
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: SD card file directory does not exist
ERROR: ($1)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOM
fi
echo ""
echo ""
echo "Syncing..."
sync
sync
sync
echo " "
echo "Un-mount the partitions "
sudo umount -f $PATH_TO_SDBOOT
echo " "
echo "Remove created temp directories "
sudo rm -rf $PATH_TO_SDBOOT
echo " "
echo "Operation Finished"
echo " "