Page 6 of 9

Posted: Sat Aug 03, 2013 9:51 am
by doragasu
I got some more time to play with this and finally got it to work! Grabbed SGDK "windows only" makefile and started modifying it to work with GNU/Linux. At first, object files were built, but failed when linking:

Code: Select all

m68k-elf-gcc -n -T /opt/toolchains/gen/ldscripts/md.ld -nostdlib out/sega.o @out/cmd_ /opt/toolchains/gen/m68k-elf/lib/libmd.a /opt/toolchains/gen/m68k-elf/lib/gcc/m68k-elf/4.5.2/libgcc.a -o out/rom.out
/opt/toolchains/gen/m68k-elf/lib/libmd.a(memory.o): In function `MEM_init':
memory.c:(.text+0x2): undefined reference to `_bend'
collect2: ld returned 1 exit status
make: *** [out/rom.out] Error 1
It couldn't find _bend symbol. I browsed libmd.a to see if it was there, and it is, but undefined (prefixed with 'U' character):

Code: Select all

$ m68k-elf-nm $GDK/m68k-elf/lib/libmd.a
[...]
memory.o:
00000064 T MEM_alloc
00000052 T MEM_free
00000028 T MEM_getFree
00000000 T MEM_init
         U _bend
000001b0 T fastMemcpy
000001cc T fastMemcpyU16
000001ea T fastMemcpyU32
00000154 T fastMemset
00000174 T fastMemsetU16
00000194 T fastMemsetU32
00000000 b free
00000004 b heap
         U memcpy
00000116 T memcpyU16
00000134 T memcpyU32
         U memset
         U memsetU16
         U memsetU32
[...]
Then I grep the sources, and the only reference to "bend" I found was (as expected) in memory.c:

Code: Select all

// end of bss segment --> start of heap
extern u32 _bend;
It is defined as an external symbol, and as it is not defined in any other source file, I suspected it could be defined in the linker file. But it was not in the one installed by the script. So I opened the one inside SGDK package and bingo!:

Code: Select all

  .bss 0xFF0000 + SIZEOF (.data) :
  {
    _start = . ;
    *(.shbss)
    *(.bss .bss.*)
    *(COMMON)
    _bend = . ;
  } > ram
Replaced installed md.ld with latest SGDK md.ld, and the ROM was built. And it works!

If anyone wants to test the Makefile, you can find it here. You will also have to overwrite the md.ld linker file using the one from SGDK sources, and copy the src directory from SGDK to $GDK/src. I have also used $GDK variable to point to the toolchain instead of the one the build script initially set up ($GENDEV).

Posted: Sat Aug 03, 2013 10:32 am
by Stef
ElBarto wrote: It means set if not defined

SHELL?=$(BIN)/sh

is equivalent to :

.ifndef SHELL
SHELL=$(BIN)/sh
.endif
Oh ok, thanks :) I'll modify it this way then.

doragasu>Glad you got it working, seems like the linux dev env was a bit outdated compared to the last SGDK build :)

Posted: Sat Aug 03, 2013 10:45 am
by Stef
This syntax:

Code: Select all

SHELL?=$(BIN)/sh
is definitely not recognized by my version of make, i guess i have to work with ifndef / endif couple.

Added SegaCD build

Posted: Sun Nov 03, 2013 5:49 pm
by kubilus1
I've added the ability to build Sega CD images in the sgdk/skeleton make directory. Using the stuff in the new build skeleton should allow small programs to work by executing a:

$ make out.iso

Roms must be 256K or smaller to work and currently this only support 1 Rom.

This is based off of the work in LukeProjectCD. I've modified several of the files so this works with gnu-assembler and only other Linux native tools (No 'wine ASM68K.EXE!!')

Posted: Sat Feb 01, 2014 4:12 am
by Zontar
Trying to install the latest version on my laptop for when I go on a trip. I think the new version has a build problem? Make aborts with an Error 1 and doesn't create a .gendev directory. Building on Ubuntu 12.10.

Posted: Sat Feb 01, 2014 8:01 pm
by kubilus1
There is a problem with texinfo > 5.0. Rolling back to an earlier version of texinfo should work, but there is probably a better way to solve this.

Posted: Sun Feb 02, 2014 1:56 am
by Mask of Destiny
The most recent version of gcc builds fine with texinfo 5. I did some work on updating the makefile and scripts to work with the latest version of gcc and binutils. I just did the bare minimum to build the toolchain, but I could probably clean it up and produce a diff if there's interest.

Posted: Sun Feb 02, 2014 3:43 am
by kubilus1
I would definitely be interested in seeing that!

Posted: Mon Feb 03, 2014 6:47 am
by Mask of Destiny
I've uploaded a diff here: http://rhope.retrodev.com/files/gcc_4_8_2.diff. It updates the main Makefile and makefile-gen.diff to build gcc 4.8.2 and binutils 2.24 which are the latest versions. They seem to work fine with SGDK, but I didn't do any extensive testing.[/url]

Posted: Sun Apr 27, 2014 1:25 pm
by Zontar
I see some changes are being made. :D

However, I think one broke x86-64 support in the latest. Or my setup (which I'm soon leaving for Ubuntu 14.04) is bad. Recently tried to recompile and got this:
/usr/bin/ld: i386 architecture of input file `../lib/elf/aplib.a(spack.o)' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `../lib/elf/aplib.a(sgetsize.o)' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `../lib/elf/aplib.a(sdepack.o)' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `../lib/elf/aplib.a(depacks.o)' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `../lib/elf/aplib.a(crc32.o)' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `../lib/elf/aplib.a(aplib.o)' is incompatible with i386:x86-64 output

Posted: Sun Apr 27, 2014 2:33 pm
by kubilus1
Ahh. I'm running 32 bit ATM. Got a few other changes I would like to do but have been busy with life and work.

I have started to put the together a Vagrant Genesis development build environment. That should allow pretty much anyone to have a Dev environment regardless of OS choice( mac , Linux, BSD, windows)

Posted: Sun Apr 27, 2014 10:15 pm
by kubilus1
Okay, I've added a patched appack provided by r57shell and patched the makefile to hopefully build the 64 bit binary correctly. Problem was it was always pointing to the 32 bit aplib.a.

Pull in the changes and give it a try.

Posted: Sun May 04, 2014 6:42 pm
by Zontar
All right, wish I could test but I've recently upgraded to Ubuntu 14.04, which got me bitten by the texinfo 5 bug. Tried applying Mask of Destiny's diff but I may be doing it wrong as it gives an error when patching Makefile. I'll have to look further into this when I have the time.

Posted: Thu May 08, 2014 5:22 pm
by Chilly Willy
Zontar wrote:All right, wish I could test but I've recently upgraded to Ubuntu 14.04, which got me bitten by the texinfo 5 bug. Tried applying Mask of Destiny's diff but I may be doing it wrong as it gives an error when patching Makefile. I'll have to look further into this when I have the time.
I'm in the process of updating to 14.04. I always wait a week or so for the rush to die down (swamped servers), and for a few emergency bug-fixes to be released.

Posted: Sat May 10, 2014 1:57 am
by kubilus1
Okay, I finally got around to applying the patch that MaskOfDestiny provided. (Thanks for providing that!)

Give that a whirl and see if it works for you.