Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass arguments to the commands not working #4

Closed
fjtrujy opened this issue Oct 23, 2019 · 7 comments
Closed

Pass arguments to the commands not working #4

fjtrujy opened this issue Oct 23, 2019 · 7 comments

Comments

@fjtrujy
Copy link
Member

fjtrujy commented Oct 23, 2019

Hello,
After reading the documentation several times, I have tried to pass arguments using the ps2client application, but I couldn't make it work.

Documentation says:

execee <filename> [arguments]
 - Tell ps2link to load and execute a file on the EE.

I'm trying something as:

$ ps2client -h 192.168.1.150 execee host:hello.elf hello world

And the implementation of this hello.elf is:

int main(int argc, char *argv[])
{
   int i;
   
   for (i = 0; i < argc; ++i) {
        printf("Argument #%d is %s\n", i, argv[i]);
    }

  printf("Hello, world!\n);

   return 0;
}

The output that I receive is:

loadelf: fname host:hello.elf secname all
Input ELF format filename = host:hello.elf
0 00100000 000082b8 .
Loaded, host:hello.elf
start address 0x1000d8
gp address 00000000
Hello, world!

Am I using properly the command? or is it just that this is not working?

PD: I have the example that I have used here: https://github.com/fjtrujy/ps2-toolchain-tests/blob/master/PS2Client/main.c

Thanks

@fjtrujy
Copy link
Member Author

fjtrujy commented Oct 23, 2019

Hello again,
After deeper investigation I think that I found the issue, I will try to create a PR here and in the ps2link as well.

Thanks!

@sp193
Copy link
Member

sp193 commented Oct 24, 2019

I think this might have been caused by how ps2link passes arguments, which is non-standard. But if you changed it to use ExecPS2(), then it cannot remain resident anymore.

crt0.S used to have some special code for supporting this, by checking on the value of $a0. However, this resulted in bugs when the software was booted normally, due to the content of $a0 being undefined. I removed this support for ps2link from crt0, a very long time ago.

@fjtrujy
Copy link
Member Author

fjtrujy commented Oct 24, 2019

So do you think that is it impossible to fix it?
Investigating myself I reached the same point the crt0.s.
Anyway, both ps2client and ps2link they were not "parsing" properly the user arguments.

I will try to play around this, and see what I can do.
Basically the scenarios that I need to cover are:

  • Booting normally (what does "normally" means ? xD)
  • Booting from PS2Link
  • Booting from ExecPS2

Do we have more scenarios?

Thanks

@sp193
Copy link
Member

sp193 commented Oct 25, 2019

The normal way to boot a program, would be through ExecPS2(). However, this will delete all threads, which will prevent ps2link from existing together with the new program.

I did not make any changes to ps2link because I hoped that the author would make their own fix.

Given that each software may be built with different SDK versions and require different IOP modules, I do not think ps2link remaining resident would have worked very well anyway.

@bignaux
Copy link

bignaux commented Jun 5, 2022

To add information on that, ps2-packer elf seems to work well with arguments :

 helloworld: version 80f1739\n
helloworld: #4 Argument \n
helloworld: Argument #0 is host:helloworld.elf\n
helloworld: Argument #1 is bonjour\n
helloworld: Argument #2 is les\n
helloworld: Argument #3 is amis\n

Drawback is that i can't ps2client reset on packed elf.

@rickgaiser
Copy link
Member

This patch works to get arguments from ps2link to the elf that gets executed. Note that it has not been tested if normal elf execution still works.
ps2dev/newlib@5cbc394

@fjtrujy
Copy link
Member Author

fjtrujy commented Mar 27, 2024

Closing this issue as this is working currently!
Thanks

@fjtrujy fjtrujy closed this as completed Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants