Skip to content
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

do not assume DTM version unless dtmcontrol is read successfully #929

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

aap-sc
Copy link
Collaborator

@aap-sc aap-sc commented Sep 28, 2023

Change-Id: I02906dbbe04778623a51774bc21fa45b55d12881

@aap-sc
Copy link
Collaborator Author

aap-sc commented Sep 28, 2023

@timsifive I know that changes to riscv-0.11 are discouraged, however in this case I believe it's better to add this fix. There were a couple of serious bugs:

  1. dtmcontrol_scan could return an error code as a scanned value.
  2. in case when dtmcontrol was read as "0" we had an implicit fallback to v0.11 that caused register cache to be populated. This could result in a weird situations like:
XLEN=64, misa=0x14112f

Copy link
Collaborator

@timsifive timsifive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you test the riscv-011 changes?

src/target/riscv/riscv-011.c Outdated Show resolved Hide resolved
src/target/riscv/riscv.c Outdated Show resolved Hide resolved
LOG_TARGET_DEBUG(target, "dtmcontrol=0x%x", dtmcontrol);
// FIXME: if examine fails we may need to restore the original dtm_version
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Can you add that change? Shouldn't be much more complicated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will try... though I'm not sure that we need to fix it in this patch. examine has it's share of issues:

for example, it halts the target, but if something goes wrong - the target is not resumed. The fix for such situations may be complicated. But having said that - I'll try to address at least dtm_version stuff

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed..

Apparently my whining about examine implementation is not relevant to riscv.c

@aap-sc
Copy link
Collaborator Author

aap-sc commented Oct 2, 2023

How did you test the riscv-011 changes?

Regarding this...

  • I haven't tested on v0.11 since I don't have such HW, unfortunately. As far as v0.11 goes I've only tried to make sure that the change is reasonable by visually inspecting the code.
  • In case of v0.13 there was extensive testing: the whole riscv_tests and additional tests on fpga

@TommyMurphyTM1234
Copy link
Collaborator

How did you test the riscv-011 changes?

Regarding this...

  • I haven't tested on v0.11 since I don't have such HW, unfortunately. As far as v0.11 goes I've only tried to make sure that the change is reasonable by visually inspecting the code.

If it helps, I can run the tests against a HiFive1 (Rev A I think) in the next couple of days?

@aap-sc
Copy link
Collaborator Author

aap-sc commented Oct 2, 2023

If it helps, I can run the tests against a HiFive1 (Rev A I think) in the next couple of days?

Oh, it would be great! If you have the bandwidth - please, do. Though I'll need to address few comments by @timsifive

@TommyMurphyTM1234
Copy link
Collaborator

If it helps, I can run the tests against a HiFive1 (Rev A I think) in the next couple of days?

Oh, it would be great! If you have the bandwidth - please, do. Though I'll need to address few comments by @timsifive

I take it that this PR still needs some changes before it makes sense for me to test against the HiFive1?
(Just to confirm - my HiFive1 is indeed Rev A01 but I presume that that's OK?).

@aap-sc
Copy link
Collaborator Author

aap-sc commented Oct 4, 2023

I take it that this PR still needs some changes before it makes sense for me to test against the HiFive1?

I've already addressed all concerns raised by @timsifive . Maybe we should wait for Tim to confirm that this is good enough.

Copy link
Collaborator

@JanMatCodasip JanMatCodasip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this fix/improvement and the increased level of robustness it brings.

I have only few minor comments, otherwise it looks fine.

src/target/riscv/riscv-013.c Outdated Show resolved Hide resolved
src/target/riscv/riscv.c Outdated Show resolved Hide resolved
src/target/riscv/riscv.c Outdated Show resolved Hide resolved
src/target/riscv/riscv.c Outdated Show resolved Hide resolved
src/target/riscv/riscv.c Show resolved Hide resolved
Change-Id: I5f2003b7ac5ce87af6ca9a4fcb46140682a8cfdf
Signed-off-by: Parshintsev Anatoly <[email protected]>
Copy link
Collaborator

@JanMatCodasip JanMatCodasip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me.

When testing on HiFive01 Rev A01 with known fails skipped:

  • On HiFive1.py target, the testing passed without any issues.
  • On HiFive1-flash.py, there were 8 exceptions, occurring both with and without this change. I haven't investigated these further.
:::::::::::::::::::::::::::[ ran 72 tests in 465s ]:::::::::::::::::::::::::::
28 tests returned not_applicable
36 tests returned pass
8 tests returned exception
   DebugBreakpoint > logs/20231009-082756-HiFive1Flash-DebugBreakpoint.log
   DebugExit > logs/20231009-082844-HiFive1Flash-DebugExit.log
   DebugFunctionCall > logs/20231009-082926-HiFive1Flash-DebugFunctionCall.log
   Hwbp1 > logs/20231009-083025-HiFive1Flash-Hwbp1.log
   Hwbp2 > logs/20231009-083108-HiFive1Flash-Hwbp2.log
   Registers > logs/20231009-083240-HiFive1Flash-Registers.log
   TooManyHwbp > logs/20231009-083342-HiFive1Flash-TooManyHwbp.log
   UserInterrupt > logs/20231009-083442-HiFive1Flash-UserInterrupt.log

@TommyMurphyTM1234
Copy link
Collaborator

The changes look good to me.

When testing on HiFive01 Rev A01 with known fails skipped:

  • On HiFive1.py target, the testing passed without any issues.
  • On HiFive1-flash.py, there were 8 exceptions, occurring both with and without this change. I haven't investigated these further.

If it's of any use, I plan to look at this imminently and could also look at those additional (?) exceptions?

@JanMatCodasip
Copy link
Collaborator

If it's of any use, I plan to look at this imminently and could also look at those additional (?) exceptions?

Any help with the failing tests is appreciated :)

@aap-sc
Copy link
Collaborator Author

aap-sc commented Oct 13, 2023

Hi @timsifive , just wanted to double-check if there are any additional changes/fixes required for this PR?

@timsifive timsifive merged commit e1fa78d into riscv-collab:riscv Oct 16, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants