Zephyr out of tree driver, not seen by west

239 views Asked by At

I have the following structure in my project of a out-of-tree driver for the TI's cc1101 sub-ghz transceiver:

h@Mint53:~/Documents/devel/Zephyr/cc1101$ tree -I zephyr -I build
.
├── app
│   ├── boards
│   │   ├── adafruit_feather_nrf52840.conf
│   │   ├── adafruit_feather_nrf52840.overlay
│   │   ├── adafruit_kb2040.conf
│   │   ├── adafruit_kb2040.overlay
│   │   ├── esp32.conf
│   │   └── esp32.overlay
│   ├── CMakeLists.txt
│   ├── Kconfig
│   ├── prj.conf
│   └── src
│       └── main.c
├── CMakeLists.txt
├── drivers
│   ├── cc1101
│   │   ├── cc1101.c
│   │   ├── cc1101_config.c
│   │   ├── cc1101_config.h
│   │   ├── cc1101_const.h
│   │   ├── cc1101.h
│   │   ├── cc1101_spi.c
│   │   ├── cc1101_spi.h
│   │   ├── cc1101_txrx.c
│   │   ├── cc1101_txrx.h
│   │   ├── CMakeLists.txt
│   │   └── Kconfig
│   └── CMakeLists.txt
├── dts
│   └── bindings
│       └── ti,cc1101.yaml
├── Kconfig
├── LICENSE
├── README.md
└── west.yml

7 directories, 28 files

When compiling, west doesn't seem to "see" the driver, but only the app:

(.venv) h@Mint53:~/Documents/devel/Zephyr/cc1101$ west build -d build/ada -b esp32  -p always app
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/happycactus/Documents/devel/Zephyr/cc1101/app
-- CMake version: 3.22.1
-- Found Python3: /home/happycactus/Documents/devel/Zephyr/.venv/bin/python3.10 (found suitable exact version "3.10.12
...
/../../xtensa-espressif_esp32_zephyr-elf/bin/ld.bfd: /home/happycactus/Documents/devel/Zephyr/cc1101/app/src/main.c:72: undefined reference to `cc1101_get_reg'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/happycactus/Documents/devel/Zephyr/cc1101/build/ada

This seems to happen because the driver is not compiled. Indeed if I explicitly defined CONFIG_CC1101=y in prj.conf

/home/h/Documents/devel/Zephyr/cc1101/app/prj.conf:13: warning: attempt to assign the value 'y' to the undefined symbol CC1101

but CC1101 is defined in drivers/cc1101/Kconfig:

config CC1101
    bool "Texas Instrument's cc1101 sub ghz transceiver"
    default y
    depends on DT_HAS_TI_CC1101_ENABLED
    select GPIO
    select SPI
    help
      Enable cc1101 transceiver module

So the question is: how can I check that Zerphyr/west is correctly loading the Kconfig of the driver? Is there anything I am missing?

Perhaps, is there any additional requirement of the placement of the driver? my project is in ~/Documents/devel/Zephyr/cc1101 but my zephyr base is located in ZEPHYR_BASE=/home/h/Documents/devel/Zephyr/zephyrproject/zephyr.

For reference, my repo is publicly available here: https://github.com/studiofuga/cc1101

1

There are 1 answers

0
HappyCactus On BEST ANSWER

The module must be declared in the west manifest, otherwise west will not compile and link it on zephyr. The documentation and tutorial never mention this.

The structure of the workspace and especially the location of the manifest depends from the type of "topology" you want to use. See the Supported Topologies page of the Zephyr documentation for further details.

So you need to define a west.yml file where you list your driver as a module. If you are using the "star" topology and the driver contains your manifest, simply put this:

manifest:
  self:
    path: app

  remotes:
    - name: zephyrproject-rtos
      url-base: https://github.com/zephyrproject-rtos

  projects:
    - name: zephyr
      remote: zephyrproject-rtos
      revision: v3.5.0
      import: true

Then initialize the workspace with west init -l from the root of your project, this will create a workspace in the parent directory; then run west update to populate it.

I have explained the topologies with more details in this blog post.