Skip to content

Instantly share code, notes, and snippets.

@DNA64
Last active August 6, 2021 05:43
Show Gist options
  • Save DNA64/ecb29b28f3bb016a0e0c9b5003537f82 to your computer and use it in GitHub Desktop.
Save DNA64/ecb29b28f3bb016a0e0c9b5003537f82 to your computer and use it in GitHub Desktop.
Modify your game-and-watch-flashloader and game-and-watch-retro-go installations to allow flashing of flash memory chips 128Mb (32MB) and larger.
#!/bin/bash
# Attention! - This script is now obsolete with the latest build of game-and-watch-retro-go.
# This script will modify your game-and-watch-flashloader and game-and-watch-retro-go installations
# to allow flashing of flash memory 128Mb (32MB) and larger.
# The patch must be run from the same directory containing the game-and-watch-retro-go folder and game-and-watch-flashloader folder.
# Get the latest updated patch from https://gist.github.com/DNA64/ecb29b28f3bb016a0e0c9b5003537f82
# Are we in the right place?
if ! test -d game-and-watch-flashloader; then
echo "Error! - Cannot locate the game-and-watch-flashloader folder..."
echo "Are you sure you're running this script in the right directory?"
exit 1
fi
if ! test -d game-and-watch-retro-go; then
echo "Error! - Cannot locate the game-and-watch-retro-go folder..."
echo "Are you sure you're running this script in the right directory?"
exit 1
fi
sed -i 's/HAL_OSPI_ADDRESS_24_BITS;/HAL_OSPI_ADDRESS_32_BITS;/' game-and-watch-flashloader/Core/Src/flash.c
sed -i 's/0xD8/0xDC/' game-and-watch-flashloader/Core/Src/flash.c
sed -i 's/0x52/0x5C/' game-and-watch-flashloader/Core/Src/flash.c
sed -i 's/0x20/0x21/' game-and-watch-flashloader/Core/Src/flash.c
sed -i 's/0x02/0x12/' game-and-watch-flashloader/Core/Src/flash.c
sed -i 's/0x38/0x3E/' game-and-watch-flashloader/Core/Src/flash.c
sed -i 's/0x0B/0x0C/' game-and-watch-flashloader/Core/Src/flash.c
sed -i 's/0xEB/0xEC/' game-and-watch-flashloader/Core/Src/flash.c
sed -i 's/uint32_t program_device_size = 24;/uint32_t program_device_size = 26;/' game-and-watch-flashloader/Core/Src/main.c
#TODO: Add support for multiple chip sizes
sed -i 's/EXTFLASH_SIZE ?= 16777216/EXTFLASH_SIZE ?= 67108864/' game-and-watch-retro-go/Makefile.common
sed -i 's/HAL_OSPI_ADDRESS_24_BITS;/HAL_OSPI_ADDRESS_32_BITS;/' game-and-watch-retro-go/Core/Src/gw_flash.c
sed -i 's/0xD8/0xDC/' game-and-watch-retro-go/Core/Src/gw_flash.c
sed -i 's/0x52/0x5C/' game-and-watch-retro-go/Core/Src/gw_flash.c
sed -i 's/0x20/0x21/' game-and-watch-retro-go/Core/Src/gw_flash.c
sed -i 's/0x02/0x12/' game-and-watch-retro-go/Core/Src/gw_flash.c
sed -i 's/0x38/0x3E/' game-and-watch-retro-go/Core/Src/gw_flash.c
sed -i 's/0x0B/0x0C/' game-and-watch-retro-go/Core/Src/gw_flash.c
sed -i 's/0xEB/0xEC/' game-and-watch-retro-go/Core/Src/gw_flash.c
sed -i 's/hospi1.Init.DeviceSize = 24/hospi1.Init.DeviceSize = 26/' game-and-watch-retro-go/Core/Src/main.c
# Re-build flashloader now that we've applied the patch
cd game-and-watch-flashloader
make clean
cd..
echo "Abracadabra! All done!"
sleep 5
@DNA64
Copy link
Author

DNA64 commented Apr 26, 2021

Fixed an issue with EXTFLASH_SIZE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment