hosted by guitarsite.de


Creating EPROM Images From Multiple *.BIN Files
Content
1. Introduction
2. Softwaretools
2.1 BIN Wizard
2.2 The TL866 Programmer Software
2.3. Merging *.bin Files with the HxD HEX Editor
2.4. Merging *.bin Files with Windows


1. Introduction


In case you are using an EPROM cartridge, like the
Versa64Cart, the OpenC64Cart or a Kernal Adaptor for the Commodore C64 or other, it is likely, that you want to combine a couple of smaller binary (*.bin) files to one image, that you can program onto an EPROM. Very often, a single *.bin has a size of 8kB or 16kB, but the EPROM allows to program 64kB onto it. And the cartridges mentioned before (and the Kernal adaptors) allow switching the EPROM memory banks.

Combining several *.bin files is not a trivial thing and requires tools and a bit of knowledge. Some working methods are described here.

First of all, it is important to know, what a memory bank/slot (or offset address) is and how it is related to the address of the C64/target system. For the C64, the 8k Kernal ROM always appears between address 0xE000 and 0xFFFF (those are hexadecimal numbers, in the Commodore world, they are very often noted like $E000 and $FFFF). The PLA ( a logic chip) makes the content of the ROM (or EPROM in a suitable adaptor) appear in this address space.

Which part of the EPROM appears there is usually selected by the adaptor in some way. When the adaptor selects the first 8k, the memory bewteen 0x0000 and 0x1FFF (EPROM memory address) appears between 0xE000 and 0xFFFF. The base address of the Kernal is 0xE000 (right, the PLA takes care of it!), 0x0000, 0x0001, ..., 0x1FFF are offset adresses, they are added to the base address to get the address, where the memory content is seen by the CPU of the C64/target system. If there is more than 8k programmed in the EPROM, this content will not appear beyond 0xFFFF (the highest possible address in an C64).


Memory Bank Selection of a C64 Kernal Adaptor


The 8k Keral ROM of a C64 sits in a socket with 13 address pins (A0...A12). A 27C512 EPROM has 16 address pins (A0...A15). To make use of the full memory content, the address pins A13, A14 and A15 are set by the adaptor circuit (e.g. some jumpers). So the adaptor can make the EPROM memory bank, selected by the jumpers (=by setting A13, A14 and A15) visible to the C64. It will still appear between 0xE000 and 0xFFFF for the CPU. The CPU does not noctice, which memory bank of the EPROM was selected.

The circuit shown is the C64 Long Board Kernal adaptor, which is available on my
github repositories.

This table shows the offset addresses of 8kByte memory banks in a 27C512 EPROM (that is 64kByte).


Bank No.
A15
A14
A13
EPROM Offset Addr.
0
0
0
0
0x0000 - 0x1FFF
1
0
0
1
0x2000 - 0x3FFF
2
0
1
0
0x4000 - 0x5FFF
3
0
1
1
0x6000 - 0x7FFF
4
1
0
0
0x8000 - 0x9FFF
5
1
0
1
0xA000 - 0xBFFF
6
1
1
0
0xC000 - 0xDFFF
7
1
1
1
0xE000 - 0xFFFF

8k memory banks

Note: 1kByte is not 1000 Bytes, but it is 1024 Bytes. That is 2^10 Bytes.

A *.bin file has to be loaded to exactly the start address of a memory bank. Everything else will result in the bytes not being in the place (=address), where they belong, which will always be a mess and will not result in anything that is working properly.

In case it is intended to set up a couple of 16k images (for teh Versa64Cart or the OpenC64Cart 16k), the images have to be placed at memory banks like this:

Bank No.
A15
A14
EPROM Offset Addr.
0
0
0
0x0000 - 0x3FFF
1
0
1
0x4000 - 0x5FFF
2
1
0
0x8000 - 0xBFFF
3
1
1
0xC000 -0xFFFF

16k memory banks

In a Versa64Cart, it is possible to mix 8k images andn 16k images. Both sorts of images have to be placed at offset addresses like shown in the tables above. To simplify the configuration, place the 16k images first.

2. Softwaretools


2.1 The BIN Wizard
The BIN Wizard is a software provided by Damian Woroch. It can be downloaded
here and is the most comforable way to merge several *.bin to one EPROM image. No installation required.


BIN Wizard: Setting up the image

The images can be added with "add", the user inteface is very comprehensive. Missing bytes will be filled with 0xFF and size, start and end address of the image are displayed. The sequence can be modified and finally, the image will be saved by clicking "Merge!".


BIN Wizard: Saving (Merging) the EPROM image

The resulting image file is again a *.bin file. It is recommended to name it carefully for later use.

2.2 The TL866 Programmer Software
The (Xgpro) TL866(II Plus) is a wide spread programmer for EPROMs, Flash Memory, Microcontrollers etc. The software that comes with this programmer is capable of loading binary (or HEX) files to the desired locations in the programmming buffer, which can also be saved for later use or immideatly programming the EPROM.

After selecting the EPROM type, a buffer in the size of the EPROM is present in memory.


Loading a *.bin file with default options

The first *.bin file can be loaded with the default options (as shown in the image above). It will be placed in the lowest memory bank and the rest of the buffer is filled with 0xFF, which is handy, because this is the state of a not programmed byte.


Program buffer
All following *.bin files have to be loaded with a proper address offset and “Clear Buffer…” disabled . The “TO Buffer… Addr (HEX)” address can be found in tables (8k memory banks or 16k memory banks).


Options for the second 8k file

Note: It is even possible to load the content of an already programmed but not completely filled EPROM, find a free memory bank (which is filled with 0xFF), place a further *.bin there and program the EPROM without having to erase it prior to that.

It is strictly required to load the additional *.bin files to the memory banks shown in the tables.

2.3. Merging *.bin Files with the HxD HEX Editor

A HEX editor, which allows to see the bytes as hexadecimal numbers is probably suitable to merge the *.bin files. The
HxD editor offers this functionality. Thus, it will be explained, how to do the task with this software.

First, it is important to check, whether the images have exactly the right size (which is 8k or 16k). Otherwise the merged images will not be in the right position in the begin of a memory bank. This will cause a malfunction, since the software will not start properly. The result might be a black screen or a boot screen, showing a number less than 38911 basic bytes free.


*.bin file of a not suitable size


An 8k *.bin has to fill the exact address space of 0x0000 – 0x1FFF, which is a byte count of 0x2000 (=8kbyte). The file shown in the figure above is missing one byte. This has to be filled up with preferably 0xFF (or any other value).


Inserting a byte with the HxD editor

Move the cursor at the position of the missing byte and select the operation “Insert bytes…” from the “Edit” menu. Here one byte is missing, so the byte count is “1”. The HEX-value is “FF”.

Some old EPROM images are 4k in size. This has to be filled up. So, again, position the cursor after the end of the data (0x1000, assuming, that the size is exactly 4k) and insert a
hex byte count of 0x1000 (which is exactly 4k) to fill up to an 8k image.

Finally save the *.bin file. Fill up all files to 8k (0x2000 bytes) or 16k (0x4000 bytes).

After this operation, the files can be concatenated to get a proper image for the complete EPROM spanning over up to the maximum memory banks for the intended EPROM.


The Concatenate... tool

Select all files, that are intended to be programmed in one EPROM, specify the output directory and file name (…) and click ok.


Concatenating the *.bin files

The output file can be used for programming an EPROM. The risk of the concatenate tool is, that a file does not have the proper size.

2.4. Merging *.bin Files with Windows
Combining several *.bin to one file can be accomplished with the copy instruction, that is part of Windows. To execute it, it is required to start the Windows Command Processor. This is accomplished by entering cmd in the search box like shown in the image below.


cmd being entered in the search box

First, you have to make sure, that your *.bin files are in one directory. The size is displayed by the
dir command (refer to the image below).

For an 8k image the size has to be exactly 8192 bytes, for a 16k image, it is 16384 bytes. In case those values are not exactly the same, the image will not be in the right position and the cartridge will not work (except for the first image). Such a problem can be fixed with the HEX editor as described in the chapter 2.2.
.
To make sure, that 16k images are in a correct memory bank, it is suggested to put the 16image(s) on the first positions, followed by the 8k images. Alternatively, an even number of 8k images in front, will also work.

Merging of the *.bin files is accomplished with the
copy command:

copy /b 16kimage1.bin + 16kimage2.bin + 8kimage1.bin epromimage.bin

Format of this instruction:

copy /b <input file 1> + <input file 2> + <input file 3>… <output file>

The execution of this command is shown in the image below. It should be paid attention to the output message of the copy command. All desired input files should be enumerated here.


Executing the required commands on the Command Processor shell

For this page, I have re-used a part of the manual, which I wrote for bwack's Versa64cart.

Dec. 29th, 2019