forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

32X Devkit

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> Other Development
View previous topic :: View next topic  
Author Message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed Feb 04, 2009 7:32 am    Post subject: 32X Devkit Reply with quote

I've been doing a little work on the SEGA 32X recently, and had to put together a devkit to do homebrew. Now I'm sharing this with others. The programs developed by this work in a 32X emulator (Gens and Kega so far). I plan on getting a flash cart to get it working on a real 32X. When I do, this will get updated. (EDIT: I've gotten one report that this DOES work with a real 32X using the TotoTek MD-Pro flash cart!)

This is for linux. The SH2 toolchain is gcc from KPIT, and the 68000 toolchain is gcc from the uclinux project. You can get a Windows toolchain for the SH2 from KPIT, but you'd need a Windows 68000 assembler like asmx to get this devkit working in Windows. I leave that to the reader as an exercise. :D

Just copy the gendev directory from the archive to wherever you keep your toolchains (usually /usr/local). You'll need a couple exports:

Code:
export GENDEV=/usr/local/gendev
export PATH=$GENDEV/sh2/bin:$GENDEV/m68k/bin:$GENDEV/bin:$PATH


The project-src directory in the archive has the files needed to get your 32X program running. You should only need to add to the OBJS list in the makefile and change the name from "example" to whatever you want.

The makefile assembles the two m68k files into binary, then compiles all the rest, linking the result into a binary suitable to running with your 32X emulator. The entry for your code is main(), just like normal. If you wish to use the second SH2 in your program, comment out the _slave function in sh2_crt0.s, then add a slave() entry in your code.

One of the funny things about the KPIT toolchain for the SH2 is you can't compile the code as SH2. It seems when they built the toolchain, they enabled hardware floating point for all SH2 variants, not just the A and E variants. As such, you have to compile as SH1. The toolchain included here includes the SH1 libraries. You can still do SH2 specific code via inline assembly or separate assembly files.

The debug code should look familiar - it's based on the PSP homebrew SDK debug code. It's VERY handy for seeing whats going on in the 32X. It could also be used for simple interfaces like people often do on the PSP. One issue is the SH libraries don't seem to do varargs properly, so don't use Debug32xScreenPrintf() - sprintf to a string and use Debug32xScreenPuts() instead.

DevKit32X-20090203.7z
Back to top
View user's profile Send private message AIM Address
hardhat



Joined: 02 Mar 2006
Posts: 17

PostPosted: Wed May 27, 2009 3:11 am    Post subject: Reply with quote

Hi there,

This is just the sort of thing that I'd like to have up and running. I gave it a try, but there are some problems with this version. I am wondering if you can help me with them.

First, a minor thing: the Makefile expects some files to be in Src/ when they aren't. After trying a few things the simplest change is to get rid of the Src/ references in the makefile.

Second, example.c is missing. I made my own, so that should be fine.

Third, the distro includes two gcc cross-compilers, but they are made without a prefix such as 68k-gcc or sh-elf-gcc. A a result, if I put them at the beginning of the path like you suggest then it'll take over from regular gcc.

Now for the big one: when I compile debug_32x.c which contains some functions that I'd really like to have access to, it fails with this error:

Code:

tinkerbell:~/packages/DevKit32X/project-src$ make
/home/hardhat/packages/DevKit32X/gendev/sh2/bin/gcc -m1 -mb -O2 -Wall -g -fomit-frame-pointer -I. -I/home/hardhat/packages/DevKit32X/gendev/sh2/include -c debug_32x.c -o debug_32x.o
debug_32x.c: In function ‘Debug32xInit’:
debug_32x.c:330: internal compiler error: Illegal instruction
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.kpitgnutools.com> for instructions.
make: *** [debug_32x.o] Error 1


Is that related to the third problem? Before I changed my path, it couldn't find cc1. It should be correct now.
_________________
HardHat
Try my homebrew: Open Gladiator, Fur Trader, Skater Maze, Jafe's Hike, Jumping Jack
Back to top
View user's profile Send private message Visit poster's website
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed May 27, 2009 4:24 am    Post subject: Reply with quote

This package is a little old. I've made some changes since then, so I'll update the package today some time. The example makefile is just that - an example. It's not meant to compile as is - just show how one would be done. If you want an "example" that actually compiles, you should try my Wolf32X project... which I'll also post the latest code to here at the same time I post the updated toolchain. I'm not sure about the third issue, but try it again with the updated toolchain and Wolf32X code once I post it.

I keep everything relative to gendev to keep it all organized. Within gendev, I make a bin directory for non-gcc related stuff, then a directory each for the m68k and sh2 toolchains. Sometimes that means being more specific in the makefile about which gcc you're using for things, or perhaps splitting the makefile into pieces and doing make -f file or make -C dir. I'll have an example of that when I finish the CD 32X example I'm working on (another week or two on that).

Well, I am glad someone is at least trying this. :)
Back to top
View user's profile Send private message AIM Address
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed May 27, 2009 4:41 am    Post subject: Reply with quote

