sd2iec (firmware)
From C64-Wiki
This page describes the functionality of the sd2iec firmware. For hardware projects using this firmware, see MMC2IEC, SD2IEC, and uIEC.
The most prominent use of sd2iec is emulation/replacement of a Commodore-1541 disk drive for a C64 using Atmel AVR-based hardware. sd2iec is available as open source (GPL).
To distinguish the firmware from the hardware design that shares the same name, the firmware should always be referenced in lowercase, while the hardware should be denoted in uppercase.
[edit] History
sd2iec started as a set of modifications to the MMC2IEC firmware, but quickly morphed into a complete rewrite. Initially, the firmware targeted only the MMC2IEC boards, but was later enhanced to support other media types.
Firmware
- 2009-05-20: sd2iec 0.8.1 release (mostly bugfixes)
- 2009-03-08: sd2iec 0.8 release including support for DreamLoad, Exos, FC3 freezes, D71/D81 images, direct SD card sector access, and many other small changes.
- 2008-05-02: sd2iec 0.7 release including support for the Final Cartridge 3 fastloader among many other small changes.
- 2008-02-20: sd2iec 0.6 release including support for long filenames, B-R, B-W, M-R, writing configuration to EEPROM, and several bugfixes.
For a complete and detailed firmware version history, see the git web interface.
[edit] Features
- D64/D71/D81/M2I support (both reading and writing for Dxx, even with direct sector access using U1/U2)
- T64 is not supported
- PRG/P00 etc. support
- limited REL support
- Subdirectory support (CMD command syntax).
- Support for Turbo Disk AKA Fast Load AKA Speeddisk fastloader
- Supports the JiffyDOS fast serial bus protocol, the Final Cartridge 3 fastloader/fastsaver, DreamLoad, Exos
- Supports an external "disk change" button
- Supports FAT long file names
- Supports FAT12/FAT16/FAT32 formatted SD and SDHC cards
- Supports sector access of SD cards from C64 side
- Good standard IEC compatibility
- Supports most typical IEC functions (LOAD, SAVE, OPEN, GET, PUT, CLOSE, ...)
- 1571 ROM has been taken as reference for implementation
- Many non-fastloader games run (see znarF's M2I list).
[edit] Usage
These are just some examples for drive commands. For a complete reference, read the README. See Drive command for information on how to send drive commands in general.
- Changing directories (CMD syntax)
- OPEN1,8,15,"CD/SOMEDIR/":CLOSE1 - change to SOMEDIR (relative)
- OPEN1,8,15,"CD//":CLOSE1 - change to root directory
- OPEN1,8,15,"CD//SOMEDIR/":CLOSE1 - change to SOMEDIR (in root)
- OPEN1,8,15,"CD:←":CLOSE1 - go to parent directory
- Using M2Is or D64s
- OPEN1,8,15,"CD//SOMEDIR/:SOMEGAME.M2I":CLOSE1 - change to/mount SOMEGAME.M2I
- OPEN1,8,15,"CD//SOMEDIR/:SOMEGAME.D64":CLOSE1 - change to/mount SOMEGAME.D64
- OPEN1,8,15,"CD:←":CLOSE1 - leave M2I/D64
- Loading files
- LOAD"//SOMEDIR/:SOMEFILE" - load SOMEFILE in SOMEDIR (filename gets separated from path using colon)
- Change device address
- OPEN1,8,15,"U0>"+CHR$(address):PRINT#1,"XW":CLOSE1 - change sd2iec device number to address and save setting to EEPROM
[edit] FAQ
[edit] Are fastloaders supported?
In general, no. Fastloaders consist of a code portion running on the C64 and of code running on the floppy. sd2iec cannot emulate a complete 1541 since this would imply emulating a whole 6502 processor, several additional circuits, and the floppy's mechanism. A microcontroller's resources are just not enough for that (it's not only about processing power and timing but also memory requirements). This can be done using an FPGA though - see 1541 Ultimate. For sd2iec, it is possible to add special support for individual fastloaders to the firmware only (which basically means reimplementing the fastloader's code formerly running on the floppy for the ATMega controller).
[edit] What about compatibility?
sd2iec is quite compatible concerning standard CBM IEC routines. Expect almost all software that runs in VICE without exact floppy emulation to work (at least in D64 mode). Note that in Gamebase64 Advanced Search you can explicitely search for "No true drive emulation needed".
Many recent releases of games and applications let you choose to disable built-in fastloaders. See znarF's M2I list for a list of games known to work with MMC2IEC/SD2IEC. Onefilers are okay, too - for a onefiler compilation see here
(login required). Also most applications that have been fixed for IDE64 should work.
[edit] Why the new M2I format? How do I create M2I files?
The M2I format exists mostly for historical reasons. The original MMC2IEC firmware was not able to write to D64 files, but a container format capable of handling PETSCII filenames and large capacities was needed. Instead of adding D64 or D81 write support, the M2I format was invented, writing normal FAT files to the SD card, but using a mapping file (.M2I) to map PETSCII filenames to ASCII/FAT filenames.
Since a large number of MMC2IEC/sd2iec compatible games have been converted to the M2I format, support for the M2I format has been kept in sd2iec. With D64/D81 read/write support in sd2iec, there is no reason to create new M2I containers these days unless you need 'disks' bigger than 800k (D81).
You can create M2I files using the M2I maker (Forum64 thread
). M2I is file-based and in contrast to D64 does not support sector access. Games (Maniac Mansion...) and applications (GEOS...) that need sector access do not work with M2I.
[edit] Is GEOS supported?
GEOS comes with an own fastloader that is currently not supported by sd2iec. A proof-of-concept GEOS driver that uses standard IEC routines (that is compatible with sd2iec) has been written though. Contact 1570 if you are interested.
[edit] How does sd2iec compare with the 1541-III firmware and the 1541 Ultimate firmware?
- 1541-III vs. sd2iec
- sd2iec does not yet support a display. Exchanging disks is possible using the disk switch button though.
- sd2iec-based designs usually feature a bootloader that fetches firmware from the SD card at startup.
- sd2iec uses the Atmel AVR microcontroller (open source C compilers are available for this platform).
- Some fastloader support is available.
- 1541 Ultimate vs. sd2iec
- sd2iec-based designs are much cheaper.
- Since the 1541 Ultimate completely emulates a 1541, it's much more compatible (supports all fastloaders).
- sd2iec does not provide any extra functionality the 1541 Ultimate provides (cartridge emulation).
- sd2iec is faster than 1541 Ultimate for all normal IEC operations it emulates since it emulates only protocol level (no slow mechanics).
[edit] How to copy files from/to sd2iec?
Using the C64, you can use for example FCOPY (from the HD Utilities Disk available here) or DraCopy for copying files.
To write D64 files to a 'real' floppy (1541, 1571...) use gunzip.c64; for creating a D64 from a floppy use PuZip. These tools are slow and can be sped up by using JiffyDOS. Both tools do copying on a per-file basis. For writing images sector by sector, use for example DCOPY.PRG.
[edit] What file/directory browsers can I use?
- CBM FileBrowser - sd2iec browser for C64/C64DTV and Vic-20 (unexpanded, +3K RAM, +8K RAM or plus and with Mega-Cart)
- sd2brwse - lightweight sd2iec browser (discontinued).
- FIBR - general-purpose C64 file browser supporting sd2iec, too. Forum64 thread
.
- DraBrowse
[edit] Why is LOAD"IMAGE.D64",8,1 to mount D64 files not supported?
This was supported in the sd2iec predecessor MMC2IEC firmware. However, this is basically an ugly hack and has some side effects; for example, copying or writing to D64 files using the C64 is not possible then (i.e., creating a D64 file from a 1541 disk using the C64 as described above does not work). This is why this 'feature' was never implemented in sd2iec and will not be considered for inclusion.
[edit] Do I really need to type OPEN... to change dirs/mount image files?
Consider using a file/directory browser for navigating dirs, mounting image files, and starting programs.
If you do not want to use a browser, there is a helper program for assigning commands to F-keys (see this page, download section).
With JiffyDOS or cartridges such as Final Cartridge 3 or Action Replay, shortcuts for sending commands to the floppy exist.
[edit] What is sd2iec's speed?
Test 1 is a non-continuous 115 blocks file so seeks occur. Test 2 is a continuous 193 blocks file. Times are measured manually including initial seeks and, thus, give just a rough guess.
Note these are LOAD times. Multiload games typically do not use LOAD but CHRIN when loading additional parts. This can get accelerated with kernal extensions only.
| System | RelSpeed 1 | AbsSpeed 1 | RelSpeed 2 | AbsSpeed 2 |
|---|---|---|---|---|
| x64 (true drive emulation) | 1.0x | 380 Bytes/Sec | 1.0x | 400 Bytes/Sec |
| x64 with Turbo Disk | 4.6x | 1770 Bytes/Sec | 5.7x | 2280 Bytes/Sec |
| x64 with Jiffy | 5.5x | 2090 Bytes/Sec | 6.0x | 2400 Bytes/Sec |
| x64 with FC3 | 6.7x | 2540 Bytes/Sec | 10.4x | 4150 Bytes/Sec |
| x64 with AR6 | 10.5x | 4000 Bytes/Sec | 14.3x | 5700 Bytes/Sec |
| x64dtv with DTV Speed Load (1) | 9.4x | 3550 Bytes/Sec | 13.2x | 5270 Bytes/Sec |
| C64DTV with sd2iec-based device(1) | 1.7x | 650 Bytes/Sec | 1.6x | 650 Bytes/Sec |
| C64DTV with sd2iec-based device and Turbo Disk (1) | 11.5x | 4360 Bytes/Sec | 12.6x | 5050 Bytes/Sec |
| C64 with sd2iec-based device and FC3 | 20x | 8000 Bytes/Sec | ||
| C64DTV with sd2iec-based device and Jiffy (1) (2) | 22.6x | 8600 Bytes/Sec | 21.5x | 8600 Bytes/Sec |
| C64DTV with sd2iec-based device and SJLOAD (1) | 25x | 10000 Bytes/Sec | ||
| C64DTV with sd2iec-based device and proof-of-concept speeder (1) | 40.3x | 15300 Bytes/Sec | 38.0x | 15300 Bytes/Sec |
(1) No speed enhancements of the C64DTV are used here so expect performance to be the same using a C64.
(2) Also accelerates EE13/CHRIN used by many multiload applications.
VICE(plus)/x64(dtv) emulates the 1541 timing including mechanics. As you can see, sd2iec speed is quite a bit faster even without any fastloader since no mechanic latency exists and sd2iec data processing is much faster. Note that speeders that do all processing in the floppy are limited to about 6x speed. These speeders run much faster with the sd2iec since computing power is not an issue there. The theoretical maximum speed of the CBM bus with a floppy that does not let the C64 wait ever is estimated at about 20-25k/Sec. Speed between test 1 and test 2 on the sd2iec differs because of speedloader setup time.
[edit] Can I use a parallel cable with sd2iec-based devices ?
Not currently. Some designs can accommodate a parallel cable and the firmware can be enhanced to support parallel transfer. However, note that the CBM bus seems quite fast already (see above).
[edit] Software
[edit] Bootloader
On selected devices, a bootloader is present that will read firmware binary files from the mass storage device (FAT12/16/32 supported) and updates the AVR flash if needed
- On powerup, bootloader scans root directory of priary mass storage device and checks each file size and file signature (which includes version, checksum, and firmware type)
- If a suitable file is found and the version of the file is 0 or greater than the version installed on the AVR, the flash is reprogrammed with the updated firmware.
[edit] Firmware
See Unseen's sd2iec firmware page. The source code can be found in the Git repository[1].
[edit] Media Support
Below lists the various media options known (not) to work with the SD2IEC. Please add "OK" only to the boot loader column if you could update your firmware from this card. "DOS" means the normal operation from the computer.
[edit] SD and MMC cards tested
| Brand | Type | Capacity (MB) | Product code | Tester | Tested with version | Boot Loader | DOS |
|---|---|---|---|---|---|---|---|
| BlueMedia | SD | 128 | ? | Shadowolf | 0.6.4 | OK | OK |
| Canon | MMC | 16 | ? | Shadowolf | 0.6.4 | OK | OK |
| Canon | SD | 32 | ? | Shadowolf | 0.6.4 | NOK | OK |
| EMTEC | SD | 2048 | ? | Retrostyle | 0.6.3a | OK | OK |
| Formel1 | SD | 512 | 6451AE | skoe | 0.6.4 | OK | OK |
| Hama | SD | 1024 | ? | ogf | 0.6.4 | NOK | OK |
| Kingston | SD | 1024 | SD-M01G/TR4924U | 1570 | 0.6.4 | OK | OK |
| Panasonic | SD | 16 | ? | Shadowolf | 0.6.4 | OK | OK |
| Platinum | SD | 2048 | ? | Shadowolf | 0.6.4 | OK | OK |
| SanDisk | microSD | 1024 | SDSDQ-1024-E10M | Shadowolf | 0.6.4 | OK | ? |
| SanDisk | microSD | 2048 | SDSDQ-2048-E10M | Shadowolf | 0.6.4 | OK | ? |
| SanDisk | microSDHC | 4096 | SDSDQ-4096-E11M | Shadowolf | 0.6.4 | NOK | OK |
| SanDisk | SD | 1024 | SDSDH-1024-902 | Shadowolf | 0.6.4 | OK | OK |
| SanDisk | mini-SD | 512 | SDSDM-512-E10M | Shadowolf | 0.6.4 | OK | OK |
| SanDisk | SD | 512 | ? | ogf | 0.6.4 | OK | OK |
| Traxdata | SD | 2048 | I3M2G | skoe | 0.6.4 | OK | OK |
| Verbatim | SD | 2048 | ? | LooZee | 0.8.1 | OK | OK |
| (Example entry) | MMC/SD/SDHC | 512 | 1234/? | me | 0.6.4 | OK/NOK/? | OK/NOK |
[edit] CF cards tested
| Brand | Type | Capacity (MB) | Product code | Tester | Tested with version | Boot Loader | DOS |
|---|---|---|---|---|---|---|---|
| AData | CF | 1024 | ? | Brain | 0.7.2 | OK | OK |
| AData "Speedy" | CF | 4096 | ? | Rittwage | 0.7.2 | ? | OK |
| Nikon | CF | 8 [sic!] | EC-8CF | ik | 0.7.2 | NOK | NOK |
| PNY | CF | 64 | ? | Brain | 0.7.2 | OK | OK |
| PQI | CF | 512 | ? | saehn | 0.8.0 | OK | OK |
| SanDisk | CF | 32 | FC-32MH | Brain | 0.7.2 | OK | OK |
| SanDisk | CF | 4096 | SDCFH-004G-A11 | Naberezny | 0.7.2 | OK | OK |
| Lexar | CF | 128 | P/N 2250, Rev. A | Vanessa E. | 0.8.3 | OK | OK |
| Lexar | CF | 128 | P/N 2175, Rev. A | Vanessa E. | 0.8.2, 0.8.3 | OK | OK |
| Canon | CF | 16 | FC-16M | Vanessa E. | 0.8.2, 0.8.3 | OK | OK |
| (Example entry) | CF/IDE | 512 | 1234/? | me | 0.6.4 | OK/NOK/? | OK/NOK |
[edit] See also
[edit] Weblinks
- SD2IEC/MMC2IEC forum at forum64.de
- M2I Forum64 thread
- HOWTO-SD-FAT16 - how to format your SD card using FAT16 (using live Linux)
- Panasonic SD Memory Card Formatting Software (Windows)
- ↑ git clone http://sd2iec.de/sd2iec.git, the directory is hidden, but readable.
