Tutorial for an external 8x Kernal module for the C64

There are several ways to run a kernel in the Commodore C64 on the expansion port. There are a few small stumbling blocks. Of course it would be perfect to have the kernel compatible at the expansion port exactly as if it was built in. This is for example the case with the Easyflash 3 module. Thomas ‘SKOE’ Giesel has described this in detail in this document.

However, the effort to realize this is very high. Especially if you want to do this with normal TTL devices.

Another possibility is to start the kernel in the so-called Ultimax mode from an external module. The Ultimax mode is actually an emulation of the Japanese predecessor “MAX” from the C64. But this one had only 2k RAM and no own kernel, basic, etc.. Everything had to be loaded from an external module. This mode is still present in the C64, which allows to start a kernel from an external module.

And this mode can be used to boot a kernel from an external module. But with this method it is not possible to use the RAM area below the kernel. For this you need the method mentioned above, which is also used by Easyflash 3. Or one must lay a line between the kernel module and the CPU. Unfortunately the /HIRAM signal is not available at the expansion port. With this signal it would be quite easy to use the RAM area from $E000 to $FFFF. So without this memory area 8kByte are lost.

To copy the kernel into the memory area $E000-$FFFF at startup or reset of the Commodore C64, an address decoder is needed. For this purpose a 74LS30 is used. This is an 8x NAND gate.

Apply the following signals from the expansion port to the inputs of the NAND gate:

  • Phi2
  • Addresslines
    • A13
    • A14
    • A15
  • R/W
  • BA

And the output of this gate is switched to /GAME. The EPROM is connected to the address lines A0 to A12 and the data lines D0 to D7. The CE and OE lines go to ROMH.

This is how the whole circuit would look like:

This would be the basic circuit. What is missing are the basic points, such as the blocking capacitors, pull-up resistors, etc.. Of course these have to be provided in a later implementation.

With this you can now run an 8kByte kernel on the expansion port of the C64. If you want to switch multiple kernels, you need a larger EPROM or EEPROM and a way to select the address lines.

Since meanwhile the 512kbit large EEPROMs from Winbond (W27C512) are almost given away, it was my goal to use this for my external kernel module. This memory chip can be written with the usual EPROM programmers, like the popular TL866A without any problems and it can be erased just as easily. For this, in contrast to EPROM, no UV light is needed, but the erasing process is also done by the EPROM programmer. Because these memory chips can be erased electrically.

Of course, EEPROMs can be used. Also it does not have to be such a “big” memory chip. It can be also a 256kbit or also only 128kbit large chip selected.

I remain with my example however times with the 512kbit version. This one holds, to express it in kilobytes, 64kByte of memory. Since the kernel is only 8kByte, 8 of them fit into one chip. I admit that this is probably only needed in the rarest of cases. I myself already had difficulties to find 8 different kernels at all, which differ not only in color and power-on message.

Depending on the size of the memory chip you have up to 3 additional address lines, which can be used to select the appropriate kernel. The kernels are stored one after the other in the E(E)PROM. So there are 8x 8kByte areas in the E(E)PROM. Furthermore 3 address lines (A13 to A15) are necessary to select these 8 single sections. And this is done by binary values.

The 8kByte correspond to 8192 bytes, which would be 2000 bytes in hexadecimal format. Since you start counting from 0, the first kernel would be from $0000 to $1FFF, the second kernel from $2000 to $3FFF and so on. So the previously mentioned EEPROM of Winbond has memory from $0000 to $FFFF.

The logical table looks as follows:

No.Memory areaA13A14A15
1$0000 – $1FFFLLL
2$2000 – $3FFFHLL
3$4000 – $5FFFLHL
4$6000 – $7FFFHHL
5$8000 – $9FFFLLH
6$A000 – $BFFFHLH
7$C000 – $DFFFLHH
8$E000 – $FFFFHHH
L = LOW / H = HIGH

So you just put the corresponding lines on 5V, depending on which kernel you want.

There is, however, a small stumbling block between the 64kb/128kb and the 256kb/512kb devices.

Image title

Your subtitle here

As you can see on the picture above, the lines at PIN 1 and PIN 27 of the 256kb and 512kb devices are also address lines. So these lines can’t be set to high with 5V at these types. This must be considered with a switching possibility. If one would leave both lines generally on 5V, one could select only the last two kernels, as this can be taken well from the table further above.

On the other hand one should not put the two lines on LOW, i.e. GND, with the 64kb and 128kb memory chips. So this should be taken into account when switching. The easiest way to do this is to use a DIP switch.

The circuit diagram would be as follows:

Image title

Your subtitle here