Okay, here's an update to DevKit32X and the latest Wolf32X code.

DevKit32X-090526.7z
Wolf32X-090526.7z

To make Wolf3D Shareware, do the exports mentioned in the first post, then "make -f Makefile-wsw". The Spear of Destiny Demo is "make -f Makefile-sdm".
Back to top
View user's profile Send private message AIM Address
hardhat



Joined: 02 Mar 2006
Posts: 17

PostPosted: Wed May 27, 2009 4:44 am    Post subject: Reply with quote

Thanks for your effort to update this package. I'll defiantly keep my eye out for the update. It could come in quite useful for me with an upcoming project. I don't mind having multiple makefiles if it all works in the end. Coding for multiple CPUs in one executable is always a nuisance.
_________________
HardHat
Try my homebrew: Open Gladiator, Fur Trader, Skater Maze, Jafe's Hike, Jumping Jack
Back to top
View user's profile Send private message Visit poster's website
hardhat



Joined: 02 Mar 2006
Posts: 17

PostPosted: Thu May 28, 2009 6:28 am    Post subject: Reply with quote

Great. I got it to work, once I switched to a computer with a Dual Core cpu. The other computer's Atom core CPU doesn't do all of the 686 instructions I guess. Thanks again for posting the update for me.
_________________
HardHat
Try my homebrew: Open Gladiator, Fur Trader, Skater Maze, Jafe's Hike, Jumping Jack
Back to top
View user's profile Send private message Visit poster's website
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu May 28, 2009 8:34 am    Post subject: Reply with quote

hardhat wrote:
Great. I got it to work, once I switched to a computer with a Dual Core cpu. The other computer's Atom core CPU doesn't do all of the 686 instructions I guess. Thanks again for posting the update for me.


Yeah, I'm not sure what CPU the uclinux (m68k) or KPIT (sh2) compilers are compiled for beyond generic 686. Never even crossed my mind that some CPUs might not like them. :)

Glad you could get it working. Hopefully, it helps us see more 32X homebrew.
Back to top
View user's profile Send private message AIM Address
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sat Sep 26, 2009 2:35 am    Post subject: Reply with quote

Okay, here's archives for my latest gendev toolchain and "SDK". The SDK is the source for bin2c, libheap, libmd, libromfs, and zasm. The binaries are all in the toolchain archive in the proper place. Note that this arc, unlike previous ones, is entirely 32 bit. Most 64 bit linux distros can handle that, but you may need 32 bit compatibility libraries installed. The SH compiler has been updated to the latest KPIT 902 release.

gendev-20090925.7z
gendev-sdk-20090925.7z

Notes: libheap is a basic allocator library that would be underneath a malloc library. libmd is Stef's MiniDevKit support files all made into a library for convenience. libromfs is a library for reading romfs generated rom files (genromfs included). bin2c and zasm are used for making Z80 programs that can be included in programs. See the musicdemo example for details.

Please note the exports needed for Genesis or 32X compiling:
MD
export GENDEV=/home/jlfenton/Tools/gendev
export PATH=$GENDEV/m68k/bin:$GENDEV/bin:$PATH

MARS
export GENDEV=/home/jlfenton/Tools/gendev
export PATH=$GENDEV/sh2/bin:$GENDEV/m68k/bin:$GENDEV/bin:$PATH

Wolf32X serves as the example of 32X programming, while any of the musicdemo apps serve as a demonstration of Genesis programming.

w3d-sod-sw-b5.zip
musicdemo4.7z
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> Other Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group