cancel
Showing results for 
Search instead for 
Did you mean: 

Error compiling ToF sensor drivers on Linux - VL53L4CX

Frooney
Associate

I am trying to compile the drivers for the ToF sensor: VL53L4CX for an embedded Linux application. I am running Ubuntu 22.04. When I try to make the drivers I get the following error:

 

 

 

CONFIG_STMVL53LX=m make -C /lib/modules/`uname -r`/build M=$PWD
make[1]: Entering directory '/usr/src/linux-headers-6.5.0-15-generic'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  You are using:           gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  CC [M]  /home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.o
/home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.c:567:19: error: initialization of ‘int (*)(struct i2c_client *)’ from incompatible pointer type ‘int (*)(struct i2c_client *, const struct i2c_device_id *)’ [-Werror=incompatible-pointer-types]
  567 |         .probe  = stmvl53lx_probe,
      |                   ^~~~~~~~~~~~~~~
/home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.c:567:19: note: (near initialization for ‘stmvl53lx_driver.<anonymous>.probe’)
/home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.c:568:19: error: initialization of ‘void (*)(struct i2c_client *)’ from incompatible pointer type ‘int (*)(struct i2c_client *)’ [-Werror=incompatible-pointer-types]
  568 |         .remove = stmvl53lx_remove,
      |                   ^~~~~~~~~~~~~~~~
/home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.c:568:19: note: (near initialization for ‘stmvl53lx_driver.remove’)
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:251: /home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx/stmvl53lx_module-i2c.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.5.0-15-generic/Makefile:2037: /home/USERNAME/programs/VL53L4CX_LinuxDriver_1.1.2_bare_1.2.8/driver/vl53Lx] Error 2
make[1]: *** [Makefile:234: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.5.0-15-generic'
make: *** [Makefile:8: default] Error 2

 

 

 

 

It seems that I am using a very similar but slightly different compiler version, but I wouldn't think that it should matter as its the same major version. I am getting a type error within the driver code.
Does anyone know how I can remedy this? I can't seem to find this x86_64-linux-gnu-gcc-12 version to try it with.
Thanks for your help

1 ACCEPTED SOLUTION

Accepted Solutions
John E KVAM
ST Employee

Installing drivers into the Kernel is not for the faint of heart. 

But do you need to?

If you are building something where you don't want some user's code to gain access to the I2C bus then you have to create a kernel driver.  

But if you don't allow user code onto your system, you can run the sensor as a user app and bypass this problem. 

The job of the kernel driver is to make it so a user application can access the VL53L device via i2c with exposing other devices on that bus. The kernel can verify that the transaction is valid and talking to a legitimate device - as opposed to trying to read system EEPROM or something. 

User apps are a lot easier - just download the API from ST.com and make the platform.c functions work for Linux. Or you can simply search GitHub for Linux applications. They will have working Platform.c files.

That code was verified on a Raspberry Pi, and different versions of Linux are going to be slightly different. 

I googled "ubunto struct i2c_client" and saw several articles that might shed some light on the issue. 

Sorry I cannot help more.

- john

 


Our community relies on fruitful exchanges and good quality content. You can thank and reward helpful and positive contributions by marking them as 'Accept as Solution'. When marking a solution, make sure it answers your original question or issue that you raised.

ST Employees that act as moderators have the right to accept the solution, judging by their expertise. This helps other community members identify useful discussions and refrain from raising the same question. If you notice any false behavior or abuse of the action, do not hesitate to 'Report Inappropriate Content'

View solution in original post

1 REPLY 1
John E KVAM
ST Employee

Installing drivers into the Kernel is not for the faint of heart. 

But do you need to?

If you are building something where you don't want some user's code to gain access to the I2C bus then you have to create a kernel driver.  

But if you don't allow user code onto your system, you can run the sensor as a user app and bypass this problem. 

The job of the kernel driver is to make it so a user application can access the VL53L device via i2c with exposing other devices on that bus. The kernel can verify that the transaction is valid and talking to a legitimate device - as opposed to trying to read system EEPROM or something. 

User apps are a lot easier - just download the API from ST.com and make the platform.c functions work for Linux. Or you can simply search GitHub for Linux applications. They will have working Platform.c files.

That code was verified on a Raspberry Pi, and different versions of Linux are going to be slightly different. 

I googled "ubunto struct i2c_client" and saw several articles that might shed some light on the issue. 

Sorry I cannot help more.

- john

 


Our community relies on fruitful exchanges and good quality content. You can thank and reward helpful and positive contributions by marking them as 'Accept as Solution'. When marking a solution, make sure it answers your original question or issue that you raised.

ST Employees that act as moderators have the right to accept the solution, judging by their expertise. This helps other community members identify useful discussions and refrain from raising the same question. If you notice any false behavior or abuse of the action, do not hesitate to 'Report Inappropriate Content'