A new post titled "[GSoC] Better RISC-V support, week #4/5" has been published on the coreboot blog. Find the full post at http://blogs.coreboot.org/blog/2016/06/27/gsoc-better-risc-v-support-week-45/

<p><strong>Week 4</strong></p>
<p>In week 4, I tracking down why coreboot halted after about one line of output. It turned out to be a spike bug, that I wrote up in <a href="https://github.com/riscv/riscv-isa-sim/issues/54">this bug report</a>, and affect any program that doesn’t have a <tt>tohost</tt> symbol. As a workaround, I extended my script that turns <tt>coreboot.rom</tt> into a ELF <a href="https://review.coreboot.org/#/c/15288/">to also include this symbol</a>.</p>
<p>After <a href="https://review.coreboot.org/#/q/after:2016-06-20+before:2016-06-22+author:Neusch%C3%A4fer">some more patches</a> I could run coreboot in spike and get the familiar “Payload not loaded” line.</p>
<p><strong>Week 5</strong></p>
<p>I was now clearly moving towards being able to run linux on spike/coreboot. But there was a problem: The RISC-V linux port requires a working implementation of the Supervisor Binary Interface (SBI), which is a <a href="https://github.com/riscv/riscv-pk/blob/1e62fdfce7b0095a57e4672c6c5fa4d3efb33d2a/machine/sbi.S">collection of functions</a> that the supervisor (i.e. the linux kernel) can call in the system firmware.</p>
<p>Coreboot has an implementation of the SBI, but it’s probably outdated by now. To get an up-to-date SBI implementation, I decided to use <a href="https://github.com/riscv/riscv-pk/tree/1e62fdfce7b0095a57e4672c6c5fa4d3efb33d2a/bbl">bbl</a> as a payload. When I built bbl with coreboot’s RISC-V toolchain, I noticed that it depends on a libc being installed in two ways:</p>
<ul>
<li>The autoconf-generated configure script checks that the C compiler can compile and link a program, which only succeeds if it finds a linker script (<tt>riscv.ld</tt>) and a <tt>crt0.o</tt> in the right place.</li>
<li>bbl relies on the libc headers to declare some common functions and types (it doesn’t use any of the implementations in the libc, though).</li>
</ul>
<p>The coreboot toolchain script doesn’t, however, install a libc, because coreboot doesn’t need one.</p>
<p>I tweaked the bbl source code until it didn’t need the libc headers, changed the implementation of <tt>mcall_console_putchar</tt> to use my 8250 UART, got the payload section of bbl (where linux is stored before it’s loaded) out of the way of the CBFS by moving it to 0x81000000 (<tt>bbl/bbl.lds</tt> is the relevant file for this change), and could finally observe Linux booting in spike, on top of coreboot and bbl. It stops with a kernel panic, though, because it doesn’t have a root filesystem.</p>
<p><strong>Plans for this week</strong></p>
<p>This week I will document my work on the <a href="https://www.coreboot.org/Board:emulation/spike-riscv">Spike wiki page in the coreboot wiki</a>, so others can run coreboot on spike, too.</p>