2010-11-21

making gdb-stub work from rom

Well after some long break I'm back on the m68k... I had time to draw some of the schematics of the circuit, only the CPU and most of the support circuitry. The rest of the circuit is straight forward, I connected my EPROM emulator and a massive 512K bytes SRAM to the bus and finally a MC68901 Multi Function Peripheral (MFP) handling the serial port and SD card interface. The CPU clock is at the moment 4MHz, so I can share it with the MFP, later I intend to clock the CPU at 8MHz.
Since my previous post, I've done/settled on a couple of things:
  1. I'll use gcc and gdb to do get the system up and running. Currently I managed to compile gcc-3.4.6 for target m68k-elf and gdb-6.8;
  2. I've created basic linker scripts for running from ROM and running from RAM. Both have been proven to work with C source (C++ probably won't work). I've also created two CRT0.S for each of these linker scripts;
  3. Compiling the gdb-stub and link it to ROM proved a big challenge, but I managed in the end. The source m68k-stub.c that comes with gdb suffers from severe bit rot, most of the assembly source doesn't compile either because the syntax is no longer supported or because "handling multi line strings has changed in 2001";
  4. Still doesn't work perfect, the first time I load, break main and continue, remote-gdb ends up "somewhere", on the second time I load and continue (no need to break main, this is handled by the server) it works OK and I can even step lines of code. This probably has to do with my "trick" to make gdb-stub work from ROM without referencing any program at all (the frame information is not correct... I think...). On the second run (after the initial crash), this frame is correctly initialized.
  5. I'll add a 3V power supply and a SD Card interface for "disk drive", based on some previous work I did with the Arduino, I don't expect big difficulty.
  6. Placing the vectors in memory was actually quite easy, I needed to learn some m68k assembly and now I do it in CRT0.S. Due to a requirement of the gdb-stub to identify the generated exception, I had to build a two step exception processing. First the vectors 0 to 256 are initialized to unique locations starting at 0x400 in steps of 8. On each of these, 8 bytes there's a NOP and a Jump to Sub Routine long to the exception_handler, this pushes a unique address per exception on to the stack, the exception_handler pops this address and identifies the exception that was generated.
I had a old monitor that I "pop" from storage, to test dual head with openSUSE 11.2 and it works great. I really think it's a great advantage to work with two monitors, one for programming other for debugging or one for drawing the circuit and the other to check the PCB, Bill of Materials, Stocks, vendors, spreadsheet, etc.
Another thing I noticed is that I still can't get away from printouts of the code.. and I wish I had an old matrix printer with form paper... those were the days...

2010-11-13

Hardware Single Step for the 8085

As usual my current developments tend to wander towards all directions, as the ever expanding universe... Although I haven't really finished any of my other "side jobs", I want to further develop the mini85 into a real single board CP/M computer, but more on that later.
This week, I looked for a Hardware Single Stepping circuit for the 8085. Something that proves that "everything is on the internet" is not true (if you didn't already knew), at least until up to now.
The internet came up with nothing, so I had to resort to older methods... Books, applications notes, etc... First of it was the 8080 datasheet, on the description of the READY line it states "Can be used for single stepping the processor" but this sentence is strangely absent from the 8085 datasheet (a nice circuit with one wait state is drawn instead). Then I found something on a great book "Microcomputers and Microprocessors - The 8080, 8085 and Z-80 Programming, Interfacing, and Troubleshooting" by John Uffenbeck. There are caveats, about the same as others and my previous pseudo-DMA circuit for the 8085, doesn't allow the use of dynamic RAM hidden-refresh (end of M1). I've redrawn it with gschem.


It is not exactly what I want. I want a single lever switch with 3 positions RUN, HALT, SingleStep. I found this one on Digikey a nice C&K switch that "has the looks" of a 1980 Computer and could do the job. The problem is that I need to do some adaptation from the schematics above to a single switch with 3 positions, the main problem is halt the computer when the switch is off (centre position) and at the same time set the FF clock low... I might need some magic...