= how to get launcher and retro-go on your G&W =

1. get modified RetroGo on linux or mac

https://github.com/kbeckmann/game-and-watch-retro-go

2. modify 5 files on linux or mac

in Core/Src/main.c

223: uint32_t save_address = flash_ptr - &__EXTFLASH_REAL__;
263: uint32_t save_address = flash_ptr - &__EXTFLASH_REAL__;
431:// MX_RTC_Init();
597: PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;

in Core/Src/system_stm32h7xx.c

267: SCB->VTOR = FLASH_BANK2_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */

in Core/Inc/gw_linker.h

add this line under line 007:
008:extern uint8_t __EXTFLASH_REAL__;

in STM32H7B0VBTx_FLASH.ld

075: __EXTFLASH_START__ = 0x90100000;
088: __EXTFLASH_LENGTH__ = DEFINED(__EXTFLASH_TOTAL_LENGTH__) ? __EXTFLASH_TOTAL_LENGTH__ - (__CONFIGFLASH_LENGTH__ + __SAVEFLASH_LENGTH__ + 1024K) : 1024K - (__CONFIGFLASH_LENGTH__ + __SAVEFLASH_LENGTH__);
107: FLASH (xr ) : ORIGIN = 0x08100000, LENGTH = __FLASH_LENGTH__

then add this line under line 075:
076:__EXTFLASH_REAL__ = 0x90000000;

in /Core/Src/porting/odroid_system.c
add this line under line 080:

081: *((uint32_t *)0x2001FFF8) = 0x544F4F42; // "BOOT"
082: *((uint32_t *)0x2001FFFC) = 0x08100000; // vector table

3. build on linux or mac

$ make -j8 LARGE_FLASH=1

put these 2 files to windows disk.

build/gw_retro_go_intflash.bin
build/gw_retro_go_extflash.bin

you need internal_flash_backup.bin and flash_backup.bin in next step. also put the file to windows disk. maybe the file is in game-and-watch-backup/backups/

4. patch stock internal firmware on windows

get "Game & Watch - Stock Firmware Patcher"
http://users.skynet.be/bk327964/gnw/
extract on windows and patch internal_flash_backup.bin and save as internal_flash_backup_patched.bin
select SPI Flash you use.
FileSystem address as 90100000.
FileSystem Size as 00F00000.
Firmware as 08100000.
then press Patch button.

5. install STM32CubeProg on windows

https://www.st.com/en/development-tools/stm32cubeprog.html
** I tested only win32 version.

6. install "SPI flash external loaders for STM32CubeProgrammer and STM32CubeIDE"

http://users.skynet.be/bk327964/gnw/

7. flash files using STM32_Programmer_CLI.exe on windows

STM32_Programmer_CLI.exe is in C:\Program Files (x86)\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin

connect stlink and g&w, then use these command.

>STM32_Programmer_CLI.exe -c port=SWD -w internal_flash_backup_patched.bin 0x08000000
>STM32_Programmer_CLI.exe -c port=SWD -w gw_retro_go_intflash.bin 0x08100000
>STM32_Programmer_CLI.exe -c port=SWD -w flash_backup.bin 0x90000000 -el "\path\to\ExternalLoader\MX25U12835F_GAME-AND-WATCH.stldr"
>STM32_Programmer_CLI.exe -c port=SWD reset=HWrst -w gw_retro_go_extflash.bin 0x90100000 -el "\path\to\ExternalLoader\MX25U12835F_GAME-AND-WATCH.stldr" -rst

8. get some coffee or beer with G&W

normally boot up.
push left+a+game and release the buttons.
launcher menu shown up.
select LAUNCHER -> FW @08100000
now, you can see retro-go menu.

*. known issues
nothing!!
*. fixed issues
time will not reset by booting retro-go. Thanks _tim_!
save & quit / quit to menu now return to retro-go menu. Thanks GaryZ!
state save feature now works fine. Thanks _tim_!

--------
2021/02/28 fixed RTC feature.
2021/02/28 fixed quit to menu feature.
2021/02/28 fixed state save feature.
2021/02/28 initial release(my birthday)

by macohime