mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-09 21:25:23 +00:00
flash-sd.sh fixed. GPT table is now destroyed before re-partioning, thus avoiding backup table collisions.
This commit is contained in:
parent
356a0dbdde
commit
d4405da703
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Exit on any error (return code != 0)
|
# Exit on any error (return code != 0)
|
||||||
set -e
|
# set -e
|
||||||
|
|
||||||
# Output colors
|
# Output colors
|
||||||
GREEN='\033[1;32m'
|
GREEN='\033[1;32m'
|
||||||
@ -11,10 +11,10 @@ NAME="$GREEN"${0:2}"$NC"
|
|||||||
|
|
||||||
# File location variables
|
# File location variables
|
||||||
RISCV=/opt/riscv
|
RISCV=/opt/riscv
|
||||||
IMAGES=/home/ross/repos/buildroot/output/images/
|
IMAGES=$RISCV/buildroot/output/images/
|
||||||
FW_JUMP=$IMAGES/fw_jump.bin
|
FW_JUMP=$IMAGES/fw_jump.bin
|
||||||
LINUX_KERNEL=$IMAGES/Image
|
LINUX_KERNEL=$IMAGES/Image
|
||||||
DEVICE_TREE=$IMAGES/wally-artya7.dtb
|
DEVICE_TREE=$IMAGES/wally-vcu108.dtb
|
||||||
|
|
||||||
# Mount Directory
|
# Mount Directory
|
||||||
MNT_DIR=wallyimg
|
MNT_DIR=wallyimg
|
||||||
@ -61,12 +61,19 @@ echo -e "$NAME: Device tree block size: $DST_SIZE"
|
|||||||
echo -e "$NAME: OpenSBI FW_JUMP block size: $FW_JUMP_SIZE"
|
echo -e "$NAME: OpenSBI FW_JUMP block size: $FW_JUMP_SIZE"
|
||||||
echo -e "$NAME: Kernel block size: $KERNEL_SIZE"
|
echo -e "$NAME: Kernel block size: $KERNEL_SIZE"
|
||||||
|
|
||||||
read -p "Warning: " -n 1 -r
|
read -p "Warning: Doing this will replace all data on this card.\nContinue? y/n: " -n 1 -r
|
||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]] ; then
|
if [[ $REPLY =~ ^[Yy]$ ]] ; then
|
||||||
# Make empty image
|
DEVBASENAME=$(basename $1)
|
||||||
#echo -e "$NAME: Creating blank image"
|
CHECKMOUNT=$(lsblk | grep "sdb4" | tr -s ' ' | cut -d' ' -f 7)
|
||||||
#sudo dd if=/dev/zero of=$1 bs=4k conv=noerror status=progress && sync
|
|
||||||
|
if [ ! -z $CHECKMOUNT ] ; then
|
||||||
|
sudo umount -v $CHECKMOUNT
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Make empty image
|
||||||
|
echo -e "$NAME: Creating blank image"
|
||||||
|
sudo dd if=/dev/zero of=$1 bs=64k status=progress && sync
|
||||||
|
|
||||||
# GUID Partition Tables (GPT)
|
# GUID Partition Tables (GPT)
|
||||||
# ===============================================
|
# ===============================================
|
||||||
@ -76,11 +83,9 @@ if [[ $REPLY =~ ^[Yy]$ ]] ; then
|
|||||||
# to 1 sector boundaries I think? This would normally be set to 2048
|
# to 1 sector boundaries I think? This would normally be set to 2048
|
||||||
# apparently.
|
# apparently.
|
||||||
|
|
||||||
# sudo sgdisk -g --clear --set-alignment=1 \
|
sudo sgdisk -z $1
|
||||||
# --new=1:34:+$FW_JUMP_SIZE: --change-name=1:'opensbi' --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985 \
|
|
||||||
# --new=2:$KERNEL_START:+$KERNEL_SIZE --change-name=2:'kernel' --typecode=2:3000 \
|
sleep 1
|
||||||
# --new=3:$FS_START:-0 --change-name=3:'filesystem' \
|
|
||||||
# $1
|
|
||||||
|
|
||||||
echo -e "$NAME: Creating GUID Partition Table"
|
echo -e "$NAME: Creating GUID Partition Table"
|
||||||
sudo sgdisk -g --clear --set-alignment=1 \
|
sudo sgdisk -g --clear --set-alignment=1 \
|
||||||
@ -92,6 +97,8 @@ if [[ $REPLY =~ ^[Yy]$ ]] ; then
|
|||||||
|
|
||||||
sudo partprobe $1
|
sudo partprobe $1
|
||||||
|
|
||||||
|
sleep 3
|
||||||
|
|
||||||
echo -e "$NAME: Copying binaries into their partitions."
|
echo -e "$NAME: Copying binaries into their partitions."
|
||||||
DD_FLAGS="bs=4k iflag=fullblock oflag=direct conv=fsync status=progress"
|
DD_FLAGS="bs=4k iflag=fullblock oflag=direct conv=fsync status=progress"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user