feat(ethernet/ptp): added support for gPTP (IDFGH-14203)#15001
feat(ethernet/ptp): added support for gPTP (IDFGH-14203)#15001scrambletools wants to merge 0 commit intoespressif:masterfrom
Conversation
|
|
π Hello scrambletools, we appreciate your contribution to this project! π Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. ποΈ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
|
Next commit will handle receiving peer delay response and response follow up messages for gPTP case. Currently only supports processing gPTP peer delay requests and sending correct response and response follow up. |
|
Hi @scrambletools, thanks for the update! The current PTP implementation really misses the P2P mode. So it's great you've had a look into it. However, our PTP is currently not fully stable so I cannot give you any time frame when your PR could be merged. I need to stabilize the API at first. Luckily it doesn't mean you to stop your effort! Please try to update |
|
I'll take a look, thanks!
β¦On Mon, Dec 9, 2024 at 12:34β―AM Ondrej Kosta ***@***.***> wrote:
Hi @scrambletools <https://github.com/scrambletools>, thanks for the
update! The current PTP implementation really misses the P2P mode. So it's
great you've had a look into it. However, our PTP is currently not fully
stable so I cannot give you any time frame when your PR could be merged. I
need to stabilize the API at first.
Luckily it doesn't mean you to stop your effort! Please try to update
emac_hal_ptp_start function, add emac_ll_ts_ptp_snap_type_sel(hal->ptp_regs,
1); and you should be able to receive Pdelay messages via IREC. Please
let me know if it worked.
β
Reply to this email directly, view it on GitHub
<#15001 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BGW4UN5YFGROOWWLY2TE5C32EVIYZAVCNFSM6AAAAABTHZ7CPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMRXGI3DEMRUGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
It seems to have worked! Thanks. I'll keep testing... |
|
How is the status on merging this PR?
β¦On Mon, Dec 9, 2024 at 2:33β―AM John Gildred ***@***.***> wrote:
I'll take a look, thanks!
On Mon, Dec 9, 2024 at 12:34β―AM Ondrej Kosta ***@***.***>
wrote:
> Hi @scrambletools <https://github.com/scrambletools>, thanks for the
> update! The current PTP implementation really misses the P2P mode. So it's
> great you've had a look into it. However, our PTP is currently not fully
> stable so I cannot give you any time frame when your PR could be merged. I
> need to stabilize the API at first.
>
> Luckily it doesn't mean you to stop your effort! Please try to update
> emac_hal_ptp_start function, add emac_ll_ts_ptp_snap_type_sel(hal->ptp_regs,
> 1); and you should be able to receive Pdelay messages via IREC. Please
> let me know if it worked.
>
> β
> Reply to this email directly, view it on GitHub
> <#15001 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/BGW4UN5YFGROOWWLY2TE5C32EVIYZAVCNFSM6AAAAABTHZ7CPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMRXGI3DEMRUGY>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
|
@scrambletools, I'm very sorry for the delay but I'm busy with other tasks and the PR will require deeper look... |
|
Checking in on this PR. |
|
what is the next step? |
|
@kostaond are you waiting for me to do anything? |
|
Hi @scrambletools, I see it must be super frustrating for you and I'm sorry for that. However, I'm currently still busy with other tasks... I would like to get into it in one or two months. Thank you for your patience. |
|
@kostaond thanks for letting me know. I tried to keep a light touch on the changes, so hopefully once you take a look it won't be too much work to review. |
|
@kostaond is there anything I can do to make this PR easier for you to look at? |
|
@scrambletools, it's on my plate. Once I finish some Ethernet test related task, I'll start working on PTP updates which also includes your PR. This should happen in 2 or 3 weeks. For now, please just rebase and resolve conflicts if there are any. I added a support of PPS (supported by ESP32P4 rev 3) prior Christmas. |
|
That's great to hear! I rebased and working on bug right now. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 4 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| static inline void ring_buffer_advance_head(esp_apptrace_uart_rb_t *rb, uint32_t count) | ||
| { | ||
| rb->head = (rb->head + count) & ring_buffer_mask(rb); | ||
| rb->count += count; |
There was a problem hiding this comment.
UART ring buffer counter races ISR
Medium Severity
rb->count is modified in both producer and ISR paths via ring_buffer_advance_head() and ring_buffer_advance_tail() without shared synchronization. put_up_buffer() uses a lock, but the ISR does not, so concurrent updates can lose increments/decrements and corrupt ring-buffer state, causing dropped or stalled app_trace UART data.
Additional Locations (2)
| static void IRAM_ATTR esp_apptrace_uart_isr_handler(void *arg) | ||
| { | ||
| esp_apptrace_uart_data_t *uart_data = arg; | ||
| esp_apptrace_tmo_t tmo; |
There was a problem hiding this comment.
Oversized UART message corrupts ring accounting
Medium Severity
ring_buffer_put() assumes len <= tx_ring.max_size, but up_buffer_get() only validates against tx_msg_buff_size. If CONFIG_APPTRACE_UART_TX_MSG_SIZE exceeds CONFIG_APPTRACE_UART_TX_BUFF_SIZE, need can be larger than rb->count, so rb->count -= need underflows and breaks ring-buffer state.
Additional Locations (1)
| } | ||
| if (GPIO_IS_VALID_GPIO(uart_config->rx_pin_num)) { | ||
| gpio_mask |= BIT64(uart_config->rx_pin_num); | ||
| } |
There was a problem hiding this comment.
Invalid UART pins are not rejected
Medium Severity
esp_apptrace_uart_init() only checks whether at least one GPIO is valid via gpio_mask, but it never validates tx_pin_num and rx_pin_num individually before configuring both pins. If one configured pin is invalid, the code still calls low-level GPIO/UART routing on it, which can cause initialization failure or undefined behavior.
Additional Locations (1)
| bool | ||
| default "y" if IDF_TARGET="esp32h4" | ||
| select IDF_TARGET_ARCH_RISCV | ||
|
|
There was a problem hiding this comment.
ESP32-H4 bringup flags unintentionally removed
Medium Severity
IDF_TARGET_ESP32H4 no longer selects IDF_ENV_BRINGUP and conditional IDF_ENV_FPGA, while the new esp32s31 target now selects them. This changes esp32h4 environment classification and can enable unsupported paths or disable bringup-specific behavior for H4 builds.
|
My pull request is messed up. Apologies for the huge update, perhaps I should remove this pr and resubmit? |
4519981 to
ffb63db
Compare
|
@kostaond I had to reset my fork as the rebase went very wrong. I will resubmit the pr soon 1-2 commits. |


This includes handling peer delay messages and TLVs in announce and follow up messages. Also, handles simpler BMCA in gPTP case. Currently it seems the HW timestamp is not showing in the IREC in the case of received frames, so that made it difficult to test interop with other gPTP devices.
Tested with MOTU AVB Switch as well as Apple Mac desktop. Hoping to see a fix for the HW timestamp issue, assuming I'm not missing something.
Note
High Risk
Touches CI orchestration and low-level tracing/UART transport code, so failures could break pipelines or tracing reliability across targets. The UART driver rewrite and config migrations are especially sensitive to timing/interrupt behavior and backward-compatibility.
Overview
CI/CD overhaul: Simplifies
.gitlab-ci.ymlincludes, restructures build/host-test/deploy pipelines (new metrics + JUnit aggregation jobs, new label-drivenbuildv2test runs, new macOS brew runner template), and broadens artifact patterns (notablysize*.json, recursiveXUNIT_RESULT_*.xml/pipeline.env). Several host tests switch topytest_for_ut, rules/patterns are reorganized, and a manualretry_failed_jobsis moved intopre_check.Target/config updates: Adds bringup target
esp32s31across CI/docs (Kconfig,.idf_build_apps.toml, docs build matrix) and introduces new build options in top-levelKconfig(RISC-VZCMPenablement, Xtensa-mtext-section-literals, buildv2 menus for excluded components). Top-levelCMakeLists.txtchanges GCC RTTI flag handling to use toolchain flag helpers and rerun ABI detection.Tracing refactor: Migrates
components/app_tracefromCONFIG_APPTRACE_ENABLEtoCONFIG_ESP_TRACE_TRANSPORT_APPTRACE, splits config intoKconfig.apptrace, removes in-component SystemView/heap-to-host pieces, and makesesp_apptrace_init()a public API while gating early init whenesp_tracelibraries are active. The UART transport (port_uart.c) is rewritten around UART HAL + ISR-driven TX with a power-of-two ring buffer (dropping RX ring/task-priority config fields), and host file I/O adds UART framing (STX/LEN/CMD/ARGS/ETX) plus finite read timeouts.Docs/metadata: Updates compatibility docs (EN/CN) and README chip-support section, adjusts issue template wording for
esptool.pyon older IDF, expands CODEOWNERS coverage, and marks multiple submodules asshallowin.gitmodules.Written by Cursor Bugbot for commit 4519981. This will update automatically on new commits. Configure here.