Re: qemu-arm 6.2.0 command line argument

2023-06-01 Thread Peter Maydell
On Wed, 31 May 2023 at 18:48, Tanmay Das  wrote:
>
> Hi,
>
> Hope all is well with you!
>
> I am trying to use qemu-arm to run a binary and trying to pass a command line 
> argument to the main method like below
>
> qemu-arm -cpu cortex-m3 path-to-the-binary 

This is the correct syntax. It works for me:

$ cat hello.c
#include 
int main(int argc, char **argv) {
if (argc <= 1) {
printf("no arguments\n");
} else {
printf("argv[1] = %s\n", argv[1]);
}
return 0;
}
$ arm-linux-gnueabihf-gcc -g -o hello -static hello.c
$ qemu-arm -cpu cortex-a15 ./hello
no arguments
$ qemu-arm -cpu cortex-a15 ./hello foo
argv[1] = foo

I used cortex-a15 as the CPU because I don't have a cross
compiler that builds M-profile Linux binaries. But the
principle is the same.

If your binary isn't seeing the command line arguments
then it's likely something else is wrong. Some questions
to try to help in diagnosing what:

 * Is your guest binary built for M-profile Linux?
 * How exactly is the C runtime it's built against expecting
   to get the command line arguments? (The other option that
   can be made to work is semihosting.)
 * Is the guest binary definitely successfully executing
   main() and just not seeing the right command line arguments?
   (i.e. check the problem is not that it is crashing before
   it even gets to main, or that you're trying to print
   the argument but the printing-output part goes wrong, etc.)

thanks
-- PMM



qemu-arm 6.2.0 command line argument

2023-05-31 Thread Tanmay Das
Hi,

Hope all is well with you!

I am trying to use qemu-arm to run a binary and trying to pass a command
line argument to the main method like below

qemu-arm -cpu cortex-m3 path-to-the-binary 

apart from the above, I have also tried
qemu-arm -cpu cortex-m3 path-to-the-binary -1 

But none of them are passing the argument to the main method. Can you
please help me with this? Any documentation on this will be very helpful.

Thanks & Regards
Tanmay