Last active
May 30, 2024 05:21
-
-
Save squidrpi/4ce3ea61cbbfa3900e116f9565d45e74 to your computer and use it in GitHub Desktop.
MIST FPGA update scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Gets the latest cores and checks all the directories | |
| # in the current for any changes to the cores. | |
| # The directories MUST match the ones in the mist-binaries/cores so just create | |
| # the directories of the cores you want. | |
| LOGFILE=update_cores.log | |
| date >$LOGFILE | |
| echo >>$LOGFILE | |
| BASEDIR=_temp | |
| SRCDIR=${BASEDIR}/git/mist-binaries/cores | |
| # clone git repo if it doesn't exist | |
| if [ ! -d "$SRCDIR" ]; then | |
| mkdir -p ${BASEDIR}/git | |
| (cd ${BASEDIR}/git; git clone https://github.com/mist-devel/mist-binaries.git) | |
| #Set timestamps on git files to match repository commit dates | |
| (cd $SRCDIR; git ls-files | sed "s/'/\\\'/g" | xargs -I{} bash -c 'touch "{}" --date=@$(git log -n1 --pretty=format:%ct -- "{}")') | |
| fi | |
| # Update the cores from github | |
| (cd $SRCDIR; git pull) | |
| #Check for firmware updates | |
| SRC=`ls -Lt "${SRCDIR}"/../firmware/*.upg 2>/dev/null | head -1` | |
| DST=_firmware/`basename "$SRC"` | |
| mkdir -p _firmware | |
| if [ ! -f "$DST" ]; then | |
| cp -p "$SRC" "$DST" | |
| echo ================== | |
| echo FIRMWARE UPDATED!!! $DST | tee -a $LOGFILE | |
| echo ================== | |
| echo | |
| fi | |
| #Check all the cores in git with current matching directories | |
| for FILE in `find . -maxdepth 1 -type d | egrep -v '_temp'` | |
| do | |
| DIR=${FILE:2} | |
| DST="${DIR}/core.rbf" | |
| SRC=`ls -Lt ${SRCDIR}/$DIR/*.rbf 2>/dev/null | head -1` | |
| if [ -z "$SRC" -o -z "$DST" ]; then | |
| continue | |
| fi | |
| if [ -f "$SRC" -a ! -f "$DST" ]; then | |
| cp -p "$SRC" "$DST" | |
| echo Update CORE $DST | tee -a $LOGFILE | |
| continue | |
| fi | |
| if [ $SRC -nt $DST ]; then | |
| cp -p "$SRC" "$DST" | |
| echo Update CORE $DST | tee -a $LOGFILE | |
| echo | |
| else | |
| #Check checksum | |
| MD5SRC=`md5sum "$SRC" | awk '{print $1}'` | |
| MD5DST=`md5sum "$DST" | awk '{print $1}'` | |
| if [ $MD5SRC != $MD5DST ]; then | |
| cp -p "$SRC" "$DST" | |
| echo Update CORE $DST | tee -a $LOGFILE | |
| echo | |
| fi | |
| fi | |
| #Copy special ROMS | |
| [[ $DIR = "atari800" ]] && cp -u ${SRCDIR}/$DIR/*.ROM atari800/ | |
| [[ $DIR = "bbc" ]] && cp -u ${SRCDIR}/$DIR/bbc.rom bbc/ | |
| [[ $DIR = "c16" ]] && cp -u ${SRCDIR}/$DIR/c16.rom c16/ | |
| [[ $DIR = "fpga64" ]] && cp -u ${SRCDIR}/$DIR/*.rom ${SRCDIR}/$DIR/C64GS.ARC fpga64/ | |
| [[ $DIR = "ht1080z" ]] && cp -u ${SRCDIR}/$DIR/HT1080Z.ROM ht1080z/ | |
| [[ $DIR = "ql" ]] && cp -u ${SRCDIR}/$DIR/ql.rom ql/ | |
| [[ $DIR = "spectrum" ]] && cp -u ${SRCDIR}/$DIR/spectrum.rom spectrum/ | |
| [[ $DIR = "ti994a" ]] && cp -u ${SRCDIR}/$DIR/TI994A.ROM ti994a/ | |
| [[ $DIR = "vic20" ]] && cp -u ${SRCDIR}/$DIR/vic20.rom vic20/ | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Only updates the cores that we have in the Arcade directory | |
| # updated from Gehstock github directory. | |
| # Names also need to match the Gehstock name | |
| LOGFILE=update_gehstock.log | |
| date >$LOGFILE | |
| echo >$LOGFILE | |
| BASEDIR=_temp | |
| SRCDIR=$BASEDIR/git/Mist_FPGA_Cores/Arcade_MiST | |
| # clone git repo if it doesn't exist | |
| if [ ! -d "$SRCDIR" ]; then | |
| mkdir -p $BASEDIR/git | |
| (cd ${BASEDIR}/git; git clone https://github.com/Gehstock/Mist_FPGA_Cores.git) | |
| #Set timestamps on git files to match repository commit dates | |
| (cd $SRCDIR; git ls-files | sed "s/'/\\\'/g" | xargs -I{} bash -c 'touch "{}" --date=@$(git log -n1 --pretty=format:%ct -- "{}")') | |
| fi | |
| # Update the cores from github | |
| (cd $SRCDIR/..; git pull) | |
| for FILE in `find Arcade -name '*.rbf'` | |
| do | |
| DST="$FILE" | |
| DSTBASE=`basename "$FILE"` | |
| SRC=`find "$SRCDIR" -name $DSTBASE` | |
| if [ -z "$SRC" -o -z "$DST" ]; then | |
| continue | |
| fi | |
| if [ "$SRC" -nt "$DST" ]; then | |
| cp -p "$SRC" "$DST" | |
| echo Update CORE $DST | tee -a $LOGFILE | |
| echo | |
| else | |
| #Check checksum | |
| MD5SRC=`md5sum "$SRC" | awk '{print $1}'` | |
| MD5DST=`md5sum "$DST" | awk '{print $1}'` | |
| if [ $MD5SRC != $MD5DST ]; then | |
| cp -p "$SRC" "$DST" | |
| echo Update CORE $DST | tee -a $LOGFILE | |
| echo | |
| fi | |
| fi | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Updates and gets jt cores | |
| # Retrieves new game ROMS if needed from archive.org | |
| BASEDIR=_temp | |
| SRCDIR=$BASEDIR/git/jtbin | |
| ZIPDIR=$BASEDIR/mame | |
| MRABIN=./mra | |
| FLAGFILE=update_jtcores.flag | |
| if [ ! -f $FLAGFILE ]; then | |
| touch -t 197201010000 $FLAGFILE | |
| fi | |
| mkdir -p $ZIPDIR | |
| # clone git repo if it doesn't exist | |
| if [ ! -d "$SRCDIR" ]; then | |
| mkdir -p $BASEDIR/git | |
| (cd $BASEDIR/git; git clone https://github.com/jotego/jtbin.git) | |
| #Set timestamps on git files to match repository commit dates | |
| (cd $SRCDIR; git ls-files | sed "s/'/\\\'/g" | xargs -I{} bash -c 'touch "{}" --date=@$(git log -n1 --pretty=format:%ct -- "{}")') | |
| fi | |
| # Update the cores and mra from jtbin | |
| (cd $SRCDIR; git pull) | |
| echo | |
| #Process MRA files first | |
| find $SRCDIR/mra -type f -name '*.mra' -newer $FLAGFILE -print0 | | |
| while IFS= read -r -d '' FILE | |
| do | |
| MRAFILE="$FILE" | |
| # Exclude what I'm not interested in | |
| [[ "$FILE" == *_alternatives* ]] && continue | |
| [[ "$FILE" == *Tokio* ]] && continue | |
| [[ "$FILE" == *'Hyper Fighting'* ]] && continue | |
| [[ "$FILE" == *Trojan* ]] && continue | |
| # Check ROM exists | |
| ZIPFILE=`$MRABIN -l "$MRAFILE" | grep 'zip\[0\]' | awk '{print $2}'` | |
| # Skip roms not interested in | |
| if [ $ZIPFILE = "qtono2j.zip" ]; then | |
| continue | |
| fi | |
| echo $ZIPFILE | |
| if [ ! -f "${ZIPDIR}/${ZIPFILE}" ]; then | |
| echo Downloading ROM $ZIPFILE | |
| (cd "$ZIPDIR"; wget -nc -nv https://archive.org/download/MAME223RomsOnlyMerged/${ZIPFILE}) | |
| fi | |
| $MRABIN -A -O Arcade/ -z "$ZIPDIR" "$MRAFILE" | grep -v 'expected: None' | |
| done | |
| #Check for new RBF cores | |
| SRCDIR=$SRCDIR/mist | |
| find Arcade -name '*.rbf' -print0 | | |
| while IFS= read -r -d '' FILE | |
| do | |
| DST="$FILE" | |
| DSTBASE=`basename "$FILE"` | |
| DSTBASE="${DSTBASE/.rbf/}" | |
| SRC="" | |
| SRC=$(find "$SRCDIR" -name "${DSTBASE}_*rbf" -newer "$FILE" -print0 | xargs -0 -r ls -t | head -1) | |
| if [ -z "$SRC" -o -z "$DST" ]; then | |
| continue | |
| fi | |
| if [ "$SRC" -nt "$DST" ]; then | |
| cp -p "$SRC" "$DST" | |
| echo cp -p "$SRC" "$DST" | |
| echo Update CORE $DST | |
| echo | |
| fi | |
| done | |
| touch $FLAGFILE |
Author
dont forget to use chmod to mark the content as executable after you get the script and mra
wget https://gist.github.com/squidrpi/4ce3ea61cbbfa3900e116f9565d45e74/raw/cdbfa6d52a87ebdb7524f8fc8ceed49876c24b1d/update_jtcores
wget https://github.com/mist-devel/mra-tools-c/raw/master/release/linux/mra
chmod u+x ./update_jtcores
chmod u+x ./mra
Thanks for a great script, I had tried and failed a few times to do this manually after reading the doco. (I think I had the wrong version of the ROMS).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create a directory to store your MIST cores and ROMS. In this directory create subdirectories of the cores you want, name based on https://github.com/mist-devel/mist-binaries/tree/master/cores. In addition for the arcade cores create a "Arcade" subdirectory.
Run these scripts to retrieve the latest cores and ROMS.
Copy the directories to individual SD cards or one SD card using linux_sync.
Requires a number of Linux commands: git, wget and the mra executable.