Ardumower / Sunray

Ardumower Sunray
73 stars 59 forks source link

Corrupt MPU FIFO (MPU6050, MPU9150 etc.) on Raspberry PI (quaternion is outside of acceptable threshold) #150

Closed greymfm closed 8 months ago

greymfm commented 8 months ago

When compiling and running Sunray firmware on a Raspberry PI, the MPU FIFO gets corrupted.

Steps to reproduce:

  1. Connect MPU (6050, 9150 etc.) to Raspberry PI. image
  2. Activate Raspberry CPU-based I2C driver ('sudo raspi-config'), MPU should be found with: sudo i2cdetect -y 1 Screenshot from 2024-01-21 15-30-10
  3. Compile Sunray firmware on your PI: git clone https://github.com/Ardumower/Sunray cd Sunray/alfred/build cmake .. make
  4. sudo ./sunray

The MPU will be found but will not return any data. The reason is that the FIFO corruption check (in src/mpu/inv_mpu_dmp_motion_driver.c) fails:

https://github.com/Ardumower/Sunray/blob/f64c6f5493343587f5f41e7c2befb9bfb10d72ba/sunray/src/mpu/inv_mpu_dmp_motion_driver.c#L1276

Any ideas? :-)

To simply testing, I have made a 'IMU hello world project', just to test the MPU IMU:

  1. Unzip arduino_pi_imu_test.zip on your Rasperry PI

arduino_pi_imu_test.zip

  1. Adjust MPU type (in 'src/mpu/inv_mpu.c': #define MPU9150, MPU6050 etc.)
  2. Compile test code on your PI:
    cd arduino_pi_imu_test/build cmake .. make
  3. Run test code: sudo ./imu_test

The FIFO will be corrupted:

Screenshot from 2024-01-21 16-19-06

Playback of recorded I2C data can be activated (to test MPU-library without hardware) in ' src/mpu/arduino_mpu9250_i2c.cpp' (play=true) - If MPU library is compiled correctly, output should be like this:

Screenshot from 2024-01-23 11-01-30

greymfm commented 8 months ago

Further tests (with different hardware, different OS etc.) show:

MPU 6050 working properly (without FIFO corruption message):

raspberry 3     Linux 4.14.79-v7+   armv7l    gcc 6.3.0            YES  
raspberry 4     Linux 4.19.97-v7l+  armv7l    gcc 8.3.0            YES
raspberry 3     Linux 6.1.21-v8+    aarch64   gcc 10.2.1           YES  ??
raspberry 4     Linux 6.1.21-v8+    aarch64   gcc 10.2.1           NO   
raspberry 5     Linux 6.1.0-rp7     aarch64   gcc 12.2.0           NO   
raspberry 4     Linux 6.1.0-rp7-v8  aarch64   gcc 12.2.0           NO   
greymfm commented 8 months ago

bugfixed in commit ( https://github.com/Ardumower/Sunray/commit/6afe8502d9281efa0e8c05e36e277ab9feecad45 )