NuttX CAN drivers on STM32H7x3

Hello, everyone!
I am trying to connect to the CAN port on a board with a STM32H7 chip. I set CONFIG_CAN=y in the defconfig file and get the error

/src/can.c:26:10: fatal error: stm32_can.h: No such file or directory
   26 | #include "stm32_can.h"
      |          ^~~~~~~~~~~~~
compilation terminated.

After a little understanding I realized that STM32H7 chips do not support NuttX CAN because

In
PX4-Autopilot/platforms/nuttx/NuttX/nuttx/arch/arm/src/stm32h7
does not exist files stm32_can.h stm32_can.c
and
PX4-Autopilot/platforms/nuttx/NuttX/nuttx/arch/arm/src/stm32h7/hardware
does not exist file stm32_can.h

In this connection I have a question:
How does UAVCAN work without CAN bus libraries on a board with STM32H7 chip? @PavelKirienko
Are there plans to implement CAN support on STM32H7 chips in NuttX and when? @nuttx

There is CAN-FD support coming on H7 with the next NuttX update, check these PRs:

I’m not sure if it’s in NuttX 10.3 or 10.4 but some PRs are coming soon here.

That being said, I tried to get a CAN device (not UAVCAN) working on top of 10.4 but I could not see my device using candump in the console. Maybe I’m missing something, or maybe it’s not that trivial to use a CAN device using CAN-FD although I thought it was backwards compatible.

Hi!
Thank you so much for your reply. I just saw that 5 hours ago the NuttX platform was upgraded to version 10.3+
I too am now trying to add a CAN 2.0A device, it is a microwave radio altimeter based on the Nanoradar NRA24. I hope I succeed and share this driver with everyone, maybe you can do it now too.
Thanks a lot to you and the dev team!

Unfortunately with the NuttX update the CAN port does not start this is also due to missing files in

PX4-Autopilot/platforms/nuttx/NuttX/nuttx/arch/arm/src/stm32h7
does not exist files stm32_can.h stm32_can.c
and
PX4-Autopilot/platforms/nuttx/NuttX/nuttx/arch/arm/src/stm32h7/hardware
does not exist file stm32_can.h

Sorry, I should have specified. This now uses the socketcan interface.

I am now immersed in studying the AUVCAN driver software code for the STM32H7. Since Pavel Kirienko answered that UAVCAN can share the same bus with other protocols based on CAN 2.0A (11-bit identifiers).
I am planning to either write a new function in the existing UAVCAN driver which will pass the standard CAN frames I need or use the existing ones, similar to what was already described, like this:

	/* Copy SocketCAN frame to CanardFrame */

	if (_can_fd) {
		struct canfd_frame *recv_frame = (struct canfd_frame *)&_recv_frame;
		out_frame.id = recv_frame->can_id;
		out_frame.dlc = recv_frame->len;
		memcpy(out_frame.data, &recv_frame->data, recv_frame->len);

	} else {
		struct can_frame *recv_frame = (struct can_frame *)&_recv_frame;
		out_frame.id = recv_frame->can_id;
		out_frame.dlc = recv_frame->can_dlc;
		memcpy(out_frame.data, &recv_frame->data, recv_frame->can_dlc);
	}

If it works, then we do not have to disable UAVCAN to receive messages from CAN 2A devices and receive and process them on the same wires as the UAVCAN devices

I guess that would as well.

I now have writing working inspired by cansend.c and I’m just trying to get reading to work like in candump.c.

The driver I meant is here: