Pi1541 Floppy Drive Emulator
Pi1541 is a Raspberry Pi hat created by Steve White, that emulates the 1541 floppy drive with cycle-accurate timing. This allows you to load programs/games from an SD card to your Commodore 64/128 machine, just like SD2IEC. However, unlike SD2IEC, Pi1541 is able to handle disk swapping (for those multi-side, multi-disk programs like Maniac Mansion or GEOS), among other 1541-ey quirks that some games’ copy protection and loading routines rely on to work.
Yes, there is the 1541 Ultimate-II cartridge. Somewhere out there. It costs a lot more if all you need is the drive emulation functionality, but that’s if you can get your hands on one, and if you can justify the purchase price. Until then, this little fella will carry the ball nicely for you.
What you need
- Hardware
- Raspberry Pi 3A/3B+
- https://www.rpilocator.com/?cat=PI3
- Technically a Pi 0/1 will work, with overclocking. Pi Zero 2 is a good (cheaper) alternative to Pi3, but Pi3B+ has a full-size HDMI port.
- Pi1541 hat (ready-built, around $30)
- Pi power adapter
- IEC serial cable
- MicroSD card
- Use any size you want, but don’t bother with anything larger than 32GB. The base installation takes like 6MB, and you can slap almost every game, demo and utility ever made for the C64 on what’s left, but that is a LOT of files to have to navigate through when you’re looking for something specific. Pi1541 doesn’t do file searches, unfortunately.
- Raspberry Pi 3A/3B+
- Software
- Raspberry Pi Firmware
- From the Raspberry Pi Foundation itself
- From this site (in case the source goes away, may be specific to Pi 3B+)
- Pi1541 base software (as of 12/8/2023, check their site every so often; he’s still producing updates!)
- https://cbm-pi1541.firebaseapp.com/Pi1541.zip
- From this site (again, archived here as of 12/8, will be updated from time to time when possible)
- A 1541/1541-II/JiffyDOS ROM dump
- http://www.zimmers.net/anonftp/pub/cbm/firmware/drives/new/1541/index.html
- I recommend you use one of the 1541 models, but whatever you choose, the ROM must be renamed to DOS1541 or d1541.rom or d1541II or Jiffy.bin (for JiffyDOS of course, and don’t forget you’ll have to have JiffyDOS on your C64 too!)
- Raspberry Pi Firmware
SD Card Setup
Format Card
Format an SD card to FAT32 this can be done in Windows (right click on drive and select format) or use a proper SD formatting tool
Install Pi Firmware
Open the Pi firmware zip file
Copy or move 3 files found in the “boot” folder (as shown below) into the rood folder of the SD card
- bootcode.bin
- fixup.dat
- start.elf
Install PI1541 Software
Extract the contents of the Pi1541 base software archive to your SD card
There will be multiple files in the 1541 folder in the source archive; these are various versions of the internal file browser. You only need “fb64” for Commodore 64, fb16 for Commodore 16, etc; the rest can go away. Having only one file here will become important later.
- 1541 folder
- fb64
- config.txt
- kernel.img
- options.txt
Install system ROMs
Transfer your chosen floppy drive ROM to the SD card root (don’t forget to rename the file!)
Also transfer chargen file here as well, if you’ve chosen to include it
The final file structure should look like this
Configuration
Now it’s time to configure Pi1541 so it works as you expect it to (based on the features you’ve chosen to install or simply came with your hat). Open the file “options.txt”. I’ll point you to the major sections of note, the rest of the options are fairly self-explanatory.
*** ENABLE THIS (remove the "//") IF YOU WILL BE DAISY-CHAINING ANOTHER DEVICE FROM THE PI1541,
*** LIKE ANOTHER DRIVE OR A PRINTER
// If you are using the split line hardware option (ie Option B) then you need to specify this option
// splitIECLines = 1
*** THIS IS REFERRING TO THE FILE BROWSER AVAILABLE TO RUN FROM THE C64
*** HAVING THIS ENABLED WILL CAUSE THE PI TO DISMOUNT THE CURRENT DISK AND
*** GO BACK TO ROOT FOLDER WHERE THE FILEBROWSER IS
// 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
*** THIS MATTERS IF YOU INTEND TO USE THE PI'S OWN VIDEO OUTPUT ON ANOTHER MONITOR. IT PRESENTS A NEAT REALTIME
*** READOUT OF THE CURRENT MOUNTED DISK'S FILE LISTING, DATA MAPPING, AND DRIVE ACTIVITY WHEN LOADING/SAVING
// This option displays the IEC bus activity on the bottom of the Pi's screen
GraphIEC = 1
*** THIS MATTERS IF YOU WANT THE PI1541 TO MAKE LITTLE BUZZY BEEPS WHEN THE (VIRTUAL) HEAD MOVES.
*** IT'S NOT VERY GOOD FOR EMULATING THE REAL DRIVE'S SOUNDS, BUT YOU MIGHT FIND IT BETTER THAN SILENCE.
// 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
*** CUTE LITTLE WAY TO CREATE COVER ART FOR THE OLED SCREEN
// You can create 320x200 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 are using a LCD screen then specify it here
// LCDName = ssd1306_128x64 ## UNCOMMENT THIS FOR OLED
// 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 (rather than the HDMI screen) then specify this option
//KeyboardBrowseLCDScreen = 1
*** THIS WILL PRESENT A LITTLE LOGO OR 1541/1571 IMAGE ON THE OLED AT STARTUP
// change startup logo on oled - 1541ii or 1541classic
//LcdLogoName = 1541ii
// LcdLogoName = 1541classic ##UNCOMMENT THIS FOR OLED
//LcdLogoName = customfile.raw
to use CBM font on LCD. Small but fun !
*** BASED ON THE OPTIONS PRESENTED, RATHER THAN UNCOMMENT SPECIFIC LINES, I JUST INPUT MY OWN NEW LINES
*** SO IT'S EASY TO SEE WHICH OPTIONS I'M USING IN MY CONFIG FILE. IT WORKS EITHER WAY FOR THE PI, BUT
*** IT'S EASIER FOR ME TO FIGURE THINGS OUT WHEN MY SPECIFIC CHOICES ARE TOGETHER UP IN A PREDICTABLE PLACE
*** BEWARE THESE OPTIONS MAY NOT BE RIGHT FOR YOU UNLESS YOU BOUGHT THE SAME EXACT THING I DID
LCDName = ssd1306_128x64
i2cBusMaster = 1 //SDA - pin 3 SCL - pin 5
LcdLogoName = 1541classic
So for that OLED screen… If you have one, try to determine which model it is (photos below) and un-comment the appropriate model name in the config file. The Pi1541 currently only supports these few models for now (more may be coming), but there are other variants and knockoffs that might just work with a particular configuration. You’ll have to experiment on your own for that, but if you want the easiest time getting a display to work, just hit up Amazon or Ali Express for one of the supported models specifically.
// If you are using a LCD screen then specify it here
//LCDName = ssd1306_128x64
//LCDName = ssd1306_128x32
//LCDName = sh1106_128x64
Remove the “//” in front of the line that describes the component you have installed.
Finally, you’ll need some programs to run! Everything goes in the 1541 folder, and you can feel free to set up your own folder structure within there, as well. For example, my 1541 folder has the fb64 file (the C64 file browser), and folders named DEMO, GAMES, and UTILITIES.
DEMO contains scene demos for playback and appreciation, naturally
GAMES contains -duh- games! These are further organized into letter folders so I don’t have to scroll through a ridiculously-long list of titles to get to that Ultima entry. π
UTILITIES holds useful things like various versions of CCGMS, which I use with my StrikeLink modem to connect with the rest of the world and do testing with my own emerging BBS project
Setup and Usage
Now that you have a loaded SD card, itβs almost time to fire it up!
The last decision is how you want to control this thing. The program files you put on here are not by themselves the actual programs; rather, they are like .zip files: containers for more files inside. Each .d64 file represents a floppy disk, which may contain many other files. So, you’re going to need some way to choose which disk you want to virtually insert (mount) to the drive. If your Pi1541 hat came with buttons on it, that’s what they’re for.
- If you have a lot of files, do yourself a favor: connect the Pi1541 to another monitor, then plug in a USB keyboard (or wireless receiver if you have one). Personally, I use a small portable HDMI screen and Logitech K400+ wireless keyboard and mouse combo.
- If you got your Pi1541 hat pre-built with buttons and OLED screen, you can use those buttons to navigate your files and mount your preferred disk image.
- If you have none of these things, you can still access your file structure via the fb64 program (File Browser 64).
If you have an external screen and keyboard/receiver, now is the time to connect them, then continue on!
- Insert the micro SD to the Raspberry Pi portion of the Pi1541
- Connect the Pi1541 to your Commodore 64 with Serial Cable and micro USB power supply
- Use the little dimple in the plug collar, or arrow on the jacket molding to determine “up” on the cable
- Plug the cable into the LEFT socket as you look at pinholes (unless your variant only has one socket)
- If you intend to use an external monitor and keyboard, connect them to the HDMI and USB ports
- Power on the Pi1541
- Turn on the Commodore 64
Using the onboard buttons
If you’re working with just the onboard buttons, this is what they do in the default configuration. Select will enter a folder, or if you’re highlighting a disk image file, mount it and enter emulation mode (insert the virtual disk and stand ready to actually do 1541-y things as directed by the C64. “Add” will set up a playlist so that you can trigger quick swaps to another disk image (for those programs that require multiple sides or floppies)
If you don’t find the button layout particularly intuitive, you can adjust their assignments in the options.txt file. Don’t forget to disconnect the Pi1541 before taking the SD card back out, connect it to your computer to you can access the file in your preferred editor again, and look for this section
// You can remap the physical button functions
// numbers correspond to the standard board layout
//buttonEnter = 1
//buttonUp = 2
//buttonDown = 3
//buttonBack = 4
//buttonInsert = 5
Edit as you like, save, and slap the card back in the Pi1541 to resume.
Using the File Browser program
So what if you don’t have buttons on your Pi1541, and don’t have the option or desire to add another monitor and keyboard to your space?
Good news! There’s a file browser you can use from the C64 directly, instead! After everything is booted up, the default configuration is already pointing to the fb64 file browser program (you DID take out the alternate variants during the setup above, riiiight?)
LOAD"*",8,1
RUN
The file browser is pretty straightforward. Once running, you use the CRSR keys to move up and down the file list’. Back arrow (at top of the list) goes up one level, pressing return on a file will trigger it to load immediately (or at least attempt to; make sure you’re loading the appropriate PRG file!)
BONUS: If you’re using the FileBrowser method, you can swap out the default FB64 file on your card for a modified version that also embeds a fastloader too, no additional hardware or modifications needed! This alternate browser is still a bit young in its development, and does not work very well if there are other devices on the bus (like other floppy drives or printers), but if you’re just messing around and looking to relive some gaming nostalgia, this is a great way to get there faster. Download the modified CBM Filebrowser (specially for Pi1541) from here: https://csdb.dk/release/?id=223021&show=summary
Using HDMI and Keyboard
If you’ve chosen the more intuitive and flexible option with a monitor and keyboard, you will be presented with this display. The keyboard controls are as follows:
- Up/down arrow keys, Pg Up/Dn: Scroll through current directory line-by-line, or page-by-page
- [ENTER]: Select file or open directory
- [ESC]: Exit emulation mode and go back to browser mode
- [BACKSPACE]: Back one directory level
- Insert: Select all images in current directory
- Alt-L: Create .lst file from currently-selected images (named “autoswap.lst”). This is like a playlist file that you can use to create the list of disks you might need to swap between for multi-side/multi-disk programs.
- A-Z/0-9: Jump to the next entry starting with that number or letter. Type more than one character to search.
- Alt W: Toggle the write protection of a disk image.
- Alt N: Create a new D64 image (The naming of the new images can be set via “AutoBaseName” variable in the options.txt file.
Here, I used the arrow and Enter keys to enter Utilities folder, and selected the CCGMS 2017 image in there. The image file mounts and the Pi1541 switches to emulation mode. The virtual disk is now “inserted” and waiting for me to do something with it. When a disk is mounted, it presents you with some cool info that I wish had been available back when the Commie was in its prime.
You get a full listing of the disk contents at top left, a map of the disk blocks which contain data (as opposed to empty blocks or “Blocks Free” shown at the bottom of the directory listing).
At bottom left you see a confirmation of the current device ID (8) and the ROM image currently being used. In this case, our Pi1541 is 1541 drive #8. Beneath is a line of data showing information about the drive’s current state. Most of the elements are 0=off, 1=on
- LED: Shows the state of the drive activity light if this were a real 1541 drive (the red light in right image, there may be a matching light on the Pi1541’s board too).
- Motor: Indicates if the drive motor would be spinning right now
- Track: Shows the disk track over which the read/write head is positioned. In this case, it’s about the middle of the disk at track 19. A floppy disk had 40 tracks, but in one of those quirks borne of its hardware ancestry, only 35 were normally used, (the format increased the tracks after the hardware mechanism was designed, but the 1541 could technically reach those tracks anyway, so some developers used them for copy protection or extended save data).
- ATN: The state of the drive’s ATteNtion flag on the IEC bus, signaling if it needs control next opportunity
- DAT: The state of the data transfer line
- CLK: The state of the master clock line. The drive takes control of the clock line when it’s using the bus for data transfer, then releases if there’s another device demanding ATteNtion, or continues the current operation if there are no interrupting requests on the bus. If there are no other drives or printers daisy-chained and active, then of course there won’t be any such interruptions.
At the very bottom of the display is something that looks like an EEG or heart monitor with a sweeping line. This graph shows the actual data and clock states graphically in a timeline. When there’s a load or save operation happening, you’ll see those green and blue lines jumping up and down in time with the DATA and CLocK states as they flip-flop between 0 and 1 while data is being transferred. You can literally see the 0’s and 1’s being read from or written to the virtual disk!
After the image is mounted, you can now load the content on your Commodore 64:
LOAD"*",8,1
This loads the first file on the disk. It used to be that there was no real standard about how a program was stored on a disk, nor even which file on there was the “loader” program you were supposed to start with! Most times we’d either list out the disk directory…
LOAD"$",8
LIST
…and take a guess at which program was the magic door, or just roll with the tried and true “*”,8,1 method. For most commercial disks, this worked fine. For home copies, compilations and homebrew disks we traded back in high school, this would have unpredictable results (because you really didn’t know if the 1st file on the directory was even a program or maybe a data file for one.
These days, most of the disk images you can find online are sort of remixes of the originals. They are usually setup so that loading the first file on the disk will load the very thing you expected, so that element of surprise/potential disappointment is pretty much a thing of the past, unless you’re working with images created from your own personal disk collection made up of trades of your youth! π
Afterword
Now, you can technically improve the device’s functionality the same as if were a real 1541. For example, you could purchase a JiffyDOS ROM chip for your C64, then a software version of the 1541’s ROM to be used in place of the 1541.ROM file on its SD card. The result is the same as upgrading a real Commie/1541 installation with physical chips, and read/write times speed up drastically! You can also use one of the popular fastloader cartridges on your C64 to gain big boosts without making changes to your Pi1541 configuration, too.
If you’re an especially hardcore hardware geek, you may enjoy learning more about the Commodore 1541’s history and everything possible to know about how it actually works (as well as why it was so cotton-picking SLOW when it was obviously capable of much better transfer rates!)
Custom case
Oh yeah, and because I’m always looking for ways to improve things, I’ve been working on my own enclosure for this thing. It is most certainly overkill, but adds a fun, modern element to the old setup that takes advantage of the features the Pi1541 offers!
It’s designed as a 3D-printed assembly, and uses a 7″ HDMI display along with some mechanical keyboard switches and custom-printed (or casted) keycaps. I’m still working on the internals so that it literally only needs power and IEC connections (like the original!), and a decent screen hinge that doesn’t look like crap, is spring-loaded, and feels smooth and solid to manipulate.