Clockwork

Amiga 500 Restauration, Part 1

My first Amiga was an Amiga 500. A classmate already had one, and when I visited him and saw the Amiga for the first time, I just had to have my own, so I pestered my parents until they gave in and bought one for me. With this computer I learned 68000 assembler, programming in general, and blind ten-finger typing.

A few years later, I bought an Amiga 4000 from the pay I got doing my civilian service. My good old Amiga 500 spent a few grace months in a closet, and was then stowed away in a box in the basement, forgotten for about three decades.

I would like to restore this machine, make it beautiful again, and give it a subtle technical overhaul. This project is a work in progress. I will report in my blog whenever there is something new. And in the end, I can hopefully share a feeling of success with you.

These are my goals for the restauration project:

  • The case has likely got a yellow tint over the years, like all white computer cases of that era. The yellowing has to go, the case should look as good as new again.
  • I will give it a technical overhaul. The electrolytic capacitors may have leaked and will be replaced. But after all the years, there may be even more technical problems that need to be fixed.
  • Since I have almost no floppy disks left, the floppy drive will be replaced by a drive simulator.
  • The old 1084 CRT monitor is long broken and disposed of (I hated these old flicker boxes anyway). I want to connect the Amiga to a modern TV instead, preferably via HDMI, so I will have a closer look at this Raspberry Pi Zero based converter that will be connected to the Denise socket.

After the restauration, the Amiga should feel (more or less) like it did when I got it in 1988. This means that there will be no accelerator card or harddisk controller. Apart from the HDMI output and the floppy simulator, the only acceptable "tuning" is the chip RAM extension to 1 MByte.

Okay, so let's get the computer out of the box and have a first look at it:

My Amiga 500 before restauration.

The case is not quite as yellowed as I had feared, nevertheless the ugly "nicotine yellow" has to go. On the right side of the case I had added four switches. At that time the Amiga was rather a commodity. Today I scolded my old self for drilling holes into that beautiful case. So there's one more item on my to-do list: fill the holes.

As for the case, I couldn't decide if I should have it dyed black, or have it bleached at the CBM Museum Wuppertal. I couldn't find a paint shop who would dye plastic though (they only offered varnishing), and the contact to the CBM Museum turned out to be nice, so the case will now be bleached by the professionals there.

I have to admit: My fingers were itching to plug the Amiga into the wall socket and the TV right away. Fortunately I didn't do that. The circuit board of the power supply looks like it has been soaked in coke:

There is some dried liquid all over the PCB.

There are no traces of that liquid inside the case, so my guess is a leaked capacitor. Maybe it was this one:

There are also traces of liquid on this capacitor.

A homemade repair is totally out of the question if mains voltage is involved. Modern switching power supply modules are simply too cheap for that. So the next item on my to-do list is: get a new power supply.

Let's have a look inside the Amiga. The metal cage is a bit rusty here and there, but all in all still in good shape. The circuit board inside smells a bit of cellar mustiness, but everything is in its place and nothing seems to be damaged. It all certainly does look very good!

The mainboard looks good. The self-made PCB is for an NMI button and is connected to the IRQ lines of the CPU.

For recapping I inspected all the electrolytic capacitors and listed their values. After that I found out that someone else did that work already. I will replace all the capacitors with premium ones, which sounds more dramatic than it is for cent items. I chose Panasonic caps with a lifetime of up to 10,000 h. The old capacitors were standard types with maybe a tenth of that lifetime.

What's next? The case is now on its way to the CBM Museum for bleaching. I've also placed multiple orders for the new power supply, the capacitors, the HDMI adapter and the floppy drive simulator. So let's wait for the deliveries.

Multiplication on a Z80 processor

The one thing computers are really good at is calulating. You might now expect that all CPUs are capable of the four basic arithmetic operations, but that isn't the case. The first 8 bit processors were only able to add and subtract numbers, and even the subtraction was performed by adding the negated subtrahend. Multiplication and division instructions first appeared on 16 bit processors, albeit they were still very slow in the first generation.

Simple multiplications and divisions with powers of two can be achieved by shifting a value bitwise to the left or right, respectively. This is, shifting a value by one bit to the left is the same as multiplying it by 2, while shifting by two bits to the left multiplies it by 4, and so on.

But how could you multiply any two numbers? It had to be done step by step, by using basic operations like addition or bit rotation. This article will explain how it works on a Z80 CPU.

Back at school, we have learned to multiply large numbers by long multiplication. Basically, we break up the problem by multiplying the multiplier with each digit of the multiplicand, and then summing the products. For example, if we want to compute the product of 27 and 12, we compute 27×2 = 54 and 27×10 = 270, and then sum the products 57+270 = 324.

  27 × 12
———————————
       54
 +    27∙
———————————
      324

We can use the same algorithm on a computer. But wait, wouldn't we still have to multiply, even if with smaller numbers? Actually not! Since computers use binary digits, we only need to multiply either by 1, giving the value itself, or by 0, always giving 0.

This is the the same long multiplication of 27 (11011) and 12 (1100) with binary numbers:

  11011 × 1100
————————————————
         00000
        00000∙
       11011∙∙
 +    11011∙∙∙
————————————————
     101000100

The steps can be executed in a loop. At the beginning, a result register is initialized with zero. If the rightmost bit of the multiplicand is 1, the multiplier is added to the result register. After that, the multiplicand is rotated to the right by one bit, and the multiplier is rotated to the left by one bit. This loop is repeated until the multiplicand is zero, because the result won't change after that anymore.

The following Z80 assembler code example multiplies the values in the BC and DE register pairs, and returns the product in the HL register pair. If an overflow occured during multiplication, the Carry flag will be set.

The multiplicant is kept in the BC register pair. To rotate it one bit to the right, we first use the srl b instruction. It rotates the B register, moving the value of bit 0 to the Carry flag, and inserting a 0 to bit 7, so the multiplicant is filled up with zeros with each rotation. After that, rr c rotates the C register and moves the content of the Carry flag to bit 7. Both instructions combined rotate the BC register pair one bit to the right, insert a 0 to the highest bit. The lowest bit is moved to the Carry flag, where it can be tested.

image/svg+xml0010010110011010Carry0BCCarrysrl brr c7654321076543210

We essentially do the same with the multiplier in the DE register pair, but in the opposite direction. As a rotation to the left by one bit essentially just doubles the value, we also could have used add de, de. Sadly the Z80 does not offer such an instruction.

multiply:	ld	hl, 0		; clear the result register
.loop:		ld	a, b		; is BC == 0?
		or	c		;   (also resets carry flag)
		ret     z		; then we're done!
		srl	b		; logical right shift of BC
		rr	c		; bit 0 goes to carry flag
		jr	nc, .zerobit	; unless bit 0 was 0
		add	hl, de		; add multiplier to result
		ret	c		;   return on overflow
.zerobit:	sla	e		; shift multiplier to the left
		rl	d		;   topmost bit goes to carry flag
		ret	c		;   return on overflow
		jr	.loop		; next iteration

The example only multiplies positive integers. To multiply negative integers, we first need to change all factors to positive numbers and do the multiplication. The result then needs to be negated if one of the factors was negative, but not both.

Reading Amiga Harddisks with Linux

While cleaning up the cellar, I found my Amiga 500 and also a GVP Impact Series II SCSI host adapter. Inside, there was a Fujitsu M2611SA harddisk. After about 25 years, I had totally forgotten about it, and I wondered what was stored on it. So let me take you on the adventure trip of how to salvage old Amiga harddisks on modern Linux machines.

The Amiga ecosystem has always been very SCSI friendly. Commodore broke this tradition only with the final AGA models, where they switched to the IDE bus to reduce costs. The Amiga community never approved this change, and many accelerator cards that were sold for these machines also came with a SCSI host adapter. The SCSI bus was a lot faster than the IDE bus. Also a single ribbon cable could connect up to seven SCSI devices, where the IDE bus only permitted two devices.

Today this SCSI affinity turns out to be a problem though. SCSI was never a topic on consumer PCs, so there are no SCSI-to-USB adapters on the market (I wish they were), and SCSI cards for the PCIe bus are very expensive. I'm still having an Adaptec SCSI card in my cupboard that I bought many years ago, but it is for the old-style PCI bus. Luckily there are PCI-to-PCIe adapters available on the market, so I could reuse this old card in my computer. The card stack looks adventurous, but it will do for a few hours of operation to backup the data.

