Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# compactflash.device
AmigaOS compactflash.device driver for CompactFlash cards in PCMCIA

*Author*: Torsten Jager (t.jager@gmx.de); v1.32 (18.11.2009)
*Patched by*: Paul Carter (); 1.33 (1.1.2017)
* *Author*: Torsten Jager (t.jager@gmx.de); v1.32 (18.11.2009)
* *Patched by*: Paul Carter (); 1.33 (1.1.2017)
* *Patched by*: Jaroslav Pulchart (jaroslav.pulchart@gmail.com); 1.34 (20.10.2025)

# Purpose

Expand Down Expand Up @@ -98,16 +99,22 @@ If some trouble occurs, like cards not recognized by cfd, please:
```
cfddebug ram:cfdlog
```
* send ro `t.jager@gmx.de (Torsten Jager)` the binary file just created (about 4 kbytes). I promise there are no passwords and such in it.

In case there is another PCMCIA driver (eg. a network card driver) blocking the card socket, try setting the CF0 mountlist entry "Flags" to
send ro `t.jager@gmx.de (Torsten Jager)` the binary file just created (about 4 kbytes). I promise there are no passwords and such in it.
* In case there is another PCMCIA driver (eg. a network card driver) blocking the card socket, try setting the CF0 mountlist entry "Flags" to
```
Flags = 1 /* enable "cfd first" hack */
```
Damaged or simply not quite officially standardized cards may sometimes cooperate using
```
Flags = 2 /* skip invalid PCMCIA signature */
* `Work in progress`: please ensure the IO request is limited to use single sector per IO for >4GB CF units:
```
MaxTransfer = 0x200
```
this influence IO performance (drop by ~50%) bit it is relieable.

NOTE: be CAREFULL the MaxTransfer over 0x200 (>1*512B) cause IO unrealibilty. The IO read reqest is going to repeat last 32b from first sector instead reading next one.


# History
* v1.01 02/2002 First experiments.
Expand Down Expand Up @@ -142,5 +149,6 @@ Flags = 2 /* skip invalid PCMCIA signature */
* v1.31 11/2009 Fixed bug in "memory mapped" mode. Further optimizations.
* v1.32 11/2009 Added more detailled error messages. 04/2014 Removed "dd" as it is part of "fat95". Finally made this open source.
* v1.33 1/2017 Makes init routie more reliable. Cards that previously would, Not work might now start to work. Tested with a variety of SD cards in an SD to CF adapter and now all SD cards initialise properly and work reliably. Cheap storage now available for all Succesfully tested 32gb SD cards with fat95 v3.18. See ADAPTER2.JPG for the type of adapter used.
* v1.34 10/2025 make >4GB compact flash cards usable (1. workaround "get ide id", 2. limit multisector IOs)

Have Fun!
92 changes: 92 additions & 0 deletions cfd134.readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
Short: CompactFlash PCMCIA driver for A600/1200
Uploader: jaroslav.pulchart@gmail.com (Jaroslav Pulchart)
Author: jaroslav.pulchart@gmail.com (Jaroslav Pulchart), based on work by Torsten Jager and Paul Carter
Type: driver/media
Version: 1.34
Replaces: driver/media/CFD133.lha
Requires: AmigaOS 2.0+, PCMCIA slot, CF-to-PCMCIA adapter
Architecture: m68k-amigaos
Kurz: CompactFlash PCMCIA Treiber fuer A600/1200

compactflash.device V1.34 - PCMCIA CompactFlash driver for Amiga 600/1200

Fork of driver/media/CFD133.lha with improvements for >4GB CompactFlash cards.

CHANGES IN 1.34 (22.10.2025)
============================
* Made >4GB CompactFlash cards usable
- Workaround for "get IDE ID" on large capacity cards
- Limited multi-sector IOs for reliability on >4GB cards
* See README.md for detailed configuration options

FEATURES
========
* Supports CompactFlash, MicroDrive, and various adapters (SD, MemoryStick, SmartMedia)
* TD64 and SCSI emulation support
* Works with fat95 filesystem for FAT32 support
* Supports cards up to 4GB reliably
* Transfer speeds up to 2.2 MB/s read, 1.9 MB/s write (with MaxTransfer > 0x200 if reliable and working CF firmware)

REQUIREMENTS
============
* Amiga 600 or 1200 with PCMCIA slot
* AmigaOS 2.0 or higher (3.2.3 tested)
* "CompactFlash to PCMCIA/ATA" adapter card
* fat95 filesystem (disk/misc/fat95.lha) recommended

INSTALLATION
============
1. Copy devs/compactflash.device to DEVS:
2. Have fat95 installed on your system
3. Mount the drive by double-clicking devs/CF0

For OS 3.5+:
Copy def_CF0.info to sys:prefs/env-archive/sys and env:sys

SOURCE CODE
===========
Source code available at:
https://github.com/pulchart/cfd

Licensed under GNU LGPL v2.1

HISTORY
=======
v1.34 10/2025 - >4GB CF card support (Jaroslav Pulchart)
v1.33 1/2017 - Init reliability fix (Paul Carter)
v1.32 11/2009 - Error messages, open source release (Torsten Jager)
v1.31 11/2009 - Memory mapped mode fix
v1.30 11/2009 - Major API rework for ROM use
...
(see README.md for complete history back to v1.01 from 2002)

WORKAROUNDS
===========
For PCMCIA conflicts with other drivers:
Flags = 1 /* enable "cfd first" hack */

For cards without valid signature:
Flags = 2 /* skip invalid PCMCIA signature */

CHECKSUMS
=========
compactflash.device (8412 bytes):
MD5: 4e7ad2c204d9a9731d954aa2ef689ab6
SHA256: 175e071af7cee84b6fd2553f4c19a9a54a49c3972da838a1623047d973226d6b

CONTENTS
========
cfd/c/cfddebug - Debug/logging tool
cfd/c/pcmciacheck - PCMCIA check utility
cfd/c/pcmciaspeed - Speed test utility
cfd/devs/CF0 - Mountlist entry
cfd/devs/compactflash.device - The driver
cfd/src/ - Full assembler source code
cfd/adapter*.jpg - Example adapter photos
cfd/LICENSE - GNU LGPL v2.1
cfd/README.md - Full documentation

Have Fun!

"CompactFlash" is (TM) by CompactFlash Association

37 changes: 18 additions & 19 deletions devs/CF0
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
/* compactflash.device $VER: 1.21 (19.10.2002) */
/* fat95 file system by Torsten Jager */

FileSystem = l:fat95
Device = compactflash.device
Unit = 0
Flags = 0
LowCyl = 0
HighCyl = 0
Surfaces = 1
BlocksPerTrack = 1
BlockSize = 512
Buffers = 20
BufMemType = 1
BootPri = 0
Stacksize = 4096
Priority = 5
GlobVec = -1
DosType = 0x46415401
/* compactflash.device $VER: 1.34 (22.10.2025) */
FileSystem = l:fat95
Device = compactflash.device
Unit = 0
Flags = 0
LowCyl = 0
HighCyl = 0
Surfaces = 1
BlocksPerTrack = 1
BlockSize = 512
Buffers = 20
BufMemType = 1
BootPri = 0
Stacksize = 4096
Priority = 5
GlobVec = -1
DosType = 0x46415401
/* MaxTransfer = 0x200 */
4 changes: 2 additions & 2 deletions devs/compactflash.device
Git LFS file not shown
91 changes: 91 additions & 0 deletions make_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash
# Script to create Aminet-compatible LHA release for cfd
# Run this from the cfd directory

set -e

VERSION="134"
RELEASE_NAME="cfd${VERSION}"
ARCHIVE_NAME="cfd${VERSION}.lha"

echo "Creating Aminet release: ${ARCHIVE_NAME}"
echo "=================================="

# Check if lha is installed
if ! command -v lha &> /dev/null; then
echo "ERROR: lha command not found!"
echo "Install with: sudo dnf install lha (Fedora)"
echo " or: sudo apt install lha (Debian/Ubuntu)"
exit 1
fi

# Create clean staging directory
STAGING_DIR=$(mktemp -d)
RELEASE_DIR="${STAGING_DIR}/cfd"

echo "Staging directory: ${STAGING_DIR}"

# Create directory structure
mkdir -p "${RELEASE_DIR}/c"
mkdir -p "${RELEASE_DIR}/devs"
mkdir -p "${RELEASE_DIR}/src"

# Copy files
echo "Copying files..."

# Binaries
cp c/cfddebug "${RELEASE_DIR}/c/"
cp c/pcmciacheck "${RELEASE_DIR}/c/"
cp c/pcmciaspeed "${RELEASE_DIR}/c/"

# Device and mountlist
cp devs/compactflash.device "${RELEASE_DIR}/devs/"
cp devs/CF0 "${RELEASE_DIR}/devs/"
cp devs/CF0.info "${RELEASE_DIR}/devs/" 2>/dev/null || true

# Source code
cp src/*.s "${RELEASE_DIR}/src/"

# Documentation and metadata
cp README.md "${RELEASE_DIR}/"
cp LICENSE "${RELEASE_DIR}/"

# Images (optional, but useful for documentation)
cp adapter.jpg "${RELEASE_DIR}/" 2>/dev/null || true
cp adapter2.jpg "${RELEASE_DIR}/" 2>/dev/null || true

# Amiga icon files (if they exist)
cp c.info "${RELEASE_DIR}/" 2>/dev/null || true
cp devs.info "${RELEASE_DIR}/" 2>/dev/null || true
cp adapter.jpg.info "${RELEASE_DIR}/" 2>/dev/null || true
cp adapter2.jpg.info "${RELEASE_DIR}/" 2>/dev/null || true
cp def_CF0.info "${RELEASE_DIR}/" 2>/dev/null || true

# Create LHA archive
echo "Creating LHA archive..."
cd "${STAGING_DIR}"
lha c "${ARCHIVE_NAME}" cfd

# Move archive to original directory
cd -
mv "${STAGING_DIR}/${ARCHIVE_NAME}" .

# Cleanup
rm -rf "${STAGING_DIR}"

# Show result
echo ""
echo "=================================="
echo "Created: ${ARCHIVE_NAME}"
echo ""
ls -lh "${ARCHIVE_NAME}"
echo ""
echo "Contents:"
lha l "${ARCHIVE_NAME}"
echo ""
echo "For Aminet upload:"
echo " 1. ${ARCHIVE_NAME}"
echo " 2. cfd${VERSION}.readme"
echo ""
echo "Upload to: ftp://main.aminet.net/new"

31 changes: 20 additions & 11 deletions src/cfd.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
; compactflash.device driver V1.33
; compactflash.device driver V1.34
; Copyright (C) 2009 Torsten Jager <t.jager@gmx.de>
; Small bugfix by Paul Carter on 1/1/2017
; This file is part of cfd, a free storage device driver for Amiga.
;
; This driver is free software; you can redistribute it and/or
Expand All @@ -17,11 +16,15 @@
; License along with this library; if not, write to the Free Software
; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

;compactflash.device v1.32
;TJ. 14.11.2009
;compactflash.device v1.33
;TJ. 01.01.2017
; Small bugfix by Paul Carter on 1/1/2017
;compactflash.device v1.34
; Improved >4GB CF compatibility by Jaroslav Pulchart (22.10.2025)

FILE_VERSION = 1
FILE_REVISION = 33
FILE_REVISION = 34

;--- from exec.library -------------------------------------

Expand Down Expand Up @@ -598,7 +601,7 @@ s_name:
dc.b `compactflash.device`,0
dc.b `$VER: `
s_idstring:
dc.b `compactflash.device 1.33 (01.01.2017)`,LF,0
dc.b `compactflash.device 1.34 (22.10.2025)`,LF,0
dc.b `� Torsten Jager`,0
CardName:
dc.b `card.resource`,0
Expand Down Expand Up @@ -1719,6 +1722,13 @@ Wait40:
move.l d0,TR_Seconds(a1)
move.l #40000,TR_Micros(a1) ;wait 40 ms
JMPEXEC DoIO
Wait1:
lea CFU_TimeReq(a3),a1
move.w #TR_ADDREQUEST,IO_Command(a1)
moveq.l #0,d0
move.l d0,TR_Seconds(a1)
move.l #100,TR_Micros(a1) ;wait 0.1 ms
JMPEXEC DoIO

UnitCode:
Test:
Expand Down Expand Up @@ -2887,8 +2897,7 @@ _gid_command:
tst.b (a1)
nop
_gid_wait:
tst.b (a1)
nop
bsr.w Wait1
move.b 14(a0),d0
bpl.s _gid_done

Expand Down Expand Up @@ -3008,8 +3017,8 @@ _rb_0:
tst.l CFU_DriveSize(a3)
beq.w _rb_nodisk

moveq.l #1,d4
lsl.l #8,d4
moveq.l #0,d4
move.w CFU_MultiSize(a3),d4
cmp.l d4,d3
bcc.s _rb_1

Expand Down Expand Up @@ -3513,8 +3522,8 @@ _wb_swath:
move.l d3,CFU_Count(a3)
move.l a2,CFU_Buffer(a3)
_wb_try:
moveq.l #1,d4
lsl.l #8,d4
moveq.l #0,d4
move.w CFU_MultiSize(a3),d4
cmp.l d4,d3
bcc.s _wb_1

Expand Down