Hi all,
I want to update my application with the newer NCS 1.7.0 version. I've changed my west.yml, which containing only NCS-SDK as the only dependency. After running west update, I can't compile the vl52l0x sensor sample anymore. In Addition to the sample source, I have an overlay DTS file with a node for this sensor on my nrf9160dk board and this works fine in older version 1.6.0.
I wonder if there are some breaking changes from the device tree API? maybe the DTS syntax become more strict?
I've seen this issue (https://github.com/zephyrproject-rtos/zephyr/issues/32139) warning about using instance-based API. So I used this for my sample:
const struct device *dev = device_get_binding(DT_LABEL(DT_NODELABEL(lidar)));
Still, for the newer NSC version, it didn't work as well.
Please help. Thank you all in advance!
Here are the sources:
sample_folder/src/main.c:
/*
* Copyright (c) 2017 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <device.h>
#include <drivers/sensor.h>
#include <stdio.h>
#include <sys/printk.h>
void main(void) {
const struct device *dev = device_get_binding(DT_LABEL(DT_NODELABEL(lidar)));
//const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, st_vl53l0x)));
struct sensor_value value;
int ret;
if (dev == NULL) {
printk("Could not get VL53L0X device\n");
return;
}
while (1) {
ret = sensor_sample_fetch(dev);
if (ret) {
printk("sensor_sample_fetch failed ret %d\n", ret);
return;
}
ret = sensor_channel_get(dev, SENSOR_CHAN_PROX, &value);
printk("prox is %d\n", value.val1);
ret = sensor_channel_get(dev, SENSOR_CHAN_DISTANCE, &value);
printf("distance is %.3fm\n", sensor_value_to_double(&value));
k_sleep(K_MSEC(1000));
}
}
sample_folder/prj.conf:
CONFIG_STDOUT_CONSOLE=y CONFIG_I2C=y CONFIG_GPIO=y CONFIG_SENSOR=y CONFIG_VL53L0X=y CONFIG_VL53L0X_PROXIMITY_THRESHOLD=100 #debug #CONFIG_DEBUG=y #CONFIG_LOG=y #CONFIG_SENSOR_LOG_LEVEL_DBG=y CONFIG_CBPRINTF_FP_SUPPORT=y
sample_folder/boards/nrf9160dk_nrf9160ns.overlay :
&i2c2 {
lidar: vl53l0x@29 {
compatible = "st,vl53l0x";
reg = <0x29>;
label = "VL53L0X";
status = "okay";
};
};
my_project_root/west.yml:
manifest:
remotes:
# short names for project URLs
- name: nrf-connect-sdk
url-base: https://github.com/nrfconnect
projects:
# a list of projects managed by west
- name: sdk-nrf
remote: nrf-connect-sdk
path: nrf
revision: v1.7.0
import: true
# defaults:
# default project attributes
self:
# configuration related to the manifest repository itself,
# i.e. the repository containing west.yml
# --when excecute: west init -m git@some_git_repo.git --mr some_git_tag
# will clone some_git_repo to this path and init .west/ to its parent
# folder
path: my_project_root
version: "0.10"
# group-filter:
# a list of project groups to enable or disable