Skip to content

stm32: add support for CAN on N6 and enable on OPENMV_N6#19334

Open
dpgeorge wants to merge 7 commits into
micropython:masterfrom
dpgeorge:stm32-n6-can-support
Open

stm32: add support for CAN on N6 and enable on OPENMV_N6#19334
dpgeorge wants to merge 7 commits into
micropython:masterfrom
dpgeorge:stm32-n6-can-support

Conversation

@dpgeorge

@dpgeorge dpgeorge commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

This is a continuation of #19316, to get CAN working on STM32N6, and enable it on OPENMV_N6.

Currently it supports only CAN1, but CAN2/CAN3 will follow in a separate PR.

Testing

Tested CAN1 on OPNEMV_N6. The following tests run and pass:

  • extmod_hardware/machine_can_timings.py
  • ports/stm32/pyb_can.py
  • multi_extmod/machine_can_*.py (8 tests, run against PYBV10 in both directions with CAN tranceivers)

All other CAN tests skip (mainly because there's only one CAN peripheral enabled).

Also tested on NUCLEO_H723ZG, to make sure the modified pyb_can.py test didn't regress.

Trade-offs and Alternatives

N6 is basically the same as H7, and I configured it to use the same buffer settings as H7. That allows a second CAN peripheral to work (eventually, once support is added). Maybe one day the CAN API can be extended to allow all the buffers to be allocated to one peripheral, or that could be done at compile time. But for now one CAN is allocated 50% of buffer resources.

Generative AI

Not used.

kwagyeman and others added 7 commits June 8, 2026 15:49
Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Changes:
- Use the same deep-tx-queue logic as the STM32H7.
- Use `time.sleep_ms()` instead of `pyb.delay()` (the latter is not
  available on all stm32 boards).

This test now passes on OPENMV_N6.

Signed-off-by: Damien George <damien@micropython.org>
So that CAN3 has a chance of working.

Signed-off-by: Damien George <damien@micropython.org>
These aren't technically needed, but good to make sure they are populated.

Signed-off-by: Damien George <damien@micropython.org>
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.49%. Comparing base (af38ee1) to head (2271594).
⚠️ Report is 25 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19334      +/-   ##
==========================================
+ Coverage   98.47%   98.49%   +0.01%     
==========================================
  Files         176      176              
  Lines       22845    22911      +66     
==========================================
+ Hits        22497    22566      +69     
+ Misses        348      345       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

Code size report:

Reference:  rp2: Build with nano.specs for newlib-nano. [6552836]
Comparison: stm32/fdcan: Initialise all entries in FDCAN_InitTypeDef struct. [merge of 2271594]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@octoprobe-bot

Copy link
Copy Markdown

Octoprobe PR report

Test Tests
passed
Tests
skipped
Tests
xfailed
Tests
failed
format flash 5
run-tests.py 4650 632 4
run-tests.py --via-mpy --emit native 4586 691 9
run-tests.py --via-mpy 4650 632 4
run-perfbench.py 120
run-natmodtests.py 180 25
run-tests.py --test-dirs=extmod_hardware 23 17 5
run-tests.py --test-dirs=extmod_hardware --emit-native 23 17 5
Total 14237 2014 27
Failures

@kwagyeman

Copy link
Copy Markdown
Contributor

Nice

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

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

3 participants