#43636 - funkaster - Wed May 25, 2005 7:25 am
I'm trying to test the installation of devkitARM (compiled from CVS on a G4 running debian sarge, installed on /extra), so this is the most simple example I could find:
Code: |
#include <gba_base.h>
#include <gba_video.h>
int main()
{
unsigned char x, y;
SetMode (MODE_3 | BG2_ENABLE);
for (x=0; x < 240; x++)
for (y=0; y < 160; y++)
((u16 *)VRAM)[x+y*240] = RGB5(31,0,0);
while (1) ;
}
|
it was referencing a "gba.h" that I couldn't find in the devkitARM package, so I changed them to the gba_* headers of libgba.
Next, I made a makefile, following the suggestions on the FAQ and other tutorials:
Code: |
CC= arm-elf-gcc
LIBS= -L$(DEVKITARM)/arm-elf/lib -L/extra/libgba/lib/libgba.a
INCS= -I/extra/libgba/include
BIN= GBATest.gba
CFLAGS= $(INCS) -specs=gba.specs -mthumb -mthumb-interwork
all: $(BIN)
$(BIN): first.o
$(CC) first.o -o $(BIN) $(LIBS)
first.o: first.c
$(CC) -c first.c $(CFLAGS)
clean:
rm *.gba *.o
|
when I try to compile my simple proyect, the compiler screams this:
Code: |
Warning: /extra/devkitARM/lib/gcc/arm-elf/3.4.4/libgcc.a(_udivsi3.o) does not support interworking, whereas GBATest.gba does
|
and when I try the GBATest.gba on the emulator, I only get a white screen... can anyone point me to a good makefile for linux using the latest devkitARM?... thanks!
#43642 - Cearn - Wed May 25, 2005 9:09 am
The interworking thing can probably be fixed by adding -mthumb-interwork to your linker flags as well. That might work, or maybe not because there are other flaws as well
First of all, building a GBA file has three stages, not two: compilation (.c ->.o), linking (.o -> .elf) and conversion/translation (.elf -> .gba) (anyone have a better name for this?). An ELF file still has a lot of extra data that the GBA doesn't understand, so it has to be converted into a pure binary file by arm-elf-objcopy. Some compilers do accept ELF files, but it's better to add the conversion step too, because hardware will not. Oh, and just because you've named the output of the linker .gba doesn't make it so; it's still and ELF file.
For a more complete make file, you might try this:
Code: |
# === Project details (add your own stuff here) ===
PROJ := foo
INCLUDE :=
LIBPATHS :=
LIBS :=
COBJS := $(PROJ).o
SOBJS :=
OBJS := $(COBJS) $(SOBJS)
# --- boot type ---
MB = 0
ifeq ($(MB),1)
EXT := mb.gba
SPECS := -specs=gba_mb.specs
else
EXT := gba
SPECS := -specs=gba.specs
endif
# --- Compiling ---
CROSS:= arm-elf-
AS= $(CROSS)as
CC= $(CROSS)gcc
LD= $(CROSS)gcc
OBJCOPY= $(CROSS)objcopy
MODEL := -mthumb-interwork -mthumb
CBASE := $(INCLUDE) -O2 -Wall -mthumb-interwork
ASFLAGS := -mthumb-interwork
CFLAGS := $(CBASE) -mthumb
LDFLAGS := $(SPECS) $(MODEL) $(LIBPATHS) $(LIBS) -Wl,-Map,$(PROJ).map
# === Building steps ===
build: $(PROJ).$(EXT)
# --- convert to binary ---
$(PROJ).$(EXT) : $(PROJ).elf
@$(OBJCOPY) -v -O binary $< $@
-@gbafix $@
# --- link ---
$(PROJ).elf : $(OBJS)
$(LD) $(OBJS) $(LDFLAGS) -o $@
# --- compile ---
$(COBJS) : %.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
# === Clean ===
.PHONY : clean
clean :
@rm -fv $(OBJS)
@rm -fv $(PROJ).$(EXT)
@rm -fv $(PROJ).elf
#EOF
|
Add your own stuff to the project details, set MB depending on ROM or multiboot files and it should work fine (unless I missed something in copying)
Furthermore, I would suggest not having a space between SetMode and its first parentheses. SetMode is a macro and I remember someone having problems with this in the past. OTOH, it seems to work just fine now, so maybe it was just a problem with earlier toolchains.
Secondly, as I've mentioned before, do not use anything else except ints (signed or unsigned) as local variables, especially loop variables. I'd even suggest switching the order of the for-loops since C matrices are row-based and you might want to keep the fastest moving index on the inside. These things aren't fatal or anything, but will help you in the long run.
What still puzzles me is the exact error you've been having: _udivsi3.o has to do with integer division. What integer division?
#43658 - tepples - Wed May 25, 2005 2:13 pm
I think you need to specify
Code: |
LDFLAGS := -mthumb -mthumb-interwork |
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#43701 - funkaster - Wed May 25, 2005 8:49 pm
Cearn wrote: |
The interworking thing can probably be fixed by adding -mthumb-interwork to your linker flags as well. That might work, or maybe not because there are other flaws as well |
Well, I modified my makefile taking yours as a start point, but now the linker says:
Code: |
arm-elf-ld: unrecognised emulation mode: thumb-interwork
|
and this was the way the linker executed:
Code: |
arm-elf-ld first.o -specs=gba.specs -mthumb -mthumb-interwork -L/extra/devkitARM/arm-elf-lib -L/extra/libgba/lib/libgba.a -o GBATest.elf
|
:-S
#43742 - tepples - Thu May 26, 2005 3:36 am
I think the -mthumb -mthumb-interwork works when using arm-elf-gcc (not arm-elf-ld) as the linker.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#43745 - funkaster - Thu May 26, 2005 5:59 am
tepples wrote: |
I think the -mthumb -mthumb-interwork works when using arm-elf-gcc (not arm-elf-ld) as the linker. |
Well, I replaced ld with gcc as the linker, and now this is the output:
Code: |
rolando@baka:~/sandbox/prueba$ make
arm-elf-gcc -I/extra/libgba/include -O2 -Wall -specs=gba.specs -mthumb -mthumb-interwork -c first.c -o first.o
arm-elf-gcc first.o -specs=gba.specs -mthumb -mthumb-interwork -L/extra/devkitARM/arm-elf/lib -L/extra/libgba/lib/libgba.a -o GBATest.elf
/extra/devkitARM/lib/gcc/arm-elf/3.4.4/../../../../arm-elf/bin/ld: Warning: /extra/devkitARM/lib/gcc/arm-elf/3.4.4/thumb/libgcc.a(_call_via_rX.o) does not support interworking, whereas GBATest.elf does
/extra/devkitARM/lib/gcc/arm-elf/3.4.4/../../../../arm-elf/bin/ld: Warning: /extra/devkitARM/lib/gcc/arm-elf/3.4.4/thumb/crtend.o does not support interworking, whereas GBATest.elf does
/extra/devkitARM/lib/gcc/arm-elf/3.4.4/../../../../arm-elf/bin/ld: Warning: /extra/devkitARM/lib/gcc/arm-elf/3.4.4/thumb/crtn.o does not support interworking, whereas GBATest.elf does
/extra/devkitARM/lib/gcc/arm-elf/3.4.4/../../../../arm-elf/lib/gba_crt0.o(.init+0x210): In function `$t':
: undefined reference to `fake_heap_end'
collect2: ld returned 1 exit status
make: *** [GBATest.elf] Error 1
|
the same error (the unkown symbol `fake_heap_end') appears when I try to compile the examples (from cvs)...
#43751 - funkaster - Thu May 26, 2005 7:00 am
I figured out the problem: the build of devkitARM is WRONG... :-(
I build it from cvs on a dual 3Ghz Xeon and it worked ok :-(
the installed version on my G4 is missing about 200 files... I'll try to install it again...
#43803 - funkaster - Thu May 26, 2005 9:58 pm
Ok, I got the problem... the compiler and liker are working ok now. I tested with my really simple example.
I'll post the linux-powerpc binaries of devkitARM on my site soon... (and also the linux-powerpc binaries of VisualBoyAdvance)
#43820 - wintermute - Fri May 27, 2005 1:02 am
funkaster wrote: |
Ok, I got the problem... the compiler and liker are working ok now. I tested with my really simple example.
I'll post the linux-powerpc binaries of devkitARM on my site soon... (and also the linux-powerpc binaries of VisualBoyAdvance) |
please submit them to me & save your bandwidth, I'd be happy to host them on the SF project :)
#43837 - funkaster - Fri May 27, 2005 6:14 am
wintermute wrote: |
please submit them to me & save your bandwidth, I'd be happy to host them on the SF project :) |
check your private messages