about target software

92 views
Skip to first unread message

Tao Wang

unread,
May 25, 2022, 10:17:02 AM5/25/22
to Chipyard
Hi,

To run baremetal RISC-V programs on chipyard-generated chips, is the riscv64-unknown-elf cross compiler the only option?

I am trying to build complex programs (e.g., nginx) to run on chipyard, however the riscv64-unknown-elf cross compiler may not support multi-threading.

Albert Ou

unread,
May 26, 2022, 2:24:59 AM5/26/22
to chip...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Chipyard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chipyard+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chipyard/e33a4e8c-c215-4c16-a526-2d0469542fdbn%40googlegroups.com.


A complex user application that depends on a multitude of non-trivial syscalls cannot simply be recompiled for a bare-metal environment without some serious porting effort.

While newlib (though not newlib-nano) is reentrant, you would need to implement your own threading library to schedule threads in a bare-metal environment, which by definition lacks an OS to provide such services.

The Chipyard boot ROM redirects all harts to the same entry point, by default the start of main memory at 0x80000000.  The startup code in the payload usually then reads hartid to identify which hart it is running on and decide how to proceed.  If the number of software threads does not exceed the number of harts in the system, a thread pool approach that does not require preemptive multitasking could be feasible.

Multithreading is the least of the potential hurdles, however -- presumably, Nginx relies on some form of support for filesystem and networking I/O.

newlib factors out some of the platform-specific functionality into libgloss (essentially a board support package), which also must be modified.  Since it makes very few assumptions about the execution environment except for the absence of an OS, the default RISC-V target mostly contains unimplemented stubs for a couple dozen syscalls:

I'm not sure if newlib actually supports a BSD-compatible sockets API.  Even if that were the case, you would still need a TCP/IP stack and a NIC driver.

For applications that are heavily reliant on POSIX, by far the easiest option is to use the riscv64-unknown-linux-gnu toolchain with a GNU/Linux system.

--
Albert Ou

Tao Wang

unread,
May 29, 2022, 8:02:44 PM5/29/22
to Chipyard
Thanks for the detailed explanation.

If we use the riscv64-unknown-linux-gnu toolchain to compile the applications, is that possible for us to run those applications on Chipyard simulation?

Best,
Tao

Albert Ou

unread,
May 30, 2022, 6:57:30 PM5/30/22
to chip...@googlegroups.com
Yes, Chipyard designs are capable of booting Linux, but doing so in RTL simulation would take a few hours, even with a minimal kernel config that removes unnecessary drivers.

For longer running workloads, you could instead try to map a Chipyard design onto an FPGA:

Or use Chipyard with FireSim if you have access to EC2 F1:

The Chipyard repo also includes FireMarshal, which can be used to produce a fairly compact buildroot-based Linux image:

Best,
Albert


Reply all
Reply to author
Forward
0 new messages