Notes on SCSI-Changer June 18, 2004 See http://linux.bytesex.org/misc/changer.html (bytesex by the way, refers to bytesexual, meaning this hardware can handle either Big- or little-Endian.) Downloaded a 286720-byte tar.gz file to ~jasper/scsi-changer-0.20.tar.gz On vinu, cd /usr/src/linux-$(uname -r) which was /usr/src/linux-2.4.21-15.0.2.EL.Jukebox gzip -d < /u/jasper/scsi-changer-0.20.tar.gz | tar xf - chown -R root:root changer cd changer That got me -rw-r--r-- 1 500 users 7253 Apr 26 2002 autojuke.c -rw-r--r-- 1 500 users 170 Jan 17 1998 autojuke.conf -rw-r--r-- 1 500 users 2557 Jul 4 2001 autojuke.man -rw-r--r-- 1 500 users 37769 May 17 2000 ch-2.2.15.diff -rw-r--r-- 1 500 users 47211 Apr 29 2002 ch-2.4.19-pre7.diff -rw-r--r-- 1 500 users 4961 Apr 26 2002 ChangeLog -rw-r--r-- 1 500 users 5144 Apr 26 2002 chio.h -rwxr-xr-x 1 500 users 361 Apr 25 2002 fallback.pl -rw-r--r-- 1 500 users 1163 Apr 26 2002 INSTALL -rw-r--r-- 1 500 users 4374 Apr 26 2002 list.h -rwxr-xr-x 1 500 users 90 Jul 17 1997 MAKEDEV.sch -rw-r--r-- 1 500 users 1448 Apr 26 2002 Makefile -rw-r--r-- 1 500 users 2998 Apr 26 2002 man.c -rw-r--r-- 1 500 users 195 Apr 26 2002 man.h drwxr-xr-x 2 500 users 4096 Jul 25 1997 misc -rw-r--r-- 1 500 users 10121 Apr 26 2002 mover.c -rw-r--r-- 1 500 users 3711 Apr 26 2002 mover.man -rw-r--r-- 1 500 users 6404 Apr 26 2002 README -r--r--r-- 1 500 users 48698 Apr 25 2002 RegEdit.c -r--r--r-- 1 500 users 2302 Apr 25 2002 RegEdit.h -r--r--r-- 1 500 users 10223 Apr 25 2002 RegEditI.h drwxr-xr-x 2 500 users 4096 Sep 13 2000 todo -rw-r--r-- 1 500 users 191 Apr 26 2002 TODO -rw-r--r-- 1 500 users 1304 Jul 4 2001 unload.c -rw-r--r-- 1 500 users 1065 Jul 4 2001 unload.man -rw-r--r-- 1 500 users 4771 Apr 26 2002 xmover.ad -rw-r--r-- 1 500 users 22068 Apr 26 2002 xmover.c -rw-r--r-- 1 500 users 4893 Apr 26 2002 xmover.h -rw-r--r-- 1 500 users 1753 Apr 26 2002 xmover.man --------------------------------------------------------------------------- The INSTALL file had this in it Compiling the package --------------------- The driver itself is provided as patch. ... Apply the patch, configure the kernel, recompile. ... A simple 'make' should compile the tools. After compiling you should have the following files: mover - a small program for testing the driver / sending commands to the changer xmover - a X11 frontend for the driver -- needs Motif. autojuke - a tool for using a changer with autofs. unload - a even smaller program to send a eject to any SCSI device load - (symlink to unload) sends a load instead of eject. man-pages for these utilities are available. Also have a look at the README for some general informations about scsi changers and about the driver. ... --------------------------------------------------------------------------- I like the way the above directions glibly say to just "Apply the patch, configure the kernel, recompile." Boom, boom, boom. Simple. Easy. Sure it is, if you know how to do all those things. (Three weeks later, I knew.) I reworked the ch-2.4.19-pre7.diff patch file, into a ch-2.4.21-15.EL.diff patch file for RHEL v3.0 ES, that modified or created the following files (all based on /usr/src/linux-2.4.21-15.EL on the vinu machine) Documentation/Configure.help - Added 15 lines documenting the new CONFIG_CHR_DEV_SCH configuration option. Documentation/scsi-changer.txt - New 184-line file. Essentially, the README. drivers/scsi/Config.in - Add 1 dep_tristate line. drivers/scsi/Makefile - Add 1 line to "make" ch.o. drivers/scsi/ch.c - New 1066-line file, the SCSI Media Changer device driver. include/linux/chio.h - New 160-line header file. include/linux/major.h - Adds 1 line to define new device major number (86). include/scsi/scsi.h - Adds 3 lines for new changer SCSI commands. The patch was saved as ~/aixnotes/linux/scsi-changer.2.4.21-15.EL.patch. To patch the kernel, cd /usr/src/linux-2.4 patch -bp0 < /u/jasper/aixnotes/linux/scsi-changer.2.4.21-15.EL.patch Note that due to patch's -b option, the original files were saved as .orig, in our case, -rw-r--r-- root root 1216999 Apr 21 21:09 Documentation/Configure.help.orig ---------- root root 0 Jun 22 12:44 Documentation/scsi-changer.txt.orig ---------- root root 0 Jun 22 12:44 drivers/scsi/ch.c.orig -rw-r--r-- root root 14181 Apr 21 21:09 drivers/scsi/Config.in.orig -rw-r--r-- root root 7934 Apr 21 21:09 drivers/scsi/Makefile.orig ---------- root root 0 Jun 22 12:44 include/linux/chio.h.orig -rw-r--r-- root root 5633 Apr 21 21:08 include/linux/major.h.orig -rw-r--r-- root root 7169 Nov 28 2002 include/scsi/scsi.h.orig Note the empty backup files for the ones that didn't exist before. --------------------------------------------------------------------------- The rest of the building was easy, just make & make install, netting me /usr/local/bin/mover /usr/local/bin/xmover /usr/local/sbin/autojuke related man files, and /etc/autojuke.conf. Interesting that the load & unload programs didn't get moved to /usr/local/bin. Why not? I guess they stay in this /usr/src/linux-2.4.21-15.0.2.EL.Jukebox/changer directory? Odd. I tried starting xmover, but I get an error, "open /dev/sch0: No such device" Didn't the jukes get configured correctly? dmesg | less shows scsi0:A:0:0: Tagged Queuing enabled. Depth 32 Vendor: PIONEER Model: DVDROM DVD-D7362 Rev: 1.01 Type: CD-ROM ANSI SCSI revision: 02 blk: queue f7fd2c18, I/O limit 4095Mb (mask 0xffffffff) Vendor: PIONEER Model: DVDROM DVD-D7362 Rev: 1.01 Type: CD-ROM ANSI SCSI revision: 02 blk: queue f7fd3c18, I/O limit 4095Mb (mask 0xffffffff) Vendor: PIONEER Model: DVDROM DVD-D7362 Rev: 1.01 Type: CD-ROM ANSI SCSI revision: 02 blk: queue f7fd3e18, I/O limit 4095Mb (mask 0xffffffff) Vendor: PIONEER Model: DVDROM DVD-D7362 Rev: 1.01 Type: CD-ROM ANSI SCSI revision: 02 blk: queue f7fd1618, I/O limit 4095Mb (mask 0xffffffff) Vendor: PIONEER Model: CHANGR DRM-7000 Rev: 1.08 Type: Medium Changer ANSI SCSI revision: 03 blk: queue f7fd7018, I/O limit 4095Mb (mask 0xffffffff) So it saw the "Medium Changer", but that doesn't tell me what device it got configured as (e.g. /dev/sch0). ----------------------------------------------------------------------------- After figuring out to add this line alias char-major-86 ch in my /etc/modules.conf file, xmover now gives these error messages, Warning: Missing charsets in String to FontSet conversion Warning: Missing charsets in String to FontSet conversion X Error of failed request: BadFont (invalid Font parameter) Major opcode of failed request: 55 (X_CreateGC) Resource id in failed request: 0x9000013 Serial number of failed request: 168 Current serial number in output stream: 173 A google search on this results in this fix, export LANG=en_US.iso88591 But this utility isn't too useful. You can see the status of drives and even rename a slot's CD/DVD label, but you cannot load & unload disks. ----------------------------------------------------------------------------- mover Command: mover mv - This command moves the media from element to element . and are a letter/number combination. The letter is the element type (t,s,e or d) and the number is the number of the element (starting with 0). "s4" is slot #5, "d0" the read/write device ... Hope you get the idea. Well, no. I don't get the idea. What's t, s, e, & d? mover - With no args, lists the jukebox status, giving some hints. /dev/sch0: mt=1 st=770 ie=2 dt=5 mt = Medium Transport, aka the robot = t 1 of them, t0 -> CHET_MT = 0 or picker or is it m? mover.c seems to want m, not t. st = STorage, aka the slots = s 770 of them, s0-s769 -> CHET_ST = 1 ie = Import/Export, aka the Mail Slot = e 2 of them, e0-e1 -> CHET_IE = 2 dt = Data Transfer, aka the drives = d 5 of them, d0-d4 -> CHET_DT = 3 mover.c also has v -> CHET_V1 = 4 for "Vendor Specific" thingies. w -> CHET_V2 = 5 x -> CHET_V3 = 6 y -> CHET_V4 = 7 mover mv s587 e0 - Unloaded the DVD from slot 587 out the mail slot but mover mv e0 s587 - Didn't move it back. It complained /dev/sch0: mt=1 st=770 ie=2 dt=5 ioctl failed (MOVE): Invalid exchange Inside mover.c on line 238, is the following ioctl call, rc = ioctl(fd,CHIOMOVE,&move); Tried turning debug on. rmmod ch insmod ch debug=1 This immediately started the jukebox scanning through it's 770 slots again (sigh). (I think you can insmod ch debug=1 init=0" to not "INITIALIZE ELEMENT STATUS") In /var/log/kernel.syslog, after a "mover mv e0 s587" command, is Jul 15 14:17:33 vinu kernel: ch0: move: 0x3000 => 0x24c Jul 15 14:17:33 vinu kernel: ch0: command: Move medium/play audio(12) 00 20 00 30 00 02 4c ... Jul 15 14:17:33 vinu kernel: ch0: result: 0x8000002 Jul 15 14:17:33 vinu kernel: ch0: sense: Current 00:00: sense key Illegal Request Jul 15 14:17:33 vinu kernel: Additional sense indicates Medium source element empty You can read the ch.c source to see how they put together the MOVE_MEDIUM scsi command. Most of it is displayed in hex for you in that Jul 15 14:17:33 vinu kernel: ch0: command: Move medium/play audio(12) 00 20 00 30 00 02 4c ... line. Byte 0 = x'a5' = MOVE_MEDIUM Command (Translated into English for you) 1 = x'00' = LUN 0 2-3 = x'2000' = Medium Transport 4-5 = x'3000' = Source = e0 = The Mail Slot 6-7 = x'024c' = Destination = s587 = Slot 587 (x'24c' = Decimal 588) 8-9 = x'0000' 10 = x'00' = Whether or not to rotate 11 = x'00' Turns out there's an ANSI Standard for "SCSI Media Changer Command Set (SMC-2)", that talks about the format of SCSI commands. It confirms what I learned above. See http://www.t10.org/ftp/t10/drafts/smc2/smc2r07.pdf, for example. SCSI-3 Medium Changer Commands SMC SCSI Media Changer Commands -2 SMC-2 Am I suppose to somehow open the door and put the DVD in first? Yes!!! e0 = Import/Export, aka the Mail Slot s0 = Slot t0 = Medium Transport, aka the Robot or Picker mover mv e0 s0 -> ioctl failed (MOVE): Invalid exchange mover info e0 -> Shows Mail Slot status mover pos e0 -> Moves transport arm to Mail Slot & opens Mail Slot door. This is it!!! mover mv e0 s0 -> Moves the CD in the Mail Slot to slot 0. My Action Jukebox State "mover info e0" status ==================== ===================== ========================= Before Door Closed, s0 empty exenab access impexp <-----\ mover pos e0 Door opens except | Insert CD/Close Door CD stays in e0 inenab access impexp full | mover mv e0 s0 CD moves to Slot 0 exenab access impexp ------/ mover mv s0 e0 -> To remove CD. Note to unload is 1 command, mover mv s0 e0 to load is 2 commands, mover pos e0 then mover mv e0 s0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! !! You cannot execute any mover commands when the jukebox's !! !! front panel is not in it's neutral state, i.e. you're !! !! not doing anything at the Operator's panel. If you are, !! !! you'll get !! !! ioctl failed (POSITION): Input/output error !! !! messages from most mover commands, and see !! !! sense: Current 00:00: sense key Not Ready !! !! in the /var/log/kernel.syslog file if debug is active. !! !! !! !! Hit the "Esc" key on the jukebox front/Operator panel !! !! 'till you get back to the normal, running display. !! !! !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! To mount a CD/DVD, mover mv s0 d0 mount /mnt/cdrom1 The data will be at /mnt/cdrom1. Note: You won't be able to move the CD back to the slot without unmount /mnt/cdrom1 A "mover mv d0 s0" command will get this error message. ioctl failed (MOVE): Device or resource busy To read the volume label, mover mv s0 d0 volname /dev/cdrom1 For example, for what we know as the impact102004 DVD, volname returns IB1274_R87_-250(1)_DVD_1 To rename it, I thought I could use mover's settag command, mover settag s0 pri impact102004 but this gives this strange error ioctl failed (SVOLTAG): Invalid request code making me think that settag isn't supported on this Pioneer DRM-7000 jukebox, or it's not implemented correctly. Reference this line in the autojuke man page, "Volume tags work only if the changer supports them." The scheme will be /cdrom = Bunch of links, Real (or "renamed") volume names -> Jukebox Slots eg, /cdrom/impact102004 -> /jukebox/0 /cdrom/impact242004 -> /jukebox/1 /jukebox = Automount-watched directory, with a subdirectory for each slot in the jukebox, in our case, 0-39 and 500-769. To load a CD/DVD, I will modify the loadnn script, which will take an optional parameter (the volume label you wish - this way you don't have to do a rename command later) and maintain this "database" of volume names in /cdrom, with their respective slot numbers in /jukebox. So for example, to load a CD/DVD into slot n (n =0-39 or 500-769), n=5 (for example) mover pos e0 mover mv e0 d0 label=$(volname /dev/cdrom1) mover mv d0 s$n Lower-case the label, and if there's any funny characters in it, prompt for it to be renamed. Once you have a good CD label, do the ln -sf /jukebox/$n /cdrom/$label To get the automounter working with the /jukebox directories, the incomplete "man autojuke" said to use /usr/sbin/automount /jukebox program /usr/sbin/autojuke This translates to adding this line to the autofs master file, /etc/auto.master, /jukebox /local/usr/sbin/autojuke --timeout=60 This line is read by the autofs service (/etc/rc.d/init.d/autofs), which builds the above automount command. mkdir /jukebox cd /jukebox for i in $(seq 0 39) $(seq 500 769);do mkdir $i;done mkdir /cdrom service autofs start Since I already had the impact102004 DVD in slot 0 & impact242004 DVD in slot 1, ln -sf /jukebox/0 /cdrom/impact102004 ln -sf /jukebox/1 /cdrom/impact242004 To unload a CD/DVD, modify the unload script to If a numeric parm was given to unload, presume it was a slot number and find the corresponding CD/DVD label in /cdrom. Otherwise find the corresponding slot number. rm /cdrom/$label mover mv s$n e0 ===================================================================================== --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- -- -- -- Below is a fruitless diversion in getting a newer version of scsi-command. -- -- Perhaps it'll be useful when we move to Linux kernel 2.6. -- -- -- --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- Apparently, there's a newer scsi-changer patch than the one I picked up. See my scsi file, but the bottom line is, the patch I picked up is/was for the Linux 2.4 kernel and uses the old scsi_allocate_device routine. It should be using scsi_allocate_request instead. Searching around for an upgraded scsi-changer, I found http://www.uwsg.iu.edu/hypermail/linux/kernel/0305.1/0065.html which had a very similar scsi-changer patch file, but the key differences are #define VERSION "0.22" instead of #define VERSION "0.20" and it uses scsi_allocate_request instead of scsi_allocate_device Yay!!! This identical patch is also at http://seclists.org/lists/linux-kernel/2003/May/1984.html and another version at http://www.kernel.org/pub/linux/kernel/people/mgligh/patches/2.6.1/2.6.1-mjb1/700-scsi_changer There's a bunch of versions at http://dl.bytesex.org/patches Directory VERSION scsi_allocate_? Difference From Previous Version ============ ======= =============== ====================================== 2.4.25-rc1-1 0.20 device (Old) Doc in Documentation/Configure.help dep_tristate in arch/sparc64/config.in 2.4.26-1 0.20 device (Old) Doc in Documentation/Configure.help dep_tristate in arch/sparc64/config.in 2.6.5-1 0.22 request (New) First version that uses scsi_allocate_request but both tristate (not dep_tristate) and the Doc is in drivers/scsi/Kconfig. 2.6.6-1 0.22 request (New) 1 extra line in drivers/scsi/Makefile 2.6.6-rc2-1 0.22 request (New) No difference Doc in drivers/scsi/Kconfig 2.6.7-1 0.22 request (New) 3 extra lines in drivers/scsi/Makefile Doc in drivers/scsi/Kconfig So I'm going to take the latest scsi-changer patch from http://dl.bytesex.org/patches/2.6.7-1/10_scsi-changer-2.6.7.diff.gz and modify it for my needs as follows. - The original patch updated drivers/scsi/Kconfig, which doesn't exist in my Linux. A) It put in the documentation about the CONFIG_CHR_DEV_SCH kernel build option, which previously went in Documentation/Configure.help. B) It also added the tristate statement for CONFIG_CHR_DEV_SCH, which previously went in drivers/scsi/Config.in so I had to split up this part of the patch, patching instead, the two files Documentation/Configure.help and drivers/scsi/Config.in - Tweak the starting line number of the drivers/scsi/Makefile - Rework the include/linux/major.h update - Rework the include/scsi/scsi.h update The result is a 1585-line patch file called scsi-changer-0.22-patch. ************************** ************************** ** ** ** Rick, see also the ** ** modprobe ch ** ** and depmod -a ** ** commands. ** ** ** ************************** ************************** ==================================================================================== To rebuild the kernel on vinu, Install prereq's; - To allow "make menuconfig" work, cd /afs/d/software/base/linux/Redhat.Enterprise.Linux-3/RedHat/RPMS rpm -Uvh ncurses-devel-5.3-9.3.i386.rpm - To install the latest source, rpm -Uvh /afs/d/software/fixes/linux/kernel-source-2.4.21-15.0.2.EL.i386.rpm Establish my kernel source directory/sandbox, cd /usr/src cp -pR linux-2.4.21-15.0.2.EL linux-2.4.21-15.0.2.EL.scsi-changer.0.22 cd linux-2.4.21-15.0.2.EL.scsi-changer.0.22 Start hacking, vi Makefile and change the EXTRAVERSION line from "linux-2.4.21-15.0.2.ELcustom" to "linux-2.4.21-15.0.2.EL.scsi-changer.0.22". (That's kind of a mouthfull. Perhaps I should trim this string down?) cp -p /u/jasper/aixnotes/linux/scsi-changer-0.22-patch . patch -bp1 < scsi-changer-0.22-patch make mrproper make oldconfig # Uses configs/kernel-2.4.21-i686-smp.config to write .config vi .config # Set CONFIG_IKCONFIG=y make depend > /tmp/make.depend.out 2>&1 # Took about a minute or two To compile the kernel, make bzImage > /tmp/make.bzImage.out 2>&1 # Compiled 439 modules in 7 minutes. To compile all the separately-loadable modules, make modules > /tmp/make.modules.out.1 2>&1 # Compiled 1820 modules in 40 minutes. This gave errors when trying to compile ch.c due to a reorginization of header files. Specifically, my version of the Linux source did not have scsi_cmnd.h, scsi_driver.h, or scsi_ioctl.h in the /usr/src/*/include/linux/scsi directory, so the #include's in ch.c couldn't get satisified. =================================================================================