2416787_en-US

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2416787_en-US

2416787_en-US

Enable SPI Communication for VL53L8CX ToF Sensor on i.MX8MP EVK

We are trying to integrate an ST VL53L8CX ToF (Time-of-Flight) sensor over SPI on an NXP i.MX8MP LPDDR4 EVK using Yocto Linux.

The objective is initially to achieve basic SPI communication and successfully detect the VL53L8CX device from a custom Linux kernel driver. Full ranging functionality is not required at this stage.

Hardware

  • Board: NXP i.MX8MP LPDDR4 EVK
  • Sensor: VL53L8CX ToF sensor
  • Interface: SPI
  • EVK connector: J21 expansion connector
  • SPI controller: ECSPI2
  • Chip select: ECSPI2 SS0
  • GPIO used for CS: GPIO5_IO13
  • SPI device: spi1.0
  • SPI speed: 1 MHz
  • SPI mode: Mode 0


    The device-tree configuration currently uses:

     
    &ecspi2 {
            pinctrl-0 = <&pinctrl_ecspi2 &pinctrl_ecspi2_cs>;
            cs-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>;
            status = "okay";
    
            stmvl53l8cx: spi@0 {
                    reg = <0>;
                    compatible = "st,stmvl53l8cx";
                    spi-max-frequency = <1000000>;
            };
    };
    meta-vl53l8cx_8mp/
    ├── conf/
    │ └── layer.conf
    ├── recipes-kernel/
    │ ├── linux/
    │ │ ├── files/
    │ │ │ └── 0001-add-vl53l8cx-spi-node.patch
    │ │ └── linux-imx_%.bbappend
    │ │
    │ └── vl53l8cx/
    │ ├── files/
    │ │ ├── Makefile
    │ │ └── driver.c
    │ └── vl53l8cx.bb


The SPI device is successfully created:

 
root@imx8mp-lpddr4-evk:~# ls -l /sys/bus/spi/devices/

spi0.0
spi1.0
 

The custom driver is also registered:

 
root@imx8mp-lpddr4-evk:~# ls -l /sys/bus/spi/drivers/

stmvl53l8cx
 

The driver probe() function is being called successfully.

Could someone please advise what we should verify on the i.MX8MP EVK ECSPI2/J21 hardware and Device Tree configuration to make sure the VL53L8CX is communicating correctly over SPI?

In particular, we would like to confirm:

  1. Is ECSPI2 / spi1.0 the correct SPI controller/device for the J21 expansion connector on the i.MX8MP LPDDR4 EVK?
  2. Is GPIO5_IO13 / ECSPI2_SS0 the correct chip-select for J21?
  3. Are the ECSPI2 SCK, MOSI, MISO and CS pinmux settings correct for this connector?
  4. Is any additional Device Tree configuration required for the VL53L8CX, such as:
    • spi-cpol
    • spi-cpha
    • GPIO1/interrupt
    • LPn/reset/power GPIO
    • power-supply/regulator properties?
  5. Does the VL53L8CX require a particular SPI mode, timing, or initialization sequence before reading its device ID?
  6. Is there anything specific on the i.MX8MP ECSPI controller that needs to be configured for the VL53L8CX?
  7. Since spi_write() and spi_read() return 0, is there a recommended way to verify the actual MOSI/MISO electrical communication (for example with a logic analyzer) and determine whether the sensor is responding?

We have also attached our custom driver.c driver and kernel logs for reference.

Any guidance on the correct i.MX8MP EVK + J21 + ECSPI2 + VL53L8CX SPI configuration would be appreciated.

I have attached custom driver file driver.c
also I have attached logs

Thank you.


Re: Enable SPI Communication for VL53L8CX ToF Sensor on i.MX8MP EVK

Hello @Manuel_Salas 

Thank you for your response.

We tried reading the device ID before proceeding with any further configuration. However, we are not able to read the device ID successfully.

Our SPI driver is probing correctly, but the register read for the chip ID does not return the expected value. Because of this, we are unable to verify communication with the VL53L8CX and cannot proceed with the sensor initialization.

We are currently checking our SPI configuration, device tree, and hardware connections to identify the issue.

We will also attach our driver, logs and module image so you can review it. If you have any suggestions on what else we should verify for basic SPI communication with the VL53L8CX, we would greatly appreciate your guidance.

Best regards,
yogi96

Re: Enable SPI Communication for VL53L8CX ToF Sensor on i.MX8MP EVK

Hello @yogi96 

Hope you are doing very well.


In general, all your steps looks good.

The next step what yocan try is read any register of the sensor, for example, in your probe() function, read the ID from the chip.

If ID is correct read, continue with the configuration.


Also, I could not saw the driver attached.

Please attach is possible.


Best regards,

Salas.

Tags (1)
No ratings
Version history
Last update:
Tuesday
Updated by: