-
Notifications
You must be signed in to change notification settings - Fork 66
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
Linux Kernel Cannot Print where Bootrom and BBL can #39
Comments
Did you ever find a fix? I'm at the same issue right now. BBL and Bootloader print just fine, and when it hands over to Linux, nothing gets printed. I figured it has to do with the UART, but still trying to work out how to fix it. |
Not yet. I am still trying to figure it out. I initially thought early_init_dt_scan( ) takes care of UART initialization. But it appears in a Qemu environment, Linux Kernel can already print to console before early_init_dt_scan( ) is launched. Therefore I think the UART config was either done before MMU is enabled, or before Linux Kernel is launched. |
So if you pass earlycon through bootargs in defconfig, it will setup an early console with the uart. Are you running the Open Piton build or just regular CVA6/Ariane? What FPGA? I'm running the Open Piton build, that uses ns16550, on a VCU118. I think the uart device isn't getting picked up correctly in the device tree. Right now I'm rebuilding the FPGA bitstream. My initial hunch is that the uart in the device tree passes "ns16550" as the compatible name, and maybe "ns16550a" is what the Linux driver is looking for, even though it should work fine with "ns16550". I'll let you know how it goes. @zarubaf or @Jbalkind Would either of you have seen this issue before? |
@jctullos please be sure you're building from the openpiton branch. Also, have you set earlycon=sbi? |
I didn't on this build, but I'll add it. I didn't see it on the openpiton branch for the linux defconfig, that might need to be added if it's required. I'll try it right now. |
At what point in the boot process are you not seeing output? With the existing defconfig built from the openpiton branch it should just print. Does the prebuilt bbl.bin work? https://www.princeton.edu/~cloud/openpiton/os_images/openpiton_ariane_linux_r12.tar.gz |
Could you share the start of the output too? How did you prepare the SD? |
I am also working on another bbl build, it will print the device tree just fine, but hangs when Linux normally takes over. This is in minit.c and after which nothing outputs. At the jump to payload. I had a debug statement there previously which was the last thing it printed before jumping to the payload. |
The output looks reasonable. Partition table is correct, bbl is clearly located in the right place, and system frequency is reported correctly which means the ariane.dts should also be correct. Since the partition table is correct, the SD reading clearly isn't totally broken... Timing was probably met too I'm going to guess? Looks like you're building from openpiton-dev... Have you done a I don't really trust bbl to be honest. It has a kernel memory corruption bug which has caused us some strife. You could try opensbi instead? I shared some instructions here previously: https://groups.google.com/g/openpiton/c/8J9IX1VLRHA/m/poid3PVbCgAJ |
I haven't done an update in a few days, I'll check it out. Also, earlycon=sbi didn't change anything. And I'd like to move to opensbi, but my research is using Keystone and they still use bbl unfortunately. I've seen this issue in the past, I just can't remember how I fixed it. I had issues with 64 bit memory addressing in the dts file getting parsed correctly. That would have been my next attempt, to change address and size cells to 1 instead of 2. But the openpiton build has high addressing, so I'm assuming that's out unless it can be easily changed. |
There shouldn't be any new ariane updates in terms of our submodule pointer, it was more in case you were going from the openpiton branch to openpiton-dev and hadn't got the accompanying changes in doing so. That's a shame. I'll warn you that linux boot can be flaky with bbl. If you see random stalls and stack traces, it's likely to be bbl's fault. When we switched to opensbi, all of that went away. This was a problem both for standalone ariane and op+ariane. Others had reported the same for rocket I believe, too. You can move the ariane peripherals to a different location by changing the base addresses in piton/design/xilinx/vcu118/devices_ariane.xml and see if that helps? But we were using bbl for quite a while and I don't remember seeing this issue. That does make me suspect that perhaps not all of the SD woes have passed. May be worth trying our sdctrl_test design on vcu118 and seeing if it passes? |
I use Xilinx FPGA, bootrom.elf built off from the CVA6 fpga tree and bbl built from ariane-sdk. |
Please let me know if you have any success or have found anything with your bbl build. Thanks. |
Can you please elaborate? What I have in "\ariane-sdk\buildroot\output\build\linux-ariane-v0.7\arch\riscv\configs\defconfig":
So which routine is supposed to setup the console? |
@jctullos I have also noticed no uart output with keystone on stock Ariane (without openPiton). If I remember correctly I solved this with using a newer linux kernel version. I do not know where this comes from though. I would advise you to try a few different kernel versions (I believe I used 5.3). |
Where in Ariane SDK we can select which Linux Kernel version to use? |
According to https://github.com/pulp-platform/linux/, Linux 5.1-rc7 appears to be the latest. |
@Kendidi It is not supported to select this. You need to build it manually. I guess you could take a look at our build process and try to adapt it to an upstream kernel. |
thanks @Moschn although I'm using 5.3 right now for Keystone, so there must be something more. |
I think you might be right regarding the SD issues. After some random resets, Linux will boot. It's not consistent. So I assume data isn't getting copied over all the time. It hasn't completed a boot to the login prompt yet, right now it's failing on the RPC module, but at least there's output. |
So what changes did you make so it can print now? |
Ok. Thanks. After I downloaded Kernel 5.3, how should I modify before compiling it? |
@Kendidi I thought I replied yesterday, sorry! So I'm using a Linux 5.3 build. And passing console=hvc and earlycon=sbi to bootargs. FYI, Linux boots maybe 1/3rd of the time. And it always lags by a few seconds before it starts printing. |
Thank you @jctullos!! I will try to find a suitable copy of Linux 5.3 and try it. |
Besides "console=hvc" and "earlycon=sbi", what else do we need to put into bootargs? |
So I believe I've fixed the issue with Linux not showing the console. I remembered that I also had issues with the memory still holding data that wasn't getting cleared. I wrote a small while loop in the bootloader that just clears the memory where BBL is going, and then the sd_copy starts. So far, this has fixed it. There's no more issues between BBL and Linux handover. One question though, I still have issues with the Linux boot stopping halfway. Looking at the vmlinux system map, it seems to be when clock source switches over. Earlier, I had changed the timebased-frequency value in the DTS to half of the clock frequency, this was only because the Ariane/CVA6 repo had a commit that fixed their DTS to half the system clock. Does openpiton use another RTC build for the timebased-frequency? I know in the DTS generation script, it's the Sysclock/128. I'm changing it back to the default openpiton setting to see if this fixes Linux booting. But wanted to verify the frequency. |
I am using Kernel v5.3. I have added the following to ariane.dts but it's still not printing once Kernel has taken over
Is there anything else I have missed? |
Thank you @jctullos !! I will try it out. |
I've added those 3 config options to "../esp/soft/ariane/linux/arch/riscv/configs/ariane_defconfig". Re-run "make linux". Then used the resulted bbl. But got same result - no printout at Linux land, and stuck at "wfi" in . Did I miss anything? |
Being stuck at wfi to me suggests that your CLINT/PLIC may not be working. Usually the core will sit there waiting to be woken up by some interrupt like a timer or IPI from the CLINT. Are you using ariane-fpga? Is it up to date? I don't necessarily have much assistance to give in debugging it since I don't use Ariane's FPGA environment, but if you're definitely stuck at wfi I'd probably be looking into interactions with the CLINT. |
Thank you for your advice! Yes I am using FPGA - Xilinx VCU128. It's pretty updated I think. Which version would you recommend? Should we used the latest in repository - "master" or the last release - Ariane 4.2? |
By the way, since it's a single core setup, who's suppose to wake up Ariane? |
Ariane master is probably a good call. There have been a few important changes recently though (mainly the PMPs and 32 bit support) and so I'm not sure what state everything is in. If it's single core, the core can just be waiting for a timer that it set for itself. It's possible that that wfi is just the OS's idle loop. How did you check the instruction? |
Thanks @Jbalkind. I used GDB to run the code. I can see printout from Bootrom and from bbl. But nothing from Linux. I stopped GDB and it showed:
I used riscv64-unknown-elf-objdump to disassemble vmlinux and it shows: |
Looks like that corresponds with this (assuming kernel 5.1): https://elixir.bootlin.com/linux/v5.1/source/arch/riscv/kernel/head.S#L162 Weird place to be stuck. Maybe try disabling CONFIG_SMP if you're not using it? |
Yes, it's 5.1
|
If you look at the comments above where that's put in the trap vector here: https://elixir.bootlin.com/linux/v5.1/source/arch/riscv/kernel/head.S#L112 then you can see it's intended to help debug a particular error case. Can you maybe try and get the trap pc from gdb and see what it was executing before this happened? Honestly I find this case you're stuck in pretty weird. I would again encourage you to use opensbi if there's any possibility of that for your use case. |
Not sure how to get the trap PC from GDB since BT doesn't in current environment. I have considered replacing bbl with opensbi. I just don't know where to start. Is there any documents/website demonstrate a good way to do it? Thanks. |
With Kernel v5.3 and bbl from ariane-sdk, it stuck in memset() instead. |
In my situation, the following are required for Kernel to print messages onto the console. Somehow SMP needs to be off for the other changes to be effective.
Unfortunately, there are still some issues that forbid it to boot all the way. Have you encountered that before? Thanks.
|
Hey sorry I didn't realize the progress you've made! I should have said one of the other configure options I had was SMP off. I've seen it in the past where there's a bug that if only one core is running and SMP is on, it hangs. What commit are you building the Ariane processor from on the CVA6 repo? |
So here's my suggestion also. If you're using the OpenPiton or ESP build, and you don't need PMP, then stick to whichever Ariane version they have linked. There's an issue with PMP that I believe isn't getting captured up at the top level builds for those two, which was why the ESP folks added an issue to track it. If you don't need PMP, then keep the Ariane at the same commit as the OpenPiton/ESP builds. Also keep Linux on the 5.1 or 5.3, it says in your boot logs that you're loading Linux 5.5. The problem with this is that the Linux defconfig in the Ariane SDK is based on Linux 5.1. Same with the riscv-pk (bbl) is older. So there were a bunch of changes that happened to go to 5.5, and I believe riscv-pk had been updated as well. Some of the references in the bbl code, or the encoding.h, get updated with new values that are used in a newer version of Linux. So having 2 different versions of the bbl and Linux can work, but sometimes going too far apart it will mess with it. If you do need PMP, with the vcu128 you might be out of luck right now. There's a post on the CVA6 issues where a guy was able to get a VCU108 working and he has a repo. You could follow his changes to get your VCU128 going. I did the same for the VCU118 but was having some uart issues. And I got the vc707 working so I've switched over to it. |
Thank you very much for your advice!
I have been using Ariane CVA6 commit #453 since Thursday because I think it's prior to PMP support and it was recommended by the ESP folks.
So what setup/config you have now that will allow Kernel to boot successfully? Are you still having SMP turned off and with the other 3 config option set? |
Can you link it here the commit url for CVA6? Using the default Ariane SDK build (probably worth it to wipe it and start with a fresh repo) the only changes I made were to the Linux defconfig are: The changes I did make to the Ariane SDK linux_defconfig are: CONFIG_DEFAULT_HOSTNAME="ariane-fpga" So all I did was remove the ethernet items they have listed. I even kept the SMP it looks like. But this allowed the VCU118 to build and boot, so it should work for you as well. |
By the way, I recall if I set the following options in the ESP environment, then Kernel will crash during boot the same way as my Ariane now does.
Have you experienced that? To me, seems like these options help printing messages on the console, but somehow will generate issues later on on both Ariane and ESP platforms. |
https://github.com/openhwgroup/cva6/pull/453/files Thank you very much for the config option list! I will try it. |
No luck so far. I downloaded SDK. Replaced default linux_defconfig with yours and compiled bbl. Below is the DST file I am using. The clock frequency we are using is 40MHz and time-base frequency is 20MHz. Our design doesn't support ethernet. It shouldn't matter if we keep CONFIG_NET enabled. Right?
|
Which build are you using? OpenPiton or ESP? |
CVA6 commit #453. |
So you customized the CVA6 build for a VCU128? You're not relying on ESP/OpenPiton? FYI I didn't get my VCU118 working on the CVA6, it builds but the onboard uart wasn't working for me. Could you upload your build to github for the vcu128 for CVA6? If yours works I could take a look at why my uart doesnt. |
We thought CVA6 is the simplest therefore should be easiest to work with. I only have info on the device tree. I do not have source code to the build. |
For ESP builds, which of the following is being using?
|
If you look at the Make targets in /utils/Makefile, you should be able to navigate all the dependencies. Also, adding the flag e.g. make soft -n The other folders exist because they are part of the Ariane's repository. The ESP-Ariane bootloader |
Cool! Thank you @paulmnt !! |
Hello @Kendidi |
Hi,
I tried to load and run Bootrom, BBL and Linux Kernel on FPGA.
Bootrom and BBL can print on UART console without any issue, but the Linux Kernel cannot, even it went pass through a few places in setup.c and init.c where it should have printed something on the console. I think the ariane.dts in bootrom should be OK, otherwise BBL may not be able to print.
I wonder:
1) What may be the issue? Where should I look at?
2) How does the UART/console get initialized normally so that functions like pr_info( ) and printk( ) can print?
Thanks a lot in advance!
The text was updated successfully, but these errors were encountered: