Pixhawk2 I2C init failed


Hi everybody,
I’m trying to plug a SW20 lidar in my plane that uses a Pixhawk2, but I cannot make it work.

I followed the instructions on these pages: https://docs.px4.io/en/sensor/rangefinders.html https://docs.px4.io/en/sensor/sfxx_lidar.html and plugged it on the I2C 2 socket.
QGroundControl doesn’t give me any distance_sensor and on the console sf1xx says [sf1xx] driver start failed
I tried editing sf1xx.cpp to use PX4_I2C_BUS_ONBOARD as suggested here: https://github.com/PX4/Firmware/issues/6358 but no more success.
In the startup log, I have the following line:
WARN [blinkm] I2C init failed
It seems to indicate me that the problem comes from the I2C in itself.
I tested on another Pixhawk and I have the same problem, so I don’t think that it’s a hardware fault on my device.

Is there some config (in the Pixhawk or directly in the code) that I must change to make it work?

Here is the whole start log if it can be of any help:

MUv2 ver 0xE : Rev 0 V30
[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: PX4FMU_V2
HW type: V30
HW version: 0x0009000E
HW revision: 0x00000000
FW git-hash: 82aa24adfca29321cfd1209e287eab6c2b16780e
FW version: Release 1.8.1 (17302015)
OS: NuttX
OS version: Release 7.22.0 (118882559)
OS git-hash: 63775322bf25adb406594f8e610122fe0cef2f7a
Build datetime: Oct 20 2018 00:19:12
Build uri: BUILD_URI
Toolchain: GNU GCC, 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]
MFGUID: 3334353731375104002e0029
MCU: STM32F42x, rev. 3
UID: 2E0029:31375104:33343537 
[hardfault_log] Fault Log is Armed

INFO  [tune_control] Publishing standard tune 1
INFO  [param] selected parameter default file /fs/mtd_params
WARN  [rgbled] no RGB led on bus #2
WARN  [blinkm] I2C init failed
WARN  [blinkm] init failed
nsh: rgbled_pwm: command not found
MS5611_SPI on SPI bus 4 at 3 (20000 KHz)
MS5611_SPI on SPI bus 1 at 3 (20000 KHz)
WARN  [bst] no devices found
WARN  [hmc5883] no device on bus 1 (type: 2)
WARN  [lis3mdl] no device on bus 2
WARN  [hmc5883] no device on bus 2 (type: 1)
WARN  [mpu6000] no device on bus #3 (SPI1)
WARN  [mpu6000] no device on bus #5 (SPI4)
MPU9250 on SPI bus 4 at 4 (1000 KHz)
INFO  [mpu9250] accel cutoff set to 30.00 Hz
INFO  [mpu9250] gyro cutoff set to 80.00 Hz
L3GD20 on SPI bus 4 at 1 (11000 KHz)
LSM303D on SPI bus 4 at 2 (11000 KHz)
MPU9250 on SPI bus 1 at 4 (1000 KHz)
INFO  [mpu9250] accel cutoff set to 30.00 Hz
INFO  [mpu9250] gyro cutoff set to 80.00 Hz
WARN  [sdp3x_airspeed] not started on bus 1
WARN  [sdp3x_airspeed] not started on bus 2
WARN  [ms5525_airspeed] not started on bus 1
WARN  [ms5525_airspeed] not started on bus 2
WARN  [ms4525_airspeed] not started on bus 1
WARN  [ms4525_airspeed] not started on bus 2
WARN  [ets_airspeed] not started on bus 1
WARN  [ets_airspeed] not started on bus 2
INFO  [load_mon] stack check enabled
INFO  [px4io] default PWM output device
INFO  [mavlink] mode: Normal, data rate: 1200 B/s on /dev/ttyS1 @ 57600B
px4flow [215:100]
WARN  [px4flow] scanning I2C buses for device..
INFO  [mavlink] mode: Config, data rate: 800000 B/s on /dev/ttyACM0 @ 57600B
INFO  [init] Mixer: /etc/mixers/AETRFG.main.mix on /dev/pwm_output0 
INFO  [init] Mixer: /etc/mixers/pass.aux.mix on /dev/pwm_output1 
INFO  [logger] logger started (mode=all)
1 Like

How are you starting the driver from qgc? Did you set the SENS_EN_SF1XX parameter from qgc? Or did you try manually from the mavlink shell? In this case you would have to run the following command: sf1xx start -a



Thanks for your answer. SENS_EN_SF1XX is set to 5 (SF/LW20). I tried starting with the -a option as you suggested, and the answer is that -a is an Unknown option!

I successfully made my sensor work by using its serial interface (but had to adapt the code to add the support for this sensor). I’ll make a pull request on PX4 as soon as I have a clean solution for selecting the correct baudrate.

Meanwhile, I’m still interested on how to make I2C working as I’ll still need to use it in the future.


Apparently the -a argument was added recently and was not included in the latest release. Can you try to flash the master branch from github. In theory this should be fixed there. On master setting the parameter to 5 should start the driver with the -a flag.


I flashed the Master branch, and now I have this option. But still the same.
I still have this worrying warning at startup WARN [blinkm] I2C init failed.
sf1xx accepts the start -a command (either on startup with the SENS_EN_SF1XX parameter set to 5, or manually), but it says [sf1xx] driver not running if I type sf1xx status.
By adding a bit of debug prints, it seems to fail when sending its first I2C command: transfer returns an error code of -6, that I failed to trace any further.
I tried to update the API (the command it sends is marked as deprecated, and I had to update the API to make it work in Serial as well), but I have the same problem. (same with trying to change SF1XX_BUS_DEFAULT to PX4_I2C_BUS_ONBOARD instead of PX4_I2C_BUS_EXPANSION)

I can connect the sensor using an I2C interface on my computer, the sensor works correctly, so it is not a problem on its side.

For the moment I’m stuck with the Serial version, and when I wanted to send back my additions to the official repo, I saw that PX4 does not support the serial version of these sensors anymore (since commit
f0c0b6f6e893a1e7164b4ffc5b60dc16cb62df91), which concerns me furthermore.


I will check on Monday if I can find this sensor to reproduce it. Are you using the SF20 or the LW20? I was not able to find the SW20 online


No worries, I won’t be able to test things before Tuesday.
I’m using the SF20/c
Is the WARN [blinkm] I2C init failed warning normal? Or should I search the origin of my problem somewhere else, as this warning is here even if no sensor is plugged or if I don’t activate the driver.
Thanks a lot for your help


No the blinkm is the driver for an i2c led controller. It scans the i2c bus to look for one of these controllers at every boot and it fails because you don’t have one on your board. Your issue is not related to the blinkm.