lately I have been trying to execute code on Leon3 processor using qemu. My code looks like this:
#include <stdio.h>
#include <stdint.h>
int main(void) {
int a,b,c,d,e;
printf("hello world!");
if(a){
a++;
};
if(b){
b++;
};
if(c){
c++;
};
if(d){
d++;
};
if(e){
e++;
};
while(1){
}
return 0;
}
so it's a pretty simple program.
I start Qemu with following command:qemu-system-sparc.exe -nographic -M leon3_generic -m 64M -kernel testapp.elf
but I don't get any outupt. Qemu seems to start and immidiately quits, not even hanging on infinite loop.
Trying to debug leads to crash(?) with following code: qemu-system-sparc.exe: QEMU: Terminated via GDBstub
I think that maybe i don't undesrtand something about qemu, but I cannot find any help regarding running .elf files.
Maybe anyone have done this and can help me?
OK, so I have found a way to do this.
As Peter mentioned in the comments: Qemu needs "something" more than bare metal .elf file.
I have found that there is a tool MKPROM2
provided by Cobham-Gaisler that takes an .elf file and creates a ROM image that later can be loaded to Qemu with -kernel
option.
The ROM image is different from bare metal .elf in a way that ROM image contains some initalization code that allows to run the program we initally wanted to execute.
So finally all that has to be done is running:
mkprom2 -freq 20 -romres testapp.elf
This outputs prom.out
file that can be loaded to qemu.