openhwgroup / cva6-sdk

CVA6 SDK containing RISC-V tools and Buildroot
59 stars 64 forks source link

cva6-sdk uart driver doesn't work for CVA6 #85

Closed jimaandro closed 4 months ago

jimaandro commented 11 months ago

Is there an existing CVA6-SDK task for this?

Task Description

I am trying to boot the fw_payload via OpenOCD and GDB. It is executing correctly till it fails to initialize IRQ chip, (but this is not the actual problem). The problem is that before trying to initialize the IRQ it should have printed the OpenSBI banner and it doesn't

sbi_boot_print_banner(scratch);

rc = sbi_platform_irqchip_init(plat, TRUE);
if (rc) {
    sbi_printf("%s: platform irqchip init failed (error %d)\n",
           __func__, rc);
    sbi_hart_hang();
}

I also noticed that the driver of OpenSBI is a bit different from CVA6 uart drivers and also it doesn't match with the uart hardware (UART 16750) So what should I do to print in uart?

Description of Done

I tried to change the UART IP iin my disign to UART 16550 in order to match with the driver, but it didn't work

eyssartk commented 11 months ago

Hello,

With GDB + OpenOCD, you remove the arguments passed by the bootrom to OpenSBI firmware. Register a1 needs to contain the address of the device tree binary. There is one DTB available in the bootrom but its adress is dependent of the bootrom compilation.

You can check the address of the bootrom's DTB in https://github.com/openhwgroup/cva6/tree/master/corev_apu/fpga/src/bootrom by compiling the bootrom and checking the _dtb symbol's address. The DTB should start with 0xd00dfeed. On my machine, I find address 0x10C00 for 64bits bootrom and 0x11200 for 32bits.

Or you can load your own dtb somewhere in ram.

Good luck ! Kevin

jimaandro commented 11 months ago

Thank you very much for the reply. Well, the problem actually was on PLIC, I had to reduce input sources from 30 to 1 ( I use only UART, so I have only this interrupt). Now it prints the OpenSBI logo and booting, and then it goes to u-boot. The problem is that it doesn't print everything correctly (e.g. it misses characters) like this: image