Skip to content

Mazda: decouple TJA MADS from MRCC - #6

Open
chinna244 wants to merge 4 commits into
zoompilot:mazda-devfrom
chinna244:mazda-tja-mrcc-clean-pr
Open

Mazda: decouple TJA MADS from MRCC#6
chinna244 wants to merge 4 commits into
zoompilot:mazda-devfrom
chinna244:mazda-tja-mrcc-clean-pr

Conversation

@chinna244

@chinna244 chinna244 commented Aug 24, 2026

Copy link
Copy Markdown

This makes the physical TJA button the MADS lateral-control source on the supported Mazda CX-5 platform instead of tying lateral availability to MRCC state.

The TJA state is preserved on synthetic CRZ_BTNS messages, while the forwarded copy to the FSC has the TJA bit cleared so stock TJA does not take ownership. Panda safety still receives the original bus-0 state.

Mazda can arm MRCC as a side effect of a TJA press. When that happens from an MRCC-off state, the controller sends a bounded MRCC_OFF cleanup after release. The cleanup keeps driver input priority, uses raw MRCC state for confirmation, preserves ownership across repeated TJA interaction, and is limited to three transmitted frames.

The behavior is scoped behind TJA_MADS. Mazda platforms without that capability continue using the existing MADS/MRCC path.

Required Panda dependency

This OpenDBC PR is not sufficient by itself. Panda must call the new safety_fwd_modify() hook on the copied forwarding packet. Without this call, the physical TJA bit is forwarded unchanged to the FSC and stock OEM TJA can still take ownership.

The required Panda change is commit 950151de. Add this one line in board/drivers/fdcan.h, after copying the RX payload into to_send and before recalculating its checksum:

(void)memcpy(to_send.data, to_push.data, dlc_to_len[to_push.data_len_code]);
safety_fwd_modify(bus_number, &to_send);
can_set_checksum(&to_send);

Required integration order:

  1. Merge this OpenDBC PR so safety_fwd_modify() is declared and implemented.
  2. Apply the one-line Panda fdcan.h change.
  3. Update the Zoompilot OpenDBC and Panda submodule pins, then rebuild Panda firmware.

The complete combination—this OpenDBC work plus Panda 950151de—is already pinned and field-tested on the author's Zoompilot develop branch.

Tests

  • 358 passed, 40 skipped
  • forwarding isolation and lateral-source scoping
  • raw MRCC state and cleanup ownership
  • deadline/counter wrap/interruption cases
  • OP cancel/resume interaction
  • non-TJA Mazda regression coverage

Expose a nullable per-mode hook so board code can sanitize a copied packet without changing the original RX packet.
Carry the dedicated safety parameter only for the platform whose physical TJA button layout has been verified.
Preserve wheel state in synthetic button frames, suppress TJA-visible ICBM traffic, and strip TJA only from the FSC-bound forwarding copy.
Track pre-press ownership and use a delayed, interruptible three-frame MRCC-off hold with its deadline, counter, and interruption regression tests.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for contributing to opendbc! In order for us to review your PR as quickly as possible, check the following:

  • Convert your PR to a draft unless it's ready to review
  • Read the contributing docs
  • Before marking as "ready for review", ensure:
    • the goal is clearly stated in the description
    • all the tests are passing
    • include a route or your device' dongle ID if relevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant