riscv_common: Refactor common fe310 code to riscv_common#15718
riscv_common: Refactor common fe310 code to riscv_common#15718aabadie merged 2 commits intoRIOT-OS:masterfrom
Conversation
2248a49 to
a9eae0e
Compare
5c8a422 to
b045327
Compare
benpicco
left a comment
There was a problem hiding this comment.
looks good to me, but I don't have any hardware to test this.
| void riscv_fpu_init(void); | ||
|
|
||
| /** | ||
| * @brief Initialization of the interrupt controller | ||
| */ | ||
| void riscv_irq_init(void); |
There was a problem hiding this comment.
Doesn't have to be, but I'm going to leave that cleanup to a possible follow up :)
|
There are still a few places where the riscv_common code uses code from the fe310. Slapping on a WIP label to prevent accidental merges while this is still the case. |
cpu/riscv_common/ldscripts/riscv.ld
Outdated
| * | ||
| * @file | ||
| * @brief Memory definitions for the SiFive FE310 | ||
| * @brief Memory definitions for for the RISC-V CPU |
There was a problem hiding this comment.
| * @brief Memory definitions for for the RISC-V CPU | |
| * @brief Memory definitions for the RISC-V CPU |
|
TODO:
|
|
Without the following patch, the build is broken for application requiring irq/timer: index c66b62719e..2582e92261 100644
--- a/cpu/riscv_common/Makefile.dep
+++ b/cpu/riscv_common/Makefile.dep
@@ -4,6 +4,8 @@ USEMODULE += riscv_common
# include common periph code
USEMODULE += riscv_periph_common
+FEATURES_REQUIRED += periph_coretimer periph_plic
+
USEMODULE += periph_pm
# Make calls to malloc and friends thread-safe
diff --git a/cpu/riscv_common/Makefile.features b/cpu/riscv_common/Makefile.features
index 6880670a79..f0eca40db5 100644
--- a/cpu/riscv_common/Makefile.features
+++ b/cpu/riscv_common/Makefile.features
@@ -6,6 +6,7 @@ FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_plic
FEATURES_PROVIDED += periph_pm
FEATURES_PROVIDED += ssp
+FEATURES_PROVIDED += periph_coretimer periph_plic
# RISC-V toolchain on CI does not work properly with picolibc yet
ifeq (,$(RIOT_CI_BUILD))I'm not sure that declaring the coretimer/plic as peripherals is the way to go. You could simply add them to the riscv_common module. But maybe I'm missing something here ? |
|
Is this still wip @bergzand ? |
Unfortunately |
515c5c0 to
f9c960d
Compare
Me neither. The issue is that the PLIC is one of the possible implementations for interrupt controllers on the RISC-V. There is also the CLIC. A CPU could use the CLINT timer for periph_timer, but it could also use a different (more advanced) timer peripheral |
|
@fjmolinas No longer WIP! |
|
Please squash, I'd like to know what Murdock has to say with this PR :) |
61ae50a to
f7b149c
Compare
|
This needs a rebase now. |
f7b149c to
43a894d
Compare
43a894d to
423268b
Compare
|
Rebased! |
|
This one needs a rebase again @bergzand |
6c65c5b to
6414885
Compare
|
Rebased! |
aabadie
left a comment
There was a problem hiding this comment.
Still needs some work. With the following diff, things should be better:
diff --git a/cpu/fe310/Makefile b/cpu/fe310/Makefile
index 0dbf0f1807..fd024edf0e 100644
--- a/cpu/fe310/Makefile
+++ b/cpu/fe310/Makefile
@@ -2,6 +2,6 @@
MODULE = cpu
# add a list of subdirectories, that should also be built
-DIRS += $(RIOTCPU)/riscv_common periph vendor
+DIRS = $(RIOTCPU)/riscv_common periph vendor
-include $(RIOTCPU)/riscv_common/Makefile
+include $(RIOTBASE)/Makefile.base
diff --git a/cpu/fe310/Makefile.features b/cpu/fe310/Makefile.features
index 5715137124..66120f1516 100644
--- a/cpu/fe310/Makefile.features
+++ b/cpu/fe310/Makefile.features
:...skipping...
diff --git a/cpu/fe310/Makefile b/cpu/fe310/Makefile
index 0dbf0f1807..fd024edf0e 100644
--- a/cpu/fe310/Makefile
+++ b/cpu/fe310/Makefile
@@ -2,6 +2,6 @@
MODULE = cpu
# add a list of subdirectories, that should also be built
-DIRS += $(RIOTCPU)/riscv_common periph vendor
+DIRS = $(RIOTCPU)/riscv_common periph vendor
-include $(RIOTCPU)/riscv_common/Makefile
+include $(RIOTBASE)/Makefile.base
diff --git a/cpu/fe310/Makefile.features b/cpu/fe310/Makefile.features
index 5715137124..66120f1516 100644
--- a/cpu/fe310/Makefile.features
+++ b/cpu/fe310/Makefile.features
@@ -4,5 +4,6 @@ FEATURES_PROVIDED += cpp
FEATURES_PROVIDED += libstdcpp
FEATURES_PROVIDED += newlib
FEATURES_PROVIDED += periph_cpuid
+FEATURES_PROVIDED += periph_gpio periph_gpio_irq
include $(RIOTCPU)/riscv_common/Makefile.features
diff --git a/cpu/fe310/cpu.c b/cpu/fe310/cpu.c
index a244c1f49b..a10ea94dd6 100644
--- a/cpu/fe310/cpu.c
+++ b/cpu/fe310/cpu.c
@@ -18,7 +18,6 @@
*/
#include "cpu.h"
-#include "nanostubs.h"
#include "periph/init.h"
#include "periph_conf.h"
diff --git a/cpu/riscv_common/Makefile b/cpu/riscv_common/Makefile
index 880129078d..e09377cd1e 100644
--- a/cpu/riscv_common/Makefile
+++ b/cpu/riscv_common/Makefile
@@ -1,3 +1,3 @@
-DIRS += periph
+DIRS = periph
include $(RIOTBASE)/Makefile.base
diff --git a/cpu/riscv_common/Makefile.dep b/cpu/riscv_common/Makefile.dep
index 4c9bbe5ef7..70aa523b8c 100644
--- a/cpu/riscv_common/Makefile.dep
+++ b/cpu/riscv_common/Makefile.dep
@@ -2,7 +2,7 @@
USEMODULE += riscv_common
# include common periph code
-USEMODULE += riscv_periph_common
+USEMODULE += riscv_common_periph
# Make calls to malloc and friends thread-safe
USEMODULE += malloc_thread_safe
diff --git a/cpu/riscv_common/periph/Makefile b/cpu/riscv_common/periph/Makefile
index b83a4e8257..db019f82ea 100644
--- a/cpu/riscv_common/periph/Makefile
+++ b/cpu/riscv_common/periph/Makefile
@@ -1,2 +1,2 @@
-MODULE = riscv_periph_common
+MODULE = riscv_common_periph
include $(RIOTMAKE)/periph.mk|
@aabadie Murdock is all green, do you mind if I squash here again? |
No problem, go ahead! |
55a4760 to
19bb182
Compare
|
Squashed! |
|
I ran compile_and_test_for_board on this PR and there are a lot of tests failing. Some are unrelated to this PR and are a regression compared to 2020.10. Example with tests/thread_flags: |
|
Here is the output of compile_and_test_for_board run on hifive1b with this PR: As said above, some of the failing tests are unrelated to this PR and some are a regression introduced by #15736 (unfortunately in the latest release), so I compared them against master (just re-ran the failing tests with the master branch): As a reference, here are results compared to 2021.01-devel: So #15736 introduced a regression for |
|
So all failures are unrelated to this PR? |
aabadie
left a comment
There was a problem hiding this comment.
Compared to master, there's no regression introduced by this PR. I added a #13086 (comment) in #13086 regarding the regression I found in master, so we don't loose track of them.
Anyway, let's not block this PR because of them.
I'm fine with the changes here, they all look good.
ACK
|
Thanks for the review! I'll try to pick up the regression asap |
Contribution description
This PR refactors the lone fe310 RISC-V cpu into a separate riscv_common director keeping the fe310-specifics in their own directory. This makes it easier to add new RISC-V based processors in the future.
My original idea was to refactor into a rv32i_common directory, but I decided that riscv_common should be enough. Changes between rv64i and rv32i are minimal and mostly in the architecture size and doesn't warrant separate directories for the two (for now). It is however possible that some doxygen or variable names are still
rv32i_, these should all be renamed toriscv_Testing procedure
Changes to the binaries should be minimal or nonexistent.
Compilation from Murdock, together with a few applications tested on the hifive1b should be enough for code tests.
Please also verify that the documentation and the generated doxygen makes sense after the split.
Issues/PRs references
None