edk2-platforms icon indicating copy to clipboard operation
edk2-platforms copied to clipboard

[WIP] Add SiFive Unmatched support

Open yqszxx opened this issue 3 years ago • 9 comments
trafficstars

  • [ ] The U7SeriesPkg is basically adapted from the U5SeriesPkg, small modifications are maded for unmatched, code are not fully cleaned up
  • [ ] PCIe RC driver for U740 will be added

yqszxx avatar Mar 22 '22 10:03 yqszxx

@yqszxx Hi Boyang, Thanks for working on this. I will take a look at those changes. BTW, did you verify U7 edk2 port on the real SiFIve platform? Can it boot to EFI shell?

changab avatar Mar 22 '22 15:03 changab

@yqszxx Hi Boyang, Thanks for working on this. I will take a look at those changes. BTW, did you verify U7 edk2 port on the real SiFIve platform? Can it boot to EFI shell?

Hello! The latest commit is tested on real SiFive Unmatched hardware, and it can boot to shell. I will update the procedure in detail in the readme file in one or two days.

yqszxx avatar Mar 24 '22 08:03 yqszxx

Thanks! BTW, we usually review the patches through edk2 mailing list but not PR. So please send your final set of patches against edk2-platform repo to [email protected] as well. thus people can give comments using email.

changab avatar Mar 27 '22 14:03 changab

Thank you for your reply! I'm still learning how to collaborate using mail list😄 I will present the final patch when I finished the PCIe driver✅

yqszxx avatar Mar 28 '22 04:03 yqszxx

Without the pcie driver working, the most of the board's peripherals cannot function.

hanf2x avatar Jan 12 '23 07:01 hanf2x

I decided to try building and running code from your branch on my Unmatched board. However, it asserts early on:

Freedom FSBL: 2023-01-20-7fdeede-dirty
Loading boot payload................

Use DBT FV
FindFfsFileAndSection: DBT FV at 0x80840000
FindFfsFileAndSection: FV at 80840000 does not have FV header signature
Use DBT FV
FindFfsFileAndSection: DBT FV at 0x80840000
FindFfsFileAndSection: FV at 80840000 does not have FV header signature
Platform Device Tree is not found on boot hart
ASSERT [SecMain] /home/bcran/src/uefi/edk2-platforms/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c(684): ((BOOLEAN)(0==1))

Is there a step I've missed?

bcran avatar Jan 21 '23 12:01 bcran

By the way the branch is quite out-of-date now. I added the following changes to get it working:

diff --git a/Platform/SiFive/U7SeriesPkg/FreedomU740HiFiveUnmatchedBoard/U740.dsc b/Platform/SiFive/U7SeriesPkg/FreedomU740HiFiveUnmatchedBoard/U740.dsc
index 2af45f8739..8dd4f6e80e 100644
--- a/Platform/SiFive/U7SeriesPkg/FreedomU740HiFiveUnmatchedBoard/U740.dsc
+++ b/Platform/SiFive/U7SeriesPkg/FreedomU740HiFiveUnmatchedBoard/U740.dsc
@@ -102,6 +102,7 @@
   UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
   FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
   VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
 # RISC-V Platform Library
   TimeBaseLib|EmbeddedPkg//Library/TimeBaseLib/TimeBaseLib.inf
diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVExceptionLib/CpuExceptionHandlerLib.c b/Silicon/RISC-V/ProcessorPkg/Library/RiscVExceptionLib/CpuExceptionHandlerLib.c
index 93fbde619f..0fda5b0a0a 100644
--- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVExceptionLib/CpuExceptionHandlerLib.c
+++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVExceptionLib/CpuExceptionHandlerLib.c
@@ -147,8 +147,6 @@ RiscVSupervisorModeTrapHandler (
   elsewhere and are necessary for the extra initializations of exception.
 
   @param[in]  VectorInfo    Pointer to reserved vector list.
-  @param[in]  InitData      Pointer to data optional for extra initializations
-                            of exception.
 
   @retval EFI_SUCCESS             The exceptions have been successfully
                                   initialized.
@@ -160,13 +158,39 @@ RiscVSupervisorModeTrapHandler (
 EFI_STATUS
 EFIAPI
 InitializeCpuExceptionHandlersEx (
-  IN EFI_VECTOR_HANDOFF_INFO  *VectorInfo OPTIONAL,
-  IN CPU_EXCEPTION_INIT_DATA  *InitData OPTIONAL
+  IN EFI_VECTOR_HANDOFF_INFO  *VectorInfo OPTIONAL
   )
 {
   return InitializeCpuExceptionHandlers (VectorInfo);
 }
 
+/**
+  Setup separate stacks for certain exception handlers.
+  If the input Buffer and BufferSize are both NULL, use global variable if possible.
+
+  @param[in]       Buffer        Point to buffer used to separate exception stack.
+  @param[in, out]  BufferSize    On input, it indicates the byte size of Buffer.
+                                 If the size is not enough, the return status will
+                                 be EFI_BUFFER_TOO_SMALL, and output BufferSize
+                                 will be the size it needs.
+
+  @retval EFI_SUCCESS             The stacks are assigned successfully.
+  @retval EFI_UNSUPPORTED         This function is not supported.
+  @retval EFI_BUFFER_TOO_SMALL    This BufferSize is too small.
+**/
+EFI_STATUS
+EFIAPI
+InitializeSeparateExceptionStacks (
+  IN     VOID   *Buffer,
+  IN OUT UINTN  *BufferSize
+  )
+{
+
+return EFI_UNSUPPORTED;
+
+}
+
+
 /**
   The constructor function to initial interrupt handlers in
   RISCV_MACHINE_MODE_CONTEXT.

bcran avatar Jan 21 '23 12:01 bcran

Sorry, my build must have been polluted: after deleting the Build directory and rebuilding I can now boot to the UEFI Shell.

bcran avatar Jan 22 '23 12:01 bcran

That is great to hear this. I am almost out of the RISC-V world and we need someone to keep maintaining SiFive platforms. It would be better if we can get someone form SiFive on board.

changab avatar Jan 27 '23 03:01 changab