Skip to content

[WIP] [HELP NEEDED] Fix QMC6309 on LSM6DSO over SPIM - #166

Open
meganukebmp wants to merge 2 commits into
SlimeVR:mainfrom
meganukebmp:main
Open

meganukebmp wants to merge 2 commits into
SlimeVR:mainfrom
meganukebmp:main

Conversation

@meganukebmp

Copy link
Copy Markdown

The LSM6DSO driver was evidently just a find and replace job of the LSM6DSV driver and thus had some inconsistencies and things that were plain out wrong.

Most importantly that it never actually ran the while loop since status was initialized to 0.

Currently this sort of works but is not really properly functional

scan
[00:00:10.948,516] <inf> sensor: Stopped sensor thread
[00:00:10.948,547] <inf> sensor: Requested sensor scan
[00:00:10.948,608] <inf> sensor: IMU address: 0x00, register: 0xFF
[00:00:10.948,730] <inf> sensor: Magnetometer address: 0xFF, register: 0xFF
[00:00:10.948,730] <inf> sensor: Scanning SPI bus for IMU
[00:00:10.948,730] <dbg> sensor_scan_spi: sensor_scan_spi: Scanning register: 0x80
[00:00:10.948,822] <dbg> sensor_scan_spi: sensor_scan_spi: err: 0
[00:00:10.948,822] <dbg> sensor_scan_spi: sensor_scan_spi: Read value: 0xFF, 0x00, 0x00 (0x00)
[00:00:10.948,852] <dbg> sensor_scan_spi: sensor_scan_spi: Scanning register: 0xF2
[00:00:10.948,913] <dbg> sensor_scan_spi: sensor_scan_spi: err: 0
[00:00:10.948,944] <dbg> sensor_scan_spi: sensor_scan_spi: Read value: 0xFF, 0x00, 0x00 (0x00)
[00:00:10.948,944] <dbg> sensor_scan_spi: sensor_scan_spi: Scanning register: 0xF5
[00:00:10.949,035] <dbg> sensor_scan_spi: sensor_scan_spi: err: 0
[00:00:10.949,035] <dbg> sensor_scan_spi: sensor_scan_spi: Read value: 0xFF, 0x00, 0x00 (0x00)
[00:00:10.949,035] <dbg> sensor_scan_spi: sensor_scan_spi: Scanning register: 0x8F
[00:00:10.949,127] <dbg> sensor_scan_spi: sensor_scan_spi: err: 0
[00:00:10.949,127] <dbg> sensor_scan_spi: sensor_scan_spi: Read value: 0xFF, 0x6B, 0x48 (0x6B)
[00:00:10.949,127] <inf> sensor_scan_spi: Valid device found using register: 0x8F (value: 0x6B)
[00:00:10.949,157] <inf> sensor: Found LSM6DSR/ISM330DHCX
[00:00:10.949,188] <inf> sensor: Scanning bus for magnetometer through IMU I2CM
[00:00:10.949,188] <wrn> sensor: No magnetometer detected
[00:00:10.949,920] <inf> status: Cleared status: 1
[00:00:10.949,951] <inf> status: Status: 24
[00:00:10.950,012] <inf> sensor: Started sensor loop
[00:00:10.950,073] <inf> sensor: Sensor init, shutdown first
[00:00:10.951,232] <inf> sensor: Sensor clock rate: 32768.00Hz
[00:00:10.951,263] <inf> sensor: Accelerometer range: 4.00g
[00:00:10.951,263] <inf> sensor: Gyroscope range: 1000.00dps
[00:00:10.952,026] <inf> sensor: Requested SPI frequency: 10.00MHz
[00:00:10.952,056] <inf> sensor: Accelerometer initial rate: 111.51Hz
[00:00:10.952,056] <inf> sensor: Gyrometer initial rate: 223.02Hz
[00:00:10.952,087] <inf> sensor: Initialized sensors
[00:00:10.952,087] <inf> sensor: Accelerometer matrix:
[00:00:10.952,087] <inf> sensor: 0.00000 1.00000 0.00000 0.00000
[00:00:10.952,117] <inf> sensor: 0.00000 0.00000 1.00000 0.00000
[00:00:10.952,117] <inf> sensor: 0.00000 0.00000 0.00000 1.00000
[00:00:10.952,148] <inf> sensor: Gyroscope bias: 0.00000 0.00000 0.00000
[00:00:10.952,423] <inf> sensor: Using VQF
[00:00:10.952,423] <inf> sensor: Initialized fusion
[00:00:10.952,728] <wrn> sensor: No packets in buffer
[00:00:10.983,612] <inf> sensor: Switching sensors to low noise
[00:00:11.785,705] <inf> sensor: No motion from sensors in 500ms
[00:00:11.790,161] <inf> sensor: Switching sensors to low power
scan
[00:00:12.659,545] <inf> sensor: Stopped sensor thread
[00:00:12.659,576] <inf> sensor: Requested sensor scan
[00:00:12.659,729] <inf> sensor: IMU address: 0x00, register: 0xFF
--- 11 messages dropped ---
[00:00:12.673,706] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x00
--- 26 messages dropped ---
[00:00:12.816,619] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x40
--- 13 messages dropped ---
[00:00:12.887,725] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x00
--- 12 messages dropped ---
[00:00:12.940,643] <dbg> sensor_scan_ext: sensor_scan_ext: Read value: 0x00
[00:00:12.940,673] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning address: 0x1C
[00:00:12.940,704] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x00
[00:00:12.958,679] <dbg> sensor_scan_ext: sensor_scan_ext: Read value: 0x00
[00:00:12.958,709] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x0F
[00:00:12.976,715] <dbg> sensor_scan_ext: sensor_scan_ext: Read value: 0x00
[00:00:12.976,745] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning address: 0x1E
[00:00:12.976,776] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x0A
[00:00:12.994,659] <dbg> sensor_scan_ext: sensor_scan_ext: Read value: 0x00
[00:00:12.994,689] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x0F
[00:00:13.012,695] <dbg> sensor_scan_ext: sensor_scan_ext: Read value: 0x00
[00:00:13.012,725] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x4F
[00:00:13.030,639] <dbg> sensor_scan_ext: sensor_scan_ext: Read value: 0x00
[00:00:13.030,670] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning address: 0x30
[00:00:13.030,822] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x20
[00:00:13.047,729] <dbg> sensor_scan_ext: sensor_scan_ext: Read value: 0x00
[00:00:13.047,729] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x2F
[00:00:13.065,734] <dbg> sensor_scan_ext: sensor_scan_ext: Read value: 0x00
[00:00:13.065,765] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x39
[00:00:13.083,679] <dbg> sensor_scan_ext: sensor_scan_ext: Read value: 0x00
[00:00:13.083,679] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning address: 0x3C
[00:00:13.083,709] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x00
[00:00:13.101,623] <dbg> sensor_scan_ext: sensor_scan_ext: Read value: 0x00
[00:00:13.101,654] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning address: 0x7C
[00:00:13.101,684] <dbg> sensor_scan_ext: sensor_scan_ext: Scanning register: 0x00
[00:00:13.119,689] <dbg> sensor_scan_ext: sensor_scan_ext: Read value: 0x90
[00:00:13.119,689] <inf> sensor_scan_ext: Valid device found at address: 0x7C (register: 0x00, value: 0x90)
[00:00:13.119,750] <inf> sensor: Found QMC6309
[00:00:13.120,178] <inf> status: Cleared status: 1
[00:00:13.120,178] <inf> status: Status: 24
[00:00:13.120,361] <inf> sensor: Started sensor loop
[00:00:13.120,422] <inf> sensor: Sensor init, shutdown first
[00:00:13.138,122] <inf> sensor: Sensor clock rate: 32768.00Hz
[00:00:13.138,244] <inf> sensor: Accelerometer range: 4.00g
[00:00:13.138,275] <inf> sensor: Gyroscope range: 1000.00dps
[00:00:13.139,068] <inf> sensor: Requested SPI frequency: 10.00MHz
[00:00:13.139,099] <inf> sensor: Accelerometer initial rate: 111.51Hz
[00:00:13.139,343] <inf> sensor: Gyrometer initial rate: 223.02Hz
[00:00:13.149,658] <err> LSM6DSO: lsm6dso_ext_write: Write timeout
[00:00:13.157,684] <err> QMC6309: qmc_update_odr: Communication error
[00:00:13.157,714] <inf> sensor: Magnetometer initial rate: 10.00Hz
[00:00:13.157,745] <err> status: set_status: Sensor communication error
[00:00:13.157,897] <inf> status: Status: 25
[00:00:13.175,628] <wrn> QMC6309: Data not ready
[00:00:13.176,025] <wrn> sensor: Expected 7 timesteps, got 4
[00:00:13.219,207] <wrn> sensor: Sensor interrupt timeout
[00:00:13.220,001] <inf> sensor: Switching sensors to low noise
[00:00:13.220,886] <wrn> sensor: Expected 7 timesteps, got 14
[00:00:13.291,687] <wrn> QMC6309: Data not ready
[00:00:13.309,600] <wrn> QMC6309: Data not ready
[00:00:13.309,844] <wrn> sensor: Expected 1 timestep, got 3
[00:00:13.327,850] <wrn> QMC6309: Data not ready
[00:00:13.328,247] <wrn> sensor: Expected 1 timestep, got 4
--- 7 messages dropped ---
[00:00:13.399,017] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.416,625] <wrn> QMC6309: Data not ready
[00:00:13.417,022] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.434,783] <wrn> QMC6309: Data not ready
[00:00:13.435,058] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.451,721] <wrn> QMC6309: Data not ready
[00:00:13.452,026] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.469,635] <wrn> QMC6309: Data not ready
[00:00:13.469,909] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.487,670] <wrn> QMC6309: Data not ready
[00:00:13.487,915] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.505,645] <wrn> QMC6309: Data not ready
[00:00:13.505,920] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.523,590] <wrn> QMC6309: Data not ready
[00:00:13.523,864] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.541,748] <wrn> QMC6309: Data not ready
[00:00:13.542,144] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.558,685] <wrn> QMC6309: Data not ready
[00:00:13.559,051] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.576,629] <wrn> QMC6309: Data not ready
[00:00:13.576,995] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.594,665] <wrn> QMC6309: Data not ready
[00:00:13.595,062] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.612,731] <wrn> QMC6309: Data not ready
[00:00:13.613,006] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.630,706] <wrn> QMC6309: Data not ready
[00:00:13.630,981] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.648,681] <wrn> QMC6309: Data not ready
[00:00:13.648,986] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.665,618] <wrn> QMC6309: Data not ready
[00:00:13.665,893] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.683,624] <wrn> QMC6309: Data not ready
[00:00:13.683,898] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.701,629] <wrn> QMC6309: Data not ready
[00:00:13.701,904] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.719,757] <wrn> QMC6309: Data not ready
[00:00:13.720,031] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.737,731] <wrn> QMC6309: Data not ready
[00:00:13.738,128] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.738,159] <inf> sensor: No motion from sensors in 500ms
[00:00:13.756,103] <wrn> QMC6309: Data not ready
[00:00:13.756,408] <inf> sensor: Switching sensors to low power
[00:00:13.757,537] <wrn> sensor: Expected 1 timestep, got 4
[00:00:13.774,230] <wrn> QMC6309: Data not ready
[00:00:13.775,024] <wrn> sensor: Expected 7 timesteps, got 4
[00:00:13.800,018] <wrn> QMC6309: Data not ready
[00:00:13.835,937] <wrn> QMC6309: Data not ready
[00:00:13.863,006] <wrn> QMC6309: Data not ready
[00:00:13.898,101] <wrn> QMC6309: Data not ready
[00:00:13.925,170] <wrn> QMC6309: Data not ready
[00:00:13.961,029] <wrn> QMC6309: Data not ready
[00:00:13.988,098] <wrn> QMC6309: Data not ready
[00:00:14.022,918] <wrn> QMC6309: Data not ready
[00:00:14.049,957] <wrn> QMC6309: Data not ready
[00:00:14.086,090] <wrn> QMC6309: Data not ready
[00:00:14.112,243] <wrn> QMC6309: Data not ready
[00:00:14.148,010] <wrn> QMC6309: Data not ready
[00:00:14.335,083] <wrn> QMC6309: Data not ready
[00:00:14.362,121] <wrn> QMC6309: Data not ready
[00:00:14.398,101] <wrn> QMC6309: Data not ready
[00:00:14.424,011] <wrn> QMC6309: Data not ready
[00:00:14.460,113] <wrn> QMC6309: Data not ready
[00:00:14.487,243] <wrn> QMC6309: Data not ready
[00:00:14.523,406] <wrn> QMC6309: Data not ready
[00:00:14.549,133] <wrn> QMC6309: Data not ready
[00:00:14.584,930] <wrn> QMC6309: Data not ready
[00:00:14.612,030] <wrn> QMC6309: Data not ready
[00:00:14.646,911] <wrn> QMC6309: Data not ready
[00:00:14.674,346] <wrn> QMC6309: Data not ready
[00:00:14.710,083] <wrn> QMC6309: Data not ready
[00:00:14.737,182] <wrn> QMC6309: Data not ready
[00:00:14.772,003] <wrn> QMC6309: Data not ready
[00:00:14.798,950] <wrn> QMC6309: Data not ready
[00:00:14.833,923] <wrn> QMC6309: Data not ready
[00:00:14.861,083] <wrn> QMC6309: Data not ready
[00:00:14.897,094] <wrn> QMC6309: Data not ready
[00:00:14.924,163] <wrn> QMC6309: Data not ready
[00:00:14.959,991] <wrn> QMC6309: Data not ready
[00:00:14.985,900] <wrn> QMC6309: Data not ready
[00:00:15.022,155] <wrn> QMC6309: Data not ready
[00:00:15.048,065] <wrn> QMC6309: Data not ready
[00:00:15.084,197] <wrn> QMC6309: Data not ready
[00:00:15.085,510] <wrn> sensor: Last update steps took up to 35 ms
[00:00:15.111,175] <wrn> QMC6309: Data not ready
[00:00:15.147,003] <wrn> QMC6309: Data not ready
[00:00:15.172,882] <wrn> QMC6309: Data not ready
[00:00:15.209,014] <wrn> QMC6309: Data not ready
[00:00:15.236,145] <wrn> QMC6309: Data not ready
[00:00:15.271,331] <wrn> QMC6309: Data not ready
[00:00:15.294,982] <err> calibration: sensor_wait_mag: Magnetometer wait timed out
[00:00:15.297,668] <wrn> QMC6309: Data not ready
[00:00:15.334,014] <wrn> QMC6309: Data not ready
[00:00:15.360,961] <wrn> QMC6309: Data not ready
[00:00:15.396,026] <wrn> QMC6309: Data not ready
[00:00:15.423,095] <wrn> QMC6309: Data not ready
[00:00:15.459,167] <wrn> QMC6309: Data not ready
[00:00:15.486,083] <wrn> QMC6309: Data not ready
[00:00:15.521,087] <wrn> QMC6309: Data not ready
[00:00:15.547,943] <wrn> QMC6309: Data not ready
[00:00:15.584,075] <wrn> QMC6309: Data not ready
[00:00:15.610,168] <wrn> QMC6309: Data not ready
[00:00:15.646,209] <wrn> QMC6309: Data not ready
[00:00:15.673,095] <wrn> QMC6309: Data not ready
[00:00:15.708,068] <wrn> QMC6309: Data not ready
[00:00:15.735,015] <wrn> QMC6309: Data not ready
[00:00:15.770,965] <wrn> QMC6309: Data not ready
[00:00:15.797,180] <wrn> QMC6309: Data not ready
[00:00:15.833,923] <wrn> QMC6309: Data not ready
[00:00:15.860,260] <wrn> QMC6309: Data not ready
[00:00:15.896,057] <wrn> QMC6309: Data not ready
[00:00:15.921,936] <wrn> QMC6309: Data not ready
[00:00:15.957,885] <wrn> QMC6309: Data not ready

It appears the whole thing times out during initial scan and subsequent scans and only after rescanning a few times do the stars align for detection (which prior to this never happened). The data rate I believe never gets set so we get low frequency on the QMC6309 while trying to poll at a substantially higher rate.

I am requesting for help since I simply don't have the time to work on this fully.

…0_numop, which specifies the number of read operations. Its valid field values are 0–7.
@Eirenliel
Eirenliel requested a review from sctanf October 24, 2026 16:00
@OstlerDev

OstlerDev commented Oct 25, 2026 •

Copy link
Copy Markdown

It seems like the imu and mag are not communicating properly and that the actual setup of the mag isn't working right. Specifically I am wondering if the nack flag is getting set on the sensorhub status reg, since I do see the write communications timing out (which your code changes try to address and also you are aware of with the sensor data rate not working).

[00:00:13.149,658] <err> LSM6DSO: lsm6dso_ext_write: Write timeout
[00:00:13.157,684] <err> QMC6309: qmc_update_odr: Communication error

Some high value logs to add would just be to log the latest status response so that the register value can be inspected to determine where in the communication chain it is failing. It obviously can detect the sensor on the bus, but the writes don't seem to be working.

I did review the DSO datasheet and everything does look to be the same for the sensorhub registers/implementation as the DSV, so I am unsure why it wouldn't be working. I can try to take a deeper look tomorrow if it's helpful, but it is difficult to diagnose what is happening since I don't have the same hardware in front of me.

@OstlerDev

Copy link
Copy Markdown

What sensor module are you using, and how is it connected to the NRF?

It could even be something like a bad data line between the imu and mag on sdx or scx. The main thing that makes me question if it is a hardware issue is the inconsistency in the sensor detection, like when you mention that it takes multiple cycles for the mag to be detected. Does the IMU get detected consistently and it is just the communication between imu and mag?

@meganukebmp

Copy link
Copy Markdown
Author

What sensor module are you using, and how is it connected to the NRF?

It could even be something like a bad data line between the imu and mag on sdx or scx. The main thing that makes me question if it is a hardware issue is the inconsistency in the sensor detection, like when you mention that it takes multiple cycles for the mag to be detected. Does the IMU get detected consistently and it is just the communication between imu and mag?

Its a standard stacked smol with a Mumo board from Deyta. The IMU has zero issues, its only the magnetometer. The magnetometer is properly connected as far as I'm aware and all of my (20) slimes exhibit this. Its definitely a software issue. Prior to this patch it would not communicate with the magnetometer at all due to logic issues. Its very likely that the timings and error handling are wrong among other things. A lot of the current code seems to be fire and forget without delays or checks.

The initial discovery likely fails because of all of this as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants