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

Add ESP32-P4 support #2064

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add ESP32-P4 support #2064

wants to merge 3 commits into from

Conversation

orsolic
Copy link

@orsolic orsolic commented Jan 28, 2025

Continuation of mistakenly closed #2063

Here is commit with start of support for ESP32-P4.

I have started working on flashing support but I need to shelve that plan for the time being.
I am pushing the things which seems to work - patch is rough, but more will hopefully come later.

Tested with BMA and ESP-prog (FT2232H) on FreeBSD with Waveshare ESP32-P4 board with flashed IDF example.

Works:

  • JTAG scan
  • attach to target
  • run program
  • reset
  • hardware breakpoint
  • continue
  • printing of var in SRAM
>>> p var
$4 = 123
>>> p &var
$5 = (uint32_t *) 0x4ff26334
>>> x /d 0x4ff26334
0x4ff26334:     123
  • changing value of var:
>>> set var var = 100
>>> p var
$8 = 100
>>> x /d 0x4ff26334
0x4ff26334:     100

What doesn't work:

  • software breakpoint (needs flash support)
  • stepping
  • single instruction stepping

Tested on BMA, after jtag_scan:
ID code 0x00012c25: ESP32-P4
ID code 0x00012c25: ESP32-P4
RISC-V debug v0.13/v1.0 DMI
RISC-V debug v0.13 DM
Skipping hart 0 -> Unavailable
RISC-V debug v0.13/v1.0 DMI
According to the RISC-V debug specification, DM must be turned on before
accessing DM registers (like reading version of DM).
This fixes attaching to the target.
Copy link
Member

@dragonmux dragonmux left a comment

Choose a reason for hiding this comment

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

This is looking much better 🙂. We've left a review reply on #2063 for one of the notes but have otherwise done a fresh review here. We are satisfied with the items you've addressed and mostly the items here are for subtle bugs we spotted.

We look forward to this being sorted so we can schedule its merge into v2.1 when the merge window opens for that.

@@ -304,6 +304,30 @@ void riscv_dmi_init(riscv_dmi_s *const dmi)
do {
/* Read out the DM's status register */
uint32_t dm_status = 0;
Copy link
Member

Choose a reason for hiding this comment

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

This one still needs moving down to line 330 please 🙂

DEBUG_ERROR("error turning on DM!\n");
return;
}
dm_active = dm_control & 1;
Copy link
Member

Choose a reason for hiding this comment

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

Please suffix this constant with U - this does a signed-unsigned conversion that can trigger UB otherwise during application of the mask operation (changing the sign bit on a signed number is not permitted for bitwise operations).

return;
}
dm_active = dm_control & 1;
uint8_t counter = 0;
Copy link
Member

Choose a reason for hiding this comment

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

We would expect to see this defined just outside the while loop on line 317 - otherwise it won't have the intended effect.

Please suffix the initialiser and the comparison value with U to make them both unsigned.

@dragonmux dragonmux added this to the v2.1 release milestone Jan 29, 2025
@dragonmux dragonmux added the New Target New debug target label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Target New debug target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants