Topics

Optional drivers and board configuration


Michael Hope
 

Hi there.  I'm adding a new SAM0 based board.  What's the best way to enable optional peripherals?  For example, not all users need the PWM driver.  Should I:

- Put CONFIG_PWM=y and CONFIG_PWM_SAM0=y in defconfig and live with the unneeded code?
- Put CONFIG_PWM_SAM0=y in defconfig and ignore the warning?
- or add a

config PWM_SAM0
    default y
    depends on PWM

section to Kconfig.board?

Thanks,

-- Michael


Carles Cufi
 

HI Michael,

 

I’d say he cleanest way is to do it at the SoC level, like this:

 

https://github.com/zephyrproject-rtos/zephyr/blob/master/soc/arm/atmel_sam/same70/Kconfig.defconfig.series#L83

 

That way every single board that enables CONFIG_PWM in its defconfig (or any application that enables CONFIG_PWM) will be enabling CONFIG_PWM_SAM. But boards or applications that do not enable CONFIG_PWM will have CONFIG_PWM_SAM disabled.

 

Carles

 

From: <devel@...> on behalf of "Michael Hope via lists.zephyrproject.org" <michaelh=juju.nz@...>
Reply-To: "michaelh@..." <michaelh@...>
Date: Sunday, 7 June 2020 at 19:32
To: devel <devel@...>
Subject: [Zephyr-devel] Optional drivers and board configuration

 

Hi there.  I'm adding a new SAM0 based board.  What's the best way to enable optional peripherals?  For example, not all users need the PWM driver.  Should I:

- Put CONFIG_PWM=y and CONFIG_PWM_SAM0=y in defconfig and live with the unneeded code?
- Put CONFIG_PWM_SAM0=y in defconfig and ignore the warning?
- or add a

config PWM_SAM0
    default y

    depends on PWM

 

section to Kconfig.board?

 

Thanks,

 

-- Michael