fix: remap CAN from CAN2/PB12-13 to CAN1/PB8-9 (Issue #676) #677

Merged
sl-jetson merged 2 commits from sl-firmware/issue-597-can-driver into main 2026-03-17 21:39:30 -04:00
Collaborator

Summary

  • Root cause: Mamba F722S MK2 does not expose PB12/PB13 externally; Waveshare CAN module is wired to the SCL (PB8) and SDA (PB9) header pads
  • Swap CAN2CAN1, GPIO_PIN_12/13GPIO_PIN_8/9, GPIO_AF9_CAN2GPIO_AF9_CAN1 in can_driver_init()
  • Drop __HAL_RCC_CAN2_CLK_ENABLE() — CAN1 is self-clocked
  • Move filter bank from 14 → 0 (bank 14 is the CAN2 slave-start boundary; CAN1 master banks start at 0)
  • I2C1 conflict resolved: BME280 already moved to I2C2 (PB10/PB11), so PB8/PB9 are free

Test plan

  • Build firmware and flash to FC (USB-connected to mbpm4)
  • Verify CAN bus enumerates: candump on Orin /dev/ttyACM0 shows motor controller feedback frames
  • Verify motor velocity commands reach BLDC controllers (RPM follows balance PID output)
  • Confirm no I2C1 regression (baro/mag paths gracefully absent if I2C1 unused)

🤖 Generated with Claude Code

## Summary - **Root cause**: Mamba F722S MK2 does not expose PB12/PB13 externally; Waveshare CAN module is wired to the SCL (PB8) and SDA (PB9) header pads - Swap `CAN2` → `CAN1`, `GPIO_PIN_12/13` → `GPIO_PIN_8/9`, `GPIO_AF9_CAN2` → `GPIO_AF9_CAN1` in `can_driver_init()` - Drop `__HAL_RCC_CAN2_CLK_ENABLE()` — CAN1 is self-clocked - Move filter bank from 14 → 0 (bank 14 is the CAN2 slave-start boundary; CAN1 master banks start at 0) - I2C1 conflict resolved: BME280 already moved to I2C2 (PB10/PB11), so PB8/PB9 are free ## Test plan - [ ] Build firmware and flash to FC (USB-connected to mbpm4) - [ ] Verify CAN bus enumerates: `candump` on Orin `/dev/ttyACM0` shows motor controller feedback frames - [ ] Verify motor velocity commands reach BLDC controllers (RPM follows balance PID output) - [ ] Confirm no I2C1 regression (baro/mag paths gracefully absent if I2C1 unused) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sl-perception added 1 commit 2026-03-17 20:32:14 -04:00
Mamba F722S MK2 does not expose PB12/PB13 externally. Waveshare CAN
module is wired to the SCL (PB8) and SDA (PB9) header pads.

Changes in can_driver_init():
- Drop __HAL_RCC_CAN2_CLK_ENABLE() — CAN1 needs no slave clock
- GPIO: GPIO_PIN_12/13 → GPIO_PIN_8/9, GPIO_AF9_CAN2 → GPIO_AF9_CAN1
- Instance: CAN2 → CAN1
- Filter bank: 14 → 0 (CAN1 master banks start at 0; bank 14 is the
  CAN2 slave-start boundary, unused here)

I2C1 is free: BME280 has been moved to I2C2 (PB10/PB11), so PB8/PB9
are available for CAN1 without any peripheral conflict.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson added 1 commit 2026-03-17 21:38:05 -04:00
Mamba is mounted at ~12° on the frame, causing all three arm-interlock
checks to block arming. Raise fabsf(bal.pitch_deg) < 10.0f to 20.0f
at lines 375, 512, 532 (JLink arm, RC arm rising-edge, CDC arm).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson merged commit 7f67fc6abe into main 2026-03-17 21:39:30 -04:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#677
No description provided.