Pi1541 WIKI / FAQ

Pi1541 DOES NOT run Raspbian! It runs to close to the bare metal. If you are an experienced user of Raspberry Pi OSs, don’t expect your usual tool chain to work.

https://cbm-pi1541.firebaseapp.com/
Donate via PayPal <- Our devs gotta eat!

Overview

Pi1541 consists of a Raspberry Pi 3 (A,B,B+) and a specific hat/cable. There are two types. The first type (referred to as a “Type A”) can be the only thing plugged into a Commodore Serial Bus. The second type (referred to as a “Type B”) supports multiple peripherals on the Commodore Serial Bus. A thing to note, however, is that there are many applications and demos that assume that there is only one device on the Bus and simply won’t work with additional peripherals on the bus. (This has been confirmed to be the case with real hardware)

The adapters can be as simple as a connector / cable combo made by hand through to multifunction “Hats” with buttons, buzzers (To simulate drive noises) and screens.

The Pi1541 in operation is modal, with two modes. The initial mode is the browse mode, where the files on the memory card can be navigated, and one (or more) disk images can be selected. Once an image is selected, the unit converts to emulation mode, where it emulates the 1541 at a low level, allowing excellent compatibility with applications, demos and games.

Unlike SD2IEC, Pi1541 emulates a 6502 and the two 6522s. Any code it is asked to run is run in a cycle exact way. SD2IEC supports a limited set of fast loaders by attempting to guess the fast loader from the code sent to it. SD2IEC will not, and cannot, execute the code, it just simulates the communication protocols. Therefore, only a small amount of popular fast loaders are supported. As Pi1541 can execute code on its emulated 6502 core it supports a vast range of fast loaders (games and demo scene) and even copy protected originals.

There is no 1571 support yet so currently that cannot be used.

Compatibility

Pi1541 has successfully been tested with the following hardware:

Commodore VIC20
Commodore 64
Commodore 128
Commodore 128D (You’ll need to either set your Pi1541 to a different Device ID other than “8” or modify your internal drive)
Commodore SX64 (You’ll need to either set your Pi1541 to a different Device ID other than “8” or modify your internal drive)
Commodore Plus 4
Commodore 16
E-mu SP-12 drum machine

Hardware

Voltage level converters should be the ones with four discrete transistors on each line rather than an "all in one" chip, or the ones with only 2 transistors.

If constructing a “Type B” hat, some 7405/6 series will not work. Make sure you buy a brand name. The Texas Instruments ones seem to be consistently reliable. 74LS05/6 are fine. (You can actually use any open collector driver chip. 7405,7406,7407,7416, 7417 in either normal or LS variants. If you use an 07 or 17, you need to set the invertIECOutputs bit in the config.txt file)

Make sure you have a STRONG PSU for the Raspberry Pi (2.5A and a brand name). Many problems have been traced to inadequate power supplies, including knockoffs that are “rated” at the right amps but are unable to deliver. Remember, your Pi won’t be hurt by “too many Amps”.

SETTING IT ALL UP

Format an SD card to Fat32. (SDFormat will help here. If your card isn’t showing al the useable space because you’ve used it for some other project, it will even recover unused space)
Download the Raspberry Pi Firrmware from the Raspberry Pi Foundation.
Once downloaded Unzip the archive.
Copy the 3 files (bootcode.bin, fixup.dat and start.elf (found in firmware-master\boot)) into the root folder of your SD card.
Unzip the supplied zip file (Pi1541.zip) to the blank SD card. (This will create a folder called 1541 in the root folder of the SD card. This is where you can place your Commodore disk images and folders).
Copy over a file that contains a 1541 ROM image (eg vice-3.1\DRIVES\dos1541) into the root folder of the SD card. The ROM must be called dos1541 or d1541.rom or d1541II or Jiffy.bin.
(OPTIONAL) Copy over a file that contains a CBM font ROM (eg vice-3.1\C64\chargen) into the root folder of the SD card. The ROM must be called chargen.
Copy your disk images and folders into the 1541 folder now found on the SD card.
Add a hat or cable.

Enjoy!

KEYBOARD

Primary movement is managed via the cursor keys, with the “Enter” key to select a disk image.

If you wish to select multiple disks, highlight each disk in order and press the Insert key. The number keys can then be used to manage the first 9 disks simply by clicking the corresponding number key

F1-F7 Function keys select boot ROM (Specified in the config file. See below)

F8-11 chooses device number for the Pi1541 (Device 8-11)

Pg Up / Pg Dn to skip pages (in games lists)

Alt-L creates a .lst file of all the selected files. (If no files are selected, it makes a .lst file of all files in the directory.

C= + Shift if you see garbage on your C64 listing screens. (It puts the C64 into lower case mode)

If using only buttons on the PiHat, the 5 buttons (by default) map to the following key functions:

Button 1:              Enter / Select
Button 2:              Up
Button 3:              Down
Button 4:              Back / Exit
Button 5:              Insert / Multidisk (See below)

If purchasing a PiHat, please check the Hat documentation for which button maps to which number.

FB64

Yeah I haven’t used this mode. TEXT TO GO HERE SHORTLY.

Something. Something. AutoMountImage. Something

Whilst in browse mode the following SD2IEC commands have been implemented and can be used;-

·         CD – change folder

·         MD – make new folder

·         RD – remove folder

·         CP – Change partition (ie change device 0 = sdcard 1 and above = usb drive)

·         C - Copy

·         N – New D64

·         R – Rename file

·         S – Scratch/Delete file

·         U0 – Change drive’s device ID

VIDEO

HDMI, Composite, Raspberry Pi official 7" screens or I2C ONLY (At this point). You can't use screens that drive directly off the GPIO pins.

To use composite, you need the TRRS adapter for the A/V port and you’ll need to update the options.txt file with a suitable ScreenWidth and ScreenHeight value.

SCREENS

To use a screen, depending on your hat you’ll need to modify the config file (see below) and uncomment ONE of the lines below.

i2cBusMaster = 0 //SDA - pin 27 SCL - pin 28

OR

i2cBusMaster = 1 // SDA - pin 3 SCL - pin 5

You will also need to comment in the line matching the screen you are using. Eg:

LCDName = ssd1306_128x64

To create your own boot screen… (I used mostly “free” tools to do this like XNView, HxD and Notepad++. For this example I’ll use references to XNView, HxD and N++)

1.       Make yourself a 128 x 64 pixel image.

1.1.    From XNView, first use the crop tool to get your image close to a 2:1 width to height ratio. The closer you get, the less stretching you’ll see.

1.2.    Go to Image > Resize… and set the width and height to 128 Width and 64 Height. Untick Keep ratio if it’s ticked. Press OK

2.       Convert to black and white with around 50% diffusion dithering (Invert colors, depending on conversion tool)

2.1.    Go to Image > Binary and choose a dithering technique. I like Floyd Steinberg.

3.       Save as .gif (or whatever your conversion tool supports) somewhere you can find it.

4.       Convert image to code using proper conversion tool (http://www.majer.ch/lcd/adf_bitmap.php for example)

4.1.    Simply click the “Choose File” button and select the file you saved in step 4, then click “Convert File”. It’ll generate a whole heap of text.

4.2.    Save this text into Notepad ++

5.       Strip data portion to keep only hex data (0xFF, 0xAC -> FFAC) (Notepad++ was good for this using find replace. Just find 0x and replace with nothing)

5.1.    First remove all the headers and tail. Remove everything before (and including) the first “{“ and everything after (and including) the last “}”

5.2.    Do a Replace (Search> Replace…), making sure Extended Search mode is selected.

5.3.    Search for ‘0x’ and replace with nothing (Leave the field blank). You should get 1024 replacements.

5.4.    Search for ‘, ‘ (Note the space in there) and replace with nothing. You should get 1023 replacements.

5.5.    Search for ‘\r\n’ and replace with nothing. You should get 103 replacements. This gives you your raw file,

6.       Paste hex data into hex editor and save as .raw.

6.1.    Open HxD and paste the final line of text from Notepad++.

6.2.    Simply save the file. File > save as and name the file something that ends in .raw Save it somewhere you can find it.

7.       Copy the file to the root of your memory card.

8.       Edit options.txt and set LcdLogoName to the name of your bitmap file.

9.       Boot and Enjoy!

MULTIPLE DISKS

Remember with multiple disk titles ALL images need to be pre-selected.

You do this by highlighting the first disk image.

On the keyboard press the insert key or button 5 on the pi hat.
Now highlight the second and last disk and press enter on the keyboard or button 1 on the pi hat. Pi1541 will now load all selected images and display the list of disk images prefixed by a number.

You can swap disks by pressing that particular number on the keyboard or use the up and down buttons (2 and 3) on the pi hat.

You can also make a .LST file and select that (a text file in the same folder as the disk images with a list of the disk images filenames).

Exiting out of a disk image back to the Pi1541's browse mode is like power cycling a real 1541 every time you flip the disk. Most multi disk software is not expecting this (as their loaders will be wiped from the drive's memory).

LST files are descriptor files for multiple disk images. Along with the disk image names you can also list a ROM name from your ROMs set (listed in your options.txt file) and it will automatically switch to it when the LST file is selected from FB64. FB64 will then display the 1st disk image and you can use your buttons to swap to others.

OTHER

When building a PiHat, use passive buzzers (Without generators)

Some sellers are supplying their own zip file for setting up a SD card. They do not have any right to include any Commodore or Jiffy ROMs. I provide all the files and instructions required to set up a SD card legally.

If a seller is offering SD card set ups with ROMs included please DO NOT purchase from them.

Please support the guys that are the copyright holders as these are the ones actually supporting and enhancing the community.

If anyone is interested. The fixed versions of the SidPlay64 (a bit older version, but all sid's should still play ok) and FB (minimalistic file browser, 820 bytes only) :

http://pc.sux.org/tomcat/pisidplayfb.zip

 

Example CONFIG File

// Sample options.txt configuration file for Pi1541

 

 

 

// If you would like to change the drive number then specify it here (8 is the default)

//deviceID = 9

 

// If you are using the split line hardware option (ie Option B) then you need to specify this option

//splitIECLines = 1

// If you are using some type of hardware that requires the lines to be inverted then specify these options here

//invertIECInputs = 1

//If you are using a 7407

//invertIECOutputs = 0

 

// If you are using the Pi's composite video out then these options allow you to experiment with the display resolution

//ScreenWidth = 512

//ScreenHeight = 384

 

// By default Pi1541 will search the root of the SD card for a ROM file and use this for ROM1.

// The first file found with either of the following names will be used; d1541.rom, dos1541, d1541II, Jiffy.bin

// You can override the default ROM1 by specifying it here

//ROM1 = YourDefaultRom

// You can specify additional ROMS here (up to 7)

// You can then use the function keys (F1-F7) on the keyboard to change which one you would like to use (only in browse mode and not in emulation mode)

// You can also use the buttons to swap ROMs by holding down button 1 and pressing one other buttons 2-5

// .LST files can also specify one of these ROMS that will automatically be selected when the LST file is loaded.

//ROM2 = Jiffy.bin

//ROM3 = d1541II

 

// The rate (in seconds) a long selection is scrolled

scrollHighlightRate = 0.07

 

// Enable RAMBoard emulation - 8k drive RAM expansion at 0x8000

//RAMBOard = 1

 

//ChargenFont = chargen             // 8 bit font file

 

// If using CBMFileBrowser then it is best to specify this option. When the computer resets the Pi will always revert back to the root folder ready to load CBMFileBrowser again.

OnResetChangeToStartingFolder = 1

 

// If you use FB64 (CBMFileBrowser) and want to use a fast loader cartridge (AR6, EFL, FC3) to load it then use this option to automatically mount it.

//AutoMountImage = fb.d64 // You MUST have a disk image in \1541 with this filename

 

// If you are using a FB128 in 128 mode you can get FB128 to auto boot using this option

//AutoBootFB128 = 1

 

// If you are using a 128 you can auto boot anything using this option

// This over-rides AutoBootFB128

//128BootSectorName = bootsect.128

 

// If you would ever like to disable browse mode completely you can do so here

//DisableSD2IECCommands = 1

 

// This option displays the IEC bus activity on the bottom of the Pi's screen

GraphIEC = 1

 

// If you have hardware with a peizo buzzer (the type without a generator) then you can use this option to hear the head step

//SoundOnGPIO = 1

//SoundOnGPIODuration = 1000 // Length of buzz in micro seconds

//SoundOnGPIOFreq = 1200 // Frequency of buzz in Hz

 

// You can create 320x240 PNG files with the same name as your disk images. With this option turned on they will be displayed on the Pi's screen.

//DisplayPNGIcons = 1

 

// If you would like to specify what file will be loaded by LOAD"*" in browse mode then specify it here

//StarFileName = somefile

 

// Alt-N creates a new disk image.

// Names are formed automatically as autoname001.d64, autoname002.d64 etc...

// change the base of the filename here

//AutoBaseName = autoname

 

// If you are using a LCD screen then specify it here

//LCDName = ssd1306_128x64

//LCDName = ssd1306_128x32

//LCDName = sh1106_128x64

// If you are using a LCD screen and you would like PageUp and PageDown keys to work with it then specify this option

//KeyboardBrowseLCDScreen = 1

 

// change startup logo on oled - 1541ii or 1541classic

//LcdLogoName = 1541ii

//LcdLogoName = 1541classic

//LcdLogoName = customfile.raw

 

// If you are using I2C LCD you can optionally change what pins it is connected to.

// (defaults to 0 for non-split lines (Option A) or 1 for split lines (Option B))

//i2cBusMaster = 0 //SDA - pin 27 SCL - pin 28

//i2cBusMaster = 1 //SDA - pin 3 SCL - pin 5

//i2cLcdAddress = 60  // I2C display address in decimal and shifted. 60 == 0x78, 61 == 0x7A

//i2cLcdFlip = 1 // Rotate i2c LCD screen 180 degrees

//i2cLcdOnContrast = 127 // Allows you to adjust the contrast on your i2c LCD screen

//i2cScan = 1 // scan i2c bus and display addresses on screen

 

//QuickBoot = 0             // faster startup

//ShowOptions = 0     // display some options on startup screen

//IgnoreReset = 0

 

// You can remap the physical button functions

// numbers correspond to the standard board layout

//buttonEnter = 1

//buttonUp = 2

//buttonDown = 3

//buttonBack = 4

//buttonInsert = 5

 

CONTACT

pi1541contact@gmail.com

Donate via PayPal <- Our devs gotta eat!

1581 SUPPORT

Source a version of the 1581 ROM (vice/zimmers (eg 1581-rom.318045-02.bin) or buy a legit version from Jim;- http://store.go4retro.com/jiffydos-1581-dos-rom-overlay-image/

Call it 1581-rom.318045-02.bin

In the options.txt file add the line;-
ROM1581 = 1581-rom.318045-02.bin

Example Folder structure

ROOT+ bootcode.bin
    | chargen
    | config.txt    <-This is where the magic happens
    | dos1541       <-Sourced from VICE
    | fixup         <-Sourced from Raspberry Pi Firmware
    | kernel.img    <-Sourced from Raspberry Pi Firmware
    | options.txt   <-You may need to change settings here to get your
    |                 HDMI or Composite TV working properly
    | screen.raw    <-Only if you have a boot image for your OLED
    | start.elf     <-Sourced from Raspberry Pi Firmware
    ++ 1541
     | d64, lst, d81, g64, nib and nbz files go here    

Misc

When in browse mode, that is, before disk image(s) have been mounted the drive device ID can be changed by;-

Pressing F8-F11 (for device ID F8 = 8, F9 = 9, F10 = 10, F11 =11)
Holding down button 5 and pressing buttons 1-4 (1 = 8, 2 = 9, 3 = 10, 4 = 11)
Changing the device ID via the computer using the U0 command eg, OPEN1,8,15,"U0>"+CHR$(9):CLOSE1