riscv-isa-sim icon indicating copy to clipboard operation
riscv-isa-sim copied to clipboard

tohost and fromhost symbols not in ELF

Open karimhasebou opened this issue 8 years ago • 10 comments

karimhasebou avatar Oct 07 '17 11:10 karimhasebou

tohost and fromhost are used to send requests to the simulator host. They are present in the proxy kernel, which uses it to forward requests for system calls like write to your actual OS. You should provide a description in your issue of what your problem is. AFAIR this is a warning and not an error so you can ignore it. If that's inconvenient, then just define those symbols. Or, better yet, implement to some extent tohost and fromhost to allow your simulated programs to actually communicate with your host OS (e.g. print to stdout).

luismarques avatar Oct 07 '17 13:10 luismarques

@luismarques I thought that warning was the reason gdb is not working however I was able to get a simple main function to compile and gdb was able to debug.

karimhasebou avatar Oct 07 '17 13:10 karimhasebou

Hi, @luismarques,

I also enounter this issue, and the spike hangs and can't exit. so do you know the flow of spike exit, for the ELF form riscv/riscv_tests, it would enter a loop of write_tohost, the spike exit after loop many times.

Thanks Dream

IC-Dream avatar Nov 08 '18 03:11 IC-Dream

@IC-Dream I think you are going to have to rephrase your issue a bit more clearly.

luismarques avatar Nov 10 '18 19:11 luismarques

@luismarques thanks a lot, i added the tohost and fromhost symbols in .ld files and jump to write "1" to tohost in the end of test case. the spike can exit successfully.

IC-Dream avatar Nov 12 '18 03:11 IC-Dream

I have the same issue, but it's due to the wrong libmetal library. When I link the correct libmetal library, I could use spike without any problem.

The libmetal library with spike supports. https://github.com/sifive/freedom-metal/tree/htif

JerryShih avatar Aug 23 '19 02:08 JerryShih

@luismarques do you know if spike can print terminal output this way?

isubasinghe avatar Jul 08 '22 18:07 isubasinghe

You can see an example of a completely self-contained bare-metal program that outputs to the console using the HTIF interface (tohost, fromhost) here: https://github.com/lowRISC/epic-c-example. So, yes, @isubasinghe it can print terminal output. See the htif.c file, as well as the util.c file (contains a print function).

luismarques avatar Jul 08 '22 18:07 luismarques

Thank you so much for your quick response @luismarques , this is super useful for me.

isubasinghe avatar Jul 08 '22 19:07 isubasinghe

@luismarques thanks a lot, i added the tohost and fromhost symbols in .ld files and jump to write "1" to tohost in the end of test case. the spike can exit successfully. @IC-Dream will you please mentioned in detail how did you solved the issues,as I am facing same issue my linker has to host and fromhost, do I need to add anything in program i.e. in .S file? linker.ld OUTPUT_ARCH( "riscv" ) ENTRY(rvtest_entry_point)

SECTIONS { . = 0x80000000; .text.init : { *(.text.init) } . = ALIGN(0x1000); .tohost : { *(.tohost) } . = ALIGN(0x1000); .text : { *(.text) } . = ALIGN(0x1000); .data : { *(.data) } .data.string : { *(.data.string)} .bss : { *(.bss) } . = ALIGN(8); PROVIDE(tohost = .); . +=8; PROVIDE(fromhost = .); . +=8; _end = .; }

however, while loading elf, in SPIKE, i get the same warning and SPIKE hangs.

svasekar avatar Jul 19 '24 03:07 svasekar