makestuff / umdkv2

APP:USB MegaDrive DevKit v2
http://www.makestuff.eu/wordpress/?category_name=umdkv2
GNU Lesser General Public License v3.0
111 stars 22 forks source link

Why not use the movem instruction in the monitor #7

Closed radexx closed 8 years ago

radexx commented 8 years ago

Hi, First things first: Very nice project. Congrats.

Why not using the movem instruction to save and restore the registers?. It would be faster since a lot of instruction fetches (and decodes) are avoided, and the monitor will take up less ROM saving you some valuable Flash space in the UMDK cart and some even more valuable addresses in the limited 68K ROM area. Probably the dXSave/aXSave/fpSave labels don't make sense anymore and you want to change its name to something more meaningful...

Cheers!

makestuff commented 8 years ago

Welcome to the project!

I was thinking of movem when I wrote this code, but at that time it had been ~15 years since I wrote any 68000 code, and I wasn't sure it would support any addressing-mode other than address-register with postincrement/postdecrement. Also I was at that point debugging the GDB bridge, and wanted very explicit code.

So, bottom line, I like your patch. Have you actually tried it with a real UMDK cart? I don't have mine setup right now but if you've tried it that's good enough for me.

Two minor changes:

(1) Can you resubmit your PR against the dev branch rather than master? I merge up from dev to master when doing a new release, so master always matches the most recent release. (2) Can you make the changes you suggest in your comment (i.e delete unused labels and rename d0Save to regSave)?

radexx commented 8 years ago

Hi Chris, Wow, that was a quick reply!

Nope, I haven't tested it on the actual hardware beyond checking that it compiles.

On a side note: I don't have an UMDK cart. I'd like to, but I'm unsure where to order one (SpritesMind was a bit misleading), and I'm afraid it would probably be too expensive for just hobbyist purposes. Perhaps you can clear this up for me. I'm developing some stuff on emulators. Every time I want to try my code on the real hardware I use a Mega Everdrive (very time consuming and cumbersome), and of course I can't debug.

Amusingly enough, I had a side project in mind, and would love to hear your thoughts on it:

I was thinking of building an extension to the Everdrive cart. I would talk to it through SPI by plugging an AVR uC to the SD card slot, where the firmware would forward the SPI commands to the PC via RS232 over USB. In a nutshell, my GDB bridge would serve three purposes:

Of course my code would need to have the monitor built into it (plus the interrupt vectors and stuff), besides, I would also need to patch the ROM with ILL (and probably NOPs) everytime I set a breakpoint, and I wouldn't be able to debug commercial games, but it should be good enough for homebrew demos and stuff. Bottomline: Less cool but probably cheaper.

Second side note: I was very excited to hear that Visual Studio 2015 comes with GDB support :)

Back to the patch: (1) Sure, I will resubmit my PR on the dev branch (2) No problem

Thanks! MIke

makestuff commented 8 years ago

Unfortunately your manufacturing options are limited. It may be possible to do a Kickstarter campaign and get the electronics manufactured in China, but my gut feeling is that there are not enough people interested to make it worthwhile. Another problem is that there have been several false starts to the manufacturing process, and a bit of acrimony on SpritesMind, neither of which have done the project any favours. Right now I have a kind of laissez-faire attitude; I'll help new users get up and running and I'll help developers extend UMDK further, but I don't intend to put a lot of time into developing it further on my own.

Your Everdrive idea is ingenious. I'm not familiar with the product though so I don't know if it's feasible.

Another EverDrive-based option could be to use the MD1's EXT port (which is basically an RS-232 interface) to implement the GDB remote-serial protocol. You're back to issues with write strobes and EverDrive ROM write-protect, but you could certainly set breakpoints in code copied into the MD's onboard RAM, which would be better than nothing.

radexx commented 8 years ago

Hi Chris, Sorry for abusing this thread, but I don't know of a better way to contact you, and this chat is just getting too interesting :) .

Thanks for your thoughts on my side project. Everdrive MD

Serial ports

SD emulation

USB speed

Conclussion

Thanks again!! Mike

makestuff commented 8 years ago

I'm going to close this thread. Feel free to send future responses to prophet3636 at gmail dot com and we can continue the discussion via email.

If the flash-write is implemented as you say through the CPLD (which probably has some registers mapped at 0xA13xxx) then you don't need to worry about the write-strobe issue, and no SSF2 re-mapping is necessary. The gdb proxy would get commands like "write N bytes at address A", both for loading .elf files and for setting breakpoints, etc. That means whenever you set a breakpoint, it will have to write two bytes to the underlying flash, which is kinda clunky but totally doable.

The other host-link possibility is to only use the FAT thing for booting the monitor, and from there play with the cart's CPLD registers controlling the SD-card interface directly, and use it to implement a lower-level SPI-based protocol. Unfortunately the MD would be the "master" and your PC (or the microcontroller) would be the "slave". You could implement some kind of poll (e.g at the end of the vblank routine) on the MD side to check whether the PC has issued commands to execute, and build a fairly high-level custom protocol on the microcontroller (i.e rather than marshalling single SPI bytes over USB). I did something similar with this project: https://www.youtube.com/watch?v=HTOVBADSPMs which you're welcome to cannibalize.

In short, yes it would take some effort to get this going, but it sounds totally feasible, and it would offer an alternative route for people wanting to debug on real hardware. So if you've got the time you should definitely give it a go. I'd start by trying to get the SPI interface talking.

If you do want to build a UMDK cart I can sell you an LX9 blank PCB for ~$7 plus postage, but I don't have any of the bridge PCBs left. Luckily they're small, only 2-layer, and cheap to make. Someone on SpritesMind may have spares.