andwn / ym2020

https://catskullelectronics.com/
Other
4 stars 0 forks source link

Built ROM fails to run on MiSTer and Mega EverDrive X5 #2

Closed pvalkone closed 2 years ago

pvalkone commented 2 years ago

I'm trying to build a working YM2020 ROM on Debian 11 and Marsdev 2022.02.

The built ROM seems to work on OpenEmu v2.3.3 on OS X (GenesisPlus 1.7.4.14 core), as well as on the Mega Sg (v7.8 Jailbreak firmware), but fails to load on the MiSTer (Genesis v20220626, Main v20220712) as well as on a Japanese Mega Drive II and the Mega EverDrive X5 (MegaOS v3.14).

I have the physical cart which works fine on the MD II and the Mega Sg, but unfortunately I don't have any means to dump it in order to see whether the dumped ROM would work on the MiSTer and Mega ED (I assume it would).

The behaviour I'm seeing seems to be related to issue #1, but I either get an address error (on the MiSTer; see attached screenshot) or a black screen (on the Mega EverDrive) instead of a garbled UI.

ym2020-rom-address-error

I'm using the latest revision:

❯ git rev-parse HEAD
0b4419e0db905b1772b73a8d871cb261cfefc193

Here's a small Dockerfile that can be used to build a failing ROM:

FROM debian:bullseye-slim@sha256:f576b8067b77ff85c70725c976b7b6cde960898e2f19b9abab3fb148407614e2

RUN apt-get update && \
    apt-get install \
        --assume-yes \
        --no-install-recommends \
        --quiet=2 \
        ca-certificates=20210119 \
        curl=7.74.0-1.3+deb11u1 \
        make=4.3-4.1 \
        openjdk-11-jre=11.0.15+10-1~deb11u1 \
        unzip=6.0-26 && \
    rm -rf /var/lib/apt/lists/*

RUN curl --silent \
        --location \
        --remote-name https://github.com/andwn/marsdev/releases/download/2022.02/mars-2022.02-linux-x64.zip && \
    echo '0d0a1409ca4bae3177fadc513d8996fdb85921d9a9f4110e6528d52c4db7b3aa  mars-2022.02-linux-x64.zip' | sha256sum --check && \
    unzip -d "${HOME}" mars-2022.02-linux-x64.zip

WORKDIR /src

After creating the Dockerfile, run the following commands to first build the Docker image and then the ROM (out.bin):

❯ docker build --tag ym2020:latest .
❯ docker run --volume "$(pwd):/src" --rm --name ym2020 ym2020:latest /bin/bash -c "make clean all"
pvalkone commented 2 years ago

I can now confirm that a ROM dumped from a retail cartridge (with a SHA-1 checksum of 5ca7f6f2d10dfeb72ffd61e192c681f815fd1609) works fine on both the MiSTer and the Mega EverDrive X5.

andwn commented 2 years ago

I think the hardware issues were because of an incompatibility with the version of SGDK used to originally build the retail version of YM2020 and the one included in Marsdev 2022.02. I just pushed a compatibility fix with the latest toolchain/SGDK but apparently my SD card reader is busted so I will have to try it on hardware another day.

pvalkone commented 2 years ago

Thanks for looking into this!

For what it's worth, I'm still getting the same address error on the MiSTer with a ROM built using the latest master and an updated Dockerfile with Marsdev 2022.09. OpenEMU doesn't recognise the built ROM, either. I didn't try with real hardware, but I assume the result would still be the same as before.

❯ git rev-parse HEAD
328ae9fd2c619a5e3176ddb9b5fce8e78cf92191

❯ cat Dockerfile
FROM debian:bullseye-slim@sha256:5cf1d98cd0805951484f33b34c1ab25aac7007bb41c8b9901d97e4be3cf3ab04

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get update && \
    apt-get install \
        --assume-yes \
        --no-install-recommends \
        --quiet=2 \
    ca-certificates=20210119 \
        curl=7.74.0-1.3+deb11u3 \
        make=4.3-4.1 \
        openjdk-11-jre=11.0.16+8-1~deb11u1 \
        xz-utils=5.2.5-2.1~deb11u1 && \
    rm -rf /var/lib/apt/lists/*

RUN curl --silent \
        --location \
        --remote-name https://github.com/andwn/marsdev/releases/download/2022.09/mars-2022.09-linux-x64.tar.xz && \
    echo 'f5405ba4c006e7f70426297ef47e53caaa6e53255d67e64f4346b2bacc55565a  mars-2022.09-linux-x64.tar.xz' | sha256sum --check && \
    tar --extract \
    --file mars-2022.09-linux-x64.tar.xz \
    --directory "${HOME}"

WORKDIR /src
andwn commented 2 years ago

Found the mistake and feel dumb now. The header got corrupted because I forgot a step in the Makefile.

pvalkone commented 2 years ago

Revision 100b3cf2d9940faefe571763fb5b59b09de18463 with the header fix works in OpenEmu, but still fails on the MiSTer, so it seems the compatibility fix doesn't work.

Please let me know if there's any other way I can be of assistance before you get a chance to try out the fix on real hardware yourself.

andwn commented 2 years ago

Figured it out. In my toolchain I build SGDK with bank switching enabled (changing this setting requires recompiling SGDK), which was not a problem on Everdrives and such previously, so long as the ROM was under 4MB the bank switching was unused. However, it seems recent SGDK versions make an unnecessary bank switch at startup regardless of the ROM size, causing a crash on Everdrives (likely mister is the same way). Will make another release of the toolchain in a few days that gets rid of the default bank switching.

IMG_20220930_165157_927_1

pvalkone commented 2 years ago

I just built https://github.com/andwn/ym2020/commit/3055cd26227e436ee4a59ebe55312b8130c6103c against Marsdev 2022.10, gave it a quick whirl on the MiSTer, and much to my delight, it worked. 🎉

I'm closing this issue as solved.