Skip to contentSkip to conversation

Writing a small test program - a bit off topic

DISCUSSION Peter Asemann 2 participants 2 messages May 9, 2005

lore
Share & tools
lore
#0 lore raw

Hi there!

I *hope* this mail isn't very off topic. In principle it probably is, but I don't know a mailing list which is about writing test programs to test processors in order to debug a hardware to get linux running. Plus, I suppose there are people out there who could help me. So I hope you won't stone me for this post.

Whatever:
I have to write some test program for a mpc875 processor. It should run in the processor cache as the memory of the hardware doesn't work for hardware-problem-reasons.

I set up the memory mapping of the IMMR of the processor with the debugger (BDM4GDB) so the IMMR is at 0xff000000.
Then I want to change the state of two leds. This can be done by writing some values into some memory-mapped MPC registers (PEDAT / PEDIR) which reside at IMMR + 0xac8 / 0xad8.

I wrote a C program to do that; As there is no OS I think I can just try to write to memory locations directly:

#define CONFIG_8xx

int main(void){
long* a;
long* b;
a = (long*)0xff000ac8;
*a = 0x00001800;
b = (long*)0xff000ad8;
*b = 0x00001800;
}

Actually, if I compile it (using Denx ELDK 3.1) with

ppc-linux-gcc -static led.c -o led

the resulting program is 477K big.
On the other hand, if I do

ppc-linux-as -mcom led.s
and
ppc-linux-as -mcom led.s -o led.bin

the resulting program is 439 byte big.

Now, my questions are: Will the 439 byte program faciliated this way do what I want? Did I make some fatal newbie mistakes? Does somebody know how to upload code to the mpc instruction cache and execute it?

Thanks for reading,

Peter Asemann

#1 lore raw
Quoted 5 lines · Peter Asemann

I *hope* this mail isn't very off topic. In principle it probably is, but I don't know a mailing list which is about writing test programs to test processors in order to debug a hardware to get linux running. Plus, I suppose there are people out there who could help me. So I hope you won't stone me for this post.

assuming 'foo.c' is your program, and you want to run it at origin 0.

Step 1) ppc8xx-linux-gcc -Dmain=_start -nostdlib foo.c -o foo

Step 2) ppc8xx-linux-objcopy foo -O binary foo.bin

Done!

Signature · 2 lines
Jason McMullan <[email protected]>
TimeSys Corporation