Next Previous Contents

2. Utilities

cbm4linux comes with the following utilities:

2.1 cbmctrl

Synopsis: cbmctrl ACTION ...

cbmctrl is used to send commands to external devices.

Actions

Here's a list of all valid actions for cbmctrl:

listen device secadr

Tell device device to listen on secondary address secadr. Until the next unlisten command, everything written to the special device /dev/cbm will be received by this device.

This command corresponds to the following 6502 assembly code on a C64:


lda #device
jsr $ffb1
lda #secadr
ora #$60
jsr $ff93

talk device secadr

Tell device device to talk on secondary address secadr. Until the next untalk command, data from this device can be received device by reading from the special device /dev/cbm.

This command corresponds to the following 6502 assembly code on a C64:


lda #device
jsr $ffb4
lda #secadr
ora #$60
jsr $ff96

unlisten

Ends communication with listening devices after a listen command. This corresponds to the C64 kernel routine $ffae.

untalk

Ends communication with talking devices after a talk command. This corresponds to the C64 kernel routine $ffab.

open device secadr filename

Open file filename on device device. After opening, data can be read/written by sending a talk resp. listen command with the secondary address secadr.

If secadr is greater than 1, the file type and access mode must also be specified by appending ,type,mode to filename. Valid types are D, P, S, U, R (DEL, PRG, SEQ, USR, REL), valid modes are R for reading and W for writing.

close device secadr

Close the file associated with secondary address secadr on device device.

status device

Copies input from device device, secondary address 15 (command/status channel), to the standard output stream. Note that all upper case characters are changed to lower case. Carriage return (0x0d) is also changed to linefeed (0x0a).

This command is similar to (in this case, no character conversions would be made)


cbmctrl talk device 15
cat /dev/cbm
cbmctrl untalk

command device cmdstr

Sends cmdstr to device device, secondary address 15 (command/status channel). Since there is no PetSCII->ASCII conversion, commands must be sent in upper case (kind of poor man's PetSCII conversion). This is because charset conversion would break the M-W and M-E commands.

This command is identical to


cbmctrl listen device 15
echo -n cmdstr > /dev/cbm
cbmctrl unlisten

dir device

Read directory from disk in device device, print on standard out.

download device address count

Read count bytes from drive memory, starting at address via one or more M-R commands. Memory contents are written to standard out.

upload device address file

Send file to drive memory, starting at address via one or more M-W commands. If address is -1, the first to bytes from file are considered as start address.

reset

Triggers hardware reset on all attached devices. Control is returned after a five second delay to make sure all devices are ready.

Examples

Send file contents to printer 4:


cbmctrl listen 4 0
cat file > /dev/cbm
cbmctrl unlisten

Copy file to disk drive 8:


cbmctrl open 8 2 FILENAME,P,W
cbmctrl listen 8 2
cat file > /dev/cbm
cbmctrl unlisten
cbmctrl close 8 2

Copy file from disk drive 8:


cbmctrl open 8 2 FILENAME,P,R
cbmctrl talk 8 2
cat /dev/cbm > file
cbmctrl untalk
cbmctrl close 8 2

Dump 1541 ROM:


cbmctrl download 8 8 0xc000 0xc000 > 1541.rom

2.2 cbmformat

Synopsis: cbmformat [OPTION]... DRIVE NAME,ID

cbmformat is a fast low-level disk formatter for the 1541 and compatible devices (1570, 1571, third-party clones). The drive routine was taken from the Star Commander ((C) Joe Forster/STA).

cbmformat invocation

Here's a complete list of known options:

-h

Display help and exit.

-n

Do not bump drive head at the beginning. Don't use this on eventually misaligned drives.

-x

Format 40 track disk. BAM format is SpeedDOS compatible.

-o

Fill sectors with the original pattern (0x4b, 0x01, 0x01...) instead of zeroes. The original pattern is probably due to a bug in the drive ROM, apart from this, zeroing out unused sectors should give (slightly) better results for compressed disk images.

-s

Display drive status after formatting. Normally, cbmformat exits after executing the drive code. With this option turned on, cbmformat waits until the drive has finished formatting and prints the drive status after initializing the BAM on standard out.

2.3 d64copy

Synopsis: d64copy [OPTION]... SOURCE TARGET

d64copy is a fast disk image transfer (both read and write) program for the 1541 and compatible devices (1570, 1571, third-party clones). Maximum transfer speed is achieved by custom disk- and transfer-routines based on the Star Commander ((C) Joe Forster/STA) routines.

d64copy invocation

Either SOURCE or TARGET must be an external drive, valid names are 8, 9, 10 and 11. The other parameter specifies the file name of the .d64 image.

Here's a complete list of known options:

-h

Display help and exit

-q

Quiet output, don't output track map

-s start track

Set start track (defaults to 1)

-e end track

Set end track (defaults to 35). d64copy is able to access tracks 1-35 in original transfer mode and 1-40 with serial1, serial2 and parallel.

-t transfer mode

Set transfermode. Valid modes are:

original and serial1 should work in any case. serial2 won't work with more than one device is connected to the IEC bus, parallel requires a XP1541/XP1571 cable

-i interleave

Set interleave value. This is ignored when reading in warp mode. Default is 16 for transer mode original, for turbo and warp write as follows:


          turbo (r/w)    warp (write only)
serial1       3                 5
serial2      12                11
parallel      6                 3
Lower values might slightly reduce transfer times, but if set a bit to low, transfer times will dramatically increase.

-w

Enable warp mode. this is not possible when transfer mode is set to original. Warp mode is usually a good idea for transferring disk images unless you have a very slow CPU and/or bad disk material. Warp mode sends raw GCR data over the bus, which assures data integrity on the PC side and reliefes the drive's CPU. However, although read errors are recognized and displayed, warp mode doesn't try very hard to re-read those sectors (yet). If you encounter tracks containing read errors it is often a good idea to copy those tracks via the -s and -e options once again in turbo mode to the same .d64 image. d64copy won't touch the other tracks in this case.

-b

BAM-only copy. Only blocks marked as allocated are copied. For extended tracks (36-40), SpeedDOS BAM format is assumed. Use with caution.

-B

Save BAM-only copy. this is like the -b option but always copies the entire directory track (18).

-d type

Skip drive type detection. 0 or 1541 specifies 1541 mode (1 MHz, parallel cable at VIA $1800), 1 or 1571 forces 1571 mode (2 MHz, parallel cable at CIA $4000).


Next Previous Contents