-
Notifications
You must be signed in to change notification settings - Fork 544
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
picolibc: Rocket support broken? #1049
Comments
The issue seems related to Atomics support: Changing the architecture from It can be reproduced by: |
a588c3b fixes the issue (at least provides a workaround). |
While a588c3b does fix it in the simulator, on the FPGA I still get no console output at all. Using the nexys4ddr as an example:
|
As discussed together @gsomlo, the issue can be reproduced in simulation when enabling ethernet:
Removing |
Removing It also results in no output whatsoever on the FPGA system's console when built without ethernet and sdcard (just the cpu) -- same tradeoff as shown by @enjoy-digital in simulation. |
Thanks @gsomlo, I'll try to understand the issue tomorrow. |
@gsomlo @enjoy-digital I'll check this in renode - this should give us some insight what is happening here |
On Thu, Sep 30, 2021 at 10:08:28AM -0700, enjoy-digital wrote:
@gsomlo: @kgugala will try to have someone looking at this. Sorry for the
temporary breakage...
@enjoy-digital, @kgugala: thanks! I have no experience with LTO, and
based on my brief googling it's a relatively new thing where people
still run into the occasional toolchain bug with relatively higher
frequency...
That said, it's super weird that turning it off will fix the case when
ethernet/sdcard peripherals are added, but break the case where no
peripherals are configured (on both fpga and simulator). Can't wait to
find out what the actual problem was!
BTW ***@***.***): a588c3b (ability to type at the litex prompt) is
apparently completely orthogonal to LTO, and the problem manifests
(and is solved by that commit) identically on both fpga and simulator
(again, specific to rocket only, apparently) -- just for the record :)
Thanks again,
--Gabriel
|
@gsomlo which toolchain do you use? |
On Thu, Sep 30, 2021 at 10:32:19AM -0700, Karol Gugala wrote:
@gsomlo which toolchain do you use?
https://github.com/riscv/riscv-gnu-toolchain
I'm on git commit 7553f35 (from mid-December 2020).
Not sure what @enjoy-digital is using, but he's experienced the same
symptoms on his end.
|
On Thu, Sep 30, 2021 at 01:39:14PM -0400, Gabriel L. Somlo wrote:
https://github.com/riscv/riscv-gnu-toolchain
I'm on git commit 7553f35 (from mid-December 2020).
Oh and I should mention there's a pre-built binary of that I've made
available at
http://www.contrib.andrew.cmu.edu/~somlo/BTCP/RISCV-20201216git7553f35.tar.xz
(description of how I built it at
https://github.com/litex-hub/linux-on-litex-rocket part 3 of the
Prerequisites section).
|
@kgugala: I've been testing with the one from litex_setup.py: |
On Fri, Oct 01, 2021 at 05:16:00AM -0700, enjoy-digital wrote:
@kgugala: I've been testing with the one from litex_setup.py:
riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64.
I'm currently building the latest riscv-gnu-toolchain (commit b39e361
tagged "2021.09.21"), and will report back on whether using it makes
any difference in the observed behavior of litex+rocket.
|
@kgugala @enjoy-digital : unfortunately, same behavior with the latest riscv-gnu-toolchain (pre-built binary here in case anyone wants to try it without waiting for the build). |
After some investigation with @kgugala and other team members, we've boiled it down to two issues:
I simulated the system using In my case, the faulting address is Compiling picolibc with |
Thanks for looking at this @j-piecuch, @kgugala. Setting |
Rocket routes its load/store instructions based on its own internal memory map, through one of two AXI ports dedicated to either MMIO (< 0x80000000) or MEM (>= 0x80000000). There's a point-to-point link between the Rocket MEM AXI port and LiteDRAM. Rocket also has its internal L1 [i,d]cache, and MEM load/store accesses visible on the external MEM AXI port are "south" of the L1 cache (and maintain cache coherency between Rocket's L1 and LiteDRAM). Accesses below 0x80000000 are routed through the MMIO AXI port (bypassing the L1 cache), which is then converted to WB by LiteX and connected to the shared MMIO bus, which also has the SRAM connected to it. So long story short, SRAM accesses are routed in a way that bypasses the L1 cache, which may or may not explain the behavior w.r.t. atomic memory operations. I'll try to understand this better myself, but figured it'd be useful to clarify just in case... |
After a bit more digging, I found out that
The question now is what, if anything, should be done about it. I'd argue that since the LiteX bios explicitly spins all but one of the cores while loading something into the main memory (which does support atomics), it doesn't really need to use (and/or have support for) atomics. But I'm arguing that with weak confidence, and I'm definitely open to counter arguments... :) |
@gsomlo good find! That address map clearly indicates the culprit. I'm assuming that Your argument for disabling atomics is totally reasonable IMO. I think disabling them by removing On a related note, I was investigating atomic operations in Rocket, and I inserted some atomic operations on main RAM into the bios' Do you have any insight into why this might be happening? I know this sounds weird, but maybe the address of the atomic instruction itself matters here? Maybe the atomic instruction itself must be in main RAM? |
Yes, that's correct.
I added the following patch to the bios main():
which translates into something like this in assembly:
While this does hang in the simulator, it works fine on a real FPGA (nexys4ddr in my case). Might it have something to do with the accuracy of how main-ram is simulated in EDIT: Oh, and @j-piecuch : sorry I missed your question about where the Rocket memory map came from. It's something that gets printed out to the console during chisel elaboration while building the precompiled rocket Verilog (part of what happens when you run https://github.com/litex-hub/pythondata-cpu-rocket/blob/master/pythondata_cpu_rocket/verilog/update.sh). The same information is stored (in much less human-readable json) in https://github.com/litex-hub/pythondata-cpu-rocket/tree/master/pythondata_cpu_rocket/verilog/generated-src/ *.memmap.json EDIT 1: I also tried |
@gsomlo @enjoy-digital Currently on both Rocket and Blackparrot I'm unable to start BBL or the demo using my Arty board. Oh and not using |
Nevermind turns out my toolchain was broken. |
I think all the issues have been solved and that we can now close this. @gsomlo: Please re-open if it's not the case. |
Reported by @gsomlo: https://libera.irclog.whitequark.org/litex/2021-09-27#30904583
cc @kgugala, @michalsieron.
The text was updated successfully, but these errors were encountered: