Sunday, November 29, 2026

Changing the bulb in my Torch - Torch Triple X Part 15 (Crikey!)

While I was looking back through my photos on my phone a few days ago - I think I was looking for a picture of my PET that I restored (currently in storage) - I stumbled across some of the screenshots I'd taken of my Amiga A2000. To try and help work out what was wrong with this machine I'd used the most excellent 'DiagROM' by John 'Chucky' Hertell. 

Amiga A2000 Motherboard with DiagROM

Anyone serious in repairing Amiga computers will know all about DiagROM and what it can do. For everyone else, it's a new ROM that replaces the Kickstart ROM and which runs diagnostics from the second the Amiga receives power. Even if your Amiga won't start, DiagROM gives some clues with its graphical display and serial output to point you in the direction of potential faults. In short, it's an essential tool for diagnosing and repairing anything Amiga.

 

DiagROM Main Menu

Machine info..

Memory testing

But my Torch Triple X, although based on a similar CPU (the slightly uprated 68010) does not have a DiagROM. And this makes me sad as my hardware, when it's switched on, sits on a pale blue startup screen and does nothing. Well, not quite. There is supposed to be sound out of it with an error beep sequence. For some reason I don't get that out of my Torch motherboard but I can see it if I probe the right pin on the Hitachi HD6303 service processor. 

The architecture of the Torch is also very different to the Amiga as it includes the 6303 service processor, a 68010 main CPU as well as the appropriate 68451 MMU and 68450 DMA controller (required to run the Unix OS).

Well, after some of the exploring with the emulator I seriously started to wonder if it would actually be possible to create a standalone ROM for this machine that ran diagnostics, similar to DiagROM. The issue with my motherboard is that the beep sequence I get, now worked out to be the 68010 highlighting a main RAM failure, doesn't say which bit of RAM has failed. It could be the data paths, address bus, /CAS or /RAS issues, or it could just be a single RAM chip has failed. Without knowing where this has happened it's very easy to wander around possibilities, potentially missing the actual solution every time.

The essential idea would be to use as little functioning hardware as possible initially, then progressively test and enable more of the machine. Most importantly, the earliest diagnostics wouldn't assume that the RAM, interrupts, video hardware or operating system are working. And to take on the ideology of Mr H, don't assume anything works until you've tested it!

Let's get started. (It's a bit of a long one. You might need a cuppa halfway through.)

I had to get a toolchain set up for the HD6303 processor so I installed ASxxxx assembler. This supports the 6303 just by using the processor directive .hd6303 at the start of any assembler source. Which is nice (and easy for my simple brain to comprehend). And, of course, I needed a toolchain for the 68010. For this I installed VASM which also 'just works'(R).

And there's a very good reason to use assembly instead of something like 'C'. The original Caretaker ROM is 16KB and so is burned onto a 16KB EPROM with sections of code for the 6303 and the 68010. That means we only have 16KB to play with so we have to be VERY efficient in anything that we need to write. For comparison the Amiga either uses a 256KB ROM (up to KS1.3) or a 512KB ROM (KS2.0) so DiagROM has rather more room to play with (although I suspect Chucky may still say that's not enough).

Here's a brief history of the work done so far (which has taken far longer than this little - but getting longer - summary might suggest!) :

Phase 1 - Getting to Know You  

There are a few names you might see in this blog, all related to the various programs that make the original Torch start up. Here's some brief introductions:

Caretaker - This is first thing that runs when the Torch is switched on. He's responsible for starting up the HD6303 service processor and necessary hardware, along with testing the video RAM and performing some early hardware tests. If faults are found at this stage Caretaker will signal this with a series of four beeps of different lengths. If everything is OK then he copies ERMA (see below) into video RAM and releases the MC68010 main processor from reset.

ERMA - This is a small bootstrap program responsible for getting the main processor running. Caretaker copies approximately 12 KB of code from its EPROM into video RAM, where the 68010 can execute it without requiring working main DRAM. ERMA's main responsibilities include testing the main system RAM, initialising some host side hardware, providing the initial 68010 startup code, and locating and loading WERMA from boot media (see below).

WERMA - This is a much larger and more sophisticated program than ERMA, consisting of the WERMA executable of approximately 78 KB (version 2.10c apparently). WERMA is reponsible for generating the startup interface, handling the disk operations and loading the disk toolkit if requested, managing the the key disk authorisation and serial number information, and loading and launching the Unix OS.

And now I've done all that, I'll drop the bombshell that once we get going properly, we won't use any of them in the final ROM. But we will use a similar way to get things going...

On with the show! 

 

The first diagnostic screens

For this first foray I decided to keep it simple (stupid). So I modified the original Caretaker ROM to replace the normal boot sequence with a basic diagnostics display, reusing ERMA's text handling routines. Along the way I found out that the Caretaker uses an 'additive' checksum so as soon as I added or removed anything that affected that, it didn't work (beep flippin' beep). That got fixed immediately to save my beepin' sanity..

 

Not too bad...

(All of these initial tests were done using the Torch emulator by the way. There's a little while to go before we hit real hardware, just so you know.) 

Along the way I added a 'real' test to check 4KB of main RAM (start small) using the pattern $5A5AA5A5 which for 32-bits (which is the internal bus size of the 68010) is actually:

            0101 1010 0101 1010 1010 0101 1010 0101

And then I made a mess of calculating a displacement jump which triggered an 'illegal instruction' trap in Caretaker. He was NOT happy.. 

  

Trap indeed...

 

And then to top it all, once I fixed that, I made it so it entered the test routine two bytes early, which caused writes to the video RAM with somewhat unfortunate results...

 

Hmm. I think we might just have f***ed up here..

After fixing that I added some more detailed information to identify any memory faults (by this point I had already added a flag in the emulator to introduce a memory fault - hence why it says 'fail').

From there I extended the RAM info to include the failed address, and expected vs actual data along with the XOR difference.

The XOR difference is a very clever way to identify which particular bits of memory might be faulty. It stands for 'exclusive OR' and is an 'OR' gate with a couple of extra conditions. Basically, the output is true if either input is in a different state to the other, but is FALSE if the inputs are both the same. Here's the truth table for it:

Input 1    Input 2    Output

 0          0          0            

 0          1          1        

 1          0          1        

 1          1          0

The impact of doing this is that where the system sees a difference between actual and expected bit value and XORs it, then the output will always be 1. This then corresponds to the bit number that is incorrect. Easy. Really, it is, honest...

Anyway, I found out that the formatting routines in the Caretaker ROM weren't very standard so my first attempt at useful info resulted in everything saying '8X'. Very useful..

 

A fail, yes. But in formatting, mostly... 

Proof I can sometimes get it right... 

 

Next thing, I extended the RAM test to cover the whole of the 1MB main system RAM. In reality, I could only test about 960KB because WERMA rather inconsiderately loaded loads of stuff into the first 64KB. Never mind. 

 

Another pass. Nice.

The test basically consisted of checking the memory in 240 blocks of 4KB. The emulator showed that this worked fine with both no RAM errors present and with a RAM error set.

Let's get real..

By now I'd decided it was time to stop playing with the existing ROM and to start setting up a dedicated ROM image, without WERMA and without Caretaker, just the TorchDiag. I'd certainly learned a lot from the experiments and messing about with the current ROM but it was too tied up in bringing a fully working system to the point of operation. What I needed was a bare bones set of tests that increase in complexity as more of the system is verified OK (or not) and this just wasn't going to be practical squeezing in with the existing ROM.

So, on to Phase 2 (ooooh!). At which point I restarted the numbering and renamed the files just to confuse everyone..

(Also, because the majority of initial checks in the standalone ROM rely on beep sequences, there aren't many screenshots in this bit. Just keep thinking 'beep beep' and you'll be fine...) 

 

Phase 2 - Creating a Standalone Diagnostic Firmware

The first version of the standalone ROM was not exactly 'useful'. That's not strictly true but it did initialise the service processor (HD6303) and its timer while holding the 68010 in 'reset'. It made two little beeps to say it had done that. At the first attempt, there were no beeps but it turned out I'd missed setting Port 2 direction register. But once that was changed we got a happy 'Beep! Beep!'. Nice!

This was very small but proved that it was possible to create a firmware that could operate the speaker without Caretaker, ERMA, WERMA or the 68010 CPU. 

It's ALIVE!

Next came a slightly more ambitious set of tests, by adding a real HD6303 controlled video RAM test. This tested almost all of the 64KB of video RAM - but not all. The reason being that the emulator (still not on real hardware yet, remember!) uses the last byte of each bank for.... some reason...

To check that what was added would work, there was also a minor update to the emulator to add the 'TORCH_VRAM_FAULT' variable. 

And this was actually the first useful “is it dead?” diagnostic that didn't require the main CPU to function - and it worked perfectly! Not exactly DiagROM but a big step for this project.

Next came another big step. The Caretaker ROM actually contains code for the HD6303 service processor as well as the 68010 CPU. This next update would be the first version to include 68K style code alongside the 6303 code too. All that this update did was to run the existing VRAM test but then copied a tiny VASM assembled 68010 bootstrap into video RAM, but most importantly, it then released the 68010 from reset using Port 1 bit 3. The 68010 then executed code directly from VRAM and wrote a value into a shared memory mailbox. The 6303 was looking for the acknowledgement value and reported success (or timeout) using the beeper. 

By this point there was a bit of a series of beep codes:

  •     VRAM PASS : two short beeps
  •     68010 acknowledged : three short beeps
  •     68010 timeout : long short short beeps
  •     VRAM fail : repeated long beep

Getting this working was another huge step. For the first time, both processors were running the firmware and communicating with each other (in the emulator remember), even if the 68010 really didn't do much other than say "Hello there!".

Phase 3 - Diagnosing Main RAM without using Main RAM...

Some very quick notes on this phase (before things get more interesting at Phase 4):

Early main RAM test

  • Extended the VRAM-resident 68010 bootstrap to test 4 KB of main DRAM at $110000 to $110FFF.
  • Kept executable code, stack, exception vectors and communication mailbox entirely in video RAM.
  • Added complementary memory patterns and a walking one test.
  • Introduced TORCH_EARLY_RAM_FAULT=1 in the emulator to simulate a stuck-low D3 bit during the new memory test.
  • Added a bus-error exception handler as the foundation for detecting inaccessible memory.
  • Expanded the success sequence to two, three, then four short beeps.
  • Used two long beeps for a detected RAM data mismatch.
  • Successfully verified normal startup, injected VRAM failure and injected main RAM failure.

This was a particularly important breakthrough i.e. the diagnostic could detect faulty main RAM without needing that RAM to execute its own code.

Full 1 MB RAM testing and BERR handling

  • Expanded the 68010 memory test to cover the entire original 1 MB of main DRAM, from $100000–$1FFFFF.
  • Removed the earlier need to protect the first 64 KB, because the diagnostic now runs entirely from VRAM - Yay!
  • Tested 256 blocks of 4 KB using complementary patterns and walking one checks.
  • Added a progress counter in shared VRAM so the HD6303 could monitor the 68010 during longer tests. (Emulator runs this very quick - real hardware needs testing!)
  • Implemented a bus-error exception handler using vector 2, with the handler and stack remaining in VRAM.
  • Added TORCH_EARLY_RAM_BERR=1, simulating a bus error at $180000.
  • Used distinct audible failure patterns (similar to real Caretaker errors):
    • RAM data mismatch: two long beeps.
    • Bus error: two long and one short.
    • RAM test timeout: three long beeps.
  • Successfully verified all three tests: healthy RAM, injected D3 failure and injected BERR. 

At this stage, TorchDiagROM could test the whole original main memory and survive simulated data faults and bus errors.

Phase 4 — Creating the real diagnostic display

This is where things get properly interesting.. 

Making noise is great but we needed to be displaying some useful information. To do this required understanding how to create 68010 graphics. My first experiment was writing pixel data directly into the Triple X video framebuffer to create a 'T' on screen. Again, not exactly useful but a good start. Or it would have been if it actually worked. Initially, all I got was a blank screen but this was because the emulator was expecting the HD6303 to read $0F from $43F0 before it would expose the framebuffer. Odd but OK.

And that worked. 😁 We could now draw stuff on screen. 

 

More 'T' vicar?

 

But to show useful information, we need a font. And Caretaker already has one, so I pinched it. 😆

 

Eh? Oh! "A".

 

This consisted of 95 printable ASCII characters, occupying 760 bytes. Very nice. So, after re-organising the memory 'map' in the diagROM, I added character and string rendering routines (which may look suspiciously like the Caretaker routines..) to produce an actual readable display using the authentic Torch font.  

The memory layout now looks like this:

    •   Reset vectors and interprocessor mailbox in low VRAM.
    •   Diagnostic display region in the middle.
    •   68010 executable code in upper VRAM around $8000.
    •   Original font around $9000.
    •   Supervisor stack in a separate upper-memory region.

 

I'm a real boy!

The 'garbage' and bar across the screen are actually the font and program information - remember that all this is being executed from VRAM! But the main thing now is that TorchDiagROM now looked like a real Torch diagnostic utility! GET IN!

Next on the agenda was an extended diagnostic display to report the first failed main RAM address. This captured and displayed the expected value, actual value and the XOR difference before triggering the text rendering. The existing early 6303 tests were kept with their beeps too. As an added bonus, it was relatively easy to extend the main RAM tests to also carry out a test on the Limpet RAM expansion. Nice.

 

All systems nominal, Captain..

One of the things that had started to bother me was that the screen setup in the emulator was actually cheating slightly. There was an artificial routine early on in the emulator to force the screen through the pale blue startup then dark blue caretaker screens. This meant that the colours on the emulator would not be the colours on the real hardware. So, to make sure there would be no nasty surprises, the ROM was updated to correctly initialise the CTRC. This was relatively straightforward and, in the ROM, required that the foregrond and background colours were specificed. 

The emulator was also updated to include a 'TORCH_RAW_VIDEO' mode. This worked really well as there was code in there to actually initialise everything properly and so it actually worked with the emulator starting up the real Caretaker ROM too, so it was well worth doing. But the results for the diagROM were great. I chose a black background with a pale green text. Very terminal like. 😁

 

1980's Terminal vibe. 

One thing that the diag didn't currently do was check the tiny bit of internal RAM that the 6303 processor has. There's about 128 bytes so it was worth adding a check for them before going any further.

And so, finally, we've reached the moment you've been waiting for. Let's get this on to a real EPROM and try it in the Torch.

I had an EPROM lurking around from my PET shenanigans a while ago. And I still have my phone sanitiser that works as an excellent single EPROM eraser, and my T48 EPROM writer with Xgpro software. 

 

The dynamic duo..
 

One sanitiser session later, and I had version 1.1.2 on the EPROM. But did it work?

 

It's real! It works! Wa-hoo!
 

Oh, yes. And the results were encouraging. The main RAM was working OK  (foreshadowing...) but the Limpet was reporting nothing and so triggered a 'BERR' (bus error). 

But this is EPIC!

From this it was confirmed that:

  • the HD6303 is working and executing code
  • the HD6303 internal RAM is working correctly
  • the video RAM is working correctly
  • the main 1MB RAM is working correctly (for now...)

The only thing not working was the Limpet RAM. This was not really unexpected but was a bit annoying. But based on everything I'd learned about the Torch I was sure that I should be able to remove RAM from the Limpet and the system would still boot. The mechanism that the Torch uses to work out if there is additional RAM is stupidly simple. At the initial RAM test, just keep going up through the address space until no RAM responds i.e. BERR. This should mean that if I removed the RAM one bank at a time then it might highlight where the issue with the Limpet was. So I took out the first bank of RAM.

 

Well, darnit. I didn't expect that..

Oh. Bugger.

The main 1MB of RAM is now showing a fault. What. The. Heck??

Fortunately, the diagnostics were actually helpful and showed that the test failed at the first address ($100000) and the XOR value was $04000000. From this I could see which bit was failing:

 

Bits and bobs..

So it was the third bit of the lower nybble of the second byte. This corresponds to data bit D10 on the system.

Just one point on the number presented by the Torch diagROM. It's actually a 32-bit number even though the processor has a data bus of 16-bits i.e. it's presented as $04000000. Internally, the processor can use 32-bits, but when it works with this number externally it does it in two 'hits'. But then why do we only see one error? If the fault is there and we're reading using the same data lines then surely it would affect both 16-bit portions of the readback? 

The 68000 series of CPUs are what they call 'big endian' which means they look at the most significant byte first (interestingly the term 'big endian' and 'little endian' originate from the novel Gulliver's Travels and refer to the way to eat an egg). So our test sets the memory for a 32-bit value and reads back the first 16 bits. Because this has an error the test stops immediately, so it never actually gets to the second half of the 32 bit number, leaving it as all zero.

In any case, we have a fault. 

To see if this was a single fault that just so happened to be the first address in main memory (it could be but that would be a massive coincidence) I added another RAM test, this time specifically aimed at address $1000000. This would write $0000 to that address and read it back 256,000 times, then it would write $FFFF and read that back 256,000 times. Then it would write and read $0000 and write and read $FFFF 256,000 times each. Over a million tests. Hmmm.

And the results were interesting...

 

Veeerrryyy interesting. Really.

This told me that there were exactly half of the tests failing ($7D000 is 512,000). And the XOR of the test showed what I suspected. With a value of $04000400 this meant that when the Torch was reading 32-bit values the data line D10 was faulty on both cycles. 

I extended the test a bit more to include details of how many tests failed for each run through. It confirmed one thing. Writing and reading $0000 was fine i.e. no failed tests, but EVERY test requiring a readback of $FFFF failed with the XOR value of $0400.

 

Hmmm. Not sure things have improved..

This was very weird as it showed that of the 512,000 tests, 266,240 had failed and all with the same $04000400 XOR value. 

By now I needed to start probing around the motherboard and, to be honest, it was not easy. The Limpet board is mounted over the main RAM which makes it impossible to reach the main RAM when the machine is on. Remember that the Torch will NOT start at all without the Limpet attached because IC169 is removed (and presumably discarded) when the Limpet is installed.

I had to come up with a way to lift the Limpet away from the motherboard but leave it plugged in. And this is what I came up with..

  

I see you, RAM.

After several hours of crimping the tiniest most fiddly stupid crimp things onto ribbon cable I had a working set of extensions for the Limpet. And, fortunately, they just worked. I also discovered that the connector that links to all the er... links.. on the motherboard is not required and is presumably there to make sure that no links have jumpers on when the Limpet is installed. 

Anyway, now that I can get to the RAM I can do some probing. Looking at the schematics I could see that the DRAM chips responsible for data line D10 were IC105 and IC113. Sadly, after many hours of probing and analysing I could see nothing untoward in any of the signals. I checked the data in/out, /CAS, /RAS and /WE signals and they all seemed to be a) the right voltage and b) the right timing. 

I decided to go a bit more mechanical and dismantled all the cables and reseated all the chips. For the main three Motorola chips I actually removed them completely. They were the 68010 CPU, the 68450 DMA controller and 68451 MMU. And would you believe it, underneath the CPU was the tiniest sliver of copper wire. It was an offcut from when I had previously repaired a trace. Of course I removed it. 

Then I began to wonder if any other debris might be lurking in there. So I lifted the motherboard, turned it upside down and shook it like a polaroid picture. Well, not quite, but I did give it a bloody good shake and, would you believe it (again), a piece of metal dropped out that looked like an offcut from a component leg - something like a resistor or capacitor. 

Back to the shed! 

Hooking up everything took a few minutes but then I was ready for another switch on and, well, things were a bit different...

 

Still got an error but...wait a minute..!!
 

In case you can't see it, the Limpet 1MB memory is now no longer reporting a bus error. Instead it's showing that the 1MB memory on the Limpet passed all its tests.. What. The. Heck!!

This is GLORIOUS news! It means that the memory control to the Limpet is working correctly, all the PAL chips are fine (I was worried that they had died and they are the ultimate unobtainium), and all the DRAM is working too. What a result!

But what about the main RAM error? 

After my success with the more physical maintenance I decided to have a go at reflowing the sockets for IC105 and IC113. It couldn't hurt and at least I'd be able to tick it off the list of things I'd done. So I did, using my newly purchased liquid flux (because I can't find my old flux since the move from Crashed Towers).

And here's the result of that little escapade:

 

Speechless.
 

No errors. No. Errors. NO ERRORS!! 

NO ERRORS!! 

It appears that all of the issues I had been having with this machine were down to:

  • A sliver of copper wire under the CPU
  • A 4mm piece of resistor leg offcut lurking goodness knows where
  • Dodgy solder joints on two DRAM sockets 

So, I immediately replaced the diagnostic ROM with the original Caretaker.

 

YES!

The 'SCSI controller 0 not present' error was because I hadn't connected up the SCSI cable or even plugged in the OMTI SCSI controller for the floppy drive. I connected everything up and tried again.

And got the same error.

Arse.

So, something is not right with the SCSI on the motherboard. And I'm fairly sure it is the motherboard and not the OMTI controller. I have a BlueSCSI connected as SCSI ID0 which the Torch should boot from. This should just work, even if the OMTI board isn't working. But then if the BlueSCSI was faulty (and assuming the OMTI is working) I should be able to use the Gotek floppy drive emulator to load the key disk immediately.

Both the BlueSCSI and OMTI failing at the same time is unlikely so it looks like I still have motherboard gremlins.

Great.

But at least there is a working diagnostic ROM for all the other Torch Triple X users out there (all one of them). 

Saturday, November 14, 2026

Using an Emulator to Fix Stuff - Torch Triple X (Emulator?) - Part something something...

With the Torch emulator working like a trooper I started to wonder if I could use it to help out in some way in the repair of the real thing. As a reminder, the Torch hardware frequently appeared to have problems with the Limpet RAM expansion board. On one occasion I got a bit cross and some force was applied to the Limpet and, bizarrely, that seemed to fix it. This led me to think it was the connectors it used into the motherboard. It, apparently, was not and after a while it became worse and worse until one day, the Torch would not boot.

I wasn't going to take this lying down, so on the somewhat presumptive assumption the Limpet was at fault, I went and created a new Limpet board which, on it's first couple of tests, actually freakin' worked. 

 

Shiny new Limpet board. Yay!

 

Happy days. Working Limpet.. 


But sadly, not for long. Now, the Torch will not get past the initial pale blue boot screen.

 

Sad face. No boot. :(

The LED on the Limpet only flashes once, and frequently, it displays garbage on screen which is similar to that seen waaaaay back when I was first trying to get the Torch booting. 

A few other things I noted before it went into storage while we moved from Crashed Towers to Crashed Tiny Abode:

  • The LED on the Limpet should normally flash four times during a proper boot. 
  • The voltages across the board were very, very low (down to 4.3v in most places).
  • The Torch did boot a few times with a very upsetting bend in the motherboard.

 

The horror - arrrgh!

 

So, my assumption now is that the Limpet is OK and that there is some mechanical issue with the board, or there is a failed IC hiding somewhere either on the motherboard or (potentially worse) on the Limpet. There are several PAL chips that are basically irreplaceable across both the motherboard and Limpet. This is the worst case scenario that I don't want to think about...

Anyway, on Torch startup it appears that there is some sort of RAM test, and I assume this is signified by the four flashes. Then the screen goes dark blue and shows the Caretaker version (this is basically the BIOS) before starting to boot proper. I wondered if we could nail down exactly what the thing was doing whether that might help in the quest to fix it. 

Fortunately, we have pretty much everything we need. We have the ROM, excellent schematics (redrawn by yours truly), a technical manual, and (thanks to the most excellent chap on the VCF forums) a working emulator. 

Torch Emulator - Talking to the outside word!

First things first, let's disassemble the Caretaker ROM.

But to do that, I needed to get a disassembler installed. And for this there is the most excellent (if rather powerful i.e. complex) Ghidra tool, as recommended by such luminaries as Ken Shirrif (a regular contibutor to Curious Marc's youtube channel). Installing this was a little bit of a chore but not too hard considering I was installing it on Pop OS on my new laptop (did I mention I have a new laptop?) which is a variation of Linux.

Once it was installed I threw the ROM in and it just told me everything... Just kidding. I had to install a specific extension to support the 6303 CPU. Even then, Ghidra still needs to be told what to do. And that includes where to load it... For the Caretaker ROM this needed to be at address $C000. The 6303 documentation identified that the reset vector was at $FFFE which then points back to $C2DC and that was the starting point.

 

On your marks! Reset! Go!
 

But that's not all that lurks in the Caretaker. I know that there is a section of bootstrap code for the 68010 main CPU. And to get this I ran the command:

 

Gimme the code.

So now I had another file that could help enormously. At this point I'm fairly certain that the service processor would copy Caretaker into VRAM before doing stuff, including I assume a RAM check, and then handing off control to the 68010. The questions I had were, is the RAM check carried out by the 6303 or the 68010? Is the RAM test just the VRAM or does it include the main system RAM? If the system RAM, how does it know if there's a Limpet installed? 

The first major discovery was around the 6303 service processor's diagnostic error-reporting routine. At address $C087, Caretaker enters an error handler that initialises several timing parameters before repeatedly calling a routine at $C277. That routine read the diagnostic byte store at $00B9.

But how it interprets that byte is really interesting.

Each diagnostic message consists of four beeps, with two bits controlling each beep:
- The first bit determines whether the beep is short or long.
- The second bit determines whether the pause following it is short or long.

For example, error $21 is binary 00100001. This produces short–long–short–short, with a longer pause after the fourth beep to separate each four beep sequence. That tied up with what I was seeing when the Torch wouldn't boot either with the Limpet (long-short-short-short) or without the Limpet (short-long-long-long).

The HD6303 generates these sounds using its internal timer and output-compare circuitry. The original Caretaker manual confirmed the codes identified in the disassembly and meant that Ghidra was on the right track. :)


Code    Beeps   Description
$01     SSSS    ROM checksum error
$03     SSSL    Video controller faulty
$09     SSLS    RTC stopped
$0B     SSLL    HD6303 internal RAM error
$21     SLSS    Video RAM fault
$23     SLSL    HD6303 serial port timer failure
$29     SLLS    VRAM inconsistent with copied ROM data
$2B     SLLL    Main CPU timeout


This didn't solve the code that I was seeing with the Limpet attached (long-short-short-short) but it might appear somewhere else in the code maybe (foreshadowing...).

Next thing, how the first part of RAM is tested. In actual fact, the 6303 tests the video RAM through a 32KB window located at $4000 to $BFFF and uses bit 2 of its port 1 register to determine which bank is being checked. The firmware writes a test pattern into both banks before reading the data back and comparing it.

The pattern is generated using:
         

        Next byte = (225 x Current byte + 205) mod 256

 

If any comparison fails then Caretaker stores $21 at $00B9 and runs the diagnostic routine i.e. it starts the four beep message, in this case for Video RAM fault.

The next big breakthrough was working out how error $2B gets initiated. This is one I'd seen many, many times (short-long-long-long) almost from day 1 of having the Torch. What happens is that Caretaker does the following:

 

Release the hounds, err, 68010 actually.

 

This code snippet selects VRAM bank 1, writes $FF to $BFFF, and releases the main processor by clearing Port 1 bit 3.

The service processor then repeatedly reads $BFFF, waiting for the value to change, which indicates the main CPU has started doing stuff (or not).

There are three outcomes:

Value              Meaning
$FF                Main processor has not yet responded
$00                Main processor has successfully acknowledged startup
Other value        Main processor has returned a diagnostic code


If $FF remains unchanged until the timeout expires then Caretaker generates error $2B and triggers the diagnostic routine. But if it does change to another non-zero value, then could this be the undocumented 'long-short-short-short' beep error message seen when the Limpet is connected?

Based on what we know about the beeps it's easy to see that 'long-short-short-short' should work out as '10000001' or $81. So, where does this come from? Is it a random number the just so happens to end up in $BFFF? Or is it a specific value that is inserted by some part of the system?

The answer was relatively straightforward.  

Although the HD6303 code we'd examined didn't explicitly generate it, I suspected that the 68010 might be returning the value through the video RAM or main RAM.

To test this, some logging was added logging to the emulator around the $BFFF handshake.

That produced:

[BFFF] SP WRITE PC=C54F bank=1 host=0FFFF old=81 new=FF
[BFFF] SP P1.3 PC=C552 old=1E new=16 host_release=YES
[BFFF] HOST WRITE PC=001011FA logical=0000FFFF physical=0FFFF old=FF new=00
[BFFF] SP READ PC=C55A addr=BFFF bank=1 host=0FFFF actual=00 returned=00

 

This is basically the processors (virtual in the emulator) communicating with each other. The HD6303 wrote $FF, released the 68010, and subsequently received $00.  

Interestingly, the initial behaviour in the emulator was a lie. The emulator had a bit of a shortcut that basically checked the value three times and then just returned '00'. Cheeky. There wasn't actually a need to do this as the code was written to process the communication properly and a quick modification to remove the shortcut was made, and the emulator still booted. Nice.

And now the smoking gun. Disassembling the 68010 bootstrap code revealed:

        0000004A  move.b  #$81,$0000FFFF
        00000052  bra     $00000052 

 

Bingo! The 68010 explicitly writes diagnostic $81 to the memory location monitored by Caretaker, then enters an endless loop. Tracing backwards revealed the reason for this. Immediately before reporting the error, the processor compares a value read from main RAM against an expected test pattern: 

        00000042  cmp.l   (A0)+,D1
        00000044  dbne    D0,$00000042
        00000048  beq     $0000003E
        0000004A  move.b  #$81,$0000FFFF

 

If the comparison fails then, boom!, $81 is written to $FFFF and the 68010 checks out into an infinite loop.

Weirdly, there is also another diagnostic value of $83 which converts to long-short-short-long. I haven't figured out what could trigger that yet...

Anyway, digging further into the 68010 code shows that the main RAM is tested by two passes, the first writing a pattern of 5A5AA5A5 and the second a pattern of A5A55A5A. Rather strange though, the code doesn't know how much RAM is present. It starts the test at $100000 and then just keeps going up until there is a bus error which indicates the end of available RAM. Then it repeats with the second pattern. Very odd but very clever as it means the system can use any amount of additional memory (although I'm not sure what any limit might be..).

Once the two sweeps are complete it writes $00 into $0000FFFF to tell Caretaker the RAM check is complete and all OK.

To check that all this was as expected, the emulator got another modification to deliberately put an error into the RAM test. At address $100000 instead of '5A' the value '5B' was inserted. The results were:

        [RAM-FAULT] First verification pass:
        physical $00100000 5A -> 5B

        [BFFF] HOST WRITE PC=00000052
        logical=0000FFFF physical=0FFFF old=FF new=81

        [BFFF] SP READ PC=C55A
        addr=BFFF bank=1 actual=81 returned=81

 

In other words, it's gone pear shaped! Stick $81 in $0000FFFF!

And the emulator also made the same beep pattern (but a little bit quicker) of long-short-short-short but also showed garbage on screen.

 

Beep, beep, beep, beep (I'm a sheep)

And this is very, very similar to the garbage that the real hardware presents when it's switched on:

 

It's the real thing...

 

So, where does that leave me? Well, I now have a much better understanding of the 'long-short-short-short' beep diagnostic. It indicates that the main 68010 has encountered a RAM readback mismatch during the main RAM tests. That could result from faulty memory chips, but also from problems elsewhere in the memory-access circuitry (address decoding, data buffers, RAM multiplexers or timing/control signals etc).

The Limpet expansion changes the physical configuration of the system, and the bootstrap tests whatever contiguous RAM the hardware makes available, but I can't run the system without it due to the missing U169 chip - which the Limpet effectively replaces. 

So I still can't say whether the failure is in mainboard RAM, Limpet expansion RAM or shared circuitry affected by fitting the Limpet.

But it does mean that my hardware tests can be much more targeted now that I have some idea on how the Torch actually starts up. I'll be using the oscilloscope and logic analyser to have a closer look at:

  • The 68010's /AS, R/W, /UDS, /LDS and /DTACK signals.
  • The DRAM /RAS and /CAS0–/CAS3 signals.
  • Memory address activity during writing and verification.
  • How the Limpet changes memory selection or bus acknowledgement (maybe allowing me to put something in to replace the missing U169)

 

Now, if the weather would just get a bit warmer and I could get over COVID (again), that would be great. 

 

 

Monday, November 09, 2026

Schroedinger's Floppy - Torch Emulator Part 5

One of the cool things in the Torch Triple X emulator is having the floppy disk support working properly. The emulator can read and write floppy images (thanks to the Torch architecture using the SCSI interface for floppies so it’s the same code as for hard disks – yay, Torch!), and now I've even added a separate graphical disk manager to insert and eject floppy disks while the emulator is running. Ohh, get me.

 

Look at that there fancy disk manager window


Everything appeared to be working rather well. And then I hit a snag.

The Torch Triple X runs its own version of System V Unix, and the emulator supports floppy disk images that use the correct format. These images can also be mounted directly under Linux, provided the Linux kernel supports the correct format which just so happens to be the old System V (sysv) filesystem. Most modern Linux kernels have dropped support for SysV, which is why I've had to install an older 6.14 kernel specifically for working with Torch Unix filesystems on my new laptop. (Did I mention I have a new laptop?)

This has been extremely useful as it allows me to copy files directly between my (new) laptop and the emulated Torch

At least, that was the theory.

While working with one of the floppy images, I discovered that attempting to copy another file onto it resulted in a rather unhelpful error: the disk was full. This was weird because, as far as I could see, the disk only a handful of very small files on it. 

Running df under Linux produced something like this: 

 

'df' says that /mnt/flop has 5 blocks free??
And 'ls' shows about 6KB worth of file. WTF?

But the directory listing only had three files listed occupying a grand total of about 6 KB. Where the fudge has the other 700 KB gone?

My initial suspicion was that something had gone wrong with the filesystem's allocation information. System V Unix uses a relatively simple filesystem structure compared with modern filesystems such as ext4. One of the main things it does it to keep track of which disk blocks are available for storing data. So, when a file is created, blocks are allocated to it and then when the file is deleted, those blocks are supposed to become available again.

If that process goes wrong then a disk can gradually fill up with blocks that are no longer associated with any existing file but that aren’t available to use for other files. Since the floppy image had been used several times for copying and deleting files, this seemed like it could be a possibility.

 

i-node, right?
 

Looking at the inode information on the disk image in Torch unix was also confusing. The filesystem supported 174 inodes, but only five were in use. For anyone unfamiliar with Unix filesystems, an inode is essentially the record containing information about a file, including where its data is stored. So, from this, I think I could be fairly sure that there weren't hundreds of forgotten files hiding somewhere.

Something else must be happening.

Rather than continue to dig at an image that might have become corrupted through repeated use, I decided to start again to try an work out what the heck was causing the problem.

I created a brand-new 720 KB floppy image under Linux:

        dd if=/dev/zero of=floppyblank.img bs=1024 count=720

This produces a file containing 737,280 bytes, all initially set to zero.

I then inserted the image into the Torch emulator and used my shiny ‘sh’ front end (pty) in Torch Unix to prepare it:

        format /dev/fdsk/0

This formats the raw device and is basically a SCSI low level format.

        mkfs /dev/fdsk/0 1440

This creates the filesystem as SysV with 1440 blocks of 512KB, giving the expected 720KB size.

        mount /dev/fdsk/0 /mnt/flop

Finally, we mount the blank image so we can write to or read from it.

Running the equivalent ‘df’ command on the Torch showed 1412 blocks free. That means 512KB x 1412 giving 722,944 bytes or 706KB. So far so good and everything looked perfectly normal.

So then I unmounted the floppy, shut down the emulator and mounted the image under Linux (I’m using Pop OS).

        sudo mount -t sysv -o loop,ro testimage.img /mnt/flop

This mounted the image at /mnt/flop. A quick df and, would you believe it, there it was again. Most of the free space was used! And I haven’t done a **** thing with the image at ALL! GAH!

 

WHERE IS MY FREE SPACE?

At this point, I was thinking of two possibilities. Either the emulator was doing something particularly unpleasant to its floppy images when it was formatted so Linux was having difficulty interpreting them, or the emulator was fine but Linux was being a bit crap and was just having difficulty reading them.

So I went back to the Torch emulator to ask again how much free space was available. Even this turned into another minor adventure when the Torch df command initially produced absolutely no output whatsoever. Not an error. Not a warning. Nothing.

GAH!!!

After restarting the emulator and repeating the operation, however, it decided to work. (Isn’t that the definition of madness?)

The Torch reported:

        /mnt/flop /dev/fdsk/0 1412 blocks 174 i-nodes

That meant (you can probably guess):

        1412 × 512 = 722,944 bytes

Or approximately 706 KB free.

So now there were two operating systems looking at the same floppy image and seeing two totally different things. Torch says it’s empty, Linux says it’s full. Brilliant.

But both could read the directory with no issues.

This was beginning to look less like an emulator problem and more like a disagreement over the filesystem's internal structures. There’s only one way to find out. FIGHT! Ahem.

Anyway, after a lot of googling (it’s amazing how interesting filesystem formats can be) I thought I should take a closer look at the superblock. Apparently, every System V filesystem has one of these, and it contains lots of important information about the filesystem including its size, the inode information and (ta-daa) the number of free disk blocks.

So to have a look at the superblock in these images I wrote a python script to read it directly. Yay python!

The script looks at the possible byte orders and filesystem layouts, and it produces the following result:

 

        SysV2 (Big endian)

        First data block : 13

        Total blocks : 720

        Free cache count : 7

        Total free blocks: 706

 

That looked promising. The filesystem contained 720 logical blocks, and its superblock said there were 706 free blocks. In other words, Torch's filesystem ‘metadata’ said exactly what would be expected for a regular blank floppy.

But there was another number that stuck out.

        Free cache count: 7

This is suspiciously close to the seven kilobytes Linux claimed were available. Hmmm.

After a bit more reading it seems that System V filesystems use a linked free-block list to manage available disk space. In other words, rather than storing every free-block address in the superblock, they keep a small collection of addresses there. When those addresses are all used up, another disk block contains the next collection. This continues until the complete list has been followed all the way to the end.

Think of it as a series of pages in a notebook, each containing a list of free locations and a reference to the next page. Even my small brain managed to deal with that analogy..

The Torch superblock contained seven free-block entries:

    35

    32

    29

    26

    23

    20

    17

The first entry, block 35, was especially important because it should lead to the next group of free blocks. So I extended the Python script to examine the contents of block 35.

The first 32 bytes looked like this:

    00 00 00 32 00 00 00 b9

    00 00 00 b6 00 00 00 b3

    00 00 00 b0 00 00 00 ad

    00 00 00 aa 00 00 00 a7

Initially, the script interpreted the first two bytes as the number of entries:

    00 00 = 0

That would indicate an empty list. But this just wasn't right.

But then, if we interpreted the first four bytes as a 32-bit ‘big-endian’ number instead, we get:

    00 00 00 32 = 50

And then all subsequent four-byte values looked like very plausible disk block numbers:

    00 00 00 b9 = 185

    00 00 00 b6 = 182

    00 00 00 b3 = 179

    00 00 00 b0 = 176

So, could it be that the Torch filesystem is storing the number of entries as a 32-bit value, but Linux was interpreting it as a 16-bit value? Hmmm.

To test the theory, I updated the Python script again. This time it treated the count at the beginning of each chained free-list block as a 32-bit value and followed the entire chain.

The output turned out to be the smoking gun:

    Block 35: 50 entries

    Block 185: 50 entries

    Block 150: 50 entries

    Block 112: 50 entries

    Block 262: 50 entries

    Block 212: 50 entries

    Block 362: 50 entries

    Block 312: 50 entries

    Block 462: 50 entries

    Block 412: 50 entries

    Block 562: 50 entries

    Block 512: 50 entries

    Block 662: 50 entries

    Block 690: 50 entries

Fourteen linked blocks with each containing 50 entries.

When combined with the seven entries in the superblock, that gave:

    7 + (14 × 50) = 707

That was frustratingly close to the superblock's reported total of 706 free blocks. Looking at the last free-list block though, block 690, its first entry was zero. So this was the terminating marker at the end of the list, not actually a free block.

So in reality the count was:

    7 + (14 × 50) - 1 = 706

Exactly 706 free blocks. Not approximately 706. Not somewhere in the region of 706. Exactly the number recorded in the superblock. GET IN!

Every supposedly missing block accounted for. Nice.

And then Linux confessed to something that I should have spotted at the start of this impromptu investigation. I had a look at ‘dmesg’ i.e. the Linux kernel messages with and guess what I found:

    sysv_count_free_blocks:

    free block count was 706, correcting to 7

That message explained exactly what the heck Linux was doing. It read the superblock and found the recorded count of 706 free blocks. And then it then attempted to traverse the free-block list itself. But because it expected a 16-bit count where the Torch had written a 32-bit count, it interpreted the first chained block as containing zero entries. And so it stopped.

Linux then decided that the superblock's count must be wrong and used its own calculated value of seven. This explained why df had been insisting that the floppy was almost full even though nothing had been written to it.

So it wasn't a problem with the emulator losing data, it wasn't caused by deleted files failing to release their blocks, and it wasn't a completely corrupt filesystem. It was an obscure difference in how the two Unix implementations represented the linked free-block list.

Now I know what is happening, the next question was what to do about it. What I really wanted was the ability to copy files to an image under Linux and then insert that same image into the Torch emulator.

And so the solution was another trip into Python.

Rather than modify the emulator or rebuild the Linux kernel (ain’t nobody got time for that), I created another python script that converts the relevant free-block structures between the two layouts.

For Torch-formatted images, it changes the linked free-list blocks from a 32-bit count to the 16-bit count expected by Linux. And for images being returned to Torch, it performs the reverse conversion. Everything else, the actual files, directories and inodes are all left untouched.

And to make sure there’s no unfortunate data loss (due to almost certain bad programming or operator error), the utility creates a separate output file rather than modifying the original image.

To convert from Torch to Linux:

        python3 torch_sysv_convert.py --from torch testdisk.img testdisk_linux.img

 

The resulting converted image can then be mounted under Linux:

        sudo mount -t sysv -o loop testdisk_linux.img /mnt/flop

 

Files can be then be copied on to it normally.

Once finished, the image is unmounted:

        sync

        sudo umount /mnt/flop

 

And converted back:

        python3 torch_sysv_convert.py --from linux testdisk_linux.img testdisk_torch.img

 

The final image can then be inserted directly back into the emulator.

The python script also validates the free-block chain, checks for invalid or duplicate block addresses, and verifies the resulting image. I love python. :)

To make sure everything was working correctly I took a freshly formatted, empty Torch floppy image, converted it to Linux format and mounted it.

This time, Linux reported the expected free space.

Success!

But reading a blank disk is one thing, successfully creating files and then using them in the original operating system is another. So a more comprehensive test was required...

Starting with the same blank Torch image, I copied the Torch Unix kernel onto it. Then I converted the image to Linux format and mounted it on the laptop. Next, I created two additional files, each 100 KB in size. That forced Linux to allocate a decent number of blocks and update the filesystem's free-space attributes.

After un-mounting the image, I converted it back into Torch format and inserted it into the emulator.

And everything worked. Perfectly. The files were present, the filesystem mounted correctly, and the space allocation was as expected.

It does add an extra step in the conversion of disk images but at least I know what the heck was going on. I don’t like not knowing why something is the way it is.

What did we learn from all this?

Firstly, the emulator's floppy disk implementation appears to be doing its job correctly. The disk image contained the expected filesystem information, and the free-block chain was coherent and intact.

Secondly, just because two operating systems recognise the same filesystem doesn't necessarily mean they interpret every internal structure identically. This is apparently important when dealing with historical Unix implementations. Presumably, in the early days different vendors introduced their own variations, just to annoy vintage computer enthusiasts 40 years later..

Thirdly, filesystem corruption isn't always what it first appears to be. In this case, the symptoms lead me down the path of a damaged allocation structure, but the information was actually still present and consistent and it was just a misunderstanding of the block list values.

And finally, a relatively small python script can solve a compatibility problem that would otherwise have involved me trying to modify the Linux kernel (bleurgh) or changing the emulator (not necessary as it turned out).

Sometimes I wonder whether retro computing is a hobby or a particularly elaborate form of self-inflicted punishment.

And the floppy image that started all this? It was both full and empty. It just depended on which operating system was observing it…

(Insert Schroedinger joke here...)