The big question is: Can a modern Linux machine even read Amiga formatted harddisks?

Mounting Amiga Harddisks

Yes, it can. It seems that there are a lot of Amiga fans among the Linux kernel developers. The Amiga uses a different partition table scheme than PCs, but if you're lucky, your Linux will still detect the Amiga partitions and offer them as e.g. /dev/sdg1. Then all you need to do is to mount the partition via mount.

It didn't work on Fedora though, so I had to do some more typing. First I had to find out the offsets of the individual partitions. GNU Parted can be used for that, as it is able to decode Amiga partition tables:

# parted /dev/sdg
GNU Parted 3.3
Using /dev/sdg
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) u
Unit?  [compact]? b
(parted) p
Model: FUJITSU M2611S (scsi)
Disk /dev/sdg: 45078528B
Sector size (logical/physical): 512B/512B
Partition Table: amiga
Disk Flags:

Number  Start   End        Size       File system  Name  Flags
 1      52224B  45078015B  45025792B  affs1        DH0   boot

(parted) q

So there is only one partition on the HD. It starts at offset 52224 and is Amiga FFS formatted. Luckily most Linux distributions are able to mount this file system out of the box. The start offset is needed to mount the partition. I also mount it read-only to make sure that I won't accidentally change or delete my precious old data.

mount -o ro,offset=52224 -t affs /dev/sdg /mnt/

Et voilà:

# ll /mnt/
drwx------. 1 root root    0 Apr 16  1997 C
drwx------. 1 root root    0 Jun 11  1994 Devs
-rw-------. 1 root root 1233 Apr 16  1997 Devs.info
drwx------. 1 root root    0 Apr 16  1997 Fonts
drwx------. 1 root root    0 Apr 16  1997 L
drwx------. 1 root root    0 Apr 16  1997 Libs
drwx------. 1 root root    0 Feb 27  1992 Locale
drwx------. 1 root root    0 Apr 16  1997 Prefs
-rw-------. 1 root root 1238 Apr 16  1997 Prefs.info
drwx------. 1 root root    0 Apr 16  1997 S
drwx------. 1 root root    0 Apr 16  1997 Storage
-rw-------. 1 root root 1233 Apr 16  1997 Storage.info
drwx------. 1 root root    0 Jan  4  1992 System
-rw-------. 1 root root 1233 Apr 16  1997 System.info
drwx------. 1 root root    0 Feb 27  1992 Tools
-rw-------. 1 root root 1233 Apr 16  1997 Tools.info
drwx------. 1 root root    0 Jan  4  1992 Trashcan
-rw-------. 1 root root 1588 Apr 16  1997 Trashcan.info
drwx------. 1 root root    0 Feb  3  1992 Utilities
-rw-------. 1 root root 1233 Apr 16  1997 Utilities.info
drwx------. 1 root root    0 Apr 16  1997 WBStartup
-rw-------. 1 root root 1233 Apr 16  1997 WBStartup.info

Disk Dumps

As old harddisks are quite noisy, it might be a good idea to dump the entire content first, and salvage the partitions later. dd is the classic tool for creating a dump:

dd if=/dev/sdg of=amiga-hd.dd bs=512 status=progress

Later a loop device will simulate a real harddisk device:

losetup /dev/loop1 amiga-hd.dd

/dev/loop1 can now be used for parted and for mount.

To remove the loop device again:

losetup -d /dev/loop1

Smart File System

Back in the Amiga days, the Smart File System was very popular as an alternative to the original Fast File System. It was freeware, it was a lot faster than FFS, and it even had a stateless defragmentation that ran in the background.

The Linux kernel does not support SFS out of the box. However, Marek Szyprowski implemented a kernel module in 2003, which (sadly) never left the experimental stage and thus never found its way into the official set of supported Linux file systems.

To use it, you first need to set up a Linux with a 2.6.27 kernel, for example Fedora 10. After that, download the kernel patch and compile it to a kernel module. If you managed that, you can also mount Amiga SFS partitions. I was able to recover all files from an SFS partition that way, though it wasn't much fun.

PS: Sadly the harddisk I've found didn't contain forgotten source codes or other secrets. It just had a standard Amiga Workbench on it, and a copy of the game Scorched Tanks.

