-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cpu/fe310: several cleanup in implementation #12934
Conversation
I had many problems with the onboard jlink until I upgraded JLink to the latest version (v6.56b). That in turn updated the onboard JLink firmware. Since then flashing is super reliable. Maybe that helps? |
@kenrabold this might be interesting to you |
It helps a lot. Thanks! |
04e60c9
to
d05f142
Compare
Overall I really like the changes. Much cleaner and I like the option for various clock selections. I had a couple questions about the SPI flash config, but overall looks good to me. I will try out the PR on both of the HiFive1 and HiFive1b boards that I have. |
Note that I only tested with hifive1b and it's working well without the code related to quad spi. It's still unclear to me why this quad SPI mode was needed. Can you point to some documentation @kenrabold ? |
e0c371c
to
0fb3cda
Compare
There are two reasons for wanting QuadIO mode:
|
c56c2bd
to
b906fd1
Compare
@kenrabold, I restored the flash initialization function but it's still unclear to me what is the related between the CPU frequency, the SPI clock divider and the maximum flash frequency. In the current state of this PR, the default CPU clock is 48MHz. When using the HFROSC, it's about 36MHz and when using the HFXOSC without PLL, 16MHz. I'll compare with the core frequency configured in master. |
Why are you running the CPU at such a slow speed? I have the HiFive1b clocked at 320Mhz and the older HiFive1 at 200Mhz. At 48Mz for the core clock, the SPI clk will 48/8 = 6MHz with the default sckdiv setting. |
@kenrabold, I update the PLL settings so now the core clock runs at 192MHz. It will be difficult to do better with the HFXOSC. In master, I noticed that the CPU is running at ~300MHz but it uses HFROSC, with PLL, which is what this PR is not doing in fact... But the main problem in master is the call to |
I pushed some commits that makes it possible to configure the boards so that they can operate at 300MHz using HFROSC with PLL: only in this case the SPI flash needs a special handling. I need to do more testing (especially with #12946, #12957 and #12953). In the current state of this PR, all 4 clocks modes are usable: HFXOSC, HFXOSC with PLL, HFROSC and HFROSC with PLL. With the latter, one can reach ~320MHz clock but it takes more ROM space and it adds a 2s delay at boot. |
Finally I was able to reach a precise 320MHz core clock with HFXOSC. So now the default is 320MHz :) |
Looks good. I haven't been able to try your changes because it looks like Windows based builds are broken because of this change #12773 which spits out a generates\autoconf.h file that has this garbage in it: C:/MinGW/msys/1.0/* RIOT Configuration File */ And causes the build to fail. If I can figure out the issue, I'll try your updates. |
Thanks, that would be great. I don't have a hifive1 so I'm not sure it will work at 320MHz. |
@leandrolanzieri do you have any idea of what can be happening in windows, did you try it at some point? |
bd72892
to
f9463e8
Compare
Maybe I should squash @fjmolinas ? It will simplify the review I think. |
43bb0ea
to
b601e7f
Compare
There is something I do not understand, @aabadie tested with
maybe @kaspar030? |
@aabadie re-ran tests:
Let me know if you want the whole results, I can push to a repo. |
@aabadie I would go with this PR as is, |
That would help. Locally, I don't have problems with cpp tests. |
here: https://github.com/fjmolinas/ci-results/tree/master/results/hifive1b |
I've looked into the test failures:
|
@fjmolinas, are you ok to squash this one ? |
Ran both tests again without issues. |
Yes, please to both :)
I would keep the new clock speed and raise the issue, this would be our board with the fastest clock speed, it might be an issue that doesn't show at lower speeds. |
Interestingly when running multiple times it fails, suceeds on first run. |
b0873ca
to
75e9799
Compare
This macro is now defined in periph_cpu.h
75e9799
to
a953b74
Compare
@fjmolinas, rebased and squashed. I also opened #13086 for tracking the known issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, I've tested with hifive1b
but not with hifive1
, but since this board doesn't seem available for purchase (at least broadly), I think it is OK.
Contribution description
This PR tries to improve the RISCV FE310 cpu implementation:
Now most of the tests run fine on the board but the on-board flasher is not very reliable so it cannot be really automatized.
The clock initialization only supports PLL and PLL bypass. Other clock source could be configured but I haven't looked at it. I have to say that I'm not 100% sure of the approach here, especially with low-power. Any help here would be appreciated.
I know the PR is quite large and will be difficult to test and review.
Follow-up work still needed:
This PR is only tested on hifive1b.
Testing procedure
Use
compile_and_test_for_board.py
on hifive1b: most of the test should pass. But sometimes they break because the flasher fail. Using an external JLink adapter could help for more reliable results. Some tests are failing but are not related to this PR (tests/ps_schedstatistics
, because the xtimer low-level timer is clocked at 32768Hz)Issues/PRs references
This PR is based on #12917