Skip to content

feat(ethernet/ptp): added support for gPTP (IDFGH-14203)#15001

Closed
scrambletools wants to merge 0 commit intoespressif:masterfrom
scrambletools:master
Closed

feat(ethernet/ptp): added support for gPTP (IDFGH-14203)#15001
scrambletools wants to merge 0 commit intoespressif:masterfrom
scrambletools:master

Conversation

@scrambletools
Copy link

@scrambletools scrambletools commented Dec 9, 2024

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.yml includes, restructures build/host-test/deploy pipelines (new metrics + JUnit aggregation jobs, new label-driven buildv2 test runs, new macOS brew runner template), and broadens artifact patterns (notably size*.json, recursive XUNIT_RESULT_*.xml/pipeline.env). Several host tests switch to pytest_for_ut, rules/patterns are reorganized, and a manual retry_failed_jobs is moved into pre_check.

Target/config updates: Adds bringup target esp32s31 across CI/docs (Kconfig, .idf_build_apps.toml, docs build matrix) and introduces new build options in top-level Kconfig (RISC-V ZCMP enablement, Xtensa -mtext-section-literals, buildv2 menus for excluded components). Top-level CMakeLists.txt changes GCC RTTI flag handling to use toolchain flag helpers and rerun ABI detection.

Tracing refactor: Migrates components/app_trace from CONFIG_APPTRACE_ENABLE to CONFIG_ESP_TRACE_TRANSPORT_APPTRACE, splits config into Kconfig.apptrace, removes in-component SystemView/heap-to-host pieces, and makes esp_apptrace_init() a public API while gating early init when esp_trace libraries 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.py on older IDF, expands CODEOWNERS coverage, and marks multiple submodules as shallow in .gitmodules.

Written by Cursor Bugbot for commit 4519981. This will update automatically on new commits. Configure here.

@CLAassistant
Copy link

CLAassistant commented Dec 9, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 24 committers have signed the CLA.

βœ… scrambletools
βœ… hfudev
❌ georgik
❌ adokitkat
❌ ESP-Marius
❌ suda-morris
❌ 0cici
❌ Lapshin
❌ Bruce297
❌ Astha-cpu
❌ esp-wzh
❌ KonstantinKondrashov
❌ wanckl
❌ jack0c
❌ Espressif-liuuuu
❌ tore-espressif
❌ Finney-esp
❌ QingzhaoYin
❌ Icarus113
❌ mythbuster5
❌ Kainarx
❌ April-Yjj
❌ ginkgm
❌ Ashish285
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link

github-actions bot commented Dec 9, 2024

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message " fix(esp_hw_support): adjust pvt prepare cost in sleep wakeup":
    • summary looks empty
    • type/action looks empty
  • the commit message "Update CN terms":
    • summary looks empty
    • type/action looks empty
  • the commit message "bugfix(periph): fix esp32s3 periph_ll_get_clk_en_reg interface":
    • type/action should be one of [change, ci, docs, feat, fix, refactor, remove, revert, test]
  • the commit message "change(esp_hw_support): update esp32 sleep parameters when disabling system sleep IRAM optimization":
    • summary appears to be too long
  • the commit message "change(esp_pm): fix ci failed test case of Automatic light occurs when tasks are suspended":
    • summary appears to be too long
  • the commit message "doc(compatibility): update the compatibility docs for C5 and C61":
    • type/action should be one of [change, ci, docs, feat, fix, refactor, remove, revert, test]
  • the commit message "doc: clarify NULL return value of esp_ota_get_last_invalid_partition":
    • type/action should be one of [change, ci, docs, feat, fix, refactor, remove, revert, test]
  • the commit message "feat(ethernet/ptp): sending peer delay req and processing respons/followup":
    • body's lines must not be longer than 100 characters
  • the commit message "feat(p4): added rev3_1 macro":
    • summary looks too short
  • the commit message "fix some issues found by Opus 4.5":
    • summary looks empty
    • type/action looks empty
  • the commit message "fix(ci) : Fix offchan tx and roc related unit test case":
    • summary looks empty
    • type/action looks empty
  • the commit message "fix(cmakev2/component_validation): accelerate component validation":
    • probably contains Jira ticket reference (3-4). Please remove Jira tickets from commit messages.
  • the commit message "fix(ethernet/ptp): Removed remaining debug statements.":
    • summary should not end with a period (full stop)
  • the commit message "fix(tee): fix failed to configure flash on C6 v0.1 and above when REV_MIN_0 configured":
    • summary appears to be too long
  • the commit message "fix(uhci): fixed rx buffer potential corruption issue due to cache coherence issue caused by autowriteback":
    • summary appears to be too long
  • the commit message "fix: remove reference to closed JIRA tracker IDF-10694":
    • probably contains Jira ticket reference (IDF-10694). Please remove Jira tickets from commit messages.

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 20 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

