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

Command line for testing output of the plugin device #1

Open
xzj478 opened this issue Jul 27, 2023 · 9 comments
Open

Command line for testing output of the plugin device #1

xzj478 opened this issue Jul 27, 2023 · 9 comments

Comments

@xzj478
Copy link

xzj478 commented Jul 27, 2023

I used the test drive which posted in this repo: "https://github.com/vexingcodes/spike-plugin" to test the output

With this command line:
"spike -m1 --extlib=/tmp/riscvtoolchain/lib/libspikedevices.so --device=sifive_uart,0x10000000,argument /tmp/spike-devices/plugin_test"

but it reports:
"terminate called after throwing an instance of 'std::runtime_error'
what(): Plugin "sifive_uart,0x10000000,argument" not found in loaded extlibs.
Aborted (core dumped)"

Could you please show me the right way of testing the output? Thanks.

@jerryz123
Copy link
Contributor

It should just be --device=sifive_uart.

@xzj478
Copy link
Author

xzj478 commented Jul 31, 2023

I tried "spike -m1 --extlib=/tmp/riscvtoolchain/lib/libspikedevices.so --device=sifive_uart /tmp/spike-devices/plugin_test", but nothing happened, and if I press Ctrl+C right after, it will be in spike debugging mode (I guess).

It should just be --device=sifive_uart.

@xzj478
Copy link
Author

xzj478 commented Aug 1, 2023

Okay, after I tried "spike --extlib=/home/zijianxie/riscvtoolchain/lib/libspikedevices.so --device=sifive_uart --isa=RV64GC --dtb /home/zijianxie/spike-devices/test.dtb /home/zijianxie/spike-devices/plugin_test"

it printed "Found uart at 10000000"; which means spike could recognize the mmio device?

Then how could I pass a string argument to the plugin device to test the store/load function? Since the original command of "--device=<P,B,A>; P -- Name of MMIO plugin, B -- Base memory addr. of the device, A -- String arguments to pass to the plugin" is no longer available in spike.cc.

@xzj478
Copy link
Author

xzj478 commented Aug 1, 2023

All I want to ask is how to access the device with memory load/store? Should I write an assembly file like they did in repo: https://github.com/vexingcodes/spike-plugin?

Or I write a simple function C code to do that(after compilation)?

@jerryz123
Copy link
Contributor

You should write a test program, whether in C or assembly, and execute it.

@xzj478
Copy link
Author

xzj478 commented Aug 1, 2023

Any simple example (in C) for that would be appreciated.

@xzj478
Copy link
Author

xzj478 commented Aug 8, 2023

Ping :-) I am really struggling to put together a working code, could you by any chance provide a c or asm example?

@pranjalchanda08
Copy link

HI @jerryz123, can you please provide a sample test (C) example and a related LD script being used to compile it.

@pranjalchanda08
Copy link

pranjalchanda08 commented Oct 21, 2024

I somehow figured this thing out hence documenting for beginners like me:

  1. We first need to compile the test.dts file to generate a test.dtb file -> dtc -I dts -O dtb test.dts > test.dtb
  2. Make a classic hello_world.c program and compile it using riscv64-unknown-elf-gcc
  3. Test the program using: spike --extlib libspikedevices.so --device sifive_uart --dtb=test.dtb pk hello
  4. We shall see the output as Found uart at 10000000 Hello World.
  5. In above the Hello World which you compiled via printf in step 2 is actually being shown via the syscall done by the uart device.
  6. As a proof you can remove the --device sifive_uart and rerun. You would not be able to see Hello World.
  7. --dtb command would override the pk default compiled dtb and use the sifive_uart as display output driver
    @xzj478 you can try this if I am not very very very late 😅

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