Add scripts

automates the process of overwriting the boot sector of the SD card and
copying over the filesystem.
This commit is contained in:
Byron Lathi
2022-04-18 20:29:10 -05:00
parent 24d5a8c8ac
commit 4e2e030e52
2 changed files with 42 additions and 0 deletions

19
sw/script/copy_files.sh Normal file
View File

@@ -0,0 +1,19 @@
DEVICE=/dev/mmcblk0
TMPMOUNT=/tmp/sd
FSDIR=fsdir
V=
echo "$(tput bold setaf 11)Mounting Device$(tput sgr 0)"
mkdir $V -p $TMPMOUNT
sudo mount $V $DEVICE $TMPMOUNT
echo
echo "$(tput bold setaf 11)Copying Files$(tput sgr 0)"
sudo cp $V -r $FSDIR/* $TMPMOUNT
echo
echo "$(tput bold setaf 11)Unmounting Device$(tput sgr 0)"
sudo umount $V $DEVICE
rmdir $V $TMPMOUNT
echo

23
sw/script/format_disk.sh Normal file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
BOOTLOADER=bootloader/bootloader.bin
DEVICE=/dev/mmcblk0
TMPBOOTSECT=/tmp/bootsect
TMPMOUNT=/tmp/sd
V=
STATUS="status=none"
echo "$(tput bold setaf 11)Creating Filesystem$(tput sgr 0)"
sudo mkfs.vfat -F32 $DEVICE -n SUPER6502 $V
echo
echo "$(tput bold setaf 11)Modifying Boot Sector$(tput sgr 0)"
sudo dd if=$DEVICE of=$TMPBOOTSECT bs=512 count=1 $STATUS
sudo dd conv=notrunc if=$BOOTLOADER of=$DEVICE bs=512 skip=0 count=1 $STATUS
sudo dd conv=notrunc if=$TMPBOOTSECT of=$DEVICE bs=1 skip=0 count=90 iflag=skip_bytes,count_bytes $STATUS
sudo dd conv=notrunc if=$BOOTLOADER of=$DEVICE bs=1 skip=0 count=3 iflag=skip_bytes,count_bytes $STATUS
echo
echo "$(tput bold setaf 10)Done!$(tput sgr 0)"