This is an old revision of the document!


Laboratorul 04.

Presentation

Practical lab

Exercise 1

Step 1 - Create the hardware setup

Enable I2C proximity sensor vl53l.

Identify GND, VCC, I2C_SCL and I2C_SDA data lines on expansion header and connect the sensor accordingly.

.

Setup should look like this:

setup1.jpeg.

Step 2 - Find a proper Linux kernel driver

Look inside ~/work/nss-linux/drivers/iio and find a proper driver for vl53l sensor. Use git grep vl53l. Once you find the correct source file look inside the driver and remember the compatible string.

Once you found the driver, use make menuconfig and select it to be compiled as a module. <M>

Step 3 - Create a proper device tree node

Look inside arch/arm64/boot/dts/freescale/imx8mq-pico-pi.dts and add your node under i2c3 node.

Your node should look like this:

&i2c3 {
       proximity-sensor@XX {
           compatible = <compatible-you-found-in-the-driver>;
           reg =<XX>;
           pinctrl-0 = <&pinctrl_prox>;
           status = "okay";
       };
};

XX - is the address of the I2C device. There are two ways of finding this. You can dig inside the datasheet and confirm the address by scanning for devices on i2c3 node on the hardware. Use i2cdetect -y 2.

Step 4 Load the driver & read the distance measured by sensor

Once the device tree is ready, recompile the kernel and boot the board. On the board, use modprobe <driver-name> to load the driver. If everything goes well the driver will be correctly loaded and you will be able to read data.

$ modprobe vl53l0x-i2c
$ cat /sys/bus/
lkd/laboratoare/04.1720701751.txt.gz ยท Last modified: 2024/07/11 15:42 by daniel.baluta
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0