Burning ISO image on CD with SPTI, need some help

Hi all, first post!
I woke up one day and wanted to face a completely new challenge in programming for educational purposes.
The task: Burning an ISO-image to a CD-RW using SPTI. (Which is completely new to me)

I’ve been reading the MMC and SPC documents, and also different threads on this forum to figure out how to command the drive. I’ve come quite far I think but I need some help for my last steps.

This is what I’m doing…
A formatted, blank, CD-RW is mounted in drive.
Not doing any actual checks in my code (media capacity, format, profile etc). I know I’m lazy but I just want to see the CD-image written to the disc by my own commands, nothing more, nothing less.
1. Sending Write parameters mode page

  • [li]Settings:[/li]BUFE=1
    WriteType=02 (SAO)
    Data block type=8 (2048bytes)
    Session format code=00 (00 = CD-DA, or CD-ROM or other data disc)
    FP=0(ignored if not packetwriting)
    TrackMode=0110 (Data track, recorded uninterrupted, digital copy permitted)

    [li]Ignored fields:[/li]Packet Size
    Audio Pause Length
    Media Catalog Number

2. Sending cue sheet

  • [li]Cue sheet:[/li]The ISO image I’m trying to burn here is quite small. Only 00:11:73 in length. And as the 2 second pre-gap seems to be included in ISO images, so I don’t have to compensate for it.

61 00 00 01 00 00 00 00
61 01 00 10 00 00 00 00
61 01 01 10 00 00 02 00
61 aa 01 01 00 00 0b 49

[li]As you can see, I’ve set 4th byte (Data form) to be 01 for both Lead-in and lead-out. This will cause the drive to generate it, right?[/li][li]I’m using 61 for all entries, is this OK?[/li][li]This command fails when I tried to BCD-encode the MSFs. But I shouldn’t, right?[/li][/ul]

3. Writing (using Write(10) )

  • [li]Settings:[/li]FUA=0
    Starting to write at LBA -150
    [li]For the first Write command. The drive fails with:[/li]5 2C 00 COMMAND SEQUENCE ERROR.
    Can someone figure out why?
  • How many blocks can I transfer with one Write(10) command? A whole CD if I wanted?
  • Is it possible to use several Write(10) commands to complete one session/track? Or is that not permitted during “uninterrupted” writing?

4. Sync cache

[li]Not reached this far yet[/li][/ul]

I know it is a lot to ask and a lot of of information for you to analyze. But could could someone please try to answer my questions (greenish) and try to find the cause to the error (brownish)?
And if you see anything else that is completely insane in my procedure, please lecture me :o

Thanks for any help I can get!


There are people here who know how to do what you want to do
but it is way too much to cover in a forum. This may be why you haven’t
gotten a response yet.

Don’t be discouraged. You will find it interesting and certainly a challenge.

First, if you haven’t already, get the documentation :



Next you need some good working examples to learn from. There are
some open source burner programs out there but they are very complex
and not easy to follow. I highly recommend the website of one of the moderators of this forum. Go to Truman’s website and basically read, study and download everything on it.

You might also get this handy easy to understand guide.


I would not try DAO as a beginner. It can be tricky. Instead try TAO.
It’s very straight-forward; no cue sheet, no writing to LBA -150.

You have the right idea about the preparation stage.
But you’re not quite understanding the write stage although you hinted at it.

Writing the ISO to the disc is done by making a loop (repeat/until or While do) and using Write(10/12) to burn say 64k chunks of the ISO during each iteration.

You include the Read Track Information command in the loop to provide you with the next-writable-address (NWA) to use in the following Write(10/12) command for it’s Logical Block Address parameter. Your chunk size goes in the Transfer Length parameter. In the case of 64k chunks, the transfer length (blocks) would be 32 (65536 div 2048).

After the last chunk of the ISO file has been written to the disc and you exit the loop, call the Sync cache command to write any bytes remaining in the drive’s buffer cache. It’s also a good idea to do a sync cache before you start your write loop to flush any stray bytes that might be in there. Use 0 & 0 for the LBA & number of blocks parameters.

Finally you need to close the logical track, close the session and finalize the disc. This is done by calling the Close Track Session command 1st with Close Function 1 (Close a Logical Track) then with Close Function 2 (Close Session/Finalize disc).

SPTI is the transport. It sends each scsi MMC command to the drive and returns the response. It’s vital to handle the response correctly. For example the Read Track Information command returns the NWA (among other info). If you get that wrong the next write command tries to burn the next chunk at the wrong place (address) on the

Using a CD-RW is a good choice. When you get an error, do a fast blank on it, fix your code and try again. With CD-R you’d probably have a fairly high stack of “coasters” before you succeeded. Good for office parties maybe but not much else.

This is just a very basic sketch of the process.
Study the documentation and examples.


Thank you so much [B]nifmud [/B]for answering my post!

I realized myself that my first post was far to huge and technical for anyone to answer all my questions.

I had already read most of the sources that [B]nifmud [/B]posted, but there was of course some new interesting things to read too. But unluckily, there was nothing that could fix the evil “COMMAND SEQUENCE ERROR”. My current implementation was already based on the instructions from the “cookbook.txt” so I knew I was at least somewhere near a correct solution, but yet I had that damn error :confused:

I hate to admit it, but I actually cheated a bit. I downloaded TraceSPTI and traced the commands from ImgBurn, when it burned my image. It turned out that my commands was almost the same, except for a few major things:

[li]ImgBurn sets the Write Mode Page and the Cue Sheet to burn images with “digital copy prohibited” instead of “digital copy permitted”. (I however doubt that this matters significantly in my situation)[/li][li]The 2sec pregap was not included in the ISO as I thought from the beginning. So these two seconds needed to be added to the track in the Cue Sheet. The pregap, consisting of 150 blocks of zeros, had to be written to the media manually starting from LBA -150.[/li][li]It seemed like ImgBurn also included the command “SET STREAMING” to set the write speed (even though a “SET CD SPEED” command also was issued). Don’t know if this is necessary for some drives but since ImgBurn did it for my drive, so I did it as well.[/li][li]As [B]nifmud[/B] pointed out, a Sync cache was issued once before write.[/li][li]ImgBurn also locked the medium during the whole operation. Which my application didn’t. When I discovered this I thought: [I]“omg omg, this must be why my program can’t write”. [/I]So I did the same.[/li][/ul]
And guess what? Still COMMAND SEQUENCE ERROR! :Z
I started to make small insignificant changes everywhere, hoping it would solve the problem. But no luck :frowning:

And now the strangest part. During the troubleshooting I came to a point where I needed some specific output which made me add a printf-command in my program class that handles the SCSI-commands. This resulted in a recompile of that class. And then everything just started to work! So maybe this was a VS2008-problem all from the beginning.

So now I can happily inform everyone that I just burned my first ISO image, MODE1, using SAO from my own application :slight_smile:

Sorry for this second long post, but someone else may find my struggle interesting in the future.

Love and respect!


I should have added “cookbook.txt” is a “rough” guide.
I have differences with it on the details in various sections.

You didn’t need TraceSPTI for ImgBurn. It has a debug mode that saves all that info to a log file; settings for the cue sheet, write parameter mode page, etc. Although it won’t show you how to
burn the lead-in.

It’s always good to check the CD-RW you burned for errors by comparing against the original material.
Personally I recommend CDCheck at
it does DVDs too. Free for personal use.

Now that you can do a DAO on CDs, DVDs should be easy.
I’ve always thought CDs were more difficult what with sub-channels and all the different data modes.