From 2084054d3d60c2e02ac24d708ad88bb4630c9e1a Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Fri, 6 Oct 2023 06:48:47 -0700 Subject: [PATCH] Add script for creating verilog filesystem image --- sw/.gitignore | 3 +++ sw/script/create_verilog_image.sh | 42 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 sw/script/create_verilog_image.sh diff --git a/sw/.gitignore b/sw/.gitignore index ec73f2b..5e3b75b 100644 --- a/sw/.gitignore +++ b/sw/.gitignore @@ -53,3 +53,6 @@ modules.order Module.symvers Mkfile.old dkms.conf + +# Filesystem Images +*.fat diff --git a/sw/script/create_verilog_image.sh b/sw/script/create_verilog_image.sh new file mode 100644 index 0000000..e95ce0b --- /dev/null +++ b/sw/script/create_verilog_image.sh @@ -0,0 +1,42 @@ + +#!/bin/bash + +BOOTLOADER=../bios/bootloader.bin +FILE=fs.fat + +TMPMOUNT=/tmp/lo +FSDIR=../fsdir + +V=-v + +# Smallest number of blocks where mkfs doesn't complain +BLOCKS=33296 + +rm $FILE + +echo "$(tput bold setaf 11)Creating Filesystem$(tput sgr 0)" +mkfs.vfat $V -I -F32 -C $FILE -n SUPER6502 $BLOCKS +echo + +echo "$(tput bold setaf 11)Modifying Boot Sector$(tput sgr 0)" +dd if=$BOOTLOADER of=$FILE bs=1 conv=notrunc count=11 $STATUS +dd if=$BOOTLOADER of=$FILE bs=1 conv=notrunc count=380 seek=71 skip=71 $STATUS + +echo "$(tput bold setaf 11)Mounting Device$(tput sgr 0)" +mkdir $V -p $TMPMOUNT +sudo mount $FILE $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 $FILE +rmdir $V $TMPMOUNT +echo + +echo "$(tput bold setaf 11)Converting Image to Verilog$(tput sgr 0)" +objcopy --input-target=binary --output-target=verilog $FILE $FILE.hex +echo "$(tput bold setaf 10)Done!$(tput sgr 0)" +