Creating a Bootable CD

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
Velovix
DCEmu Cool Newbie
DCEmu Cool Newbie
Posts: 11
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Tue Nov 27, 2012 12:19 am
Has thanked: 0
Been thanked: 0

Creating a Bootable CD

Post by Velovix »

After going crazy trying to get the toolchain for KallistiOS set up, I was finally successful, and every thing appears to be working. I wrote a simple program that uses SDL and I would like to burn it to a CD.
Apparently, a bootable Dreamcast CD has:
A four second audio track (which isn't a big deal)
IP.BIN (which I used makeip to create)
and 1ST_READ.BIN, or the code (?)

When I compiled my code using KallistiOS, I got an .elf file. Apparently, this needs to be a header-less .bin file. Allegedly, I should be able to use objcopy to convert it, but when I try to, it says it doesn't recognize my .elf file. EDIT: Using "sh-elf-objcopy -O binary test.elf test.bin" I was able to convert it.

If I need to clarify anything, please let me know, but what I really want to know is this: Am I even on the right track? To get much of this information, I've been using http://mc.pp.se/dc/, which is pretty comprehensive, but it's also a decade old. Is there a better source for this kind of information? Thanks for help!

EDIT: I guess it would also be helpful to know where the romdisk data goes.
User avatar
SiZiOUS
DC Developer
DC Developer
Posts: 404
Joined: Fri Mar 05, 2004 2:22 pm
Location: France
Has thanked: 27 times
Been thanked: 19 times
Contact:

Re: Creating a Bootable CD

Post by SiZiOUS »

In order to boot your '1ST_READ.BIN' file, you need to scramble your binary by using the 'scramble' command, which can be found on the Marcus site (http://mc.pp.se/dc/).

So the actions in order is:
  • Compile your project to get the .elf file
  • Use sh-elf-objcopy to get the the binary '.bin' form
  • Scramble the binary generated by sh-elf-objcopy.
Then after you can selfboot your program:
  • Burn the fake audio track (4 sec length)
  • Prepare the IP.BIN (bootstrap)
  • Make the ISO with mkisofs (and inserting the IP.BIN with the -G switch)
  • Burn the ISO generated in the second session.
Ayla
DC Developer
DC Developer
Posts: 142
Joined: Thu Apr 03, 2008 7:01 am
Has thanked: 0
Been thanked: 4 times
Contact:

Re: Creating a Bootable CD

Post by Ayla »

SiZiOUS wrote:In order to boot your '1ST_READ.BIN' file, you need to scramble your binary by using the 'scramble' command, which can be found on the Marcus site (http://mc.pp.se/dc/).
Is that really needed for homebrew?

I strongly discourage to burn the disc with an audio track. My experience is that those discs are not nice to the dreamcast's lens. You'd better try to burn a data/data disc, unless your game has cdda tracks.

I made a burn script, not so long ago, which can burn data/data discs under Linux: http://crapouillou.net/~paul/burn.sh.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5663
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Creating a Bootable CD

Post by BlueCrab »

Yes, you do have to scramble your binary in order to boot it still. The scrambling procedure is due to the way that the Dreamcast BIOS loads the binary off of a CD (basically, by scrambling it, you ensure that the BIOS actually loads it properly).

Also, there should be no functional difference between an audio/data disc and a data/data disc in terms of lens wear and tear.
Ayla
DC Developer
DC Developer
Posts: 142
Joined: Thu Apr 03, 2008 7:01 am
Has thanked: 0
Been thanked: 4 times
Contact:

Re: Creating a Bootable CD

Post by Ayla »

BlueCrab wrote:Also, there should be no functional difference between an audio/data disc and a data/data disc in terms of lens wear and tear.
Well, my three dreamcasts disagree :)
They all have problems with booting audio/data discs, unless the console is cold; but data/data discs never give me issues. And that's obviously with the very same kind of cd-roms.
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: Creating a Bootable CD

Post by PH3NOM »

Velovix wrote:After going crazy trying to get the toolchain for KallistiOS set up, I was finally successful, and every thing appears to be working. I wrote a simple program that uses SDL and I would like to burn it to a CD.
Apparently, a bootable Dreamcast CD has:
A four second audio track (which isn't a big deal)
IP.BIN (which I used makeip to create)
and 1ST_READ.BIN, or the code (?)

When I compiled my code using KallistiOS, I got an .elf file. Apparently, this needs to be a header-less .bin file. Allegedly, I should be able to use objcopy to convert it, but when I try to, it says it doesn't recognize my .elf file. EDIT: Using "sh-elf-objcopy -O binary test.elf test.bin" I was able to convert it.

If I need to clarify anything, please let me know, but what I really want to know is this: Am I even on the right track? To get much of this information, I've been using http://mc.pp.se/dc/, which is pretty comprehensive, but it's also a decade old. Is there a better source for this kind of information? Thanks for help!

EDIT: I guess it would also be helpful to know where the romdisk data goes.
Have you solved your problem?
Another solution to the one SiZiOUS posted, is a solution SiZiOUS coded some time ago, a tool that creates a .cdi image from your data files instead of burning it directly to disk ( thanks for that tool by the way Siz, I have been using it for some time now )
Ayla wrote:
BlueCrab wrote:Also, there should be no functional difference between an audio/data disc and a data/data disc in terms of lens wear and tear.
Well, my three dreamcasts disagree :)
They all have problems with booting audio/data discs, unless the console is cold; but data/data discs never give me issues. And that's obviously with the very same kind of cd-roms.
When you burn as data/data, are you using LBA 45000, or 11702?
My DC has never failed to boot at LBA 45000, but can be finicky and refuse to boot at LBA 11702.
Ayla
DC Developer
DC Developer
Posts: 142
Joined: Thu Apr 03, 2008 7:01 am
Has thanked: 0
Been thanked: 4 times
Contact:

Re: Creating a Bootable CD

Post by Ayla »

PH3NOM wrote:When you burn as data/data, are you using LBA 45000, or 11702?
My DC has never failed to boot at LBA 45000, but can be finicky and refuse to boot at LBA 11702.
If I'm not mistaken, LBA 0.
User avatar
Neoblast
DC Developer
DC Developer
Posts: 315
Joined: Sat Dec 01, 2007 8:51 am
Has thanked: 5 times
Been thanked: 1 time

Re: Creating a Bootable CD

Post by Neoblast »

LBA 45000 data/data works best, the other ones might not work if the lens is close to its death...
Happened to me, quite a few times...
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: Creating a Bootable CD

Post by PH3NOM »

Ayla wrote:
PH3NOM wrote:When you burn as data/data, are you using LBA 45000, or 11702?
My DC has never failed to boot at LBA 45000, but can be finicky and refuse to boot at LBA 11702.
If I'm not mistaken, LBA 0.
Not if your self-booting the disc, LBA 11700 ( ususally 11702 ) I is the minimum start address for a self-boot disc.
LBA 0 would infer a disc with 1 data session, i.e., non-selfbooting.
LBA 45000 is the address where retail GD-Roms data track start, and seems to work best on my DC.
User avatar
SiZiOUS
DC Developer
DC Developer
Posts: 404
Joined: Fri Mar 05, 2004 2:22 pm
Location: France
Has thanked: 27 times
Been thanked: 19 times
Contact:

Re: Creating a Bootable CD

Post by SiZiOUS »

PH3NOM wrote:Another solution to the one SiZiOUS posted, is a solution SiZiOUS coded some time ago, a tool that creates a .cdi image from your data files instead of burning it directly to disk ( thanks for that tool by the way Siz, I have been using it for some time now )
Thank you PH3NOM. :) I think you're talking about img4dc, which is open source now.
Anyway, your work on the Dreamcast seems to be very impressive, including your 'bsp parser'.
PH3NOM wrote:Not if your self-booting the disc, LBA 11700 ( ususally 11702 ) I is the minimum start address for a self-boot disc.
LBA 0 would infer a disc with 1 data session, i.e., non-selfbooting.
LBA 45000 is the address where retail GD-Roms data track start, and seems to work best on my DC.
There's several boot method.
Every method uses at least 2 sessions (to 'emulate' the low and high density areas of original GD-ROM), which each session contains 1 track.
The second session always contains the bootstrap (IP.BIN).

Audio/Data:
This classic method was the first discovered, known under the MIL-CD hack.
The content of the disc is:
  • A first audio track in the first session, the most common used one is a 4 sec silent (which is the minimum track length, corresponding to 300 sectors - 302 with gap)
  • The second session, containing the data track, which start at LBA 11700 (for 300 sectors audio session) or 11702 (for 302 sectors audio session) - this depends on your CD burner I think.
This hack won't work on the latest produced Dreamcast (which seems to be very rare... I never saw any).

Data/Data:
This is a newer boot method. It exists two kinds:
  1. The first data track (Session 1) contains the game data (LBA 0) and the second, is a fake data track which contains the bootstrap (IP.BIN). It's a method created by Xeal I think. It's the one used in my img4dc tool.
  2. The first data track (Session 1) contains the datas of your choice, and the second contains also the datas of your need. The big advantage is the second data starts at the LBA 45000 which is identical of original GD-ROM (this data tracks contains the IP.BIN). This method is used by the Data/Data pack by FamilyGuy.
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has thanked: 0
Been thanked: 0

Re: Creating a Bootable CD

Post by patbier »

Very interesting SiZiOUS !

Which method is the best to be compatible with MIL-CD Dreamcast compatible and not compatible (the last ones in the US) ?

The Data/Data with the second data which starts at the LBA 45000 ?

Thanks
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
Ayla
DC Developer
DC Developer
Posts: 142
Joined: Thu Apr 03, 2008 7:01 am
Has thanked: 0
Been thanked: 4 times
Contact:

Re: Creating a Bootable CD

Post by Ayla »

LBA 45000 is interesting only when burning backups. LBA0 works fine for homebrew and gives less headache, as you don't have to select which files should go to the first session to reach LBA 45000.

Another (untested) boot method is to storeonly the binary in the first session and the data in the second session, without trying to reach LBA 45000, so that you don't lose any space on the CD with a fake session.
User avatar
SiZiOUS
DC Developer
DC Developer
Posts: 404
Joined: Fri Mar 05, 2004 2:22 pm
Location: France
Has thanked: 27 times
Been thanked: 19 times
Contact:

Re: Creating a Bootable CD

Post by SiZiOUS »

Yeah Ayla is right, the LBA 45000 trick is used only for making backups from original GD-ROM.
For homebrews, I guess data/data with LBA 0 is much efficient. You're only wasting some bytes with the second data track (the size of the this track can be 300 sectors as well) ; and I think the data/data structure format is more compatible than the audio/data format, but I'm not sure.
Velovix
DCEmu Cool Newbie
DCEmu Cool Newbie
Posts: 11
Joined: Tue Nov 27, 2012 12:19 am
Has thanked: 0
Been thanked: 0

Re: Creating a Bootable CD

Post by Velovix »

Wow, this thread blew up! Sorry for such a late response :o

I've kind of abandoned the idea of burning my programs to a CD, as it's not a very good way to test my programs so early on. I've recently gotten ahold of an SD card adapter, so I've been trying to use that instead!

That being said, all the discussion above has been very educational to read, so thanks!
Post Reply