move who_am_i() after soft reset and SPI toggle#103
Conversation
Testing on m5stampfly the BMI270 IMU is not recognized due to failed who_am_i() returning 255, rather than the ID 0x24. This problem is caused because who_am_i() is called before soft reset and SPI toggle. ** Without patch ** Arduino library: Arduino-ESP32 v2.0.17 Board: ESP32-S3 DevKitC-1 (default board) Processor: ESP32-S3 -D ARDUINO_BOARD=Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD, No PSRAM) -D ARDUINO_VARIANT=esp32s3 -D ARDUINO=10812 -D ARDUINO_RUNNING_CORE=1 -D ARDUINO_EVENNO_USB_CDC_ON_BOOT=1 CFG: Loading EEPROM - OK CFG: Loading config - madflight_board loaded OK, madflight_config loaded OK I2C: Scanning i2c_bus:0 - 0x10(16) 0x29(41) 0x40(64) 0x76(118) - Found 4 device(s) LED: RGB RCL: Channels: roll:1 pitch:2 throttle:3 yaw:4 armed:5 flightmode:6 BAR: BMP280 BAR: BMP280 i2c_adr=0x00 SensorID=0x58 MAG: NONE BAT: NONE RDR: NONE OFL: PMW3901 GPS: NONE ALT: KALMAN3 altCov=0.200000 accCov=0.010000 biasCov=0.100000 AHR: MAHONY IMU: BMI270 IMU: , check pin/bus/bus_type config FATAL ERROR: IMU install failed. - Type 'help' for help... ** With patch ** Arduino library: Arduino-ESP32 v2.0.17 Board: ESP32-S3 DevKitC-1 (default board) Processor: ESP32-S3 -D ARDUINO_BOARD=Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD, No PSRAM) -D ARDUINO_VARIANT=esp32s3 -D ARDUINO=10812 -D ARDUINO_RUNNING_CORE=1 -D ARDUINO_EVENT_RUNNING_CORE=1 -D ARDUINO_USB_MODE=1 -D ARDUINO_USB_CDC_ON_BOOT=1 CFG: Loading EEPROM - OK CFG: Loading config - madflight_board loaded OK, madflight_config loaded OK I2C: Scanning i2c_bus:0 - 0x10(16) 0x40(64) 0x76(118) - Found 4 device(s) LED: RGB RCL: NONE - Channels: roll:1 pitch:2 throttle:3 yaw:4 armed:5 flightmode:6 BAR: BMP280 BAR: BMP280 i2c_adr=0x00 SensorID=0x58 MAG: NONE BAT: NONE RDR: NONE OFL: PMW3901 GPS: NONE ALT: KALMAN3 altCov=0.200000 accCov=0.010000 biasCov=0.100000 AHR: MAHONY IMU: BMI270 IMU: IMU_EXEC_FREERTOS AHR: No Magnetometer, yaw:0.00 OUT: idx:gpio:type = 0:G41:Brushed 1:G42:Brushed 2:G10:Brushed 3:G5:Brushed Setup completed, CLI started - Type 'help' for help, or 'diff' to debug
|
Thanks for this PR. Does it still work if you move the who_am_i check to immediately before the soft reset? This way it bails out before writing anything to the IMU sensor, so it doesn't potentially upset a different IMU when using auto-detect. I recently got a stampfly, but did not get to fly it with mf yet, as you noticed. :-) I did write a BMM150 mag driver, did you get it to work? Also, there is still a todo go get both the pmw3901 and bmi270 to work at the same time. They are both on the same spi bus, the current code expects the imu to be the only sensor on the bus... |
|
I tested moving the who_am_i check immediately before the soft reset and it works. I will update the PR. Regarding pmw3901 and bmi270 I didn't test it in detail, but e.g when connecting to BF configurator and moving the quad the rendered BF configurator gltf model for displaying IMU sometimes hangs for some millsecs. |
|
The BMI270 is accessed by a high priority task, which will preempt the low priority PMW3901 sensor task. As the BMI is running at a 10 times higher rate it will sort of work, but really a locking or synchronizing mechanism is needed here. Better disable the PMW for now... Thanks for the PR and the BMM150 fix, keep those fixes coming! |
Testing on m5stampfly the BMI270 IMU is not recognized due to failed who_am_i() returning 255, rather than the ID 0x24. This problem is caused because who_am_i() is called before soft reset and SPI toggle.
** Without patch **
** With patch **