So I started to test the whole thing on a breadboard. At the beginning I tested with two EPROMs up to 256kb each. Then I noticed that the 512kb EEPROMs have become so cheap that it is actually unnecessary to provide two slots. Especially since probably rarely really so many kernels are needed.

Pure chaos. These plug-in boards are truly not beautiful. But to test something, almost indispensable. You should choose Dupont connectors of higher quality. The cheap ones from China have contact problems here and there, which can drive you crazy, because you constantly have to wiggle around somewhere, so that it works. Therefore, you really shouldn’t save at the wrong end.

Of course you might ask why there are so many more components than on the schematic above. Well, just to connect an EPROM to the expansion port is boring. So I was trying out different things, especially the switching.

After I had tested the circuit so far, and everything worked so far, I built the circuit on a breadboard.

Ich habe auf das zweite EPROM verzichtet. Um das umschalten etwas schöner zu gestalten, wollte ich für jeden Kernel einen eigenen Schalter haben. Nicht jeder mag vorher sich seine Auswahl in eine Binäre Form umrechnen. Sicherlich ist dies reiner Luxus und nicht notwendig. Andererseits war dies kein Projekt aus irgend einer Notwendigkeit heraus, sondern eher aus Spaß am basteln.

So kam also ein Encoder (74LS148) hinzu, der aus 8 Leitungen, die jeweils einem DIP Schalter entsprechen und den 8 möglichen Kernel gegenüber stehen, die Binären Signale erzeugt. Und wenn man hierfür wieder eine Tabelle anlegt, ergibt sich ein ähnliches Bild, wie aus der weiter oben dargestellten Tabelle:  

DIP SWS0S1S2
1HHH
2LHH
3HLH
4LLH
5HHL
6LHL
7HLL
8LLL

If you take a closer look at the table, however, you will notice that High and Low are swapped. So it is not possible to control the EPROM or to select the single kernels. To invert the SIgnals, the 74LS04 is the perfect solution. This chip offers 6 drivers, whose output is also inverted. So a high at the input becomes a low at the output and vice versa.

And now it fits again. I used the two remaining DIP switches to switch between the 64kb/128kb and 256kb/512kb EPROM types, and an on/off switch for the card. This way the card can stay in the expansion port, but no kernel of the card is used.

At this point the card would be finished, if the play instinct would not have awakened.

Why not add some gimmick to it. And since there was a box with 7 segment displays lying around, I had the “stupid” idea, that it would be a great idea to put such a display on it. The practical thing is, that there is a chip with the 74LS247, which has everything inside, what is necessary. It can directly drive a 7 segment display. So there is no need to connect any power drivers behind it. And it is also binary controlled.

So only the signals that are needed for the address lines of the EPROM have to be tapped, and voilà, the board is ready, at least on a breadboard:

It actually looks quite tidy. I admit that the backside doesn’t look quite as fresh, especially since I had to move some things around again due to the added changes. But since it was only a prototype, a perfect installation was not my goal.

Since in digital technology counting always starts from 0, the first kernel is of course also the 0 kernel. Consequently, a 0 is naturally also displayed. The second kernel would be the 1, the third the 2, and so on. I was still thinking if I should adjust this accordingly. However, then the circuit would have become even larger, or I would have had to use a small microcontroller. I found that only for the display, the effort would not be justified.

The whole thing should be more a little fun than a real serious application.

I tested the prototype with the following memory devices:

  • AM27C64
  • AM27C128
  • AM27C256
  • AM27C512
  • AT28C64
  • AT28C128
  • AT28C256

I could not identify any problems. The switching is clean and without difficulties. Long-term tests over several hours also showed no abnormalities. So why not make a real circuit board out of it?

I have to admit that it’s different. But I had actually only started with the variant without display. Then I had the idea to add a 7 segment display. There, the selected Kernal is displayed as a number.

I admit that this does not serve a larger function, but I had the parts there by chance. And somehow the idea came over me, so why not.

The E(E)PROM is connected to the A0 to A12 address and D0 to D7 data lines.

The selection of the kernel is done by bank selection of the higher address lines A13 to A15.

The circuit diagram for this is quite simple.

This is sufficient for a simple kernel adapter on the expansion port of the Commodore C64. With the 3 address lines 8 banks can be selected, which corresponds to 8 kernels, if a 64kByte E(E)PROM is used. Because here is switched bitwise, the binary system must be used.

Decimal1. Bit2. Bit3. Bit
0000
1100
2010
3110
4001
5101
6011
7111

And this is the way to set the eight different Kernal. It is simple and functional, but certainly not comfortable. This was solved a bit more elegant with the REX 9628 External Kernal. There a 74LS148 BCD encoder was used and a DIP switch for every single Kernal. And this encoder does nothing else, and sets the bits at the output according to this table. So you don’t have to calculate in your head which position is responsible for which Kernal.

Another possibility would be to use a so called rotary encoder. These are small rotary switches, which are also available as BCD variants. There are 8 positions, which represent the digits 0 to 7. And at the output you find again the 3 bits at 3 output lines.

Unfortunately I didn’t have such a switch here, and also price-wise they are much more expensive than just using this encoder and a 8x DIP switch. But I haven’t quite buried the idea yet and I’ll see what our friends behind the big wall have to say about it.

The lines still have to be inverted, which is why a 74LS04 is used. This can also be found on the REX 9628 board. As already mentioned, the REX card uses two EPROMs to make 8 Kernal usable. In my opinion, the necessary switching is done very awkwardly. This could have been solved more elegantly also at that time.

So now the rebuild of the new REX 9628 card would be ready, with the same features, but only one EPROM. And I left out the Game Stop, because I personally didn’t see any sense in it.

Well, there was suddenly the idea with the 7-segment display. Of course you can always read off the DIP switch, which Kernal is set, because there are now 8 switches, and each one represents a Kernal. But it is a nice gag, at least I think so.

And actually this is also very simple to realize, because there is with the 74LS247 a component, to which one can connect directly an appropriate display. The 74LS247 is a BCD decoder, incl. driver for a 7-segment display with common anode. Except for the typical series resistors, no driver stages are needed. This is all already built into the chip. and through the encoder it displays the bits as decimal numbers.

So you can easily integrate this display into the circuit.

Then there is a switch for the “big” and “small” EPROMs and a general on/off switch, so that the card can stay in the expansion port, even if it is not used.

The switch for the EPROM is connected to the address line A14. With this switch A14 can either be set generally HIGH or switched by the DIP switches. For the 8 and 16kByte EPROMs A14 is generally set to HIGH, and for the even larger 32 and 64kByte EPROMS again A14 is also needed for the selection of the individual banks.

In summary, this results in the following circuit.

And from this circuit I designed the following board in KiCad. Here first the 3D design out of the software.

<br>

What is not visible on this graphic is the switch for the EPROM size. This sits under the EPROM. On the one hand it fits there perfectly, and on the other hand you can’t change this switch by mistake. A reset switch has also found its place. And so the “Pro” version of the Rex 9628 card was created.

Today, after 3 weeks, the delivery with the prototype boards arrived.

Here you can also see the switch below the EPROM. Please don’t be surprised about the name, but I changed it in the meantime, because I didn’t like it that much. In the current Gerber files this name is no longer visible.

You can also see the parts mentioned above.

Parts list

The parts list, except for the slide switches looks as follows at Reichelt:

Click on the image to go to the shopping cart…

There is also a matching shopping cart at Reichelt, except for the two slide switches. Unfortunately, Reichelt does not seem to carry them. Conrad Electronic has them under the order number 1564871.

In the list above I have used a 27C512 EPROM as a substitute. Personally I recommend the already above mentioned M27C512 EEPROM from Winbond. For the price of one EPROM you get almost 10 pieces as electrically erasable EEPROM. But I leave that gladly to everyone itself.

With about 20,- Euro, the board included, you get an external Kernal board, which is 8x switchable and can be used at the expansion port of the Commodore C64. If you have time and order the parts in China, you can even save a few Euros.

Building instructions

Once you have all the parts and the board, it’s time to assemble.

As usual with such assemblies, you start from small to large. The first step is to solder the 7x 220 Ohm resistors and the 5x 100nF capacitors. Since there is no polarity to consider here, the mounting direction is not important.

Next the two slide switches should be soldered in. The mounting direction should be clear, but can be checked again on the following picture.

Now follows the resistor network. Here you have to pay attention to the polarity. On the label side of the resistor there is a clearly visible spot on the left side. This spot must be located where the rectangular solder pad is on the PCB. Furthermore, the 10k imprint is also located at this spot on the board. Unfortunately, you can’t see the dot in the picture, but it would now be at the top near the slide switch if it were in this position.

Now it’s time for the IC sockets. It’s best to put them in from the top first and then put a little bit on top of the board so that it can be turned like a pan. Then solder the two diagonally opposite pins of each socket. This way they are fixed and can’t fall out anymore. Check the fit and solder the remaining pins.

The last step is to solder the DIP switch, the push button and the 7-segment display. This completes the soldering work. Now insert the ICs and the board is ready for operation.

Burn EPROM

What is missing now is an EPROM, or EEPROM with the appropriate Kernals, The Kernal of the Commodore is 8kByte large, which corresponds to 8192 bytes. In the internet you can find many Kernals, which are 2 bytes bigger than the total of 8294 bytes.

This is because these files were prefixed with the load address. This was needed in former times when EPROMs were burned with the Commodore C64. But if the files are burned on a PC, these two bytes would interfere. The software for the Commodore EPROM burners did not write these two bytes to the EPROM. But today’s PC programs would do this. By the two bytes at the beginning, everything shifts so naturally, and the burned EPROM will not function.

If you have a suitable file with 8192 bytes, you can skip the next section.

Correct Kernal file

The easiest way to remove the two bytes from the file is to use a HEX editor. I would recommend the free software HxD – Freeware Hex-Editor and Disk-Editor. There you open the Kernal file, delete the first two bytes and save the file again

Here for example would be such a file. If you look at the properties in the explorer, you see that it is not the expected 8192 bytes, but 8194 bytes.

Now that Hex Editor has been installed and opened, clicking and then will open the file.

Now mark the first two bytes with the mouse.

And press the remove button and delete the two bytes. The warning message is confirmed with.

And the two disturbing bytes are gone. Now the file must be saved. To do this, click again on, followed by , assign a new file name and save.

If you now look in the Explorer under Properties again, you will see that the file has the right size.

This file can now be written into an EPROM or EEPROM.

Create file with multiple Kernal

Now one will certainly not want to use only one Kernal with such a card. Depending on the memory size, 1, 2, 4 or 8 Kernal can be used. If a 512kBit EEPROM is assumed, this would be a total of 8 different Kernal.

So that one can write the Kernal into the EPROM, the individual files must be combined to a single large file.

The easiest way to do this is to copy the 8 files into one directory. Now there are two ways to combine these files to one single file.

Create EPROM file with HEX Editor

If you have installed the Hex Editor mentioned above, you can use it.

For this one calls under , the point.

With you add the 8 files. For my example I had numbered the files simply by. This is only for clarity. This should not be done, because you don’t know which Kernal is behind which file. With the green arrow keys the order can still be adapted. Now enter the file name for saving under “Output file name:” and confirm with . As ending I would take .BIN or .ROM.

If you then look at the newly created file in the Explorer, it is now 65536 bytes in size. And exactly this size the file must have.

Create EPROM file with COPY command

The second possibility to create a file for writing is the COPY command of Windows. For this a command prompt is needed.

With the command , known from DOS times, several files can also be copied together to a single one. To do this, the individual files are joined together with a “+” sign.

Very important is the parameter “/b”. This way the copy command knows that the files are binary files. If you forget to set this parameter, the created file will not work.

The command would look like this

copy /b KERNAL-1.BIN + KERNAL-2.BIN EPROM.BIN

The first two files are merged and stored in the file EPROM.BIN. And by the parameter /b Copy knows that the file must be treated as a binary file. And this can be done not only with two files, but also with 8 or more.

And again the created file “eprom.bin” must be exactly 65536 bytes.

Notes about the file sizes

As already mentioned, the kernal must be exactly 8192 bytes large. Many tools often show the value in kByte. This would be 8kByte. But Windows likes to round up. So 8190 bytes or 8194 bytes are still displayed as 8kByte. So you can’t rely on this display at all. Always display the byte size, this is the only way to make sure that the file is correct at least in size.

The EPROMs, and EEPROMS are usable in 8, 16,32 and 64kByte sizes. The following table shows the corresponding values.

EPROM TypeSize in kbitSize in kByteSize in Bytes
27C646488192
27C1281281616384
27C2562563232768
27C5125126465536

Of course, this also applies to EEPROMs.

Handling

Before the EPROM is inserted, the switch must be set according to the size. For 8 and 16K types, the switch is set to the lower position, in the direction of the expansion port. If 32 and 64k EPROMs are inserted, then upwards, towards the 7-segment display.

Now the E(E)PROM can be inserted.

At the top left of the card is another small switch. This switch is used to turn the card on or off. So the card can stay in the expansion port and after switching off the card the internet Kernal of the computer is used.

The DIP switches are used to select the Kernal. By simply setting one switch to the ON position, this kernel is selected. If two switches are accidentally set to ON, the higher value switch always counts. For example, if switch no. 3 and switch no. 6 are set, the 6th kernel is selected.

The respective number is shown on the 7-segment display. It is counted from 0 to 7. The 1st Kernal therefore has the number 0 and the 8th Kernal the number 8.

Download

For this little gimmick I didn’t open an extra GitHub repository now, but make the files available for download directly here:

Project 8x Kernal Module Pro

png

Schematic - 8x Kernal Module Pro V1.0

Size: 855.44 KB
Hits: 27
Date added: 05-04-2021
zip

Gerber - 8x Kernal Module Pro V1.0a

Size: 185.17 KB
Hits: 44
Date added: 05-04-2021
zip

BoM - 8x Kernal Module Pro V1.0

Size: 1.74 KB
Hits: 26
Date added: 05-04-2021

4.6 76 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x