PX4 / PX4-Autopilot

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

USB device not detected after boot(current Master branch) #19405

Closed dookei closed 2 years ago

dookei commented 2 years ago

Hi there, I am currently facing an USB issue on the master branch with the Holybro Durandal_v1 hardware. After boot the USB is no longer detected on the host machine. During boot(or when the STM32 enters the bootloader) this is detected. So I can rule out hardware or cable issues. This is only reproducible on the current master branch.

On the previous firmware v1.12.3 this does not happen. @davids5 : Any thoughts where I should look for ? Many thanks

davids5 commented 2 years ago

@dookei - I just verified this as working on PX4 master with today's Linux QGC build.

ercon: Registering CDC/ACM serial driver
sercon: Successfully registered the CDC/ACM serial driver
/dev/ttyACM0: launching mavlink (HEARTBEAT v2 from SYSID:255 COMPID:190)
INFO  [mavlink] mode: Config, data rate: 100000 B/s on /dev/ttyACM0 @ 2000000B
[boot] Rev 0x0 : Ver 0x0 VD00
[boot] Fault Log info File No 4 Length 3177 flags:0x01 state:1
[boot] Fault Log is Armed
sercon: Registering CDC/ACM serial driver
sercon: Successfully registered the CDC/ACM serial driver
HW arch: HOLYBRO_DURANDAL_V1
HW type: VD00
HW version: 0x00000000
HW revi[hardfault_log] Fault Log is Armed
sion: 0x00000000
FW git-hash: 67920f089bdb73e0609338a9c91ad4071a3f21d9
FW version: 1.13.0 40 (17629248)
FW git-branch: master
OS: NuttX
OS version: 0.0.0 0 (0)
OS git-hash: c5c7d2b4f26f52f1dfb425ebde83328606b65d4f
Build datetime: Mar 28 2022 10:00:56
Build uri: localhost
Build variant: default
Toolchain: GNU GCC, 9.3.1 20200408 (release)
PX4GUID: 00060000000033383331353751100035002c
MCU: STM32H7[4|5]xxx, rev. Y
INFO  [param] selected parameter default file /fs/mtd_params
INFO  [param] importing from '/fs/mtd_params'
WARN  [parameters] ignoring unrecognised parameter 'CAL_ACC0_TEMP'
WARN  [parameters] ignoring unrecognised parameter 'CAL_ACC1_TEMP'
WARN  [parameters] ignoring unrecognised parameter 'CAL_GYRO0_TEMP'
WARN  [parameters] ignoring unrecognised parameter 'RC_ACRO_TH'
WARN  [parameters] ignoring unrecognised parameter 'RC_ASSIST_TH'
WARN  [parameters] ignoring unrecognised parameter 'RC_AUTO_TH'
WARN  [parameters] ignoring unrecognised parameter 'RC_MAN_TH'
WARN  [parameters] ignoring unrecognised parameter 'RC_STAB_TH'
INFO  [parameters] BSON document size 1402 bytes, decoded 1402 bytes (INT32:24, FLOAT:44)
INFO  [param] selected parameter backup file /fs/microsd/parameters_backup.bson
Board architecture defaults: /etc/init.d/rc.board_arch_defaults
Board defaults: /etc/init.d/rc.board_defaults
INFO  [dataman] data manager file '/fs/microsd/dataman' size is 62560 bytes
Loading airframe: /etc/init.d/airframes/4014_s500
INFO  [uavcan] Node ID 3, bitrate 1000000
ERROR [uavcan] CentralizedServer init: -13
ERROR [uavcan] UavcanServers init: 0
INFO  [px4io] IO FW CRC match
Board sensors: /etc/init.d/rc.board_sensors
icm20689 #0 on SPI bus 1 rotation 2
bmi088_accel #0 on SPI bus 1 rotation 2
bmi088_gyro #0 on SPI bus 1 rotation 2
WARN  [SPI_I2C] Already running on bus 1
ERROR [SPI_I2C] bmi088: no instance started (no device on bus?)
WARN  [SPI_I2C] Already running on bus 1
ERROR [SPI_I2C] bmi088: no instance started (no device on bus?)
ist8310 #0 on I2C bus 3 address 0xE rotation 10
ms5611 #0 on SPI bus 4
WARN  [SPI_I2C] ist8310: no instance started (no device on bus?)
ERROR [heater] Valid SENS_TEMP_ID required
INFO  [pwm_out] instance: 0, max rate: 100, default: 50, alt: 50
INFO  [init] Mixer: /etc/mixers/quad_x.main.mix on /dev/pwm_output0
INFO  [init] Mixer: /etc/mixers/pass.aux.mix on /dev/pwm_output1
ekf2 [690:237]
Starting Main GPS on /dev/ttyS0
Starting MAVLink on /dev/ttyS1
WARN  [mavlink] offboard mission init failed (-1)
INFO  [mavlink] mode: Normal, data rate: 1200 B/s on /dev/ttyS1 @ 57600B
INFO  [logger] logger started (mode=all)

NuttShell (NSH) NuttX-10.2.0
nsh> /dev/ttyACM0: launching mavlink (HEARTBEAT v2 from SYSID:255 COMPID:190)
INFO  [mavlink] mode: Config, data rate: 100000 B/s on /dev/ttyACM0 @ 2000000B
INFO  [mavlink] Starting mavlink shell

Perhaps you can give a more complete description of your setup.

RamanaBotta commented 2 years ago

same problem.

dookei commented 2 years ago

Hi @davids5 I wont be able to check it today as I have no access to the FC at the moment. I will get back to you tomorrow.

vincentpoont2 commented 2 years ago

Hello @RamanaBotta & @dookei , Can you go to Mavlink Console and type in ver all and paste the print out here? image

dookei commented 2 years ago

Hi @vincentpoont2 Here is my output

NuttShell (NSH) NuttX-10.2.0
nsh> 
nsh> ver all
HW arch: HOLYBRO_DURANDAL_V1
HW type: VD00
HW version: 0x00000000
HW revision: 0x00000000
FW git-hash: df0e402c447c47458a29472c493cbfa035ae68cf
FW version: 1.13.0 0 (17629184)
FW git-branch: master
OS: NuttX
OS version: Release 8.2.0 (134349055)
OS git-hash: 017aa15746bcf6b57bb185e14dce7fa0876fc751
Build datetime: Mar 30 2022 09:12:51
Build uri: localhost
Build variant: default
Toolchain: GNU GCC, 9.3.1 20200408 (release)
PX4GUID: 000600000000343434363038510300450027
MCU: STM32H7[4|5]xxx, rev. Y
nsh> 

I have this FC connected to a nvidia jetson all the time over USB and UART . In the previous version v1.12.3 I could connect to a mavlink term over the USB port. This is my lsusb output for the Durandal during boot (when the STM is in bootloader) Bus 001 Device 012: ID 3162:004b After the bootloader when it enters the Px4 the USB device disappears. I could install wireshark to chekc whats going on with the USB...but there most be another way. Or not?

PS: I also tried direct connection to the Fc over laptop and the issue is the same. So this is not and issue from the jetson.

dookei commented 2 years ago

I believe this is the issue. Well it actually is( Just tested) image on this commit the USB was disabled:https://github.com/PX4/PX4-Autopilot/commit/6d78054f5001548ea2f1d48bb59966e2352bc9fe

@dagar would it be possible to enable this back?

davids5 commented 2 years ago

@dookei - the usbvbus detection is will automatically start the mavlink over USB once VBUS is active AND the far end opens the port and sends mavlink.

Do you have a serial debug console?

Please run on the console

listener system_power

TOPIC: system_power
 system_power
    timestamp: 32652442 (0.003585 seconds ago)
    voltage5v_v: 4.9773
    sensors3v3: [3.3065, 0.0000, 0.0000, 0.0000]
    sensors3v3_valid: 1
    usb_connected: 1
    brick_valid: 0
    usb_valid: 1
    servo_valid: 1
    periph_5v_oc: 0
    hipower_5v_oc: 0
    comp_5v_valid: 0
    can1_gps1_5v_valid: 0

and post the results here.

Can you also measure the voltage level of the USB +5V?

dookei commented 2 years ago

Hi @davids5 , that's easy. I have no USB power. I have my FC connected to a USB hub without power line. Just data and ground. Reason for it is to guarantee that the FC(and peripherals) are not powered over the USB. On the jetson side I just use then usbguard to block or allow the usb port communication.

Here is the output

nsh> listener system_power
TOPIC: system_power
 system_power
    timestamp: 602587539 (0.010019 seconds ago)
    voltage5v_v: 5.0427
    sensors3v3: [3.3090, 0.0000, 0.0000, 0.0000]
    sensors3v3_valid: 1
    usb_connected: 0
    brick_valid: 3
    usb_valid: 0
    servo_valid: 1
    periph_5v_oc: 0
    hipower_5v_oc: 0
    comp_5v_valid: 0
    can1_gps1_5v_valid: 0

Would't it be possible to allow the sercon /usb communication when USB communication is available? Instead of just checking if the USB is powered. Its probably more tricky but would be more reliable. There can also be cases where someone (not recommended)just uses a Power USB cable to power the FC and not to communicate with it.

davids5 commented 2 years ago

The FC acting as a USB device and is looking for VBUS to begin the enumeration. IIRC there would need to be changes in the nuttx driver and PX4 to support this. change. A quick fix would be to add a 100K-1M resister to pull the USB +5. It will pass the sense test and not power the FC.

dookei commented 2 years ago

Thanks I will try it next time I have phisical access to the FC. Many thanks @davids5 !