⚠️ Please consider squashing your 250 commits (simplifying branch history).
Messages
πŸ“– This PR seems to be quite large (total lines of code: 1100223), you might consider splitting it into smaller PRs

πŸ‘‹ 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 ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- Addressing info messages (πŸ“–) is strongly recommended; they're less critical but valuable.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests via this public GitHub repository.

This GitHub project is public mirror of our internal git repository

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved, we synchronize it into our internal git repository.
4. In the internal git repository we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
5. If the change is approved and passes the tests it is merged into the default branch.
5. On next sync from the internal git repository merged change will appear in this public GitHub repository.

Generated by 🚫 dangerJS against 4519981

@scrambletools scrambletools changed the title Added support for gPTP feat(ethernet/ptp): added support for gPTP Dec 9, 2024
@github-actions github-actions bot changed the title feat(ethernet/ptp): added support for gPTP feat(ethernet/ptp): added support for gPTP (IDFGH-14203) Dec 9, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Dec 9, 2024
@scrambletools
Copy link
Author

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.

@kostaond
Copy link
Collaborator

kostaond commented Dec 9, 2024

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 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 (MAC addr 01:80:C2:00:00:0E) via IREC. Please let me know if it worked.

@scrambletools
Copy link
Author

scrambletools commented Dec 9, 2024 via email

@scrambletools
Copy link
Author

It seems to have worked! Thanks. I'll keep testing...

@scrambletools
Copy link
Author

scrambletools commented Feb 19, 2025 via email

@kostaond
Copy link
Collaborator

@scrambletools, I'm very sorry for the delay but I'm busy with other tasks and the PR will require deeper look...

@scrambletools
Copy link
Author

Checking in on this PR.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@scrambletools
Copy link
Author

what is the next step?

@scrambletools
Copy link
Author

@kostaond are you waiting for me to do anything?

cursor[bot]

This comment was marked as outdated.

@kostaond
Copy link
Collaborator

kostaond commented Nov 4, 2025

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.

@scrambletools
Copy link
Author

@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.

@espressif-bot espressif-bot added Status: Selected for Development Issue is selected for development and removed Status: Opened Issue is new labels Jan 21, 2026
@scrambletools
Copy link
Author

@kostaond is there anything I can do to make this PR easier for you to look at?

@kostaond
Copy link
Collaborator

kostaond commented Feb 3, 2026

@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.

@scrambletools
Copy link
Author

That's great to hear! I rebased and working on bug right now.

@scrambletools scrambletools marked this pull request as draft February 14, 2026 11:18
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

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;
Copy link

Choose a reason for hiding this comment

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

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)

Fix in CursorΒ Fix in Web

static void IRAM_ATTR esp_apptrace_uart_isr_handler(void *arg)
{
esp_apptrace_uart_data_t *uart_data = arg;
esp_apptrace_tmo_t tmo;
Copy link

Choose a reason for hiding this comment

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

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)

Fix in CursorΒ Fix in Web

}
if (GPIO_IS_VALID_GPIO(uart_config->rx_pin_num)) {
gpio_mask |= BIT64(uart_config->rx_pin_num);
}
Copy link

Choose a reason for hiding this comment

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

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)

Fix in CursorΒ Fix in Web

bool
default "y" if IDF_TARGET="esp32h4"
select IDF_TARGET_ARCH_RISCV

Copy link

Choose a reason for hiding this comment

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

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.

Fix in CursorΒ Fix in Web

@scrambletools
Copy link
Author

My pull request is messed up. Apologies for the huge update, perhaps I should remove this pr and resubmit?

@scrambletools
Copy link
Author

@kostaond I had to reset my fork as the rebase went very wrong. I will resubmit the pr soon 1-2 commits.

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Won't Do This will not be worked on Resolution: Duplicate This issue or pull request already exists and removed Status: Selected for Development Issue is selected for development Resolution: Won't Do This will not be worked on labels Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Resolution: Duplicate This issue or pull request already exists Status: Done Issue is done internally

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants