PX4 / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
7.9k stars 13.25k forks source link

[Bug]: 6x CANFD port and Ethernet can't use at the same time. #21734

Open DaShen96 opened 1 year ago

DaShen96 commented 1 year ago

Describe the bug

There’s a problem bothering me. Why is the Ethernet device missing after configuring the CAN port?

nsh> ifconfig
can0    Link encap:UNSPEC at DOWN
    inet addr:0.0.0.0 DRaddr:0.0.0.0 Mask:0.0.0.0

can1    Link encap:UNSPEC at DOWN
    inet addr:0.0.0.0 DRaddr:0.0.0.0 Mask:0.0.0.0

nsh> 

After disabling the CAN port, the Ethernet port can work normally.

nsh> ifconfig
eth0    Link encap:Ethernet HWaddr 96:8b:9c:ce:b9:21 at DOWN
    inet addr:192.168.0.54 DRaddr:192.168.0.1 Mask:255.255.255.0

To Reproduce

  1. enable FDCAN on menuconfig , can't see the eth0 port use ifconfig command.
  2. disable FDCAN on menuconfig , the eth0 port work normally.
  3. Ethernet configuration is like that:
    nsh> netman show
    DEVICE=eth0
    BOOTPROTO=static
    NETMASK=255.255.255.0
    IPADDR=192.168.0.54
    ROUTER=192.168.0.1
    DNS=192.168.0.1

Expected behavior

I need to use both CAN and Ethernet at the same time.

Screenshot / Media

No response

Flight Log

none

Software Version

v1.14.0

Flight controller

pixhawk 6x

Vehicle type

None

How are the different components wired up (including port information)

No response

Additional context

No response

cody-czn commented 2 months ago

I have observed the same issue

DaShen96 commented 3 weeks ago

I have observed the same issue

Did you solve this issue?

cody-czn commented 2 weeks ago

I found the reason for the ethernet interface disappearing.

The issue is that the ethernet driver does not get initialised in Nuttx when CANFD is enabled.

See below requirement for multiple interfaces.

arch/arm/src/stm32h7/stm32_ethernet.c.


/****************************************************************************
 * Function: arm_netinitialize
 *
 * Description:
 *   This is the "standard" network initialization logic called from the
 *   low-level initialization logic in arm_initialize.c. If STM32H7_NETHERNET
 *   greater than one, then board specific logic will have to supply a
 *   version of arm_netinitialize() that calls stm32_ethinitialize() with
 *   the appropriate interface number.
 *
 * Parameters:
 *   None.
 *
 * Returned Value:
 *   None.
 *
 * Assumptions:
 *
 ****************************************************************************/
DaShen96 commented 2 weeks ago

I found the reason for the ethernet interface disappearing.

The issue is that the ethernet driver does not get initialised in Nuttx when CANFD is enabled.

See below requirement for multiple interfaces.

arch/arm/src/stm32h7/stm32_ethernet.c.

/****************************************************************************
 * Function: arm_netinitialize
 *
 * Description:
 *   This is the "standard" network initialization logic called from the
 *   low-level initialization logic in arm_initialize.c. If STM32H7_NETHERNET
 *   greater than one, then board specific logic will have to supply a
 *   version of arm_netinitialize() that calls stm32_ethinitialize() with
 *   the appropriate interface number.
 *
 * Parameters:
 *   None.
 *
 * Returned Value:
 *   None.
 *
 * Assumptions:
 *
 ****************************************************************************/

Thank for your reply! I found that too. I have modified the NuttX driver, and now it works properly.