Updates for ARKFPV board to use Cyphal-CAN-FD #1
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.
While both DroneCAN and Cyphal are protocol (rather than driver) specifications, they interconnect with physical layer CAN device drivers in different ways. Both protocols are implemented in PX4, but the physical layer connections are board dependent. Currently, ARKFPV supports DroneCAN, and the goal of this PR is to add a Cyphal board configuration option for ARKFPV.
My experiments show that Cyphal "nearly" works for the relatively minor config file changes documented in commit
[c5086c3](https://github.com/PX4/PX4-Autopilot/commit/c5086c346f82490a2c50aa362a2ee6fa5578caab)
. The key change is that the STM32H7 socketCAN drivers must be selected. This is already supported in the PX4 cyphal source code and is turned on by defconfig updates (see the commit). While I disabled DroneCAN in my experiments, this may not be necessary, except to save flash memory since both Cyphal and DroneCAN implementations each consume about 5% of program flash.Upon starting can0 manually in nsh (or automatically in rc.board_defaults):
ifup can0
, all CAN-FD reads occur without error, at the CAN-FD rates I tested: 1Mb (arbitration) and 4Mb (data). We used a cyphal-compliant sensor that broadcasts messages on the bus, and from a nuttx shell these messages can be monitored using the candump utility (turned on in defconfig).However, a problem exists for CAN-FD writes. Initially I noticed that the very first Cyphal heartbeat (first transmit from ARKFPV) would crash the CAN subsystem such that no further reads occur. A CAN analyzer shows that the sensor broadcasts remain as before, but ARKFPV cannot read them, and a subsequent invocation of candump hangs. The CAN analyzer doesn't recognize the transmit packet at all, and it is not present in the logged output.
But after further investigation, this problem is not related to Cyphal at all, and seems inherent in the socketCAN driver, or the ARKFPV socketCAN implementation. CAN-FD writes can be invoked from the nuttx command line using cansend, for example:
cansend can0 107D553B##F000000E3
As soon as that command is issued, CAN-FD reads are no longer possible from candump (although the sensor on the bus continues to send data, as seen in this scope screenshot (2-channel scope with chan1=CAN+, chan2=CAN-):
Three distinct messages are broadcast at roughly once per second (200 ms/div scope plot). The cansend message seems to cause a signal offset in the differential CAN signal. I tried both properly 120 ohm terminations, as well as removing the terminations, with no change.
There is enough subtlety in the socketCAN configuration that I may have missed a crucial parameter. I would appreciate some feedback on how to further isolate this behavior. As I said above, Cyphal-CAN "almost" works by configuration changes without source code change on ARKFPV.