BevanWeiss
BevanWeiss

Reputation: 155

Nested choice in KConfig, such that only one of the 'top level' can be selected, but one of 'lower level' would count as a top level selection

I'm not very familiar with KConfig structure, so struggling to get the outcome I would like. I'm hoping I'm just going about it wrong, rather than it being impossible.

What I would like is something that allows for selection of one microcontroller, but where the menu is structured in a hierarchical fashion by family. So at the top level I'd like something like this:

(X) STM32F103 ---> (STM32F103xE)
( ) STM32F207
( ) STM32F401

Selecting STM32F207 would 'deselect' the STM32F103 option. And it should be possible to drill down and select one of the STM32F103 options, doing so would 'deselect' any other selection on the Top level menu.

( ) STM32F103x4 (16kB Flash / 6kB RAM)
(X) STM32F103x6 (32kB Flash / 10kB RAM)
( ) STM32F103x8 (64kB Flash / 20kB RAM)

I've currently got something 'close'. But it's allowing multiple selections at the lower level.

choice
  prompt "Processor model"
  menuconfig MACH_STM32F103
    bool "STM32F103"
    if MACH_STM32F103
      config MACH_STM32F103x4
        bool "STM32F103x4 (16kB Flash / 6kB RAM)"
      config MACH_STM32F103x6
        bool "STM32F103x6 (32kB Flash / 10kB RAM)"
      ...
    endif
  config MACH_STM32F207
    bool "STM32F207"
  ...
endchoice

Good.. Top Level Menu

Bad.. Lower Level Menu

I've tried using a choice on the lower level menu, but that just results in the choice prompt being added to the Top Level Menu, and then it stops working as a mutually exclusive option.

I'm aware of the KConfig language guide. And have tried to find some examples similar in Linux Kernel and Zephyr, but didn't find anything like this.

Any pointers would be greatly appreciated :) thanks

Upvotes: 0

Views: 56

Answers (0)

Related Questions