libburnia.pykix.org Optical Media Rotisserie Recipes as of January 2007 Content: - TAO Multi-Session CD Cookbook (CD-R, CD-RW) - SAO CD Cookbook (CD-R, CD-RW, pure audio or pure data only) - Overwriteable DVD Cookbook (DVD-RAM, DVD+RW, DVD-RW) ------------------------------------------------------------------------------- TAO Multi-Session CD Cookbook ------------------------------------------------------------------------------- Guided by reading mmc-r10a.pdf , O.8 "Write a Track" from http://www.t10.org/ftp/t10/drafts/mmc/ backed by reading mmc5r03c.pdf from http://www.t10.org/ftp/t10/drafts/mmc5/ by reading spc3r23.pdf from http://www.t10.org/ftp/t10/drafts/spc3/ by reading libburn/* from http://icculus.org/burn and by experiments with drives NEC ND-4570A, LG GSA-4082B, LITE-ON LTR48125S which used in part code from http://icculus.org/burn. For libburnia.pykix.org by Thomas Schmitt ------------------------------------------------------------------------------- Media type can be recognized by Current Profile from 46h GET CONFIGURATION. (mmc5r03c.pdf 6.6.2.1) CD-R 0009h CD-RW 000ah The following topics are covered in this text: - About blank, appendable and finalized CD media - Writing a session to CD in TAO mode - Obtaining CD multi-session info for extending ISO-9660 filesystems - Obtaining a Table Of Content from CD ------------------------------------------------------------------------------- About blank, appendable and finalized CD media : CD media have to be blank or appendable in order to be writeable in TAO mode. The according status may be inquired by 51h READ DISC INFORMATION requesting Data Type 000b Standard Disc Information, where reply value Disc Status indicates: 00b blank 01b appendable 10b finalized 11b others (unsuitable for this recipe) (mmc5r03c.pdf 6.22.3.1.4) CD-RW which are finalized or appendable may be blanked by command A1h BLANK with blanking types 000b "Blank the disc" or 001b "Minimally blank the disc". The Start Address/Track Number will be ignored so it may well be 0. Because the operation is long running it is advised to set the Immed bit and to watch the progress by commands 00h TEST UNIT READY and 03h REQUEST SENSE with DESC bit set to 0 for fixed format reply. It is done when 00h succeeds and 03h reports 0 in PROGRESS INDICATION (byte 1+2 in Table 22 = byte 16+17 SENSE KEY SPECIFIC in table 26). (mmc5r03c.pdf 6.2 BLANK) (spc3r23.pdf 4.5.2.4.4 table 22, 4.5.3 table 26, 6.27 REQUEST SENSE, 6.33 TEST UNIT READY) ------------------------------------------------------------------------------- Writing a session to CD in TAO mode : The writing method for blank or appendable media is the same. A new session will get created automatically by the first track when it is written. If the media is blank then the new session will be the first and only one in the table of content. If the media is appendable then a new session will be appended to the existing sessions. In any case the new track will be the first one in the new session. Speed may be set by BBh SET CD SPEED parameter Drive Write Speed. Note that kbytes/sec means 1000 bytes/sec and not 1024/sec. Rotational control should be set to 00b. 1x CD speed is 176.4 kbytes/sec. Speed is usually set to the next lower possible value by the drive. So it is helpful to add a few kbytes/sec just in case the drive has rounding problems. (mmc5r03c.pdf 6.37) Before writing can occur, a Write Parameters mode page 05h has to be composed and transmitted via 55h MODE SELECT. Mode page 05h describes several burn parameters: BUFE Buffer Underrun protection 0=off, 1=on Test Write -dummy mode for writing 0=off, 1=on Write Type Packet/TAO/SAO/RAW 01h = TAO Multi-session Wether to keep appendable 00b = finalize 11b = keep appendable Track Mode Describes frame type 4 for data , 0 for audio Data Block Type Layout of payload blocks 8 for 2048 byte data blocks 0 for 2352 byte audio blocks Audio Pause Length 150 = 2 seconds Any other parameters may be set to 0. Mode page data as of MMC-5 table 644 are preceded by a Mode Parameter Header as of SPC-3 table 240. This 8-byte header may be filled with zeros. (mmc5r03c.pdf 7.5.4 The Mode Page, 4.2.3.4 Table 17 CONTROL = Track Mode) (spc3r23.pdf 6.8 MODE SELECT, 7.4.3 Mode parameter header formats) Writing has to begin at the address returned by 52h READ TRACK INFORMATION with Address/Number Type set to 01b and Logical Block Address/Track/Session Number set to FFh. The Next Writeable Address as of table 500 is the number to start writing with. (mmc5r03c.pdf 6.27 ) Writing is performed by one or more 2Ah WRITE transactions with the Logical Block Address counted up from the initial number in sync with the number of blocks written. I.e the Transfer Length of the previous 2Ah WRITE has to be added to the Logical Block Address for the next 2Ah WRITE. Only full blocks can be written. (mmc5r03c.pdf, 6.44) When writing is done, it is mandatory to force the drive's buffer to media by 35h SYNCHRONIZE CACHE. (mmc5r03c.pdf, 6.41) A track must at least contain 300 payload blocks: 4 seconds of audio or 600 KiB of data. (mmc5r03c.pdf 6.3.3.1.2) The track has to be closed by 5Bh CLOSE TRACK SESSION Close Function 001b. Older MMC specifies a valid Logical Track Number FFh to depict the open track. MMC-5 is quite silent about this. FFh works for my drives. (mmc5r03c.pdf 6.3.3.1.2) After that, a new track may be written beginning with sending the mode page 05h again. It is not tested wether 05h can be omitted if Track Mode and Data Block Type are the same as with the previous track. The new track will be added to the session which was opened by the first track. After the last track of a session, 5Bh CLOSE TRACK SESSION Close Function 010b with Logical Track Number 0 closes the session. It depends on the Multi-Session value in mode page 05h wether the disc is finalized or stays appendable. (mmc5r03c.pdf 6.3.3.1.3) ------------------------------------------------------------------------------- Obtaining CD multi-session info for extending ISO-9660 filesystems : Program mkisofs expects two numbers with its option -C which describe the situation on an appendable CD which already contains a ISO-9660 filesystem in the first track of the last session. The first number is the Logical Block Address of that track containing the existing ISO-9660 filesystem image. This number is needed for mkisofs option -M to connect to the existing image. The new image will refer to files in the previously existing image. mkisofs option -M needs read access to the CD or a blockwise copy of it on hard disk. The number is gained by 43h READ TOC/PMA/ATIP. (mmc5r03c.pdf 6.26) Untested is Format 0001b which in table 478 promises quick access via Start Address Of First Track In Last Session. (mmc5r03c.pdf 6.26.2.5 table 478, 6.26.3.3.1) libburn gets the number from its Table Of Content model which is obtained by 43h READ TOC/PMA/ATIP, Format 0010b. See below. The second number is an exact prediction of the Logical Block Address of the new track which will contain the newly generated ISO-9660 image. Even without mkisofs option -M this second number is still needed to make the inner block address pointers of the image match the Logical Block Addresses on CD. For that one may inquire 52h READ TRACK INFORMATION with Address/Number Type set to 01b and Logical Block Address/Track/Session Number set to FFh. The Next Writeable Address as of table 500 is the number to use. (mmc5r03c.pdf 6.27 ) ------------------------------------------------------------------------------- Obtaining a Table Of Content from CD : The structure of a CD is comprised of sessions. Each session contains one or more tracks and is followed by a lead-out. A track has an address and a length. Table of content information is gained by 43h READ TOC/PMA/ATIP, Format 0010b. (mmc5r03c.pdf 6.26.2.5 table 478) The number of sessions is given by Last Complete Session Number. The number of TOC Track descriptors is: (TOC Data Length - 2)/11 . Each TOC Track Descriptor contains a Session Number. If POINT is >= 1 and <= 99 (63h) then the descriptor is about the track of which POINT tells the number. The start address of this track can be read from PMIN, PSEC, PFRAME where it is encoded in MSF format: blocks = frames - 150, 75 frames = 1 sec , 60 sec = 1 min. The length of the track is given by MIN,SEC,FRAME in the same format. If POINT = A0h then the descriptor tells in PMIN the first track number of its session. POINT = A1h tells in PMIN the last track number of its session. POINT = A2h describes in PMIN, PSEC, PFRAME the lead-out of a session, i.e the first address after the session's end. (Next writeable address typically is lead-out + 11400 after the first session, lead-out + 6900 after further sessions.) POINT = B0h tells in MIN,SEC,FRAME this next writeable address or FFh,FFh,FFh for finalized disc. (mmc5r03c.pdf 6.26.3.4 table 489, 4.2.3.7 Mode-1 Q, Mode-5 Q) In libburn the address of the first track in the last session is obtained from the last session's POINT = A0h and from the track descriptor with the POINT value matching the PMIN value of the A0h descriptor. Untested is wether POINT = B0h and 52h READ TRACK INFORMATION are always in sync. libburn uses the info provided by 52h READ TRACK INFORMATION. ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- SAO CD Cookbook ------------------------------------------------------------------------------- Guided by reading libburn/* from http://icculus.org/burn backed by reading mmc5r03c.pdf from http://www.t10.org/ftp/t10/drafts/mmc5/ and by experiments with drives NEC ND-4570A, LG GSA-4082B, LITE-ON LTR48125S which used in part code from http://icculus.org/burn. For libburnia.pykix.org by Thomas Schmitt ------------------------------------------------------------------------------- Recognition of media type and state (blank, appendable, finalized) is as described in the TAO Multi-Session CD Cookbook. See there. The MMC specs do not give much hint about the combination of SAO and multi-session. My drives refused not only on a few experiments which i did in libburn but also failed with cdrecord -sao on an appendable CD. So for now only blank CD seem to be suitable for SAO writing. Different from TAO mode, the whole session layout is announced to the drive by sending a Cue Sheet. This implies that the sizes of the tracks have to be known in advance, which is a heavy drawback when dealing with track data sources like stdin, named pipes or sockets. Nevertheless, SAO seems to be best writing mode for audio purposes, as our audio expert Lorenzo Taylor found out. A SAO session in libburn may either consist entirely of audio tracks or entirely of data tracks. For mixed sessions, only TAO is usable yet. - Composing a SAO CD Cue Sheet (either audio or data, but not mixed) - Writing the prepared SAO CD session - What is known about mixed mode sessions ------------------------------------------------------------------------------- Composing a Cue Sheet (either audio or data, but not mixed) : The Cue Sheet will get submitted to the drive by 5Dh SEND CUE SHEET. Each entry of the sheet is of 8 bytes size. Its fields are named CTL|ADR, TNO, INDEX, DATA FORM, SCMS, MIN, SEC, FRAME . (mmc5r03c.pdf 6.33) CTL is 40h for data and 00h for audio. (mmc5r03c.pdf 6.33.3.4) ADR is always 01h. TNO is the track number (1 to 99). INDEX is a subaddress within tracks. This recipe uses only INDEX 01h within tracks. (mmc5r03c.pdf 4.2.3.5.2) DATA FORM is 00h for audio payload , 10h for data. (01h for audio pause is not used in libburn). (mmc5r03c.pdf 6.33.3.11 CD-DA Data Form, 6.33.3.12 CD-ROM mode 1 Form) SCMS is always 00h. MIN, SEC, FRAME give the MSF address where the described data entity starts. LBA = frames - 150, 75 frames = 1 sec , 60 sec = 1 min. This address must increase from entry to entry (or at least stay equal). The first entry describes the Lead-in. Its content is (CTL|ADR ,00h,00h,01h,00h,00h,00h,00h) With the CTL|ADR for the first track: 41h for data, 01h for audio. The LBA for the first write is negative: -150. This corresponds to MSF address 00h:00h:00h. All addresses are to be given in MSF format. The first information track on disc is preceded by a pause encoding of 2 sec: (CTL|ADR,01h,00h, DATA FORM ,00h,00h,00h,00h) with DATA FORM = 00h for audio and 10h for data. By those 2 seconds the MSF address increases to 00h:02h:00h = LBA 0. Each track is represented by an entry (CTL|ADR, TNO ,01h,DATA FORM,00h, MIN , SEC , FRAME) TNO gives the track number. MIN, SEC, FRAME give the MSF address which becomes the start address of the track. The MSF address is then increased by the size of the track (to be used with next track or with lead-out). A track must at least contain 300 payload blocks: 4 seconds of audio or 600 KiB of data. (mmc5r03c.pdf 6.33.3.6) At the end of the session there is a lead-out entry (CTL|ADR,AAh,01h,01h,00h,MIN,SEC,FRAME) marking the end of the last track. (With libburn CTL is as of the last track.) ------------------------------------------------------------------------------- Writing the prepared session : Speed may be set by BBh SET CD SPEED parameter Drive Write Speed. Note that kbytes/sec means 1000 bytes/sec and not 1024/sec. Rotational control should be set to 00b. 1x CD speed is 176.4 kbytes/sec. Speed is usually set to the next lower possible value by the drive. So it is helpful to add a few kbytes/sec just in case the drive has rounding problems. (mmc5r03c.pdf 6.37) A Write Parameters mode page 05h has to be composed and transmitted via 55h MODE SELECT. This page describes the following parameters: BUFE Buffer Underrun protection 0=off, 1=on Test Write -dummy mode for writing 0=off, 1=on Write Type Packet/TAO/SAO/RAW 02h = SAO Multi-session Wether to keep appendable 00b = finalize 11b = keep appendable Track Mode Describes frame type 0 (is ignored) Data Block Type Layout of payload blocks 0 (is ignored) Audio Pause Length 150 = 2 seconds (ignored ?) Any other parameters may be set to 0. Mode page data as of MMC-5 table 644 are preceded by a Mode Parameter Header as of SPC-3 table 240. This 8-byte header may be filled with zeros. (mmc5r03c.pdf 7.5.4 The Mode Page, 4.2.3.4 Table 17 CONTROL = Track Mode) (spc3r23.pdf 6.8 MODE SELECT, 7.4.3 Mode parameter header formats) The Cue Sheet is submitted to the drive by 5Dh SEND CUE SHEET. Cue Sheet Size is 8 times the number of entries. (mmc5r03c.pdf 6.33) Writing is performed by multiple 2Ah WRITE transactions with the Logical Block Address counted up from the initial number in sync with the number of blocks written. I.e the Transfer Length of the previous 2Ah WRITE has to be added to the Logical Block Address for the next 2Ah WRITE. Only full blocks can be written. (mmc5r03c.pdf, 6.44) Writing begins at LBA -150 which is to be transmitted as 4-byte, Big-endian, two's-complement. E.g: -150 = FFh FFh FFh 6Ah. This is the natural form found with about any 32-bit processor, so only the endianness has to be taken into respect when converting a 32-bit integer into a LBA for command 2Ah WRITE. At first the mandatory pause preceding the first track has to be written as 150 blocks of the matching sector size: 2048 for data, 2352 for audio. By this, the LBA increases from -150 to 0. Next the tracks' payload is sent. For each track exactly the number of blocks has to be transmitted as is announced in the Cue Sheet by the difference of the track's own start address and the start address of the next entry in the Cue Sheet. After each write the LBA for the next write has to be increased by the number of blocks transmitted. Just like with TAO writing. There is no separator between the tracks of a pure mode SAO session. (If the session was mixed mode, there would be extended Pre-gaps and Post-gaps between data mode tracks and audio mode tracks.) (libburn sends its own buffer to the drive at the end of each track but does not sync the drive's chache. It is unclear wether this separation of tracks on the level of 2Ah WRITE is necessary with a pure mode session. It does not harm in any case and would probably be unavoidable if audio and data tracks were mixed.) When writing of all tracks is done, it is mandatory to force the drive's buffer to media by 35h SYNCHRONIZE CACHE. (mmc5r03c.pdf, 6.41) No further finalization is necessary. (I.e. no 5Bh CLOSE TRACK SESSION.) ---------------------------------------------------------------------------- What is known about mixed mode sessions : For now, SAO sessions with a mix of data and audio are not supported in libburn. Here are the reasons why. Obviously the code of http://icculus.org/burn is incomplete in this aspect. In mmc5r03c.pdf comparison of table 555 and 6.33.3.18 seems self-contradicting. (The second Pre-gap in table 555 does not match any of the criteria of 6.33.3.18. Also, there is no Post-gap shown in table 555 although 6.33.3.19 would prescribe some.) If a data track follows an audio track then the data track gets a preceding extended Pre-gap: (CTL|ADR, TNO ,01h,DATA FORM,00h, MIN , SEC , FRAME) with TNO already the number of the data track. The MSF address is to be increased by 3 seconds. The first second of the extended Pre-gap needs to be written in the audio track's mode and the other 2 seconds are to be written in the data track's mode. (libburn compares DATA FORM rather than burn_track.mode . Wrong ?) (libburn currently does only 2 seconds and the second part of Pre-gap. There is an issue with burn_track.pregap1 about this. Seems libburn mistakes the pause preceding track 1 for a part 2 of an extended Pre-gap.) If a data track is followed by an audio track then it gets a Post-gap of at least two seconds. No example of Post-gap is given for Cue Sheet. Maybe it is to be added to the track, or maybe it gets an own Cue Sheet entry ... who knows ? (libburn contains write code for pregap1, pregap2 and postgap. But only pregap2 ever gets activated. Once hackingly for the first 2 second pause, once incompletely for a change of DATA FORM.) Seems nobody ever tested this. Libburnia simply knows no use case where the correctness of Pre-gap and Post-gap would become evident. ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- Overwriteable DVD Cookbook ------------------------------------------------------------------------------- Inspired by Andy Polyakov's http://fy.chalmers.se/~appro/linux/DVD+RW/tools , backed by reading mmc5r03c.pdf from http://www.t10.org/ftp/t10/drafts/mmc5/ and by experiments with drives NEC ND-4570A and LG GSA-4082B. For libburnia.pykix.org by Thomas Schmitt ------------------------------------------------------------------------------- Media type can be recognized by Current Profile from 46h GET CONFIGURATION. (mmc5r03c.pdf 6.6.2.1) DVD-RAM 0012h DVD-RW Restricted Overwrite 0013h DVD-RW Sequential Recording 0014h (i.e. unformatted) DVD+RW 001Ah A short compilation of the write model: - Overwriting in general The recipes described here are depending on formatting state: - DVD-RAM, fully formatted DVD+RW or DVD-RW - Unformatted DVD+RW - Partly formatted DVD+RW - Unformatted DVD-RW - Partly formatted DVD-RW - Intermediate state DVD-RW ------------------------------------------------------------------------------- Overwriting in general : Depending on media type, some kind of formatting has to have happened before data can be written. Formatting may happen separately from writing or simultaneously. See the particular recipes below. No Write Parameters mode page 05h is to be sent. Speed can be influenced by B6h SET STREAMING , speed capabilities can be inquired by ACh GET PERFORMANCE. It is advised to set only speeds and sizes which are returned by ACh. (mmc5r03c.pdf 6.39 SET STREAMING, 6.8 GET PERFORMANCE) Optimal performance is promised without any speed setting. But my experiments showed that SET STREAMING values persist after media change. In the formatted area of the media, coarse random access is possible. For DVD-RAM and DVD+RW write addresses and data size need to be aligned to 2 KiB. For DVD-RW alignment has to be 32 KiB. Within these limitations the write address is at the discretion of the sending program. Just use 2Ah WRITE to send data. (mmc5r03c.pdf, 6.44) When writing is done, it is mandatory to force the drive's buffer to media by 35h SYNCHRONIZE CACHE. (mmc5r03c.pdf, 6.41) The size of the formatted area can be inquired by 23h READ FORMAT CAPACITIES. The Number Of Blocks value in the Current/Maximum Capacity Descriptor gives this size in 2 KiB blocks. But this is true only if Descriptor Type is 10b ("Formatted Media"). (mmc5r03c.pdf, 6.24.3.2.1, 6.24.3.2.3) Not yet formatted areas may be completely forbidden or they may be allowed for sequential writing (DVD-RW Intermediate state) or they may be allowed for random access only after the necessary waiting time for formatting to reach the desired address (DVD+RW with background formatting active). Already written areas can be overwritten without special precaution. Blanking a DVD-RW actually destroys its formatting. Most of the concepts usually expressed in Write Parameters mode page 05h do not apply to the recipes here: Test-Write, Buffer Underrun protection, Multi-session, Write Type, Block Type, Track Mode, ... There are hints for multi-session formats with DVD-RW but both of my drives do not offer "Add Session" Format Types 12h or 14h. (mmc5r03c.pdf 6.5.4.2.7 , 6.5.4.2.9) Caution: Drive and media compatibility seems still to be quite an adventure. If you experience problems, especially problems with readability, then try different drives and media brands. Failure does not necessarily mean that the software did anything wrong. ------------------------------------------------------------------------------- DVD-RAM, fully formatted DVD+RW or DVD-RW : Full format is the natural state of DVD-RAM. DVD+RW reaches this state if Background Formatting is allowed to finish without being stopped by 5Bh CLOSE TRACK SESSION. (mmc5r03c.pdf, 6.5 FORMAT UNIT, 6.5.4.2.14 Format Type = 26h) The formatting state of a DVD+RW may be inquired by 51h READ DISC INFORMATION requesting Data Type 000b "Standard Disc Information". In the reply, BG Format 3 indicates fully formatted media. (mmc5r03c.pdf 6.22.3.1.13) DVD-RW reaches this state either by Format Type 00h (or 10h) with maximum size given as Number Of Blocks, or by writing sequentially until the disc is completely full into an intermediate session opened by format 15h resp. 13h. (mmc5r03c.pdf, 6.5 FORMAT UNIT, 6.5.4.2.1, 6.5.4.2.10, 6.5.4.2.8) A fully formatted DVD-RW can be recognized by 23h READ FORMAT CAPACITIES. The Descriptor Type of the Current/Maximum Capacity Descriptor is 10b ("Formatted Media") and 0 blocks are offered with Format Types 13h or 11h. (mmc5r03c.pdf, 6.24.3.2.1, 6.24.3.3) See also discussion of unformatted or partially formatted DVD-RW below. In fully formatted state there is no need for any formatting before writing nor for any finalizing other than forcing the drive's buffer to media by 35h SYNCHRONIZE CACHE (which is mandatory for writing, anyway). (mmc5r03c.pdf, 6.41) (It seems to do no harm to send to DVD+RW or DVD-RW a 5Bh CLOSE TRACK SESSION with Close Function 010b despite there is no session open in this scenario.) ------------------------------------------------------------------------------- Unformatted DVD+RW This is the state of previously unused DVD+RW media. The formatting state of a DVD+RW may be inquired by 51h READ DISC INFORMATION requiring Data Type 000b "Standard Disc Information". In the reply, BG Format 0 indicates unformatted media (or unsuitable media). (mmc5r03c.pdf 6.22.3.1.13) Formatting has to be started by command 04h FORMAT UNIT, Format Type 26h. Different from other format types, 26h allows to send a fantasy size of 0xffffffff blocks and does not require the caller to know the exact maximum size offered with that format. (mmc5r03c.pdf, 6.5 FORMAT UNIT, 6.5.4.2.14 Format Type = 26h) As its name suggests, one has not to wait for background formatting to end but may very soon start writing as on formatted media. Random access to yet unformatted areas can last long, though. If backup formatting has been started at the beginning of the session, then it may get stopped after the final cache sync by 5Bh CLOSE TRACK SESSION with Close Function 010b. (mmc5r03c.pdf 6.3.3.6) Formatting of DVD+RW is called "de-icing" because unformatted areas offer no hold for random access addressing and are thus slippery like ice. One can also see a color change from shiny unformatted to more dull formatted media. ------------------------------------------------------------------------------- Partly formatted DVD+RW : This state is achieved by stopping background formatting before the media was completely formmatted. The formatting state of a DVD+RW is obtained by 51h READ DISC INFORMATION requiring Data Type 000b "Standard Disc Information". In the reply, BG Format 1 indicates partly formatted media. (mmc5r03c.pdf 6.22.3.1.13) If the data of the session surely fit into the formatted area, then it would be unnecessary to restart background formatting. But in order to make the DVD+RW surely accept its maximum number of bytes, formatting may be restarted by command 04h FORMAT UNIT, Format Type 26h, with the Restart bit set and Number of Blocks set to 0xffffffff. (mmc5r03c.pdf, 6.5 FORMAT UNIT, 6.5.4.2.14 Format Type = 26h) From then on, the same rules apply as for previously unformatted DVD+RW. ------------------------------------------------------------------------------- Unformatted DVD-RW (media profile is 0014h) : This state is present with previously unused media. It is also present with media blanked by programs cdrecord, wodim or dvd+rw-format and with media which were sequentially written from blank state. Profile transition from formatted 0013h to unformatted 0014h is done by A1h BLANK. (mmc5r03c.pdf, 6.2) For becoming overwriteable such media need to be treated by command 04h FORMAT UNIT. (mmc5r03c.pdf, 6.5) The Format Type has to be chosen from the list replied by 23h READ FORMAT CAPACITIES. Suitable are Format Types 00h, 10h, 15h. (mmc5r03c.pdf 6.24) Format Types 00h and 10h provide a writeable area of a size given by Number of Blocks. Type 00h seems to be the most traditional and complete one. It needs no closing of a session at the end of writing. The Number Of Blocks may be at most the value reported by 23h READ FORMAT CAPACITIES in the entry for the desired format type. Full format is achieved by sending exactly the reported value. (mmc5r03c.pdf, 6.5.4.2.1 Format Type = 00h, 6.5.4.2.5 Format Type = 10h) Format Type 15h provides a writeable area of given size too, but this area can be expanded by sequential writing and afterwards marked as overwriteable by closing the session. It is even allowed to format with size 0 and to leave the size claim entirely to a sequential write process beginning at LBA 0. (mmc5r03c.pdf, 6.5.4.2.10 Format Type = 15h) When writing is done and cache is synced, one should send 5Bh CLOSE TRACK SESSION with Close Function 010b in order to bring the session out of Intermediate state. (mmc5r03c.pdf 6.3.3.2.3) If not written up to the last 32 KiB block, the DVD-RW is only partly formatted after that. ------------------------------------------------------------------------------- Partly formatted DVD-RW (media profile is 0013h) : This state is achieved by formatting a DVD-RW with a number of blocks which is less than offered for the Format Type by the drive's reply to 23h READ FORMAT CAPACITIES. If the media was most recently formatted by Format Types 015h or 013h then it must have got written some bytes and afterwards treated by 5Bh CLOSE TRACK SESSION, 010b in order to be partly formatted. (mmc5r03c.pdf 6.3.3.2.3 CLOSE TRACK SESSION 010b, 6.24 READ FORMAT CAPACITIES) Elsewise the media is in Intermediate state. See below. A partly formatted DVD-RW can be recognized by 23h READ FORMAT CAPACITIES. The Descriptor Type of the Current/Maximum Capacity Descriptor is 10b ("Formatted Media") and the Number Of Blocks with formats 00h, 10h or 15h is larger than the currently formatted size, resp. more than 0 blocks are offered with Format Types 13h or 11h. (mmc5r03c.pdf, 6.24.3.2.1, 6.24.3.3) If the data of the session surely fit into the formatted area, then it would be unnecessary to do any further formatting. But in order to make the DVD-RW surely accept its maximum number of bytes, partial formatting may be expanded by command 04h FORMAT UNIT, Format Type 13h, which is supposed to be offered by the drive in this state. This brings the session again into Intermediate state and thus allows expansion by sequential writing. As with Format Type 15h it is ok to set Number Of Blocks to 0, so that no fixed size formatting work is done and writing can begin soon after. (mmc5r03c.pdf, 6.5.4.2.8 Format Type = 13h) When writing is done and cache is synced, one should send 5Bh CLOSE TRACK SESSION with Close Function 010b in order to bring the session out of Intermediate state. (mmc5r03c.pdf 6.3.3.2.3) If not written up to the last 32 KiB block, the DVD-RW is only partly formatted after that. Format Type 13h has been tested only with expanding sessions formatted by 15h. Nevertheless it is offered with sessions from 00h and 10h, too. According to the specs, Format Type 11h would expand a session by a fixed size. This has not been tested yet because it is less appealing than 13h. (mmc5r03c.pdf, 6.5.4.2.6 Format Type = 11h) ------------------------------------------------------------------------------- Intermediate state DVD-RW (media profile is 0013h) : This state is achieved by formatting a DVD-RW with Format Type 15h or 13h without subsequentially writing data and sending 5Bh CLOSE TRACK SESSION with Close Function 010b. Such media behave very unpleasing with my DVD-ROM drive under Linux 2.4 ide-cd. One should therefore better avoid to release media in this state. This state can be recognized by 23h READ FORMAT CAPACITIES. The Descriptor Type of the Current/Maximum Capacity Descriptor is 11b ("Unknown Capacity") and no formats 13h or 11h are offered. (mmc5r03c.pdf, 6.24.3.2.1, 6.24.3.3) One may treat such media as if Format Type 15h or 13h had been freshly applied. I.e. sequential writing from LBA 0. After cache sync bring the session out of Intermediate state by 5Bh CLOSE TRACK SESSION with Close Function 010b. (mmc5r03c.pdf 6.3.3.2.3) -------------------------------------------------------------------------------