- Edited
Hi all,
I made the following post on devzone but perhaps this is a better place to begin:
https://devzone.nordicsemi.com/f/nordic-q-a/106115/difficulty-creating-a-zephyr-based-nrfconnect-project-within-vscode-that-contains-a-custom-sensor-driver
Here’s my situation. I want to make a simple, stupid “hello world” like SPI driver for a sensor chip, for example the IIS3WDB SPI based vibration sensor so I can read accelerations, etc. This chip isn’t part of Zephyr’s library, so I want to use an out of tree method. I have VSCode, the nRF SDK (2.5.0 for SDK + toolchain). I tried cloning a Zephyr example application that includes device tree bindings for a fake driver called “examplesensor.”
git clone https://github.com/zephyrproject-rtos/example-application my-app, then opening the my-app/app folder and configuring the build chain.
I added an overlay to this app to enable “examplesensor0”.
/{
examplesensor0 {
compatible = "zephyr,examplesensor";
input-gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
};
The structure of my_app contains an “app” folder then the device tree/bindings and driver folders as well.
When I try to build the app it fails here:
../src/main.c: In function 'main':
/opt/nordic/ncs/v2.5.0/zephyr/include/zephyr/device.h:85:41: error: '__device_dts_ord_DT_N_NODELABEL_examplesensor0_ORD' undeclared (first use in this function)
however the overlay references examplesensor0.
Clearly this isn’t working off the bat.
Is there a working example project that is compatible with nRF SDK that contains an example application and external driver complete with dts bindings that one can simply download, open, and build that contains both an app and a drivers/sensor/mysensor? I don’t want to modify the Zephyr source and put my driver in the tree in my own branch, that doesn’t make sense.
In addition, what architecture/directory structure is most commonly used and easiest to configure? 1(A), 1(B), or 2?
(1) Package my app with my sensor driver, in which case do I put my app at the same level as the driver, or put the driver within my app directory
Example:
(A)
my_app
---app
---src
---drivers/sensor, yaml, dts, CMakelists,etc
or
(B)
my_app
---app
---src
---drivers/sensor,yaml,dts,CMakelists,etc
2: have an app workspace that is separate from custom sensor driver (how do you link that in?) and also separate from Zephyr and nRF SDK
Best,
Josh Karch