Skip to content
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

[WIP] Update NuttX with SocketCAN drivers and add to boards #19713

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

JacobCrabill
Copy link
Member

@JacobCrabill JacobCrabill commented May 24, 2022

Describe problem solved by this pull request

Updates the NuttX submodule with new SocketCAN drivers, and adds new board configs to the relevant boards that can use the drivers.

Test data / coverage

WIP. Testing will involve using cansend/candump, and uavcan_v1 + yakut, connected to a desktop via a Peak CAN-USB-FD dongle and also using board<>board communication. Initial focus will be on CAN-FD on STM32H7 boards; following that, I hope to include F4 and F7 boards as that work gets to a ready-to-test state.

Additional context

Will keep this as draft until all relevant PX4-NuttX PR's get merged; this will simply be used as high-level status tracking in the meantime.

Point to the branch of PX4/NuttX#185
Adds SocketCAN support to STM32H7
Allows use of SocketCAN w/o also enabling UDP support in NuttX
@liu-hao000
Copy link

liu-hao000 commented Jul 12, 2022

I am using CUAV Nora flight controller to test SocketCAN and I have made the following modifications.

  1. Modified boards/cuav/nora/nuttx-config/socketcan/defconfig according to boards/cuav/nora/nsh/defconfig and /boards/mro/ctrl-zero-h7-oem/nuttx-config/nsh/defconfig
- #CONFIG_NET_ETHERNET is not set
- #CONFIG_NET_IPv4 is not set
- CONFIG_NSH_DISABLE_IFCONFIG=y
- CONFIG_NSH_DISABLE_IFUPDOWN=y
- CONFIG_SDCLONE_DISABLE=y
+ CONFIG_NET=y
+ CONFIG_NETDEV_CAN_BITRATE_IOCTL=y
+ CONFIG_NETDEV_IFINDEX=y
+ CONFIG_NETDEV_PHY_IOCTL=y
+ CONFIG_NET_CAN=y
+ CONFIG_NET_CAN_RAW_TX_DEADLINE=y
+ CONFIG_NET_CAN_SOCK_OPTS=y
+ CONFIG_NET_TIMESTAMP=y
+ CONFIG_STM32H7_FDCAN1=y
+ CONFIG_STM32H7_FDCAN2=y
+ CONFIG_CANUTILS_CANDUMP=y
+ CONFIG_CANUTILS_CANSEND=y
  1. Add boards/cuav/nora/socketcan.px4board
# CONFIG_BOARD_UAVCAN_TIMER_OVERRIDE is not set
CONFIG_DRIVERS_UAVCAN=n
CONFIG_CYPHAL_BMS_SUBSCRIBER=y
CONFIG_CYPHAL_ESC_CONTROLLER=y
CONFIG_CYPHAL_ESC_SUBSCRIBER=y
CONFIG_CYPHAL_GNSS_PUBLISHER=y
CONFIG_CYPHAL_GNSS_SUBSCRIBER_0=y
CONFIG_CYPHAL_GNSS_SUBSCRIBER_1=y
CONFIG_CYPHAL_READINESS_PUBLISHER=y
CONFIG_CYPHAL_UORB_ACTUATOR_OUTPUTS_PUBLISHER=y
CONFIG_CYPHAL_UORB_SENSOR_GPS_PUBLISHER=y
CONFIG_CYPHAL_UORB_SENSOR_GPS_SUBSCRIBER=y
CONFIG_DRIVERS_CYPHAL=y

I use make cuav_nora_socketcan upload to compile and download the program to CUAV Nora flight control, use CUAV USB to Serial to debug, there are two interfaces can0 can1 under the proc/net path.
But when I use ifconfig command, the return result is can0 UNSPEC at UP can0 UNSPEC at DOWN

nsh> ifconfig
can0    Link encap:UNSPEC at UP
can1    Link encap:UNSPEC at DOWN

And when I use cansend and candump, can0 can receive and send CAN data, but can1 can't receive nor send.

I think can1's inability to send and receive data has something to do with it being DOWN, but I can't find why can1 is DOWN.

thanks for your help.

@JacobCrabill
Copy link
Member Author

I think can1's inability to send and receive data has something to do with it being DOWN, but I can't find why can1 is DOWN.

Correct, I'm not quite sure why the default NuttX initialization only calls ifup on can0, but that's what's missing - if you use the command ifup can1, you should be all set (this could either be done manually or in an init script such as rc.board_defaults.

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

Successfully merging this pull request may close these issues.

3 participants