Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
C code in WRAM SOLUTION!   Message List  
Reply | Forward Message #5961 of 15019 |
Right, here's a working solution for putting ARM code in WRAM:

Use a simple linker script which looks something like this:

OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)

MEMORY
{
iram (wx) : ORIGIN = 0x3000000, LENGTH = 32K
eram (wx) : ORIGIN = 0x2000000, LENGTH = 256K
rom (rx) : ORIGIN = 0x8000000, LENGTH = 8M
}

SECTIONS
{
.bss :
{
*(.bss)
}
> iram

.text : AT(0x8000000)
{
*.o(.text)
*(.data)
*(.rodata)
*(.glue_7t)
*(.glue_7)
}
> rom

.armcode : AT(ADDR(.text) + SIZEOF(.text))
{
_sdata = .;
*.ao(.text);
_edata = .;
}
> iram
_datalma = LOADADDR(.armcode);

PROVIDE (end = .);

.stab . (NOLOAD) :
{
[ .stab ]
}
.stabstr . (NOLOAD) :
{
[ .stabstr ]
}
}

This puts all .o files in the ROM, including all code and data (Sorry, no
initialised global support. You have to do that yourself...).

It also puts all .ao files in work RAM after the global variables (BSS).
These are you ARM files! Make sure you compile all ARM code to .ao object
files for this to work...

All you need to do now is copy the code to work RAM using something like
this in your crt0.s (nicked from Jeff's code):

@-- COPY INITIALISED DATA / CODE TO RAM

ldr r1,=_edata
ldr r2,=_sdata
subs r3,r1,r2 @ Is there any data to copy?
beq CIDSkip @ no

ldr r1,=_datalma
CIDLoop:
ldmia r1!,{r0}
stmia r2!,{r0}
subs r3,r3,#4
bne CIDLoop

CIDSkip:

Then jump to your main here...

That's it!

Oh, except GCC is crap at working out how to call stuff, so you have to call
ALL your ARM functions via function pointers. Likewise if you want to call
THUMB function from the ARM code you have to use a function pointer.

Not sure about the ARM compiler. Will look into it later... :)

Cheers,

--Jim






Wed Aug 1, 2001 11:42 am

jim@...
Send Email Send Email

Forward
Message #5961 of 15019 |
Expand Messages Author Sort by Date

Right, here's a working solution for putting ARM code in WRAM: Use a simple linker script which looks something like this: OUTPUT_FORMAT("elf32-littlearm",...
James Boulton
jim@...
Send Email
Aug 1, 2001
11:45 am

Hello James, Wednesday, August 01, 2001, 1:42:02 PM, you wrote: JB> Right, here's a working solution for putting ARM code in WRAM: JB> Use a simple linker...
groepaz
groepaz@...
Send Email
Aug 1, 2001
4:48 pm

... Your solution seems likely to cause so many other problems :) .data should be writable, so you should not put its VMA in ROM How do you clear the bss...
Jason Wilkins
fenix@...
Send Email
Aug 1, 2001
4:51 pm

... Yep. W = read/write and X = execute. The only reason for doing this is so if the linker doesnt have somewhere to put an object, it can have a good guess...
James Boulton
jim@...
Send Email
Aug 1, 2001
9:42 pm

Hello James, Wednesday, August 01, 2001, 8:06:26 PM, you wrote: JB> The only reason for doing this is so if the linker doesnt have somewhere to JB> put an...
groepaz
groepaz@...
Send Email
Aug 2, 2001
6:26 am

holla tob(i|y) ! ... wondering how many "so-called" PC coders even _KNOW_ what a linker script is ... the same goes for most non-handheld consoles ... ... ......
Markus Glanzer
markus.glanzer@...
Send Email
Aug 2, 2001
5:36 pm

Hello Markus, ... MG> wondering how many "so-called" PC coders even _KNOW_ what a linker MG> script is ... oh well... i am not going into some anti-pc war, but...
groepaz
groepaz@...
Send Email
Aug 2, 2001
6:22 pm

... Where can I find Silph's modplayer? Greetings, Jan-Lieuwe...
Jan-Lieuwe Koopmans
jan-lieuwe@...
Send Email
Aug 2, 2001
8:50 pm

Hello Jan-Lieuwe, ... JLK> Where can I find Silph's modplayer? on www.hitmen-console.org there's a demo -- Best regards, groepaz...
groepaz
groepaz@...
Send Email
Aug 2, 2001
9:31 pm

... Then you basically repeated Jason Wilkin's argument in your original post that seemed to be disagreeing with him. Charlie ck@......
Charlie Kilian
ck@...
Send Email
Aug 2, 2001
8:59 pm

... oh?! he's moving back?! damn, neither he or Sergio told me ... anyway, last time i was playing around with the player & gcc 3.0 it sounded realy nice with...
Markus Glanzer
markus.glanzer@...
Send Email
Aug 3, 2001
1:23 pm

... I don't feel so bad now. I don't have much free time to work on GBA stuff and I have been on the scene only 2 months, so all of my time has been spent...
Jason Wilkins
fenix@...
Send Email
Aug 3, 2001
2:59 pm

... In our setup it wasnt. Allowing data to be writable caused far more problems. I'm not going through all the code marking stuff as const when there is no...
James Boulton
jim@...
Send Email
Aug 1, 2001
9:49 pm

... Did I really say anything to warrant this kind of response? I only critiqued your script, I felt that it would end up being more trouble than its worth, a...
Jason Wilkins
fenix@...
Send Email
Aug 2, 2001
6:25 am

Hello Jason, JW> I AM writing the "mother of all linker scripts," and I believe that all JW> this linker script nonsense is silly, its like asking people to...
groepaz
groepaz@...
Send Email
Aug 2, 2001
10:28 am

... I think that linker scripts are only simple if you are already bringing a lot of knowledge about how tool chains work to the table. On top of that, it...
Jason Wilkins
fenix@...
Send Email
Aug 2, 2001
3:06 pm

Hello Jason, Thursday, August 02, 2001, 4:21:59 PM, you wrote: ... JW> I think that linker scripts are only simple if you are already bringing a JW> lot of...
groepaz
groepaz@...
Send Email
Aug 2, 2001
6:14 pm

greopaz, we agree almost 100 percent except on your notion about being a true "coder" To use your phrase, thats nonsense. My whole point was: Good programmers...
Jason Wilkins
fenix@...
Send Email
Aug 2, 2001
8:57 pm

Hello Jason, JW> My whole point was: Good programmers should be smart enough to write JW> linker scripts, but they shouldn't have to. my impression is, even...
groepaz
groepaz@...
Send Email
Aug 2, 2001
9:45 pm

... As amusing of a pseudo-flame war as this has become =) I'd like to point out that half the problem with creating a linker script is that the documentation...
Dan Potter
bard@...
Send Email
Aug 2, 2001
11:08 pm

Hello Dan, Friday, August 03, 2001, 12:52:07 AM, you wrote: ... DP> As amusing of a pseudo-flame war as this has become =) I'd like to point DP> out that half...
groepaz
groepaz@...
Send Email
Aug 3, 2001
1:15 pm

... maybe ... Wow, it looked to me as if he was just being a goof. I'm amazed on how serious your taking that....
mike@...
Send Email
Aug 3, 2001
1:25 pm

... Serious? Not really. I do enjoy the way he writes as long as he is not out of line. But there could be more heat and less light if you know what I mean....
Jason Wilkins
fenix@...
Send Email
Aug 5, 2001
4:01 pm

... Half of what makes a good programmer is knowing when NOT to write something on their own. gcc -o wheel wheel.c...
Jason Wilkins
fenix@...
Send Email
Aug 2, 2001
8:59 pm

Hello Jason, ... JW> Half of what makes a good programmer is knowing when NOT to write JW> something on their own. JW> gcc -o wheel wheel.c thats not the...
groepaz
groepaz@...
Send Email
Aug 2, 2001
9:13 pm

... This statement is (of course) utter rubbish. ... Indeed, I've never used GCC before, but it all seems fairly straight forward once you know what's kicking...
Jay
Jay@...
Send Email
Aug 2, 2001
9:11 pm

Having said that it looks like the assembler is a bit bobbins :( I feel an assembler pre-processor comming on :) Regards Jay...
Jay
Jay@...
Send Email
Aug 5, 2001
3:55 pm

Hello Jay, Friday, August 03, 2001, 7:27:53 PM, you wrote: J> Having said that it looks like the assembler is a bit bobbins :( J> I feel an assembler...
groepaz
groepaz@...
Send Email
Aug 5, 2001
4:47 pm

... I worked for an archemedes software conversion house years ago and have lots of source in armcode, Speedball2, Cannon Fodder, quite a few others. The...
Jay
Jay@...
Send Email
Aug 5, 2001
9:16 pm
First  | < Prev  |  Last 
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help