Files
game-and-watch-retro-go/scripts/extflash_erase.sh
Brian Pugh 2ac8ff2e17 extflash_erase target (#143)
* extflash_erase target

* cleanup extflash_erase target script per PR comments

* remove verbosity in extflash_erase.sh

* fix syntax error in extflash_erase.sh. added flash_intflash as target dependency
2021-09-06 18:41:46 +02:00

37 lines
770 B
Bash
Executable File

#!/bin/bash
. ./scripts/common.sh
if [[ $# -lt 1 ]]; then
echo "Usage: $(basename $0) <EXTFLASH_SIZE>"
echo "This will erase the whole extflash"
exit 1
fi
EXTFLASH_SIZE=$1
DUMMY_FILE=$(mktemp /tmp/retro_go_dummy.XXXXXX)
if [[ ! -e "${DUMMY_FILE}" ]]; then
echo "Can't create tempfile!"
exit 1
fi
# Create dummy file with one page of 0xFF.
SIZE=256
/usr/bin/env python3 -c "with open('${DUMMY_FILE}', 'wb') as f: f.write(b'\xFF'*${SIZE})"
# Flash it to start of the extflash and perform a Chip Erase
${FLASHAPP} "${DUMMY_FILE}" 0 ${SIZE} 1 0
# Reset the device and disable clocks from running when device is suspended
reset_and_disable_debug
# Clean up
rm -f "${DUMMY_FILE}"
echo ""
echo ""
echo "Extflash have been erased."
echo ""
echo ""