HomeForumsWhat's newResources 
 
 
Using SBL
BrokenLizard - Dec 26, 2009
 BrokenLizard Dec 26, 2009
Are there any working examples of using the SBL libraries without SGL? I am trying to get the following test program to work, but the program just manages to display random characters on the screen. I am using a custom linker script, crto.S, and makefile that works with C++ and the standard run-time library.

Code:
  
#include "sega_dbg.h"

#include "sega_scl.h"

int main(){

    Uint16 pad;

    //SCL_Vdp2Init();

    DBG_Initial (&pad, RGB16_COLOR(31,31,31), 0x0000);

    DBG_DisplayOn();

    DBG_ClearScreen();

    DBG_SetCursol(10, 10);

    DBG_Printf("SBL DBG Test");

    for(;;);

    return(0);

}
I tried the samples that come with the SBL libraries, but they all seem to hang at the Sega logo screen. Loading the file binary files at different address locations did not appear to make a difference.

 vbt Dec 26, 2009
did you include strt1_g.o & strt2_g.o ?

 BrokenLizard Dec 26, 2009
Linking in those two files removes the random characters, but the code still does not work. It now hangs at the Sega logo screen just like all of the official SBL examples.

 antime Dec 27, 2009

BrokenLizard said:
I tried the samples that come with the SBL libraries, but they all seem to hang at the Sega logo screen.


When you built the samples, did you use the provided startup files and linker script (STRT1_G.SRC, STRT2_G.C, SATURN.LNK) or your own?

 BrokenLizard Dec 27, 2009
The official samples were compiled and linked with the support files and tools from SaturnOrbit. No modifications were made or attempted. I also tried patch 1 and patch 2 but the result was the same. Uploading the bin file to 0x06010000 on real hardware results in a hang at the Sega logo while loading the iso image in SSF or Yabause generates an unknown opcode error.

 mrkotfw Dec 27, 2009
Check the linker script. You might have to load the binary at 0x26004000.

 BrokenLizard Dec 27, 2009
The official SBL samples use the file saturn.lnk, which places the text segment at 0x06001000. This is different than the bart.lnk and sl.lnk files, which place the text segment at 0x06004000. Changing saturn.lnk to use 0x06004000 did not fix the problem. Before altering the saturn.lnk file, I tried loading the binary to 0x06001000, 0x06002000, and 0x06004000.

 vbt Dec 28, 2009
Maybe it can help you


Link flags :



  
	
	
LDFLAGS = -m2 -O2 -L$(SGLLDR) -Xlinker -T$(LDFILE) -Xlinker -Map \

-Xlinker $(MPFILE) -Xlinker -e -Xlinker START -nostartfiles



Link script :



  
	
	
SECTIONS {

.text 0x06004000 :

{

*(.text)

*(.strings)

}



.rodata ALIGN(0x20) :

{

*(.rodata)

}

.tors ALIGN(0x10) :

{

___ctors = . ;

*(.ctors)

___ctors_end = . ;

___dtors = . ;

*(.dtors)

___dtors_end = . ;

}



.bss ALIGN(0x10) (NOLOAD):

{

__bstart = . ;

B_BGN = . ;



*(.bss)

* ( COMMON )

__bend = . ;

B_END = . ;

_end = .;

}

}


 antime Dec 30, 2009
Loading the binary to some random address isn't going to fix it, the linker script says what the base address is.


If you look at the final object file (ie. before you convert it into a "raw" binary) using objdump or similar tools, is everything there? Are all the bits in their right sections and where they are supposed to be? IIRC the SBL build mechanism uses some tricks in order to be compatible with the Hitachi compiler, this may not work so well with the linker script you're using.


As a last resort, just disassemble the binary and see if the code makes sense.

 BrokenLizard Jan 1, 2010
It appears that SaturnOrbit is using the same IP.BIN file for all of its examples. Since this file specifies the loading address of the application bin file, the SBL examples (only using the provided build files) should not be able to start correctly. I tried using the IP.BIN file located in common/IP_GASM_SYS (it appears to be configured for 0x06010000), but that did not seem to work. Has anyone been able to start an SBL example compiled with the build mechanisms provided by SaturnOrbit? Before Segaxtreme moved, I downloaded the stand-alone archive of the SBL libraries and the build scripts are different. Once the download links in the resources section are operational, I will attempt to use this alternate set of build scripts with the Hitachi compiler. Hopefully, I will then be able to get a SBL example to at least start.

 antime Jan 2, 2010
You can download the SBL archive from my website. Using an emulator with debugging features is also useful, especially with simple applications like this.