Repository navigation
Apple II
FlashFloppy features two alternative firmware builds emulating an Apple II drive:
-
Apple II: the historic one in the
alt/apple2/folder of a FlashFloppy release, supports only Apple II drive emulation and only.hfe140K floppy images. -
Multi: the new one in the
alt/multi/folder of a FlashFloppy release, supports Apple II with 140K floppy images of types.hfe,.nib,.nic,.dsk,.doand.po, both for reading and writing, in addition to all other main build drive and floppy image types, auto-detecting the drive type.
The "Multi" firmware automatically detects the following:
- The FDD type, at boot: Apple II 140K (Apple, Agat, Pravetz) when at least three of the four phase inputs are low for at least 50 ms of the first 200 ms, Shugart-like (TR-DOS, IBM PC) otherwise.
- The wiring of Oleg Odintsov's old Gotek firmware for Agat - firmware 307, with phase 1 on pin 32 of the floppy connector, as well as the standard one; not in the debug build for the STM32F105 and AT32F415.
- The sector order of a .dsk: ProDOS order if a ProDOS volume directory starts in block 2 where ProDOS order puts it, DOS 3.3 order otherwise. A .do is always in DOS 3.3 order and a .po in ProDOS order, so renaming the file overrides a wrong guess.
- The 128-byte trailer that names the disk at the end of some Agat .dsk images, which is left as it is.
- Images that cannot be Apple II disks, by their size alone: an HFE over 1.25 MB and a sector image of other than 35 to 40 tracks are left out of the list, so 840K Agat disks do not show in Apple II mode.
- An HFE whose header names an encoding that does not suit the mode, GCR in Shugart mode or any other in Apple II mode, is refused.
Deliberately left out, as rare, or because the guess would be made from the disk's contents with no way to override it:
- An HFE whose header leaves the encoding unknown, as Greaseweazle writes Apple II images, is served in either mode; the "logfile" and "debug" builds note when its first track looks like the other encoding. Telling the encoding from the data would misjudge damaged disks.
- A 160K PC image named .dsk is listed in Apple II mode and served as noise.
- A sector image keeps no volume number: its sectors carry 254, the one DOS 3.3 formats with, and software that wants another fails.
- A sector image holds standard 16-sector tracks only. Half tracks, nonstandard sectors and other copy protection need .nib, .nic or HFE; a write to a sector image that is not a standard data field is dropped, with a "Bad CRC" line in the log.
- DOS 3.2's 13-sector disks are not supported.
- In Shugart mode .dsk keeps its usual meaning.
Connect the pins marked by the same labels on the diagrams below with Dupont wires or jumpers. The connections are valid for all of the Apple II, Shugart (e.g. TR-DOS) and IBM PC modes; for other drive types some variation in jumpers can be needed.
Note that the suggested scheme delivers the signals PH0 and PH1 to Gotek pins RX and TX respectively, just using the spare IDC-34 pins for convenience, so that all connections go via IDC-34 and there is no need to route wires from the floppy controller to Gotek's internal pins.
Move the encoder's button from the KC30 header to jumper JA (which is Select too).
J4 J5 JA JC S0 Encoder (view to the terminals):
--------------------- ----------------------------- . . .
| . . C D . | | . E1 . . S . . | |^-^-^|
----- | | | [| |]
| . . . . | | D E2 . . S . C | |v-v-v|
----------------- ----------------------------- E1 . E2
An AT32F415 in QFN32, such as the SFRKC30.AT2, with an Apple II host needs the Apple II bootloader, with the multi firmware as with the Apple II one. Pin PA10, the KC30 header Select pin, carries stepper phase 0 there, and the standard bootloader takes it for a held Select button, so at every power-on it stops in its update mode, showing "UPD" or "FF Update Flash". Note that the Apple II bootloader serves a Shugart-like host as well; it only stops reading the KC30 header's Select pin.
To update the bootloader, unplug the host, put the .upd file from
alt/apple2/at2-bootloader/ on the USB drive as its only .upd file
and hold both buttons at power-on. This is needed only once. If you
encounter the error E01, which means your bootloader is too old to
support this .upd format, or if there is a power cut while the
bootloader is being replaced, the board will need to be programmed
over USB or a serial cable, from the .dfu or .hex in the same
folder.
In order to make such Gotek work with IBM PC, either the JC jumper must
be installed (ATTENTION: the JC jumper may damage the Apple/Agat), or
the setting interface = ibmpc must be written to the flash memory: put
FF.CFG with this line on a USB drive and power on the Gotek, then you
can remove this file. Note that TR-DOS will work fine with or without JC
and with or without this setting. Note that any FF.CFG that sets
interface = will write the specified value back into flash, and the
Factory Reset will also delete the setting.
No special bootloader is needed. No encoder moving is needed. The JC
jumper can be installed for all the mentioned modes; there is no need to
write interface = ibmpc into flash then.
J4 J5 JA JC S0
--------------------- -----------------------------
| . . C D . | | . . J . S . C | Note the differences from 415:
----- | | | - different position of C
| . . . . | | D . J . S . . | - added JC (J-J)
----------------- ----------------------------- - no encoder reconnection
A simple cable for one drive can be made from a 14 to 34 wire ribbon cable (some wires can be unused) with IDC-20 connector on the controller's side, and IDC-34 on the Gotek side, with the wires arranged as shown in the diagrams below.
Controller side, view to the pins at the Controller:
-----------------------------------------
|PH0 PH1 PH2 PH3 WRQ . DE RD WR WRP|
|GND GND GND GND . +5 . . . . |
--------^----------___--------------^----
Gotek side, view to the pins at Gotek:
----------------- ---------------------------------------------------------------------
| . . . +5 | | . PH0 . . DE . . PH1 PH2 PH3 WR WRQ . WRP RD . . |
=======---======= | . . . GND GND GND GND . . . . . . . . . . |
--------^------------------------___----------------------------^----
A simple cable for one drive can be made from a 12 to 34 wire ribbon cable with SNP34-30V (male) on the controller side (it can be soldered to, or non-loose Dupont wires can be put on its tail pins), and IDC-34 on the Gotek side, with the wires arranged as shown in the diagrams below.
Alternative - if you have an original Agat FDD cable, you can match it with an FDC-30 (ribbon cable connector for PCB soldering) by pushing FDC's tail pins into the female connector on the cable, and crimping both sides of the ribbon cable. The edge pairs of FDC's tail pins can be soldered short to prevent misalignment when mating.
Controller side, view to the tail pins of the connector on the cable:
_-------------------------------------_
|GND . . PH0 PH1 PH2 PH3 +5 . . |
| . . . . . . . . . . |
|RD WPR . WRQ . . . DE WR GND|
-----------------------------------------
Gotek side, view to the pins at Gotek:
----------------- ---------------------------------------------------------------------
| . . . +5 | | . PH0 . . DE . . PH1 PH2 PH3 WR WRQ . WRP RD . . |
=======---======= | . . . GND GND . . . . . . . . . . . . |
--------^------------------------___----------------------------^----
For connecting multiple drives, see the details in the specialized adapter board GitHub project agat-disk-hub
Use the flashfloppy-multi-*.upd file in the alt/multi/ folder of a
FlashFloppy release, as any FlashFloppy firmware update - put it as
the only .upd file on the USB drive, and hold both buttons or press
and hold the encoder at power-on. This will install the firmware.
If you get E01, it means your Gotek has an old bootloader, and then
you can flash the firmware using an alternative file
FF_Gotek-multi-*.upd.
| IDC-20 | DB-19 | Signal Name | Gotek Pin |
|---|---|---|---|
| 2 | 11 | PH0 | UART RX=J4 |
| 4 | 12 | PH1 | UART TX |
| 6 | 13 | PH2 | 18 |
| 8 | 14 | PH3 | 20 |
| 10 | 15 | /WREQ | 24 |
| 12 | 16 | +5V / SEL | - |
| 14 | 17 | /DRVEN | 10 |
| 16 | 18 | RD | 30 |
| 18 | 19 | WR | 22 |
| 20 | 10 | WRPROT | 28 |
| 11 | 6 | +5V (Power) | +5V |
| 1,3,5,7 | 1,2,3 | Ground (GND) | 1, 3, 5... |
Notes:
- IDC-20: Pins at the Apple II IDC 20-pin header
- DB-19: Pins at the Apple II D-sub 19-pin connector
- IDC-20.12 was previously advised to connect to IDC-34.32, but that is not needed; Apple II just supplies +5V on IDC-20.12.
- Developers only: In a serial debug build of the firmware, signals PH0 and PH1 are moved respectively to KC30 rotary header pins DT (J8) and CLK
Usage is straightforward and very similar to the regular firmware. Apple II firmware currently supports only HFE images (.HFE file extension)
You can convert PO and DO files to HFE using the Greaseweazle command-line tool. For example:
gw convert mydisk.po mydisk_po.hfe::double_step
To convert a modified HFE image back to PO/DO:
gw convert mydisk_po.hfe mydisk.po
There is also a comprehensive Apple II disk format converter tool