Read this article...
#Advertisement? This blog is free of ads. All shown products have been paid by myself.
Saturday, January 16, 2021
Glühwein aus der Mikrowelle

Dieses Jahr sind die Weihnachtsmärkte mit ihren Glühweinbuden ziemlich rar. Was gibt es dann schöneres, als sich zu Hause selbst eine heiße Tasse Glühwein oder Fruchtpunsch zuzubereiten. Aber geht das auch in der Mikrowelle?

Klar geht das, und sehr gut sogar, wenn man ein paar grundsätzliche Dinge beachtet.

Wichtig ist, dass der Glühwein nicht kochen darf. Die perfekte Temperatur für Glühwein ist um die 72°C. Ab 78°C verkocht der Alkohol, ein wichtiger Aromaträger. Erhitzt man ihn weiter, verändert sich zudem das Fruchtaroma. Überhitzter Glühwein schmeckt fade und bitter.

Es kommt also darauf an, die richtige Zeit an der Mikrowelle einzustellen. Aber auch die richtige Leistung ist wichtig. Mikrowellen dringen in Flüssigkeiten nur wenige Zentimeter tief ein, der Rest wird indirekt durch Konvektion erwärmt. Wählt man einfach die höchste Leistung, verkocht der Glühwein am Tassenrand, während er in der Tassenmitte noch relativ kalt ist. Bei kleineren Leistungsstufen kann sich die Hitze im Getränk gleichmäßiger verteilen.

Machen wir uns also auf die Suche nach dem passenden Rezept für unsere Mikrowelle.

Wichtig ist, möglichst gleiche Startbedingungen zu haben. Der Glühwein sollte vor der Zubereitung also immer dieselbe Raum- oder Kühlschranktemperatur haben, und man nimmt am besten auch immer die gleichen (und natürlich mikrowellengeeigneten) Tassen.

Das Rezept für meine Mikrowelle: 2 Glastassen zimmerwarmen Glühwein à 0,2 Liter, 440 Watt, 4:30 Minuten.

Mit diesem Rezept als Ausgangsbasis kannst du nun die richtige Leistung und Zeit für deine Mikrowelle finden. Du bereitest den Glühwein zu, entnimmst ihn aus der Mikrowelle und prüfst mit einem Tee- oder Kochthermometer die Temperatur. Ist der Glühwein zu kalt, verlängerst du die Zubereitungszeit beim nächsten Mal um ein paar Sekunden. Wurde er zu heiß, reduzierst du die Zeit. Schmeckt der Glühwein verkocht, reduzierst du die Leistung oder die Zeit etwas. (Das Thermometer bitte nicht mit in die Mikrowelle stellen!)

Wenn du nur ein Glas zubereitest, halbiert sich die Zeit in etwa. Bei vier Gläsern verdoppelt sie sich. Das ist aber nur eine Faustregel. Es lohnt sich, auch für andere Mengen durch Versuche die optimale Zeiteinstellung zu finden.

Hast du dein Rezept gefunden, bereitet dir deine Mikrowelle quasi von selbst den perfekten Glühwein zu. Du musst nicht wie beim Herd ständig rühren und die Temperatur überwachen, sondern wartest einfach nur auf den Signalton.

Wichtig: Keinesfalls Flaschen, Dosen, Getränkekartons oder verschlossene Behälter auf diese Art erhitzen, sondern immer nur einzelne Tassenportionen. Und wenn der Glühwein versehentlich doch gekocht hat, lasse ihn mindestens eine Minute in der Mikrowelle stehen, bevor du ihn entnimmst.

Restauring an old iRiver iHP-120, Part 2

In the first part, we have replaced the old Li-Po battery by a new one. In this part, we will replace the mechanical hard disk by a modern (and much larger) MicroSD card. Both parts are independent, this is, you could also replace the HDD but keep the old battery.

First of all, you need to install Rockbox on your player. This is an alternate firmware that will not only make your iRiver experience more enjoyable, but will also support larger hard disk sizes. The installation procedure is out of scope of this article, but Rockbox is providing a great installer tool that does most of the work for you.

You must install Rockbox before replacing the harddisk. The reason is that the original iRiver firmware won't boot from larger harddisks, but you need a running player to install a patched Rockbox bootloader via firmware update.

Your shopping list:

  • Toshiba 50-pin to CF card adapter – I use an HXSP-09CF69 adapter. I have tried an Adaptare 48012 adapater first, but always got ATA errors with that one. The adapter must be set to "Master" mode, usually by a switch or a jumper.
  • CF card to MicroSD card adapter – I use a DeLock adapter, but any other brand should work as well. You can also just use a CF memory card, but the combination of MicroSD cards and CF card adapaters is cheaper than CF cards of equal size.
  • MicroSD card – I use a 128 GB SanDisk Ultra MicroSDXC card, but any other brand should work as well. The card speed is not really a factor here. I couldn't find a maximum size that is supported by Rockbox, so maybe even larger cards will work.

As there are a lot of different adapters and MicroSD cards on the market, there is no guarantee that your combination will work. Remember that you use parts that have been totally utopian back in 2003. Also be warned that your hardware can be damaged by this modification. You do it at your own risk.

Before you move on, make sure that Rockbox is properly installed and started. Then connect your player to your computer via USB, and backup the .rockbox directory, and any other stuff on the old harddisk that you want to keep.

Also, please read the entire article first, before you start with the modification.

Prepare the MicroSD card on your PC. It must be FAT32 formatted and should be named like your player model (e.g. IHP-120). Copy the .rockbox directory from your backup to the MicroSD card. And while you're at it, use the chance and copy your music collection to the card. The access speed will be much slower once the card is in your player.

Now turn off your player, and open it again (as described in part 1). You only need to remove the back cover this time. No more disassembling is necessary.

Remove the harddisk by gently lifting it and pulling it out of the connector. Now try to insert the 50-pin adapter. For many adapters, a plastic nose on the connector will keep you from inserting it, so you may need to remove protruding parts of the adapter with a file.

It is normal that the connector has more holes than the header has pins. Just make sure that the position marked as "PIN 1" is properly aligned with the first pin of the header. This is what it looks like when the adapter and the CF card is correctly mounted.

The next step is important. The adapter might have a jumper for mode selection. If it sticks out, it may punctuate the battery when the casing is closed later, so bend it away (like in the photo) or just unsolder it and replace it with a wire bridge.

Now make sure that the CF card stays in place and won't touch the PCB even when the player is carried around. You can use some isolating tape, or a silicone mat cut to size. I constructed a small 3D printed piece that fills the space and keeps the CF card from loosening. You can put back the original silicone HDD frame on top of that, to keep the construction from vibrating or touching the battery.

It is a good idea to do a short test drive of your modified player now. It should boot up and start Rockbox. In the Rockbox file manager, you should see all the files on your MicroSD card.

You can close your player now. Be careful and don't use force if the back cover cannot be closed, but locate and remove the obstacle. Remember that the Li-Po battery on the back cover must not be damaged or punctuated.

Enjoy your new retro mp3 player!

Troubleshooting

If you should get ATA or "check HDD" errors, it can have a lot of different causes:

  • Make sure that your MicroSD card has a single primary partition, which must be FAT32 formatted. Other file systems (e.g. FAT16, NTFS) are not supported. Try a different formatter tool.
  • Check all the connections. Is the adapter properly aligned and connected to the header? Is it switched to "Master" mode? Is a header pin bent or broken? (A few pins may be a bit longer or shorter than the other pins though, that's normal.)
  • Remove the adapter and insert the original HDD. If your player still shows an error, the daugherboard may have been dislocated. Gently press it to the main board and try again.
  • Your combination of adapters and MicroSD card brands may be incompatible. Try to boot from a real CF memory card. Try other adapter or MicroSD card brands.

If you happen to have an iHP with a broken original hard disk, you can start with the replacement right away, but use a FAT32 formatted 16 GB or 32 GB MicroSD card first. The original firmware should start in this configuration, and allow you to install the Rockbox firmware, but this is untested. After the Rockbox firmware has been installed, you can use larger MicroSD cards.

Final words…

  • You do this modification at your own risk. It might not work, damage your hardware, and turn out to be an utter waste of money.
  • I cannot help you if your modification won't boot or won't run stable. I have already said all I know about it in this article. Maybe you can find help in the Rockbox forum.
  • I cannot print the 3D printed part for you. The stl file is available for free and can be printed by commercial print services.