#164088 - kusma - Mon Oct 20, 2008 4:04 pm
I've recently gotten an ARM RVDS (4.0) license to play with at home, and I was thinking of doing some RVDS builds of various software I've written. Now, I'm pretty much able to compile my sources with no problems, but generating a bootable ROM is something I haven't quite got yet. My assumption is that I need a boot-header (including the gba header + code to setup the stacks and load data into the iwram and ewram sections). I see that some RVDS (or SDT) code refer to a boot.o, to be passed with the "-fist"-argument to armlink.
Is this correct, and where can I find a suitable source file (or do I have to write this myself)? Is there something else I should be aware of?
#164097 - kusma - Mon Oct 20, 2008 6:13 pm
OK, I figured it out :)
I'm posting the solution here for future reference:
I found a simple boot.asm at http://stc.cx/~k-statik/boot.asm, and modified it slightly (basically just added PRESERVE8 to get rid of an annoying linker-error - I haven't looked that much into it, but it looked correct to me). I renamed the file, and assembled it like this:
Code: |
armasm --cpu=ARM7TDMI start.asm |
I compiled the following C-source code in a similar way
Code: |
#define REG_DISPCNT *((volatile unsigned short*)0x04000000)
#define BG_COLORS ((volatile unsigned short*)0x05000000)
int C_Entry()
{
int i = 0;
REG_DISPCNT = 0;
while (1) BG_COLORS[0] = i++ & 0xFFFF;
return 0;
}
|
Code: |
armcc -c --cpu=ARM7TDMI main.c |
Then I produced the ROM with these commands (note that I named the file start.asm, not boot.asm as the link suggest - this seems to be a slightly more common name):
Code: |
armlink --first start.o start.o main.o --ro-base 0x8000000 --rw-base 0x3000000 --output test.elf
fromelf --bin test.elf --output test.gba
|
And now I have flashing colors with armcc. Yay.
edit: fixed the ro-base.
Last edited by kusma on Wed Oct 22, 2008 8:02 am; edited 1 time in total
#164098 - kusma - Mon Oct 20, 2008 6:15 pm
Oh, and yeah. I only ran this binary on an emulator. I guess you'd need to GBAFIX it to make it run on the real hardware...
#164123 - Lord Graga - Tue Oct 21, 2008 11:15 am
Benchmarks! Benchmarks!
#164124 - kusma - Tue Oct 21, 2008 12:20 pm
Before I can do anything like that, I need to figure out how to put code in IWRAM ;)
#164247 - Lord Graga - Fri Oct 24, 2008 11:37 am
If everything fails, manually? :P
#164252 - kusma - Fri Oct 24, 2008 12:59 pm
I want to avoid doing it manually, because all memory-references needs to be rewritten (or the code must be compiled as position independent, which lowers performance). Luckily, it didn't take long to figure it out. I just need to finish up the scatter-file and the scatter-loader first. And then I need some time on my hands first. ;)
#164266 - Lord Graga - Sat Oct 25, 2008 12:50 am
GBAwesome, looking much forward to it. If it turns out to be much better (or just 5%), I'm gonna have to spend some time sweettalking my embeded systems proffessor into getting me a student license.
#164326 - kusma - Tue Oct 28, 2008 7:19 pm
You requested benchmarks, here you've got at least one; floating point additions (the floating point support libraries is one of the really good things in armcc). The following code was executed in three different configurations
Code: |
int i;
while (REG_VCOUNT > 0);
BG_COLORS[0] = 0xF0;
for (i = 0; i < 500; ++i)
{
f += 0.01f;
}
BG_COLORS[0] = 0x0;
|
Here's the results:
gcc (ROM fp-lib code?) : 122 lines
armcc (ROM fp-lib code) : 58 lines
armcc (IWRAM fp-lib code): 21 lines
The code in question itself was in both cases compiled as thumb, and placed in iwram.
So there you go ;)
#164332 - elwing - Tue Oct 28, 2008 8:06 pm
wow, the armcc perform simply great...