Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GB/GBC: Unified flashing for MBC3/MBC5 and added option to automatically flash ROM and SAVE #183

Merged
merged 7 commits into from
Jul 22, 2021

Conversation

Dakkaron
Copy link
Contributor

@Dakkaron Dakkaron commented Jul 2, 2021

Now MBC3 and MBC5 should be handled the same way.

Also there is now an option to automatically flash the latest save corresponding to the flashed ROM.

This only works if there is a save file under /GB/SAVE/[FILENAME]/*/[FILENAME].SAV, where [FILENAME] is the file name of the chosen ROM minus anything after the dot (.).

So the user should backup the ROM from a cartridge or flashcart before using this option.

My use case for this is that I only have a single flashcart, but many different ROMs that I want to play on it. So I can quickly swap between different ROMs and don't have to manually select the save file. It is especially useful if you already have lots of save files from the same game and would have to page down a lot to find the newest save game.

@Dakkaron Dakkaron changed the title Unified flashing for MBC3/MBC5 and added option to automatically flash ROM and SAVE GB/GBC: Unified flashing for MBC3/MBC5 and added option to automatically flash ROM and SAVE Jul 2, 2021
@Dakkaron
Copy link
Contributor Author

The last few commits changed how GB flashing works quite a bit. Since I now have a flashcart that behaves quite similar to the way described in the discussion (#182 (comment)) I could reproduce and fix flashing MBC5. At least for me it works, so please check if it does for you (@sanni) as well.

This change also drops the device ID-based detection that was there before, in favour of using CFI (Common Flash Interface) to detect the flash chip's features. This is not perfect, since some flash chips don't quite follow the CFI standard perfectly. Also some flash carts don't wire the data pins straight to the cartridge connector, but instead switch them around. My code knows one special case of that (two LSB switched) and counters that. But it cannot detect all possible combinations.

In total, this should add compatibility to a lot of different flashcarts. I coded this for one type of flashcart and verified it on two different other kinds of flashcart, and all of them worked.

Also, using the new detection, I added a check if the flashcart is actually large enough to fit the ROM that should be uploaded onto it.

@sanni: Please let me know if this works or if there is further work needed.

@Androxilogin
Copy link

Androxilogin commented Jul 22, 2021 via email

@sanni
Copy link
Owner

sanni commented Jul 22, 2021

I get "CFI Query failed" on both my MBC3 with AMD 29F016 and MBC5 with Fuji 29F033 flashchip. I think I'll just add a new "Flash repro" menu and put the old and the new CFI way as a selection there.

@sanni sanni merged commit 5f3413a into sanni:master Jul 22, 2021
@Androxilogin
Copy link

I have a Pc
IMG_9485(2)
om A28F008B5 chip that says it's MBC5; 1MB with 64 banks.

I get the error:

Flash ID: C3E1
Unknown Flashrom

I noticed there is a blob of solder on the board near the chip and a glop-top over another chip. Could the solder be a write protect?

@Dakkaron
Copy link
Contributor Author

@Androxilogin Are you on the newest code version? This error message should currently not be in the code, afaik.

@sanni Adding both paths is a good idea.
Regarding the CFI Query Failed: from what I can find, your flash chip doesn't support CFI... All my repro carts support it, so I figured it might be a bit more universal than identifying the chip by the Flash ID.
What about this: if CFI fails, fetch the Flash ID and operate from a whitelist like before. That way, you'd automatically have support for all CFI compatible flash chips, and for all others support can easily be added manually, by putting it into the whitelist.

@Androxilogin
Copy link

Androxilogin commented Jul 23, 2021 via email

sanni added a commit that referenced this pull request Jan 7, 2022
GB/GBC: Unified flashing for MBC3/MBC5 and added option to automatically flash ROM and SAVE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants