Skip to main content
OKN
Associate III
Oct 21, 2026 7:17 AM UTC
Solved

[STM32MP257F]  Using the ToF Sensor (VL53L5CX) with OpenSTLinux

Hello

 

I’m planning to try using the ToF sensor (VL53L5CX) on the B-CAMS-IMX (MB1854B) with OpenSTLinux on the STM32MP257F.

Looking at the kernelconfig,
> Device Drivers > Industrial I/O support > Proximity and distance sensors
lists “STMicroelectronics VL53L0X ToF ranger sensor (I2C)”;

 

can I use the VL53L5CX with this driver?

 

Or would it be better to use this driver instead?

Linux driver for VL53L5CX multi-zone sensor

 

For now, before I set up a device driver,
I’m planning to try accessing it via the I2C driver using Ultra Lite Driver (ULD) for VL53L5CX multi-zone sensor

 

Best Regards,

--
okn

John_KvamBest answer
Graduate
Oct 21, 2026 4:51 PM UTC

The VL53L5 (L5) is significantly different from the VL53L0. There are a lot of years and a lot of flexibility between them. 

First the L0 uses single byte I2C register addresses - and a page register. Not ST’s fault. They built the chip basically to one customer’s specification, and he thought it was too much hassle to have a different I2C driver that uses 2-byte register addresses. But there are a LOT of registers, and this was a real problem. So ST fixed the issue on the VL53L1 and beyond. 

There are a lot of reasons the old driver won’t work for the new parts, but this is the biggest issue.

So you have two choices.   

If your device is closed enough that you don’t need to protect the devices on the I2C bus from users, you can address the sensor with user mode I2C commands. Just download the driver from ST.com and change the functions in platform.c to issue Linux I2C reads and writes. 

But if you are building something like a cell phone, and you really don’t want user mode routines to have access to your I2C bus, you are going to have to work harder. 

But it’s been done before. 

There is a cool post from a guy - 

Where he published his work. You might be able to just take this. 

Or there are others on GitHub you can look at. 

But basically these drivers are installed at bootup and take requests from the usermode program and vet them to only allow control to the L5 on the I2C bus and basically protecting the other devices on the bus from harm. 

good luck - 

  • john
"If this or any post solves your issue, please mark them as ""Accept as Solution"". It really helps the next guy.And if you notice anything wrong do not hesitate to ""Report Inappropriate Content"".I am a recently retired ST Employee. My former username was John E KVAM."

4 replies

John_KvamBest answer
Graduate
Oct 21, 2026 4:51 PM UTC

The VL53L5 (L5) is significantly different from the VL53L0. There are a lot of years and a lot of flexibility between them. 

First the L0 uses single byte I2C register addresses - and a page register. Not ST’s fault. They built the chip basically to one customer’s specification, and he thought it was too much hassle to have a different I2C driver that uses 2-byte register addresses. But there are a LOT of registers, and this was a real problem. So ST fixed the issue on the VL53L1 and beyond. 

There are a lot of reasons the old driver won’t work for the new parts, but this is the biggest issue.

So you have two choices.   

If your device is closed enough that you don’t need to protect the devices on the I2C bus from users, you can address the sensor with user mode I2C commands. Just download the driver from ST.com and change the functions in platform.c to issue Linux I2C reads and writes. 

But if you are building something like a cell phone, and you really don’t want user mode routines to have access to your I2C bus, you are going to have to work harder. 

But it’s been done before. 

There is a cool post from a guy - 

Where he published his work. You might be able to just take this. 

Or there are others on GitHub you can look at. 

But basically these drivers are installed at bootup and take requests from the usermode program and vet them to only allow control to the L5 on the I2C bus and basically protecting the other devices on the bus from harm. 

good luck - 

  • john
"If this or any post solves your issue, please mark them as ""Accept as Solution"". It really helps the next guy.And if you notice anything wrong do not hesitate to ""Report Inappropriate Content"".I am a recently retired ST Employee. My former username was John E KVAM."
OKN
OKNAuthor
Associate III
Oct 22, 2026 4:20 AM UTC

Hello, ​@John_Kvam ,

Thank you for your reply.

For now, I just want to evaluate the ToF sensor, so I'll try using the Ultra Lite Driver provided by ST, as you advised.
 

Best Regards,

--

okuno

 

OKN
OKNAuthor
Associate III
Oct 29, 2026 2:22 AM UTC

Hello ​@John_Kvam 

 

I tried incorporating the fork version you provided into the kernel, but it didn't work properly.
I haven't investigated the cause yet, but not only did the probe fail, but other devices connected to the same I2C bus also stopped being probed.

For now, I incorporated the ST version of the device driver (2.0.0), and it worked.
However, the probe API wasn't compatible with Linux 6.6.48, so I fixed that.

Best Rgards,

--

okn

Graduate
Oct 22, 2026 3:40 PM UTC

If you are just getting started and are even the slightest bit worried about performance, I’d go directly to the VL54L8. It’s the same cost as the L5, and better in every way. It’s a couple years newer, and ST addressed most of the complaints they got on the L5. Does take another -different - power rail. So that could cost you. 

  • john
"If this or any post solves your issue, please mark them as ""Accept as Solution"". It really helps the next guy.And if you notice anything wrong do not hesitate to ""Report Inappropriate Content"".I am a recently retired ST Employee. My former username was John E KVAM."