-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Add esp32p4 support #17951
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 esp32p4 support #17951
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #17951 +/- ##
=======================================
Coverage 98.38% 98.38%
=======================================
Files 171 171
Lines 22301 22301
=======================================
Hits 21940 21940
Misses 361 361 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Code size report: |
893f366 to
7cbf26b
Compare
projectgus
left a comment
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.
Thanks @Vincent1-python for working further on this support, I see it's mostly passing CI so I've given it a quick look. The support is impressive, but it still needs significant work before we can consider merging it.
The major tasks, as I understand after a quick review:
- Remove the TinyUSB HID feature from this PR, it's not related to ESP32-P4 support.
- Remove the FireBeetle board support and submit that in a second PR after this one, to keep this PR smaller and cleaner.
- Translate the Chinese comments and variable names.
After that the PR will be smaller, and can be reviewed again. Feel free to ping me once you've done these things.
One other note: Updating to use the newer ESP-IDF driver APIs is very welcome, thanks - however that's a big change by itself so will need a lot of testing on the existing ESP32 chips.
16abd0a to
9e959cf
Compare
12e8a4b to
220611b
Compare
|
Everything is completed except the forced download start reset. @projectgus |
2fca896 to
5e90c95
Compare
|
But now there is a problem, that is, if I plug in the usb of CDC and the default JTAG at the same time, JTAG will not be able to load the storage space, and it is bound to CDC. |
|
@projectgus Please review again. |
|
I wanted to touch base on the I2C stuff. The reason why I am suggesting a separate PR for it is if it will work with the P4 the way it is done currently it is easier to revert the I2C changes if they are made in their own PR should there be an issue with it. When I went looking at the code in the ESP-IDF I didn't see any block put into place that stop the old style of I2C from working with the P4. It does need to be updated without a doubt but a separate PR would be the better if it is not needed to make the P4 work. |
|
@Vincent1-python Please check that review comments are actually resolved before pressing "Resolve conversation". If you're not sure, then it's better to leave it unresolved! |
|
@projectgus I soon found that if I delete the LDO driven by SD card, there will be many development boards that can't use SD card. I think I should add it back, which is not unique to my development board. |
|
There's a difference between fence (CPU internal state) and cache flush (RAM state), at least on ARM Cortex. Maybe there's an IDF function to flush/invalidate RAM cache? |
|
I didn't find anything obvious in ESP-IDF, if not mentions to plain "fence" instances in a few isolated places. However, on RISC-V fence covers memory too:
(hart == CPU core in RISC-V speak) Something else to try could be the "FENCE / FENCE RW, RW / FENCE.I" sequence. "FENCE RW, RW" explicitly forces memory flushing if the default fencing model implementation is configured to only cover device i/o or other stuff, whilst "FENCE.I" forces a further flush on the next instruction fetch if the default fencing model implementation doesn't cover the instruction cache. If you don't feel like looking into this any further, feel free to disable the emitter for now - I'll place an order for an ESP32P4 board in that case. |
|
Just 2c, there is an |
Ah, excellent! Thanks for the hint @igrr . I added a call to I pushed a commit for that change to this PR. |
869167c to
e113696
Compare
|
(Rebased and force pushed.) |
TinyUSB defines TUD_OPT_RHPORT which is the same thing, make shorter definition RHPORT in the two files which use it. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
(and a smaller binary size as a result) Signed-off-by: Angus Gratton <angus@redyak.com.au>
e113696 to
1e089e9
Compare
This commit adds support for ESP32-P4 SoCs. Signed-off-by: Vincent1-python <pywei201209@163.com> Signed-off-by: Angus Gratton <angus@redyak.com.au> Signed-off-by: Damien George <damien@micropython.org>
Includes a base variant with LAN, and C5_WIFI and C6_WIFI variants with LAN, WiFi and BLE. And builds this board in the esp32 CI, to cover the P4 support. Signed-off-by: Vincent1-python <pywei201209@163.com> Signed-off-by: Angus Gratton <angus@redyak.com.au> Signed-off-by: Damien George <damien@micropython.org>
This was necessary to un-wedge the USJ TX path on ESP32-P4, I think because the bootloader prints a lot on this chip. I think it might be possible to hit it on other chips, though. The implementation is based on the ESP-IDF driver, which will always add an extra flush when the TXFIFO is empty in case the host is expecting a ZLP. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Eventually this cache flushing mechanism should be generalised to work the same way for all architectures. But for now, this allows ESP32 RV32 SoCs to flush the D-cache whenn needed. Signed-off-by: Damien George <damien@micropython.org>
This is necessary to get native code running on the ESP32-P4. Signed-off-by: Damien George <damien@micropython.org>
1e089e9 to
bdf7613
Compare
|
Now merged! I suspect there may be some teething issues with this new chip, let's see how it goes now that everyone can start using it with MicroPython. |
|
I'm getting this Possibly something I am doing wrong though as the build step shows and I used force. |
|
@exussum12 it looks like you have an early revision P4. You'll probably need to change the ESP32P4_REV_MIN option to ESP32P4_REV_MIN_0 (it defaults to ESP32P4_REV_MIN_1). Or, get newer hardware. |
|
Does --force not do basically that? The hardware only arrived this week - from https://www.amazon.co.uk/Waveshare-ESP32-P4-ETH-High-Performance-Development-Pre-Solder/dp/B0FMJD25QP Ill have a look at re-flashing now though |
|
To update here, Working fine since changing that. Thanks! |
|
I noticed that the MicroPython download page has added P4-related content, but the images are displaying abnormally. Could you please check these image links? micropython/ports/esp32/boards/ESP32_GENERIC_P4/board.json Lines 13 to 15 in e6a7dc1
https://micropython.org/download/?vendor=Espressif
|
|
@igrr Thanks for the tip about the new cache functions! May I ask a follow-up about this:
Is it reasonable for us to follow the ESP-IDF default of |
|
Hi @projectgus! Unfortunately I can't tell exactly how many development boards have been made and sold with P4 rev.0. There has certainly been a number of Waveshare boards as well as Espressif's "Function EV board"s made with rev.0. For IDF, setting the default to rev. 1 is a reasonable choice, since users can always switch it back to rev. 0 in menuconfig. However for Micropython it might make sense to support rev. 0 as well in the same binary. I don't know of any downside of selecting ESP32P4_REV_MIN_0, other than the slightly increased code size. I also want to give a heads-up that P4 revision 3.0 is not backward-compatible, meaning that it won't be possible to build a binary with support for both rev<3.0 and >=3.0. Therefore I would recommend introducing variants of binaries for rev<3 and >=3, and eventually removing rev<3 binaries when most of the boards on the market are rev>=3. The detailed information on distinguishing P4 chip revisions should appear in https://github.com/espressif/esp-chip-errata soon. |
|
@eMUQI the downloads page has now been updated, the images are all there, and the P4 now has the C5 and C6 variants. |
|
Thanks @igrr for the details about the revisions. It sounds like we should support rev 0.0, so I've opened a PR for that at #18512. My testing shows that it makes pretty much no difference to the firmware when supporting rev 0.0, which is good!
OK, thanks for the heads up! When rev 3.0 is out we will probably make that the default variant, and then a separate variant for rev<3. |

Summary
Add esp32p4 support.
Testing
All completed after #17356, except for DAC not supported by hardware.
Trade-offs and Alternatives