GaloisInc / BESSPIN-CloudGFE

The AWS cloud deployment of the BESSPIN GFE platform.
Apache License 2.0
2 stars 2 forks source link

Use native SiFive UART Driver in Linux Builds #99

Closed dhand-galois closed 4 years ago

dhand-galois commented 4 years ago

Up until now, Linux builds have been using the RISCV SBI UART interface to utilize the UART. This works fine, but is higher overhead and less responsive than having Linux communicate with the UART directly.

This issue will track progress on integrating the native SiFive UART driver.

dhand-galois commented 4 years ago

I've checked in the SiFive UART driver, along with a couple customizations, to the firesim branch of riscv-linux on gitlab-ext.

The SiFive driver requires you to have a clock source specified in the device tree, which it then uses to find the clock frequency for the UART. We're currently auto-generating the device tree from Chisel, where it's not that trivial to add the proper devices and links the driver is expecting. Therefore, I've implemented a backup approach that grabs the clock-frequency setting of the first available CPU in the device tree. This'll work for our FireSim builds. I've also disabled changing the baud rate in the driver as we never want to use anything other than the FireSim default baudrate.

This change will also require rebuilding AFIs as the devicetree is burned into the FPGA. I will rebuild them with bootargs = "earlyprintk console=ttySIF0,3686400".

To activate the driver in a kernel .config, set:

CONFIG_SERIAL_SIFIVE=y
CONFIG_SERIAL_SIFIVE_CONSOLE=y
CONFIG_HVC_RISCV_SBI=n

The SBI driver does not have to be disabled, but removing it helps avoid duplicated messages on boot where Linux tries to write out to the console both via SBI and directly to the UART.

Once the new AFIs are available, I'll update the cloudgfe_binaries package with new versions of debian and gfebusybox

kiniry commented 4 years ago

What is the status on this @dhand-galois? Has the new driver been pushed enough by the Target team that we can declare this issue closed?

kiniry commented 4 years ago

CC @rtadros-Galois so that he can flag whomever on the Target team should be aware of this work into the future.

rtadros125 commented 4 years ago

Isaiah is already aware and he linked a target issue to this as shown above.

dhand-galois commented 4 years ago

I am keeping this issue open to make sure it doesn't drop off my radar. The current state is the SiFive driver works reliably, but bootargs is burned into the AFI so I needed to rebuild them. I was also looking into ways to maintain backward compatibility with existing FireSim AFIs with the same debian/busybox ELF.

I think I can have that all wrapped up by tomorrow. The new AFIs, once ready, will be passed on to Target so the pointers in that project can be updated as well.

dhand-galois commented 4 years ago

This is working now with the latest AFIs. I'll close this issue for now as all the hardware is up to date for this change.

After more experimentation, leaving CONFIG_HVC_RISCV_SBI=y (set to y) will allow the kernel to boot properly on both old and new AFIs. The only downside is booting debian on a new AFI will result it in finding both the hvc0 and ttySIF0 serial devices. It'll temporarily start two consoles and a few boot messages get printed twice, but the ttySIF0 console takes priority and works normally after that. If FETT doesn't need to maintain compatibility with the older AFIs, it's safe to disable the SBI driver altogether.