Skip to content

ports/Xtensa: Update Xtensa support#525

Merged
fdesbiens merged 9 commits into
eclipse-threadx:devfrom
foss-xtensa:master
May 19, 2026
Merged

ports/Xtensa: Update Xtensa support#525
fdesbiens merged 9 commits into
eclipse-threadx:devfrom
foss-xtensa:master

Conversation

@ianstcdns
Copy link
Copy Markdown

Includes the following Xtensa port updates from Cadence foss-xtensa fork:

  • Add LX8 support for > 32 interrupts
  • ThreadX: Fix context switch logic
  • ThreadX: Interrupt fixes for TX_ENABLE_EXECUTION_CHANGE_NOTIFY
  • ThreadX: Support for DYNAMIC_REENT
  • ThreadX: Xtensa execution profiling support
  • ThreadX: Update xtensa port readme
  • ThreadX: Add Xtensa example to EPK
  • ThreadX: Add xtensa.cmake

All updates verified internally on multiple Xtensa configurations

PR checklist

  • [ x ] Updated function header with a short description and version number
  • [ x ] Added test case for bug fix or new feature
  • [ x ] Validated on real hardware

Also fix inconsistent SWPRI define in interrupt handler
- Disable interrupts prior to allocating a large exception frame;
  only reenable them after deallocating the extra memory.
- Any user tasks with stacks based on TX_MINIMUM_STACK do not
  have sufficient space for both a context switch frame and an ISR
  frame; ill-timed interrupts were causing stack overruns.
- Must reload register trashed by notify hook function call
- Must ensure PS.WOE is set before using call8
- Remove unused XT_USE_INT_WRAPPER define and associated changes,
  which had a bug in XEA2 usage
- Fix another case where enabling the thread notify hooks for
  call0 ABI corrupted a register
- ThreadX change to handle dynamic reent for both newlib and xclib
- Adapt ThreadX xclib interface code to handle dynamic reent pointers
- Update upstream execution profiling for Xtensa port
- tx_execution_profile.h now defines an Xtensa example
  in addition to the existing Cortex example
@fdesbiens
Copy link
Copy Markdown
Contributor

Hi @ianstcdns. Thank you for this contribution!

At least one of us will review and provide feedback.

@fdesbiens fdesbiens moved this to In review in ThreadX Roadmap Apr 24, 2026
@fdesbiens fdesbiens changed the base branch from master to dev April 24, 2026 17:42
@ianstcdns
Copy link
Copy Markdown
Author

@fdesbiens thank you for taking a look. I have not submitted PRs to eclipse projects before, so please LMK if there is any part of the process I may have missed or additional steps required. Thanks in advance.

@ianstcdns
Copy link
Copy Markdown
Author

@fdesbiens I'm not seeing any details on today's failures--all it says is "Error:". If these are due to my code changes, could you please point me to where I can find logs or reports?

@fdesbiens
Copy link
Copy Markdown
Contributor

Hi @ianstcdns.

I started reviewing the PR. We have some broken Cortex-M CI/CD builds right now. Your PR ver nearly passed the standard regression tests, but there was one specific test which timed out - which happens sometimes when GitGub infrastructure is under load. I will rerun the tests locally.

So, nothing to be worried about. Expect my feedback this week.

@fdesbiens fdesbiens self-requested a review May 13, 2026 13:18
@fdesbiens fdesbiens self-assigned this May 13, 2026
Copy link
Copy Markdown
Contributor

@fdesbiens fdesbiens left a comment

Choose a reason for hiding this comment

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

Good contribution overall, @ianstcdns. I would recommend making one specific change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When thread_ptr is NULL and neither XTHAL_CLIB_XCLIB nor XTHAL_CLIB_NEWLIB is defined, the function falls through with no return value — this is undefined behaviour that could crash or corrupt state at runtime.

Suggested fix: Convert the #if/#if chain to #if/#elif/#else and add a compile-time error for unsupported configurations:

#if XSHAL_CLIB == XTHAL_CLIB_XCLIB
    extern struct _reent g_reent;
    return &g_reent;
#elif XSHAL_CLIB == XTHAL_CLIB_NEWLIB
    extern struct _reent *_impure_ptr;
    return _impure_ptr;
#else
    #error "Unsupported C library for __DYNAMIC_REENT__"
#endif

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch! Thanks. I'll make this change shortly.

- Prevent a fall-through with no return value when neither
  xclib nor newlib are used.
@ianstcdns ianstcdns requested a review from fdesbiens May 13, 2026 14:21
@fdesbiens fdesbiens merged commit 9ccdd5d into eclipse-threadx:dev May 19, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In review to Done in ThreadX Roadmap May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants