Hello Devzone Community,
I'm a couple weeks into learning, working with Nordic ncs, Zephyr RTOS and west and friends. I'm working on an out-of-tree driver, and am stuck at an early during build error relating to the flag which enables the new sensor driver I'm writing. I'm working up code to configure and read data from Kionix KX132 accelerometer. The error I get is:
~/ncs/zephyr/samples/sandbox-de-ted/kionix-work/app/prj.conf:16: warning: attempt to assign the value 'y' to the undefined symbol KX132_1211
I have high confidence that I have installed Nordic's ncs v1.6.1 SDK, and a toolchain correctly. I can build and run multiple sample apps from 'ncs/zephyr/samples', where 'ncs' is the root directory of the SDK, the location in which I run 'west init', 'west export-zephyr' and 'west update'. I started my driver work by copying sample/basic/blinky and adding to that. I successfully combined blinky with 'hello world' so I have a one-way UART for messages and very limited debugging.
I've made two forays into device driver in-tree work. First I followed the directory and file layout of a good tutorial posted at Memfault site: https://interrupt.memfault.com/blog/building-drivers-on-zephyr. From this tutorial I created a dir structure like:
app-for-new-driver
|
+-+--------+----------+------------+
| | | |
drivers src app.overlay zephyr
| |
kionix module.yml
|
kx132-1211
There are CMakeLists.txt and Kconfig files in most of these directories, and specifically all the dirs under the 'drivers' directory. Somehow though it appears that the build process is not finding the Kconfig in directory 'kx132-1211', a file which contains:
# SPDX-License-Identifier: Apache-2.0
config KX132_1211
bool "KX132-1211 accelerometer"
depends on I2C
help
Enable Kionix KX132-1211 accelerometer
The line 'config KX132_1211' is supposed to generate a symbol early enough in the build process, such that cmake and related tools know to compile my in-tree driver. I've also tried to follow the information at https://docs.zephyrproject.org/latest/application/index.html. This document links to an example "out of tree driver" app at github: https://github.com/zephyrproject-rtos/example-application.
I cloned this example application, which entails a driver named 'EXAMPLESENSOR', into the same location where I've successfully built ncs sample apps. Building this example app, however, results in the same error:
ncs/zephyr/samples/sandbox-de-ted/example-application/app/prj.conf:7: warning: attempt to assign the value 'y' to the undefined symbol EXAMPLESENSOR
Before building this unchanged sample project I had earlier in the day restructured my Kionix driver app to have a directory tree like 'example application':
app-for-new-driver
|
+-+---------------+-------------+
| | |
drivers app zephyr
| | |
kionix +---+---+ module.yml
| | |
kx132-1211 src board
|
app.overlay
Again I have placed CMakeLists.txt files and Kconfig files in all the dirs where the two tutorials + examples show them present.
Can anyone share with me a open source, publicly available "out of tree driver" Zephyr example app? Can anyone share a document which more clearly explains the config file requirements to successfully create, and have parsed at the right build time, a new sensor driver flag of the form "CONFIG_<NEW_DRIVER_NAME>"?
- Ted