Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards: st: vbat node enabled without enabling associated adc node #72914

Open
ycsin opened this issue May 17, 2024 · 3 comments
Open

boards: st: vbat node enabled without enabling associated adc node #72914

ycsin opened this issue May 17, 2024 · 3 comments
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug Good first issue Good for a first time contributor to take platform: STM32 ST Micro STM32 priority: low Low impact/importance bug

Comments

@ycsin
Copy link
Collaborator

ycsin commented May 17, 2024

Describe the bug
The ST vbat driver expects the adc node to be enabled in the devicetree (due to the usage of DEVICE_DT_GET), but the vbat nodes in multiple boards are currently being enabled without also enabling its associated adc node

#define STM32_VBAT_DEFINE(inst) \
static struct stm32_vbat_data stm32_vbat_dev_data_##inst = { \
.adc = DEVICE_DT_GET(DT_INST_IO_CHANNELS_CTLR(inst)), \
.adc_base = (ADC_TypeDef *)DT_REG_ADDR(DT_INST_IO_CHANNELS_CTLR(0)), \
.adc_cfg = { \

this causes compilation to fail when vbat driver met its Kconfig conditions to build

config STM32_VBAT
bool "STM32 Vbat Sensor"
default y
depends on DT_HAS_ST_STM32_VBAT_ENABLED
depends on SOC_FAMILY_STM32 && !SOC_SERIES_STM32F1X
select ADC
help
Enable driver for STM32 Vbat sensor and then also ADC

To Reproduce
Steps to reproduce the behavior:

  1. west build -b nucleo_h753zi -p auto zephyr/samples/sensor/sensor_shell

Expected behavior
vbat probably shouldn't be enabled if the adc that it is using isn't enabled

Impact
Causing CI to fail in #72833

Logs and console output
See 72910

Environment (please complete the following information):

  • OS: Linux
  • Toolchain: 0.16.5-1
  • Commit SHA or Version used: main branch

Additional context
The proposed fix in #72911 only fixes the driver side of the issues, the vbat nodes are still being enabled in boards where it shouldnt

@ycsin ycsin added bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32 labels May 17, 2024
@erwango erwango assigned gautierg-st and unassigned erwango May 17, 2024
@erwango erwango added the priority: low Low impact/importance bug label May 17, 2024
@ycsin ycsin added the Good first issue Good for a first time contributor to take label May 21, 2024
@FRASTM
Copy link
Collaborator

FRASTM commented May 21, 2024

@ycsin
Adding a depends on DT_HAS_ST_STM32_ADC_ENABLED condition in the Kconfig for the drivers/sensor/st/stm32_xxx
will make the compilation successful but application is meaningless if no ADC node is enabled

@ycsin
Copy link
Collaborator Author

ycsin commented May 21, 2024

@ycsin Adding a depends on DT_HAS_ST_STM32_ADC_ENABLED condition in the Kconfig for the drivers/sensor/st/stm32_xxx will make the compilation successful but application is meaningless if no ADC node is enabled

The boards either fail to build the test in main branch's CI and fail, or becomes meaningless. I chose the latter as it seems less evil (and unblocks my PRs).

#72911 fixes half of the issue, the other half IMHO is to disable the vbat nodes in the board dts that are 'enabled' without an adc, or enable the adc properly with the correct configurations.

If there's usually only one vbat, maybe?:

#if !IS_ENABLED(DT_NODE_HAS_STATUS(DT_INST_IO_CHANNELS_CTLR(0), okay))
#warning "No ADC enabled for vbat 0"
#endif

@FRASTM
Copy link
Collaborator

FRASTM commented May 21, 2024

If there's usually only one vbat, maybe?:

#if !IS_ENABLED(DT_NODE_HAS_STATUS(DT_INST_IO_CHANNELS_CTLR(0), okay))
#warning "No ADC enabled for vbat 0"
#endif

I Agree, with #warning or #error "No ADC node enabled"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug Good first issue Good for a first time contributor to take platform: STM32 ST Micro STM32 priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

4 participants