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

semihosting_write bug in generic #339

Open
zxtxin opened this issue Dec 15, 2023 · 6 comments
Open

semihosting_write bug in generic #339

zxtxin opened this issue Dec 15, 2023 · 6 comments

Comments

@zxtxin
Copy link

zxtxin commented Dec 15, 2023

semihosting_write is called in semihosting_puts which expects that semihosting_write returns the length it writes.
Length minus the return value of syswrite trap which is normally the true length the syscall writes according to the convention is returned in the implementation of semihosting_write. So semihosting_write returns zero actually.

When I am debuging the opensbi with a debugger attached, I get infinite loop of printing 'OpenSBI 1.3.1'.

@wxjstz
Copy link
Contributor

wxjstz commented Dec 20, 2023

syscall normally return the number of bytes that are not written
semihosting_write in opensbi normally return the number of bytes that has been written
semihosting_puts in opensbi normally return the number of bytes that has been written

Regards,
Xiang W

@zxtxin
Copy link
Author

zxtxin commented Dec 21, 2023

In linux, the syscall write returns the true length it writes.
I don't know why there is a difference in the implementation of openocd.

@zxtxin
Copy link
Author

zxtxin commented Dec 21, 2023

I'm using the cklink from t-head to debug a riscv core C908. Its implementation complys with the convention of linux write

@wxjstz
Copy link
Contributor

wxjstz commented Dec 21, 2023

Its implementation complys with the convention of linux write

opensbi not running on linux. It running on debugger. You need to know how this debugger implements syscall. Like this: https://github.com/openocd-org/openocd/blob/master/src/target/semihosting_common.c#L1365

@cp0613
Copy link
Contributor

cp0613 commented Jan 10, 2024

You can download the latest XuanTie Debug Server from https://www.xrvm.cn/ and add the -ls parameter at startup to use semihosting, such as # DebugServerConsole - prereset - ls

@wxjstz
Copy link
Contributor

wxjstz commented Jan 12, 2024

XuanTie implements a strange SYS_WRITE. Is this weird stuff going to spread to all software?

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

3 participants