-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NuttX: Add UAVCANv1 support for STM32H7 MCUs via SocketCAN #19355
Draft
JacobCrabill
wants to merge
14
commits into
main
Choose a base branch
from
dev/h7-socketcan
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+608
−14
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Allows use of SocketCAN w/o also enabling UDP support in NuttX
… H7 SocketCAN driver
…ging up H7 SocketCAN driver
Add 'do_transmit()' to UavcanNode Add 'transmit()' to Publisher base class to call do_transmit() Call transmit() after canardTxPush from Publishers
Waiting on the NuttX upgrade. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DRAFT
This will require a PR against PX4 NuttX to backport apache/nuttx#6057, but I'd like some eyes on this first for a quick sanity check before going further (please!).
Requires one of the following PRs against PX4 NuttX first:
PX4/NuttX#185 or PX4/NuttX#186
DRAFT
Describe problem solved by this pull request
This pull request adds SocketCAN support for STM32H7 MCUs, and in particular, adds SocketCAN + UAVCANv1 support for the Orange Cube (an H7-based autopilot I happen to have lying around). The build target
make cubepilot_cubeorange_socketcan
points to a NuttX config including CONFIG_NET_CAN and associated config vars to enable SocketCAN(I can't remember off the top of my head whether CAN_FD gets enabled by default or not right now; be sure to check on CONFIG_NET_CAN_CANFD).
Describe your solution
This pull request updates the NuttX submodule to a WIP branch on my personal fork of upstream. As stated above, for this to leave the DRAFT phase, the changes from apache/nuttx#6057 (among others) need to be backported.
Describe possible alternatives
There are only a couple alternatives to enabling UAVCANv1 support on STM32H7 MCUs:
The downside of using a character-device driver is that that only one task can use the CAN interface at a time (not a shareable resource). SocketCAN, via the socket API, allows multiple tasks to access the CAN interface, independently and concurrently. I have a feeling this will become super useful for sharing a bus between DroneCAN and UAVCAN(v1).
The downside of using a tightly-coupled libuavcan driver is that the driver is tied to libuavcan and is hard to use for other protocols (e.g. Tattu CAN, KDE CAN, random sensors that just publish a single message, any engine ECU with a CAN interface...)
An additional benefit of the SocketCAN interface is that software using it can run on both embedded targets and your local development machine.
Test data / coverage
Testing is limited, but I have done the following so far:
yakut monitor
shows the expected outputs, but I haven't really stressed the system yet.Areas not tested, or not completed:
Additional context
I'm still doing additional bench testing for a bit longer; I'll be doing code cleanup in parallel. Once I get things cleaned up, I'll create board configs for other STM32H7-equipped autopilots and add those to this PR.
There is also some work to be done at the uavcan_v1 layer -- specifically, latency between calls to
canardTxPush()
andUavcanNode::transmit()
. I've added a quick "hack" fix here to all Publishers to remove this unwanted latency, but a cleaner solution may be desired.Looking for assistance with testing, finding bugs, and any feedback on the topic.