Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

GDB crashed when trying to enable MMU #37

Open
Kendidi opened this issue Aug 27, 2020 · 14 comments
Open

GDB crashed when trying to enable MMU #37

Kendidi opened this issue Aug 27, 2020 · 14 comments

Comments

@Kendidi
Copy link

Kendidi commented Aug 27, 2020

Hi,

I use OpenOCD, GDB to load and run Linux Kernel on Ariane FPGA. GDB session appears crashing every time when the code tries to enable MMU in "relocate" session of ...\linux-ariane-v0.7\arch\riscv\kernel\head.S:

    csrw sptbr, a0

Is it OK to to enable MMU with code running from GDB?
How do we debug this?
And is there a way to temporary disable MMU usage?

Many thanks in advance!

@Moschn
Copy link
Contributor

Moschn commented Sep 1, 2020

Debugging virtual memory with GDB is a bit of a hassle. I think you must use updated openOCD and gdb versions and even then it is pretty weird. See riscv-collab/riscv-openocd#386

@Kendidi
Copy link
Author

Kendidi commented Sep 1, 2020 via email

@Moschn
Copy link
Contributor

Moschn commented Sep 1, 2020

The newest openOCD and GDB

@Kendidi
Copy link
Author

Kendidi commented Sep 2, 2020

Thanks Moschn!.

Currently, when it tries to read fdt header at fdt32_ld( ) (called from fdt_check_header( )), it will ended up trapped in Lsecondary_park in head.S.

Before MMU started, I read the FDT header via GDB and it looks good (0xedfe0dd0).

So does that mean there is an issue with address translation? How can we verify if that's the case? Please advise. Thanks.

@Kendidi
Copy link
Author

Kendidi commented Sep 3, 2020

The newest openOCD and GDB

I believe I am already using the latest OpenOCD and GDB I could find. Thanks.

@Moschn
Copy link
Contributor

Moschn commented Sep 3, 2020

I cannot really comment on these functions as I do not know where they are from. I guess no one tried to boot the entire linux image with single stepping in GDB. I myself only had success in stepping through phyiscal adresses withouth virtual memory. What exactly are you aiming to do? If you want to debug a certain application, I would suggest you do that on qemu. If you want to debug certain additions to Ariane, I would suggest doing that without virtual memory.

@Kendidi
Copy link
Author

Kendidi commented Sep 3, 2020 via email

@Moschn
Copy link
Contributor

Moschn commented Sep 3, 2020

I believe there is a nommu patchset for linux on risc-v. However, I do not think it is stable yet and I have never used it.

Since fdt is part of the device tree, I would assume you are having device tree issues. I would try to see if some code (i.e., linux boot code before MMU) can read the entire device tree and parse it correctly.

@Kendidi
Copy link
Author

Kendidi commented Sep 11, 2020

I have modified BBL to print the device tree before calling boot_other_hart(). It printed OK.

@Kendidi
Copy link
Author

Kendidi commented Sep 14, 2020

@Moschn

Are we supposed to supply a filesystem by adding something like the following into ariane.dts?

  chosen {
    bootargs = "root=/dev/xxx console=hvc earlycon=sbi";
    stdout-path = "/soc/uart@10000000:115200";
  };

If yes, what FS should we use? If not, will Kernel generate one during bootup? Many thanks in advance!

@Moschn
Copy link
Contributor

Moschn commented Sep 14, 2020

I do not know. I never had to modify the bootrom to get linux to boot

@Kendidi
Copy link
Author

Kendidi commented Sep 14, 2020

@Moschn

Cool! Thanks! I was under the impression that a filesystem is needed for Linux to boot to prompt, therefore "bootargs = "root=/dev/xxx..." is a must.

@Moschn
Copy link
Contributor

Moschn commented Sep 14, 2020

We use initramfs and as such do not have any filesystem. Everything is put on a ramdisk that is created on boot

@Kendidi
Copy link
Author

Kendidi commented Sep 14, 2020

Thank you @Moschn !!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants