Friday, March 2, 2012

--target=m68k-elf

More nerd-notes. Setting up m68k cross compiler in gcc under Cygwin to build some code for Sega Genesis.

I installed the dgen Genesis emulator in the MinGW environment by building it and SDL-1.2.15 from sources. I am interested in experimenting with using the GNU debugger, with the Genesis emulator as the target, by integrating dgen with the modified Musashi 68k core.

Building the m68k-gcc may be a problem in MinGW - my gcc build for --target=m68k-elf failed with errors on 'pipe' 'fork' 'sleep' 'fcntl' etc. I don't know enough about MinGW to know if there is a workaround. It could be that I need to download newer sources for gcc ... I am using binutils-2.20.1.tar.bz2 and  gcc-core-3.4.6.tar.bz2. Why? because I did this about 2 years ago in Ubuntu and those were the files that worked for me then.

Alternatively, I should be able to run the m68k tools in Cygwin. My first binutils build in Cygwin blew up, but one update fixed it.

Here's a link to the setup that I followed, abeit with the file versions identified above, and changed coff to elf.

In addition, I found that the code I was building needed some standard C libraries and headers ... more on that later. I had a copy of newlib-1.12.0.tar.gz laying around so I built that with the same settings as binutils and gcc, i.e.

cd newlib-1.12.0/ ; ./configure --prefix=/usr/local/m68k --target=m68k-elf

So having done all that, the build is very close to complete, but there is one more error:


/usr/local/m68k/m68k-elf/lib/m68000//libmvme135.a(lseek.o): In function `lseek':
/cygdrive/d/tmp/m68k_cyg/newlib-1.12.0/m68k-elf/m68000/libgloss/m68k/../../../.././libgloss/m68k/../lseek.c:28: undefined reference to `__errno'

I hunted around for a second and did not find a tight solution, so I simply improvised and added the necessary definition to one of the C files in my sources:

int __errno;

... and now the make completes!

No comments:

Post a Comment