← Back to Pull requests

variants: portenta_c33: enable port_irq6 external interrupt #665

Closed
unknown closed this pull request without merging on Oct 01, 2026 13:26 UTC
View on GitHub
unknown unknown commented on Sep 29, 2026 12:34 UTC
Author

One commit, one change to
variants/arduino_portenta_c33_r7fa6m5bh3cfc/arduino_portenta_c33_r7fa6m5bh3cfc.overlay:
enable ICU external interrupt channel 6 (port_irq6) on NVIC line 36.

What it fixes

Channel 6 serves four pins: P000 (D22/A7), P301 (D40), P409 (D28) and
PA08 (D75). port_irq6 is status = "disabled" in the SoC devicetree, and
neither the board devicetree nor this variant enables it. So on these pins
attachInterrupt() arms nothing:

  • gpio_pin_interrupt_configure() returns -EWOULDBLOCK;

  • attachInterrupt() returns void and does not report the error

  • (cores/arduino/WInterrupts.cpp);
  • the sketch's interrupt handler is never called.
  • D28 is the IRQ line of the Portenta UWB Shield (Truesense DCU150, NXP SR150).
    Its library currently has to poll that line on this board.

    The change

    &port_irq6 {
    	interrupts = <36 12>;
    	status = "okay";
    };
    

  • Line 36: no device in the board's devicetree uses NVIC line 36. It is

  • one of ten lines (36, 37, 52, 53, 60, 61, 62, 73, 86, 95) with no device
    assigned. In the generated devicetree with this change, port_irq6 is the
    only user of line 36.
  • Priority 12: the same as port_irq9 and port_irq10 in the board

  • devicetree.
  • No renumbering: the port_irq6 node already exists in the SoC

  • devicetree, so enabling it renumbers nothing. The generated devicetree
    ordinals are identical with and without this change. The loader exports one
    more device, __device_dts_ord_40; every other exported symbol is
    unchanged. Sketches built against a core without this change keep working.
  • Cost: 178 bytes of code and 40 bytes of RAM (unallocated RAM above

  • _image_ram_end: 105,760 B on main, 105,720 B with this change).
    Kconfig is identical.
  • One pin at a time: only one pin of a channel can use its interrupt at a

  • time, so one of D22, D28, D40 and D75.

    Base and test builds

    The branch is on main at e56d394. The test loaders were built with
    extra/build.sh portentac33 on 39f8354, which uses Zephyr 1743741760e
    (zephyr-arduino-v4.4.1+). Between 39f8354 and e56d394 the only change to the
    build is west.yml moving to zephyr-arduino-v4.4.2. Compared with
    1743741760e, that branch does not change the RA6M5 SoC devicetree, the
    Portenta C33 board devicetree, the RA external interrupt driver or the RA GPIO
    driver. The only GPIO changes are in the GPIO emulator and in the userspace
    syscall handlers (gpio_handlers.c); hal_renesas is at the same revision.

    Tested on hardware

    Portenta C33, dynamic (llext) mode. Each test flashed the same sketch image
    on both loaders, so only the loader differs.

    1. No shield, no wire. The test sketch calls attachInterrupt() on D28,
    then gpio_pin_interrupt_configure() on the same pin, and prints the return
    code. D16 (port_irq10, enabled on main) is the control.

    | loader | D28 gpio_pin_interrupt_configure() | D16 (control) |
    |---|---|---|
    | main 39f8354 | -11 (-EWOULDBLOCK) | 0 |
    | main 39f8354 + this commit | 0 | 0 |

    The sketch's other test pins, on disabled channels (D0, D2, D4, D12, D18),
    returned -11 on both loaders. With no wire, no edges were expected, and every
    count stayed 0.

    2. UWB shield, SR150 IRQ as the signal. The shield's two-way ranging
    example needs the larger llext heap from #655, so both loaders here include
    #655: 39f8354 + #655, and 39f8354 + #655 + this commit. The sketch is the
    library's UWB_RangingController plus an attachInterrupt() on D28 that
    counts rising edges (the SR150 IRQ is active high). It prints the count every
    second next to the number of ranging notifications. The library still polls
    D28, so ranging does not depend on this change. The peer was a second
    Portenta C33 with the shield, running UWB_RangingControlee on core 1.0.0
    with a 192 KB-heap loader.

    | loader | D28 attach return | D28 rising edges per second | ranging notifications per second | distances |
    |---|---|---|---|---|
    | 39f8354 + #655 | -11 | 0 in every second for 32 s | 5 in every second (160 in 32 s) | 18-68 cm |
    | 39f8354 + #655 + this commit | 0 | 28 in the first line, then 9-11 per second (119 in 10 s) | 5 in every second (50 in 10 s) | 49-57 cm |

    39f8354 + #655:
    # D28 P409 port_irq6 attach ret=-11 -EWOULDBLOCK (channel disabled)
    # [   14s] D28 rising +0 (0) | ranging ntf +5 (5)
    # [   15s] D28 rising +0 (0) | ranging ntf +5 (10)
    ...
    # [   45s] D28 rising +0 (0) | ranging ntf +5 (160)
    
    39f8354 + #655 + this commit:
    # D28 P409 port_irq6 attach ret=0 OK
    # [   14s] D28 rising +28 (28) | ranging ntf +5 (5)
    # [   15s] D28 rising +10 (38) | ranging ntf +5 (10)
    # [   16s] D28 rising +10 (48) | ranging ntf +5 (15)
    ...
    # [   23s] D28 rising +9 (119) | ranging ntf +5 (50)
    

    Edges per notification. After the first line, D28 shows 9-11 rising edges
    per second against 5 ranging notifications, about two per notification. The
    host's read path expects two IRQ assertions per UCI packet.
    uwb_uwbs_tml_data_rx() in the NXP UWB SDK (uwb_uwbs_tml_interface.c, not
    changed for this board) works like this:

    1. It waits for the IRQ (line 185).
    2. It raises the host's read-ready line (line 254).
    3. It waits for the IRQ again (line 262, "IRQ asserted again").
    4. It reads the packet.
    5. It waits for the IRQ to drop (line 305).

    Two rising edges per packet give 10 per second if the ranging notification is
    the only packet the SR150 sends in each round. The log does not record which
    packets were read, so that part is not shown.

    The first line is higher (28) because it covers more than one second. The
    sketch attaches the interrupt before it initialises and starts the ranging
    session, so the first line counts everything from the attach to the end of
    the first second, session setup included.

    Other channels (not in this PR)

    The same change would work for more channels. Of the 16 channels, only 9 and
    10 are enabled today. The other 14 are disabled, and 44 pins in
    digital-pin-gpios sit on them.

  • Channels 4-8 and 11-15 (ten channels, this one included) fit the ten

  • unassigned NVIC lines. In a devicetree-only build with all ten enabled,
    the ordinals are identical to main, so nothing is renumbered. On the
    board, the test sketch above on a loader with all ten enabled got 0 from
    gpio_pin_interrupt_configure() on D2, D4, D12, D18 and D28, and -11 only
    on D0 (channel 0, still disabled). Together the ten channels would cover
    34 pins in digital-pin-gpios (33 pads: D29 and D60 are the same pad).
    This PR covers 4 of those pins; the other nine channels would add 30.
    Eight of the 34 are on the MKR edge: D2, D4, D7, D12, D15, D18, D19 and
    D20 (channel 6 has none there).
  • Channels 0-3 are different. Enabling any one of them, even on a free

  • line, changes the devicetree ordinals of four exported devices: ioport8,
    the ESP32 download node, the QSPI NOR flash and the PCLKA clock node
    (checked for each of the four channels alone). Dynamic sketches refer to
    devices by ordinal (__device_dts_ord_<N>), so a sketch built against the
    current core that uses one of those devices would have to be rebuilt.
    There are also no free lines left for them once the other ten are used;
    they would need lines that belong to disabled devices (for example sci0's).

    If this change is accepted, I can prepare the other nine channels the same
    way.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: facchinm Review duration: 2932m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #665"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%