CD Writer mini-HOWTO by Matt Cutts, cutts@ms.uky.edu v0.2, 17 Dec 1994 1. Introduction This is how I wrote a CD with Linux kernel v1.1.64, Philips CDD 521 (although outside label was "Kodak PCD Writer 200 PLUS"), and an Adaptec 1542cf. Your mileage may vary; not responsible if this causes your computer to explode; all trademarks are trademarks, etc. In particular, cdwrite supposedly only works with Philips writers, although to my knowledge no one has tested it on other writers. The first part is complete reconstruction of the process that I did to write a CD. After everything is done once, you need only use mkisofs and cdwrite for each CD you write. 1.1. Feedback This document describes my experience in getting a CD writer to work. I may be able to answer some questions or comments about this test. Please feel free to mail Matt Cutts, at cutts@ms.uky.edu. Let me know if this document helped, or if some other section would be helpful. Please point out any mistakes that you find as well. 2. The Process Here's a chronological recreation of what I did. You may want to skip the steps that resulted in kernel panics 8-). Note that much of this process will require you to be super-user on the machine. 2.1. shut down computer; hook CD writer to computer; reboot ---> causes a kernel panic 2.2. upgrade to 1.1.64 kernel ---> still causes a kernel panic 2.3. change 1542CF settings Mike McKenna (our local hardware guru) and I changed around quite a few settings, so I'm going to do a complete list of them. One of them fixed everything. I'm 90% sure that it was changing "Enable Disconnection" to "no" for the SCSI ID# corresponding to the CD writer, but I haven't written a CD since I've played with the settings. Try changing that first; if that doesn't work, try changing some of the other setting that I mentioned. When you boot, hit to get into the SCSI-Select utility. Go into "Configure/View Host Adapter Settings". Here are my working settings when I wrote the CD: Host Adapter IRQ Channel -> 11 Host Adapter DMA Channel -> 5 Host Adapter SCSI ID -> 7 [BIOS Revision: 2.02; Base Address: DC000h; Firmware: Rev. B.0; Checksum: A223h] (these should be irrelevant to you; DO NOT change the settings above) SCSI Parity Checking Enabled DMA Transfer Rate 5.0 MB/sec Host Adapter SCSI Termination Enabled SCSI Device Configuration (note hard drive = #0, writer = #1, 1542 = #7) #0 #1 #2 #3 #4 #5 #6 #7 Enable Sync Negotiation no no no no no no no no Enable FAST SCSI no no no no no no no no Enable Disconnection yes no yes yes yes yes yes yes Send Start Unit Command no yes no no no no no no *(default is all yes for Enable Disconnection and all no for Send Start Unit Command) Advanced Configuration Options Floppy Controller I/O Port (AHA-1542CF only) 3F0h-3F7h Reset SCSI Bus at Power-On Enabled Host Adapter BIOS (Configuration Utility Reserves BIOS Space) Enabled System Boot (INT 19h) Controlled by Host Adapter BIOS Enabled Extended BIOS Translation for DOS Drives > 1 GByte Disabled *Support Removable Disks Under BIOS as Fixed Disks Enabled Dynamically Scan SCSI Bus for BIOS Devices Disabled BIOS Support for More Than 2 Drives (MS-DOS(R) 5.0 and above) Disabled Immediate Return On Seek Command Enabled Display Message During BIOS Initialization Enabled *BIOS Support for Floptical Drives Enabled Items with an asterisk are different from the default. Sorry to dump this whole options list for those who don't need it, but I figured a few SCSI novices might appreciate it. REMEMBER: I think that the only needed change is Enable Disconnection for the ID# of your CD Writer. Make it "no" instead of "yes". The result: no panic; recognizes as CDROM drive (sr0); SCSI generic driver doesn't say anything either way, so couldn't tell if recognized 2.4. use mkisofs to produce binary image (I used mkisofs v1.00) e.g. "mkisofs -o /home/cd.image /home/dir_to_archive" [I used mkisofs1.00, from tsx-11.mit.edu, at /pub/linux/BETA/cdrom/mkisofs-1.00.tar.gz; version 1.01 is also available and would probably work even better]. Can also get iso9660-diagnose.tar.gz from the same directory, which is another cdrom tool (I haven't tried it). See mkisofs usage in section 3. 2.5. make SCSI generic devices e.g. "/dev/MAKEDEV sg" (will create sga -> sgh; generic devices are allocated/assigned at boot time). 2.6. realize that the SCSI generic driver isn't reading things correctly. Joseph Julicher at Rose-Hulman suggested a kernel hack to process the SCSI inquiry byte (it needs a bitwise and with 0x1f). I also changed the TYPE_WORM drive to be writeable; not sure that this is required for things to function correctly. In fact, I made everything writable (tacky, but effective!). The original /usr/src/{linux-1.1.64/}linux/drivers/scsi/scsi.c (beginning around line 361) switch (type = scsi_result[0]) { case TYPE_TAPE : case TYPE_DISK : case TYPE_MOD : SDpnt->writeable = 1; break; case TYPE_WORM : case TYPE_ROM : SDpnt->writeable = 0; break; default : I changed it to: switch (type = scsi_result[0] & 0x1f) { case TYPE_TAPE : case TYPE_DISK : case TYPE_MOD : case TYPE_WORM : case TYPE_ROM : /* probably shouldn't be writeable :) */ SDpnt->writeable = 1; break; default : 2.7. fix cdwrite (version that I changed was v1.3) [I obtained cdwrite from tsx-11.mit.edu, at /pub/linux/BETA/cdrom/private/mkisofs/cdwrite-1.3.tar.gz] original program had following code (beginning around line 439): set_timeout(fd, timeout); /* First make sure we know how to talk to this writer */ inquiry (fd, &reply_len, &reply, &manufacturer[0], &model[0]); if(strcmp(manufacturer,"PHILLIPS")) { I changed program to following: (added the next two lines near the top) /* new #define from drivers/scsi/scsi.h; orig program had this defined */ #define SG_SET_TIMEOUT 0x2201 (Following code replaced orig. code around line 439) /* set_timeout(fd, timeout);*/ if (ioctl(fd, SG_SET_TIMEOUT, SG_SET_TIMEOUT, &timeout) < 0) { perror ("ioctl SG_SET_TIMEOUT"); exit(5); } /* First make sure we know how to talk to this writer */ inquiry (fd, &reply_len, &reply, &manufacturer[0], &model[0]); if(strcmp(manufacturer,"IMS")) { Note that the Philips CDD 521 returns "IMS" as its manufacturer, and that I used modified the newer program to set the timeout as the original program did. When you untar cdwrite, the original program is in the "orig" directory. 2.8. recompile kernel and reboot for change to take effect Make sure to say yes to SCSI generic support, or else the generic driver won't be included in the kernel. You must reboot for the new kernel to replace the currently running one. 2.9. write a CD! e.g. "cdwrite /dev/sgb < /home/cd.image" Note that sgb was the CD writer, i.e. SCSI generic device b (because the hard drive was generic device a), and that /home/cd.image is an ISO9660 image produced by mkisofs. 3. After the First Time That should take you through the process of getting ready to write one CD. After that things are trivially easy. Make sure you have plenty o' space on your disk. Then just do "mkisofs -o filename path", where path is the path of the directory tree to be copied into ISO9660 format, and filename is the name of the resulting binary image. The mkisofs program has lots of other great options (like Rock Ridge extensions); check out the man page that Eric Youngdale included for his program. Next, do "cdwrite scsi_device < cdrom_file", where scsi_device is the generic SCSI device and cdrom_file is the ISO9660 image. The cdwrite program also has a few options, like -speed (to write single/double speed) and -dummy (to test everything without actually writing the disk). Check the cdwrite.c program to see the options it has. 4. Thank you Thanks to all the people who wrote with suggestions for my problems; thanks also to Eric Youngdale for the mkisofs code, Adam Richter for the original cdwrite program, Joseph Julicher for noticing the SCSI generic problem, Mike McKenna for figuring out the 1542 settings, and my employers for paying me to explore with a neat toy.