Guidance Required: AS7341 Sensor Driver Contribution Failing Zephyr CI/Twister Checks

Hello Zephyr Community,

I am trying to contribute a new sensor driver for the **AMS AS7341 Spectral Sensor** to Zephyr (using **NCS v3.2.2 / Zephyr**), and I would appreciate some guidance regarding CI/Twister failures during the contribution process.

## Environment

* NCS Version: **v3.2.2**
* Target Hardware: **nRF9151**
* Driver: **AMS AS7341 Spectral Sensor**
* Driver implemented using Zephyr Sensor API:

* `sample_fetch()`
* `channel_get()`
* `attr_set()`
* `attr_get()`
* Trigger support APIs

## Driver Integration

I added the driver under:

```text
zephyr/drivers/sensor/ams/ams_as7341/
```

Files:

```text
ams_as7341.c
ams_as7341.h
Kconfig
CMakeLists.txt
```

I also updated:

```text
zephyr/drivers/sensor/ams/Kconfig
zephyr/drivers/sensor/ams/CMakeLists.txt
```

to include the new driver.

---

## Devicetree Binding

Added:

```text
zephyr/dts/bindings/sensor/ams,as7341.yaml
```

Content:

```yaml
# Copyright (c) 2026 Dotcom IoT LLP
# SPDX-License-Identifier: Apache-2.0

description: AMS AS7341 spectral sensor

compatible: "ams,as7341"

include:
- sensor-device.yaml
- i2c-device.yaml
```

---

## Twister Test

Created:

```text
zephyr/tests/drivers/sensor/ams_as7341/
```

Files:

### src/main.c

```c
#include <zephyr/ztest.h>
#include <zephyr/drivers/sensor.h>

ZTEST_SUITE(ams_as7341_tests, NULL, NULL, NULL, NULL, NULL);

ZTEST(ams_as7341_tests, test_basic_assertions)
{
zassert_true(1, "basic assertion failed");
}
```

### CMakeLists.txt

```cmake
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(ams_as7341_test)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
```

### prj.conf

```conf
CONFIG_ZTEST=y
CONFIG_SENSOR=y
CONFIG_I2C=y
CONFIG_AMS_AS7341=y
```

### testcase.yaml

```yaml
tests:
drivers.sensor.ams_as7341:
tags:
- drivers
- sensor
platform_allow:
- native_sim
integration_platforms:
- native_sim
harness: ztest
```

---

## Local Validation

### Twister

Executed:

```bash
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR=/home/dnk133/ncs/toolchains/927563c840/opt/zephyr-sdk

~/ncs/v3.2.2/zephyr/scripts/twister \
-T tests/drivers/sensor/ams_as7341 \
-p native_sim \
-v
```

Result:

```text
PASS
```

### Checkpatch

Executed:

```bash
./scripts/checkpatch.pl --file drivers/sensor/ams/ams_as7341/ams_as7341.c
./scripts/checkpatch.pl --file drivers/sensor/ams/ams_as7341/ams_as7341.h
./scripts/checkpatch.pl --file drivers/sensor/ams/ams_as7341/Kconfig
./scripts/checkpatch.pl --file drivers/sensor/ams/ams_as7341/CMakeLists.txt
./scripts/checkpatch.pl --file dts/bindings/sensor/ams,as7341.yaml
```

Result:

```text
No checkpatch errors reported
```

---

## CI Failure

However, after creating the pull request, CI fails during the Twister build stage.

From the CI log, I see errors similar to:

```text
error: as7341_init defined but not used [-Werror=unused-function]
```

and multiple failures such as:

```text
drivers.sensor.generic_test
drivers.sensor.no_default
drivers.sensor.pm
drivers.sensor.trigger.own
```

The failure seems to occur on the **native_sim/native** build configurations.

Screenshot attached below for reference.

---                                        




 
                                  



                                              


                               





        


## My Questions

1. Why does the driver pass local Twister testing but fail in Zephyr CI?
2. Is `as7341_init()` expected to be conditionally compiled using a DT_INST macro?
3. Could the failure be caused by:

* Missing `DT_INST_FOREACH_STATUS_OKAY()` usage?
* Missing device instantiation macros?
* Missing Kconfig dependencies?
* Driver being compiled even when no AS7341 instance exists in the build?
4. Are there additional sensor-driver tests that must be added beyond a simple ZTest application?
5. Is there any recommended checklist for contributing a new sensor driver to Zephyr/NCS?

Any suggestions on what I should inspect next would be greatly appreciated.

Thank you for your time and guidance.

Best Regards,
**Parin Baudhanwala**
Embedded Firmware Developer
Dotcom IoT LLP

Related