Update your Genesis/32X Toolchain!

Talk about development tools here

Moderator: BigEvilCorporation

Tomy
Interested
Posts: 11
Joined: Sun Nov 26, 2006 12:23 pm

Post by Tomy » Tue Apr 05, 2011 1:08 am

They can be safely ignored as the functions AREN'T used.
If it can safely ignored, then my toolchains can successfully compile your example. But produced bin can not run.

I can build your 32x C++ example, and it can run (no warning when compile)

I use GENS/GS emulator. And tried your MD C++ example bin, it work file. But my compiled bin can not run.

If you're interest to see my compiled *.o *.elf *.bin *.map, you can download here : http://www.tototek.com/tomy/cpp_test.7z

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Apr 05, 2011 3:42 am

I'll look that over. In the mean time, did you replace the linker scripts in /opt/toolchains/gen/ldscripts/ with the ones in the examples archive? The ones that come with makefile to build the toolchain won't work.

Tomy
Interested
Posts: 11
Joined: Sun Nov 26, 2006 12:23 pm

Post by Tomy » Tue Apr 05, 2011 4:15 am

I use scripts from MD_32X_Examples.7z. So, it is the right one.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Apr 05, 2011 5:21 am

Actually, it didn't work for me either. :lol:

I changed a flag for compiling the crtstuff.c file, but then "lost" the changes to the linker script to go with it. So the problem was my fault. Sorry. Here's the updated linker scripts for the MD (this wasn't an issue for the 32X). These replace the current files in /opt/toolchains/gen/ldscripts/.

http://www.mediafire.com/download.php?2pc35tb4bp2b1yv

Tomy
Interested
Posts: 11
Joined: Sun Nov 26, 2006 12:23 pm

Post by Tomy » Tue Apr 05, 2011 6:19 am

Thanks Chilly Willy, problem fixed.
Now, we have your latest toolchain included C and C++ compiler.
Thank again for share all these stuff. :D

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Apr 05, 2011 6:30 am

Glad to hear that fixed it. :D

Fortunately it was just a simple error on my part. Given it compiled without more than the libnosys warnings and looked good from a binary viewpoint, I figured it had to be something pretty simple - something I changed right at the end before making the example archive.

Now I need to finish a CD example to help get something going there. 8)

antime
Interested
Posts: 22
Joined: Sun Feb 06, 2011 9:18 pm
Contact:

Post by antime » Wed Apr 06, 2011 12:21 pm

Chilly Willy wrote:Now you're just arguing to hear your own voice.
Same could be said for you. Quoting the documentation (emphasis added):
-fschedule-insns
If supported for the target machine, attempt to reorder instructions to eliminate execution stalls due to required data being unavailable.

-fschedule-insns2
Similar to -fschedule-insns, but requests an additional pass of instruction scheduling after register allocation has been done.
You're talking about a different phase in the code generation.

ammianus
Very interested
Posts: 124
Joined: Sun Jan 29, 2012 2:10 pm
Location: North America
Contact:

Post by ammianus » Sun Jan 29, 2012 2:31 pm

powerofrecall wrote:Windows GCC 4.5.2 toolchain (about 55mb compressed, 800+ uncompressed)

I added Make and an environment batch file to this package and it will function at a windows command prompt, but I recommend downloading msys and setting your environment variables for the toolchain in there so you can have unix commands in your makefiles.

Tested with chilly's 32x mod player and my own in-progress MD project, seems to work fine.
Wow thank you. I spent such a long time trying to find an appropriate tool chain for Windows.

Thanks for both effort.

FYI - I can run it in normal Windows 7 CMD prompt, without MinGW (I do have cygwin, not sure if any dependencies were resolved by that), I had to add the following .dlls to ${GENDEV}\bin

libintl-8.dll (http://waterlan.home.xs4all.nl/libintl.html)
libiconv-2.dll (I think I just renamed the libiconv2.dll already in the bin folder and it seems to work.

After getting 32X TicTacToe to build, I went back to an early devkit I found for building Wolf32X source that had been posted some time back by Chilly Willy I think with an older 32X devkit. As an exercise I went through updating the Makefile to build it with this toolchain. Through some tweaking, I got that to build into a playable bin.

Modified Makefile similar to set up of examples (using new toolchain).

Code: Select all

MDLD = m68k-elf-ld
MDAS = m68k-elf-as
SHLD = sh-elf-ld
SHCC = sh-elf-gcc
SHAS = sh-elf-as
SHOBJC = sh-elf-objcopy
RM = rm -f

CCFLAGS = -m2 -mb -O1 -Wall -c -fomit-frame-pointer -DHAVE_FFBLK -DDOSISM -DWMODE=0
HWCCFLAGS = -m2 -mb -O1 -Wall -c -fomit-frame-pointer
LINKFLAGS = -T $(GENDEV)/ldscripts/mars.ld -Wl,-Map=output.map -nostdlib -e _start

INCS = -I./src -I$(GENDEV)/sh-elf/include -I$(GENDEV)/sh-elf/sh-elf/include

LIBS = -L$(GENDEV)/sh-elf/sh-elf/lib -L$(GENDEV)/sh-elf/lib/gcc/sh-elf/4.5.2 -lm -lc -lgcc -lgcc-Os-4-200 -lnosys


OBJS = \
	src/sh2_crt0.o \
	src/id_ca.o \
	src/id_us.o \
	src/id_vh.o \
	src/misc.o \
	src/objs.o \
	src/vi_comm.o \
	src/vi_32x.o \
	src/wl_act1.o \
	src/wl_act2.o \
	src/wl_act3.o \
	src/wl_agent.o \
	src/wl_debug.o \
	src/sd_comm.o \
	src/sd_32x.o \
	src/adlibtables_wsw.o \
	src/wl_draw.o \
	src/wl_game.o \
	src/wl_inter.o \
	src/wl_main.o \
	src/wl_menu.o \
	src/wl_play.o \
	src/wl_state.o \
	src/wl_text.o \
	src/w3dsw_data.o \
	src/automap.o \
	src/debug_32x.o \
	src/debug_font.o

all: m68k_crt0.bin m68k_crt1.bin wolf32x.bin

wolf32x.bin: wolf32x.elf
	$(SHOBJC) -O binary $< temp.bin
	dd if=temp.bin of=$@ bs=64K conv=sync

wolf32x.elf: $(OBJS)
	$(SHCC) $(LINKFLAGS) $(OBJS) $(LIBS) -o wolf32x.elf	
	
m68k_crt0.bin: src/m68k_crt0_wsw.s
	$(MDAS) -m68000 --register-prefix-optional -o src/m68k_crt0_wsw.o src/m68k_crt0_wsw.s
	$(MDLD) -T $(GENDEV)/ldscripts/md.ld --oformat binary -o src/m68k_crt0.bin src/m68k_crt0_wsw.o

m68k_crt1.bin: src/m68k_crt1.s
	$(MDAS) -m68000 --register-prefix-optional -o src/m68k_crt1.o src/m68k_crt1.s
	$(MDLD) -T $(GENDEV)/ldscripts/md.ld --oformat binary -o src/m68k_crt1.bin src/m68k_crt1.o

%.o: %.c
	$(SHCC) $(CCFLAGS) $< -o $@

%.o: %.s
	$(SHAS) --small -o $@ $<


clean:
	$(RM) src/*.o src/*.out src/*.bin *.bin *.elf src/*.elf *.map
Modified src/sh2_crt0.s which had some references not present in the mars.ld link file

Code: Select all

_bss_dst:
        .long   __bss_start
_bss_end:
        .long   __end
(was _bstart and _bend)

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sun Jan 29, 2012 8:47 pm

Yeah, things changed a little between what I last compiled Wolf32X with, and what I use now. The next update of Wolf32X will take care of that, but it's not too hard to make the changes yourself when you know how to work with gcc. I'm happy to see Windows people learning gcc - it's vital for people learning to cross-compile for other platforms - something MS discourages.

Milkybar
Newbie
Posts: 5
Joined: Wed Jul 18, 2012 1:57 pm

Post by Milkybar » Wed Jul 18, 2012 2:17 pm

Dear all,


I am trying to use Powerofrecall’s Windows GCC 4.5.2 toolchain binaries to compile C code to run on the MegaDrive from Windows7. As a test I am trying to make Chilly Willy’s MD_32X_Examples.7z TicTacToe using the provided makefile. I have the toolchain set up in C:\gen, souce code in C:\gendev and MinGW in C:\MinGW. I have also modified my system PATH variables to reference locations previously listed in env.bat.

Using the MinGW shell I am able to successfully begin the make process. However the makefile contains the command dd (which I understand to be a method of copying data under UNIX) but is not recognised as a command under MinGW.

The make process progresses far enough that a temp.bin file is generated and appears to run correctly in an emulator (untested on hardware). As I am unsure of the significance of the dd command I do not want to skip this without resolving the issue. It is all interrupting the makefile before reaching the clear command leaving my source directory with a lot of messy temporary files.

I am a confident C programmer but have no experience with UNIX/LINUX/GCC so am finding this problem very hard to resolve.

Any help anyone could provide to resolve this issue would be greatly appreciated. Thanks in advance.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Wed Jul 18, 2012 5:56 pm

The dd command line tool is just used to pad the length of the final binary. It's not really needed - or you could use a different method to pad the binary.

You can add dd.exe to your mingw setup using the unxutils:
http://unxutils.sourceforge.net/

I LIKE having all those extra files - just in case something goes wrong. If you do "make clean", all those extra files are cleaned up. A "clean" target is pretty standard on most *nix makefiles. If a project requires you to run configure first, there is normally a target called "distclean" that cleans everything back to requiring the configure again.

Milkybar
Newbie
Posts: 5
Joined: Wed Jul 18, 2012 1:57 pm

Post by Milkybar » Wed Jul 18, 2012 6:43 pm

Thank you very much.

I copied dd.exe and got the error that the value 8k was not supported. Changed this to 8192 and everything works perfectly.

I think I need to look a little more into how to adjust the makefile. As you have said 'make clean' removes all temporary files but also removes the final.bin that I actually want to keep.

Thank you again for your help.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Jul 19, 2012 1:26 am

The clean target is pretty simple - you see something like this:

Code: Select all

clean:
	$(RM) *.o *.bin *.elf output.map
It uses the remove command to delete any files ending in .o, .bin, or .elf; it also removes the specific file output.map. If you wish to keep the bin file, just remove *.bin from the line.

I provide examples... feel free to change them however you wish. Doing so helps you learn more about how things are built so you can make your own makefiles for your projects.

ammianus
Very interested
Posts: 124
Joined: Sun Jan 29, 2012 2:10 pm
Location: North America
Contact:

Post by ammianus » Sun Aug 12, 2012 6:38 pm

Does anyone have any experience trying to use these versions of the gcc toolchain with either Code::Blocks or Eclipse CDT?

I've been using CLI and Notepad++ for a while, really would prefer having an IDE of some kind, I like eclipse for java, not so much for C. Just downloaded Code::Blocks and their compiler menu has a list of predefined compilers, but I am wondering if there are other ways to have it use this toolchain.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sun Aug 12, 2012 6:47 pm

ammianus wrote:Does anyone have any experience trying to use these versions of the gcc toolchain with either Code::Blocks or Eclipse CDT?

I've been using CLI and Notepad++ for a while, really would prefer having an IDE of some kind, I like eclipse for java, not so much for C. Just downloaded Code::Blocks and their compiler menu has a list of predefined compilers, but I am wondering if there are other ways to have it use this toolchain.
I use Geany for my IDE... Geany even has a built in terminal so I don't have to open one if I don't want to. If you are using my latest examples that set all paths in the makefile instead of using environment variables, then it's very simple to use this with any IDE - just set the build option to make the makefile... you don't have to worry about environment variables.

Code Blocks has a lot of options for things like environment variables for a project, but I find that all too much for people to deal with. That's why I like simple makefiles with all the paths set in the makefile boilerplate. People really overcomplicate makefiles these days. Just because make allows stupidly complicated makefiles is no reason to actually do so. :lol:

Post Reply