How to make a cdi file from my recent compiled KOS project?
- keidash
- DCEmu Newbie
- Posts: 4
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Tue May 08, 2018 12:03 pm
- Location: Spain/Canary Islands
- Has thanked: 0
- Been thanked: 0
- Contact:
How to make a cdi file from my recent compiled KOS project?
Hi all!
Sorry if this post exists but I'm not found some similar post (maybe a did a bad search)
I'm new on KOS. I'm comming from BennuGD development and I've many problems with the BennuGD RAM administration (a bug in BennuGD for DC port, doesn't allow me to free it) and audio on Dreamcast projects.
Currently, I'm working on my game BeatTendency for Dreamcast and I would like to see what offer me KOS to "if is possible" rewrite my bennugd code to KOS.
I'm triying to compile de hello example of KOS and I got it, but I want to run it on demul or nullDC to try it, but I don't know how to do it. My compiled project path has the next files:
- hello.c
- hello.elf
- hello.o
- Makefile
- romdisk
- romdisk.img
- romdisk.o
How I convert it to a cdi file? With Bennu, I put a 1ST_READ.BIN file in the same path of the compiled result and with BootDreams I make a CDI of this path. Sorry if this explanation exists but I don't find it
Manyu many thanks
Sorry if this post exists but I'm not found some similar post (maybe a did a bad search)
I'm new on KOS. I'm comming from BennuGD development and I've many problems with the BennuGD RAM administration (a bug in BennuGD for DC port, doesn't allow me to free it) and audio on Dreamcast projects.
Currently, I'm working on my game BeatTendency for Dreamcast and I would like to see what offer me KOS to "if is possible" rewrite my bennugd code to KOS.
I'm triying to compile de hello example of KOS and I got it, but I want to run it on demul or nullDC to try it, but I don't know how to do it. My compiled project path has the next files:
- hello.c
- hello.elf
- hello.o
- Makefile
- romdisk
- romdisk.img
- romdisk.o
How I convert it to a cdi file? With Bennu, I put a 1ST_READ.BIN file in the same path of the compiled result and with BootDreams I make a CDI of this path. Sorry if this explanation exists but I don't find it
Manyu many thanks
- BlueCrab
- The Crabby Overlord
- Posts: 5658
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: How to make a cdi file from my recent compiled KOS project?
You'll need to create a 1ST_READ.BIN out of the compiled binary, then you can pretty much follow along just like you would have before (with BootDreams or whatever).
To make a 1ST_READ.BIN, you'll want to take your .elf file that's compiled (in this case, hello.elf), and do the following:
This assumes, of course, that you're using a relatively recent version of KOS (from the past 4 years or so) that comes with the scramble utility.
Mind you, the hello example in KOS doesn't really do anything (it prints out a "hello world" message on the dcload terminal, not on the screen or anything).
To make a 1ST_READ.BIN, you'll want to take your .elf file that's compiled (in this case, hello.elf), and do the following:
Code: Select all
kos-objcopy -O binary hello.elf hello.bin
$KOS_BASE/utils/scramble/scramble hello.bin 1ST_READ.BIN
Mind you, the hello example in KOS doesn't really do anything (it prints out a "hello world" message on the dcload terminal, not on the screen or anything).
- keidash
- DCEmu Newbie
- Posts: 4
- Joined: Tue May 08, 2018 12:03 pm
- Location: Spain/Canary Islands
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: How to make a cdi file from my recent compiled KOS project?
Hi again,
Thanks for your reply BlueCrab, I have executed those commands and I have some doubts with this.
1) With the first command (kos-objcopy -O binary hello.elf hello.bin) the terminal throw me some warnings or errors (I don't know) with a unexpected operator, like this. It's a important error?
Despite of this messages, the hello.bin file was created.
2) Then, I created a 1ST_READ.BIN file with the second command ($KOS_BASE/utils/scramble/scramble hello.bin 1ST_READ.BIN). No problems here, only one question. I suposse that to make a cdi file, for example with bootdreams, I only need the hello.bin and 1ST_READ.bin file, right?
Thanks for your help, you are very kind!
Thanks for your reply BlueCrab, I have executed those commands and I have some doubts with this.
1) With the first command (kos-objcopy -O binary hello.elf hello.bin) the terminal throw me some warnings or errors (I don't know) with a unexpected operator, like this. It's a important error?
Code: Select all
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 6: [: ==: unexpected operator
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 9: [: ==: unexpected operator
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 12: [: ==: unexpected operator
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 6: [: binary: unexpected operator
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 9: [: binary: unexpected operator
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 12: [: binary: unexpected operator
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 6: [: hello.elf: unexpected operator
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 9: [: hello.elf: unexpected operator
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 12: [: hello.elf: unexpected operator
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 6: [: hello.bin: unexpected operator
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 9: [: hello.bin: unexpected operator
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 12: [: hello.bin: unexpected operator
2) Then, I created a 1ST_READ.BIN file with the second command ($KOS_BASE/utils/scramble/scramble hello.bin 1ST_READ.BIN). No problems here, only one question. I suposse that to make a cdi file, for example with bootdreams, I only need the hello.bin and 1ST_READ.bin file, right?
Thanks for your help, you are very kind!
Re: How to make a cdi file from my recent compiled KOS project?
I don't know for the kos-objcopy error, but you only need 1ST_READ.bin after the conversion to use with bootdreams.
- BlueCrab
- The Crabby Overlord
- Posts: 5658
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: How to make a cdi file from my recent compiled KOS project?
That's quite strange that you'd run into issues like that... What OS/shell are you using?keidash wrote: ↑Wed May 09, 2018 2:34 am Hi again,
Thanks for your reply BlueCrab, I have executed those commands and I have some doubts with this.
1) With the first command (kos-objcopy -O binary hello.elf hello.bin) the terminal throw me some warnings or errors (I don't know) with a unexpected operator, like this. It's a important error?
Despite of this messages, the hello.bin file was created.Code: Select all
/home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 6: [: ==: unexpected operator /home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 9: [: ==: unexpected operator /home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 12: [: ==: unexpected operator /home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 6: [: binary: unexpected operator /home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 9: [: binary: unexpected operator /home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 12: [: binary: unexpected operator /home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 6: [: hello.elf: unexpected operator /home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 9: [: hello.elf: unexpected operator /home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 12: [: hello.elf: unexpected operator /home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 6: [: hello.bin: unexpected operator /home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 9: [: hello.bin: unexpected operator /home/ubuser/dreamcast/kos/utils/gnu_wrappers/kos-objcopy: 12: [: hello.bin: unexpected operator
You could also do the following (instead of the kos-objcopy line), assuming that your toolchain install path is in your $PATH environment variable (otherwise you just need to include the whole path to sh-elf-objcopy, which is often /opt/toolchains/dc/sh-elf/bin/sh-elf-objcopy):
Code: Select all
sh-elf-objcopy -O binary hello.elf hello.bin
For this particular example program (and most other examples from KOS), all you'd need is the 1ST_READ.BIN. For other programs (anything that'd load data off the CD), you'd need more, of course.keidash wrote: ↑Wed May 09, 2018 2:34 am 2) Then, I created a 1ST_READ.BIN file with the second command ($KOS_BASE/utils/scramble/scramble hello.bin 1ST_READ.BIN). No problems here, only one question. I suposse that to make a cdi file, for example with bootdreams, I only need the hello.bin and 1ST_READ.bin file, right?
Thanks for your help, you are very kind!
- keidash
- DCEmu Newbie
- Posts: 4
- Joined: Tue May 08, 2018 12:03 pm
- Location: Spain/Canary Islands
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: How to make a cdi file from my recent compiled KOS project?
Perfect! If I use sh-elf-objcopy instead of objcopy no errores were executed and I did the 1ST file correctly. Now i'm going to do the cdi and try it and see the console log to see the hello world.
Many many thanks BlueCrab and tonma
---------------------------------------------------------------------------------------------------------------
EDITED:
The cdi file didn't work on the emulator, make it crashed Any ideas?
Many many thanks BlueCrab and tonma
---------------------------------------------------------------------------------------------------------------
EDITED:
The cdi file didn't work on the emulator, make it crashed Any ideas?
- lerabot
- Insane DCEmu
- Posts: 134
- Joined: Sun Nov 01, 2015 8:25 pm
- Has thanked: 2 times
- Been thanked: 19 times
Re: How to make a cdi file from my recent compiled KOS project?
This is what I usually use to make my CDI. Check that the paths are matching yours.
This will build your .iso and.cdi files outside the current directory. This is to prevent re-adding your .cdi/.iso to your disk everytime.
This will build your .iso and.cdi files outside the current directory. This is to prevent re-adding your .cdi/.iso to your disk everytime.
Code: Select all
DIR=$PWD
PROJECT_NAME="project"
#elf transform??
sh-elf-objcopy -R .stack -O binary main.elf output.bin
#scraming process - make sure you have your path right
/path/to/Dreamcast/kos/utils/scramble/scramble output.bin 1ST_READ.bin
#creating iso -> -o outputname.cdi / build files path
mkisofs -C 0,11702 -V PROJECT_NAME -G IP.BIN -r -J -l -o ../$PROJECT_NAME.iso $DIR
#transform iso into a CDI
/path/to/Dreamcast/kos/utils/cdi4cd/cdi4dc ../$PROJECT_NAME.iso ../$PROJECT_NAME.cdi -d > cdi4dc.log