1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
19086: Remodel the USB in Kconfig r=aabadie a=MrKevinWeiss

### Contribution description

#### The issues with current architecture
Generally there has been some confusion on how to manage KConfig with respect to the board selection of default STDIO backends, specifically for boards that require a USB based backend as there are possible stacks to use.

The `<BOARD>.config` way of selecting cannot handle conditional selects.

The issues is more with boards such as `esp32s2-wemos-mini`, currently some USB stack will be selected regardless of overridding the preferred STDIO.

Selecting a USB stack directly with `STDIO_USB*` creates some circular dependency issues with kconfig and is hard to manage.

We also have a mutually exclusive USB stacks, TINYUSB or USBUS which should probably be a choice.


#### Desired behaviour

1. Ideally we want a board to default to the most obvious STDIO implementation, for example, if I have nucleo, it uses a UART, for some ESPs, USB is the default way to communicate.

2. These backends could always be overridden though, for example, I may just connect directly to a UART and want my STDIO there, or maybe use a ble based STDIO.

3. The next condition would be specifically for boards with a USB based STDIO.  Since we have a TINYUSB stack and a USBUS stack we would want to use the associated STDIO depending on the stack the application selects.

4. However, if nothing is selected by the application, than bring in a USB stack (board based preference) unless there is a specific non-USB based STDIO is selected. For these boards that have this requirement, we DO NOT want to bring in the USB stack if the STDIO is specifically overridden (important for kconfig).

#### Update kconfiglib package to RIOT-OS org managed one

There is a problem with the upstreamed Kconfiglib implementation and the maintainer is not responsive to the fix.  The issue is to do with `menuconfig`s in choices and has been fixed with the RIOT-OS based fork.  This PR requires this fix.


#### Changes to the USB stack

A new entry point is introduced `USB_DEVICE` which indicates wanting a USB device but not caring which stack is used.  This allows making a `choice` between the `TINYUSB` and `USBUS` stack allowing mutual exclusivity.

Making the USB stack a `choice` means that a specific stack cannot be selected from non-board/non-cpu/non-application based symbols.  Thus the `REQUIRES_` design pattern is used for a module to indicate a specific stack should be selected.  This is needed for the `MODULE_TINYUSB_NETDEV` in this case.

#### Changes to USB STDIO implementations

The `MODULE_STDIO_CDC_ACM` and `MODULE_STDIO_TINYUSB_CDC_ACM` are both depends on now, using a `REQUIRES_USB_STDIO` to select the dependencies.
This means we do not have to use `select PACKAGE_TINYUSB if TEST_KCONFIG && !MODULE_USBUS` in the board select.

##### Why not just select the USB from STDIO_USB
Issue with using select for STDIO choices is that we cannot check which stack we are using to default the STDIO to that, breaking desired behaviour 3.

#### The `FORCE_USB_STDIO`

Desired behaviour 4 means that we do not want to bring in the USB stack if we override, say, to the UART STDIO backend. Due to the limitations of Kconfig, this is my solution to prevent the USB from being brought in if there is an STDIO that doesn't need it. It is only for the `esp32s2-wemos-mini` board and would not be used in other places and would only need to be explicitly disabled for applications requiring different STDIO backend and no USB.  It is not perfect but I think the best solution and fairly understandable...

<details><summary><h4>Issues with Kconfig</h4></summary>

When using a `choice` and having conditional defaults, for example:

```kconfig
choice IMPL
    default FOO if CHOOSE_FOO
    default BAR
```

 there is a limitation of the level of the level of knowledge that can be expected from Kconfig, a limitation on circular dependencies, and a limitation that the dependencies only get resolved once.

For example, if ` BAR` selects something that would eventually select `CHOOSE_FOO`, then the default should be `FOO` and which would no longer select `BAR` preventing the select `CHOOSE_FOO`... Messy stuff and we would want an error saying no no no.

What Kconfig cannot handle is something like:

```kconfig
choice IMPL
    bool "Implementation"
    default FOO if CHOOSE_FOO
    default BAR

config FOO
    bool "Foo"

config BAR
    bool "Bar"

endchoice

config CHOOSE_FOO
    bool

config SYMBOL
    bool
    select CHOOSE_FOO if !BAR
```

`SYMBOL` causes a circular dependency in Kconfig even though the only possible outcome for the `choice` selection would be static.  If we select `BAR` then `CHOOSE_FOO` would not be selected and we stay with `BAR`.  If we select `FOO` than `CHOOSE_FOO` will be selected which stays with `FOO`. Everything should be fine, but isn't because Kconfig does not resolve to that degree, it simply sees that there is a dependency of the `IMPL` choice outcome (ie. `if !BAR`) that is a condition for a dependency of the `IMPL` choice selection (ie. ` if CHOOSE_FOO`).

This is a limitation of the Kconfig what what makes this problem so challenging, with Make we say "select some sort of USB backend if no other stdio is specifically requested" and it will.
</details>


An attempt at remodelling the dependencies of the USB stack in Kconfig.

Currently there are some issues, especially with the integration of TinyUSB package as a backend.
This will require a kconfiglib package fix though...

### Testing procedure

`TEST_KCONFIG=1 BOARD=reel make menuconfig -C examples/hello-world`

### Issues/PRs references

Requires https://github.com/ulfalizer/Kconfiglib/pull/123 to be merged upstream or fork for RIOT
Relates maybe to #18998 and #19038


19672: pkg/micropython: model in Kconfig r=aabadie a=aabadie



Co-authored-by: MrKevinWeiss <weiss.kevin604@gmail.com>
Co-authored-by: Alexandre Abadie <alexandre.abadie@inria.fr>
This commit is contained in:
bors[bot] 2023-05-31 14:04:21 +00:00 committed by GitHub
commit 784692e64a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 242 additions and 198 deletions

View File

@ -25,4 +25,9 @@ config BOARD_ADAFRUIT_CLUE
select HAVE_SAUL_GPIO
select HAVE_SHT3X
select MODULE_USB_BOARD_RESET if KCONFIG_USB && TEST_KCONFIG
config FORCE_USB_STDIO
default y
source "$(RIOTBOARD)/common/nrf52/Kconfig"

View File

@ -9,10 +9,4 @@ FEATURES_PROVIDED += periph_usbdev
# Various other features (if any)
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1,$(TEST_KCONFIG))
KCONFIG_BOARD_CONFIG += $(RIOTBOARD)/common/nrf52/nrf52_bootloader.config
endif
include $(RIOTBOARD)/common/nrf52/Makefile.features

View File

@ -13,9 +13,3 @@ FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_usbdev
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1, $(TEST_KCONFIG))
KCONFIG_ADD_CONFIG += $(RIOTBOARD)/common/samdx1-arduino-bootloader/samdx1-arduino-bootloader.config
endif

View File

@ -20,4 +20,9 @@ config BOARD_ADAFRUIT_ITSYBITSY_NRF52
select HAVE_SAUL_GPIO
select MODULE_USB_BOARD_RESET if KCONFIG_USB && TEST_KCONFIG
config FORCE_USB_STDIO
default y
source "$(RIOTBOARD)/common/nrf52/Kconfig"

View File

@ -9,10 +9,4 @@ FEATURES_PROVIDED += periph_usbdev
# Various other features (if any)
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1,$(TEST_KCONFIG))
KCONFIG_BOARD_CONFIG += $(RIOTBOARD)/common/nrf52/nrf52_bootloader.config
endif
include $(RIOTBOARD)/common/nrf52/Makefile.features

View File

@ -13,9 +13,3 @@ FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_usbdev
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1, $(TEST_KCONFIG))
KCONFIG_ADD_CONFIG += $(RIOTBOARD)/common/samdx1-arduino-bootloader/samdx1-arduino-bootloader.config
endif

View File

@ -20,4 +20,9 @@ config BOARD_ARDUINO_NANO_33_BLE
select HAVE_SAUL_GPIO
select MODULE_USB_BOARD_RESET if KCONFIG_USB && TEST_KCONFIG
config FORCE_USB_STDIO
default y
source "$(RIOTBOARD)/common/nrf52/Kconfig"

View File

@ -9,10 +9,4 @@ FEATURES_PROVIDED += periph_usbdev
# Various other features (if any)
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1,$(TEST_KCONFIG))
KCONFIG_BOARD_CONFIG += $(RIOTBOARD)/common/nrf52/nrf52_bootloader.config
endif
include $(RIOTBOARD)/common/nrf52/Makefile.features

View File

@ -14,9 +14,3 @@ FEATURES_PROVIDED += periph_usbdev
# Put other features for this board (in alphabetical order)
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1, $(TEST_KCONFIG))
KCONFIG_ADD_CONFIG += $(RIOTBOARD)/common/samdx1-arduino-bootloader/samdx1-arduino-bootloader.config
endif

View File

@ -24,3 +24,6 @@ config BOARD_BASTWAN
select HAVE_SAUL_GPIO
select HAVE_SX1276
config FORCE_USB_STDIO
default y

View File

@ -1,3 +0,0 @@
CONFIG_MODULE_USBUS=y
CONFIG_MODULE_USBUS_CDC_ACM=y
CONFIG_MODULE_STDIO_CDC_ACM=y

View File

@ -17,6 +17,9 @@ config BOARD_BLACKPILL_STM32F103CB
select HAS_HIGHLEVEL_STDIO
config FORCE_USB_STDIO
default y
# HACK: This is added due to the make resolution
# make will select timer backend, probably due to the USBUS
# and kconfig cannot select if something is already selected like make

View File

@ -1,3 +0,0 @@
CONFIG_MODULE_USBUS=y
CONFIG_MODULE_USBUS_CDC_ACM=y
CONFIG_MODULE_STDIO_CDC_ACM=y

View File

@ -17,6 +17,9 @@ config BOARD_BLUEPILL_STM32F103CB
select HAS_HIGHLEVEL_STDIO
config FORCE_USB_STDIO
default y
# HACK: This is added due to the make resolution
# make will select timer backend, probably due to the USBUS
# and kconfig cannot select if something is already selected like make

View File

@ -1,3 +0,0 @@
CONFIG_MODULE_USBUS=y
CONFIG_MODULE_USBUS_CDC_ACM=y
CONFIG_MODULE_STDIO_CDC_ACM=y

View File

@ -17,9 +17,3 @@ FEATURES_PROVIDED += periph_usbdev
FEATURES_PROVIDED += arduino
FEATURES_PROVIDED += arduino_pwm
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1, $(TEST_KCONFIG))
KCONFIG_ADD_CONFIG += $(RIOTBOARD)/common/samdx1-arduino-bootloader/samdx1-arduino-bootloader.config
endif

View File

@ -1,4 +0,0 @@
CONFIG_MODULE_USBUS=y
CONFIG_MODULE_USBUS_CDC_ACM=y
CONFIG_MODULE_STDIO_CDC_ACM=y
CONFIG_MODULE_USB_BOARD_RESET=y

View File

@ -21,6 +21,7 @@ config BOARD_COMMON_PARTICLE_MESH
select HAVE_SAUL_PWM
select MODULE_BOARDS_COMMON_PARTICLE_MESH if TEST_KCONFIG
select MODULE_USB_BOARD_RESET if KCONFIG_USB && TEST_KCONFIG
config MODULE_BOARDS_COMMON_PARTICLE_MESH
bool
@ -28,4 +29,7 @@ config MODULE_BOARDS_COMMON_PARTICLE_MESH
help
Common code for particle-mesh boards
config FORCE_USB_STDIO
default y
source "$(RIOTBOARD)/common/nrf52/Kconfig"

View File

@ -12,10 +12,4 @@ FEATURES_PROVIDED += vdd_lc_filter_reg1
# Various other features (if any)
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1,$(TEST_KCONFIG))
KCONFIG_BOARD_CONFIG += $(RIOTBOARD)/common/nrf52/nrf52_bootloader.config
endif
include $(RIOTBOARD)/common/nrf52/Makefile.features

View File

@ -11,3 +11,6 @@ config MODULE_BOARDS_COMMON_SAMDX1-ARDUINO-BOOTLOADER
depends on TEST_KCONFIG
help
Common code of samdx1 boards with an arduino bootloader
config FORCE_USB_STDIO
default y

View File

@ -1,3 +0,0 @@
CONFIG_MODULE_USBUS=y
CONFIG_MODULE_USBUS_CDC_ACM=y
CONFIG_MODULE_STDIO_CDC_ACM=y

View File

@ -13,9 +13,3 @@ FEATURES_PROVIDED += periph_usbdev
# Various other features (if any)
FEATURES_PROVIDED += arduino
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1, $(TEST_KCONFIG))
KCONFIG_ADD_CONFIG += $(RIOTBOARD)/common/samdx1-arduino-bootloader/samdx1-arduino-bootloader.config
endif

View File

@ -34,4 +34,7 @@ config MODULE_BOARDS_COMMON_WEACT-F4X1CX
help
Common code of weact based boards
config FORCE_USB_STDIO
default y
source "$(RIOTBOARD)/common/stm32/Kconfig"

View File

@ -1,5 +1,2 @@
CONFIG_MODULE_BOOTLOADER_STM32=y
CONFIG_MODULE_STDIO_CDC_ACM=y
CONFIG_MODULE_USBUS=y
CONFIG_MODULE_USBUS_CDC_ACM=y
CONFIG_MODULE_USB_BOARD_RESET=y

View File

@ -28,7 +28,9 @@ config BOARD_ESP32S2_LILYGO_TTGO_T8
select HAVE_MTD_SDCARD_DEFAULT
select HAVE_ST7735
select MODULE_FATFS_VFS if MODULE_VFS_DEFAULT
select MODULE_USBUS_CDC_ACM if MODULE_USBUS && ESP32S2_LILYGO_TTGO_T8_USB
config FORCE_USB_STDIO
default y if ESP32S2_LILYGO_TTGO_T8_USB
menu "LILYGO TTGO T8 ESP32-S2 Board configurations"
depends on BOARD_ESP32S2_LILYGO_TTGO_T8
@ -53,9 +55,4 @@ menu "LILYGO TTGO T8 ESP32-S2 Board configurations"
endmenu
choice STDIO_IMPLEMENTATION
default MODULE_STDIO_CDC_ACM if MODULE_USBUS && ESP32S2_LILYGO_TTGO_T8_USB
default MODULE_STDIO_TINYUSB_CDC_ACM if MODULE_TINYUSB_DEVICE && ESP32S2_LILYGO_TTGO_T8_USB
endchoice
source "$(RIOTBOARD)/common/esp32s2/Kconfig"

View File

@ -20,12 +20,12 @@ config BOARD_ESP32S2_WEMOS_MINI
select HAS_PERIPH_USBDEV
select HAS_TINYUSB_DEVICE
select HAS_HIGHLEVEL_STDIO
select MODULE_USBUS_CDC_ACM if TEST_KCONFIG && MODULE_USBUS
select PACKAGE_TINYUSB if TEST_KCONFIG && !MODULE_USBUS
choice STDIO_IMPLEMENTATION
default MODULE_STDIO_CDC_ACM if MODULE_USBUS
default MODULE_STDIO_TINYUSB_CDC_ACM if PACKAGE_TINYUSB
config FORCE_USB_STDIO
default y
choice USB_IMPLEMENTATION
default PACKAGE_TINYUSB
endchoice
source "$(RIOTBOARD)/common/esp32s2/Kconfig"

View File

@ -23,13 +23,13 @@ config BOARD_ESP32S3_PROS3
select HAS_PERIPH_SPI
select HAS_PERIPH_USBDEV
select HAS_TINYUSB_DEVICE
select MODULE_USB_BOARD_RESET if TEST_KCONFIG && MODULE_STDIO_USB_SERIAL_JTAG
select MODULE_USBUS_CDC_ACM if MODULE_USBUS
# Only this board has a requirement to use USB_BOARD_RESET with STDIO_USB_SERIAL_JTAG
select MODULE_USB_BOARD_RESET if MODULE_STDIO_USB_SERIAL_JTAG
choice STDIO_IMPLEMENTATION
default MODULE_STDIO_CDC_ACM if MODULE_USBUS
default MODULE_STDIO_TINYUSB_CDC_ACM if MODULE_TINYUSB_DEVICE
default MODULE_STDIO_USB_SERIAL_JTAG if !MODULE_USBUS && !MODULE_TINYUSB_DEVICE
default MODULE_STDIO_USB_SERIAL_JTAG
endchoice
source "$(RIOTBOARD)/common/esp32s3/Kconfig"

View File

@ -15,9 +15,3 @@ FEATURES_PROVIDED += periph_usbdev
# Put other features for this board (in alphabetical order)
FEATURES_PROVIDED += arduino
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1, $(TEST_KCONFIG))
KCONFIG_ADD_CONFIG += $(RIOTBOARD)/common/samdx1-arduino-bootloader/samdx1-arduino-bootloader.config
endif

View File

@ -19,5 +19,9 @@ config BOARD_FEATHER_NRF52840
select HAS_HIGHLEVEL_STDIO
select HAVE_SAUL_GPIO
select MODULE_USB_BOARD_RESET if KCONFIG_USB && TEST_KCONFIG
config FORCE_USB_STDIO
default y
source "$(RIOTBOARD)/common/nrf52/Kconfig"

View File

@ -9,10 +9,4 @@ FEATURES_PROVIDED += periph_usbdev
# Various other features (if any)
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1,$(TEST_KCONFIG))
KCONFIG_BOARD_CONFIG += $(RIOTBOARD)/common/nrf52/nrf52_bootloader.config
endif
include $(RIOTBOARD)/common/nrf52/Makefile.features

View File

@ -19,5 +19,9 @@ config BOARD_NRF52840_MDK_DONGLE
select HAVE_SAUL_GPIO
select HAVE_SAUL_PWM
select MODULE_USB_BOARD_RESET if KCONFIG_USB && TEST_KCONFIG
config FORCE_USB_STDIO
default y
source "$(RIOTBOARD)/common/nrf52/Kconfig"

View File

@ -8,10 +8,4 @@ FEATURES_PROVIDED += periph_usbdev
# Various other features (if any)
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1,$(TEST_KCONFIG))
KCONFIG_BOARD_CONFIG += $(RIOTBOARD)/common/nrf52/nrf52_bootloader.config
endif
include $(RIOTBOARD)/common/nrf52/Makefile.features

View File

@ -25,4 +25,9 @@ config BOARD_NRF52840DONGLE
select HAVE_SAUL_PWM
select HAVE_SAUL_NRF_VDDH
select MODULE_USB_BOARD_RESET if KCONFIG_USB && TEST_KCONFIG
config FORCE_USB_STDIO
default y
source "$(RIOTBOARD)/common/nrf52/Kconfig"

View File

@ -12,10 +12,4 @@ FEATURES_PROVIDED += vdd_lc_filter_reg1
# Various other features (if any)
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1,$(TEST_KCONFIG))
KCONFIG_BOARD_CONFIG += $(RIOTBOARD)/common/nrf52/nrf52_bootloader.config
endif
include $(RIOTBOARD)/common/nrf52/Makefile.features

View File

@ -28,13 +28,11 @@ config BOARD_SEEEDSTUDIO_GD32
select HAVE_MTD_SDCARD_DEFAULT
select MODULE_FATFS_VFS if MODULE_VFS_DEFAULT
select MODULE_USBUS if TEST_KCONFIG && !PACKAGE_TINYUSB
select MODULE_USBUS_CDC_ACM if MODULE_USBUS
select MODULE_USB_BOARD_RESET if MODULE_USBUS_CDC_ACM || MODULE_TINYUSB_CLASS_CDC
choice STDIO_IMPLEMENTATION
default MODULE_STDIO_CDC_ACM if MODULE_USBUS
default MODULE_STDIO_TINYUSB_CDC_ACM if PACKAGE_TINYUSB
endchoice
select MODULE_USB_BOARD_RESET if KCONFIG_USB && TEST_KCONFIG
config FORCE_USB_STDIO
default y
source "$(RIOTBOARD)/common/gd32v/Kconfig"

View File

@ -11,9 +11,3 @@ FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_usbdev
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1, $(TEST_KCONFIG))
KCONFIG_ADD_CONFIG += $(RIOTBOARD)/common/samdx1-arduino-bootloader/samdx1-arduino-bootloader.config
endif

View File

@ -14,9 +14,3 @@ FEATURES_PROVIDED += periph_usbdev
# Put other features for this board (in alphabetical order)
FEATURES_PROVIDED += highlevel_stdio
FEATURES_PROVIDED += sdcard_spi
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1, $(TEST_KCONFIG))
KCONFIG_ADD_CONFIG += $(RIOTBOARD)/common/samdx1-arduino-bootloader/samdx1-arduino-bootloader.config
endif

View File

@ -12,9 +12,3 @@ FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_usbdev
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1, $(TEST_KCONFIG))
KCONFIG_ADD_CONFIG += $(RIOTBOARD)/common/samdx1-arduino-bootloader/samdx1-arduino-bootloader.config
endif

View File

@ -29,9 +29,10 @@ config BOARD_SIPEED_LONGAN_NANO
select HAVE_MTD_SDCARD_DEFAULT
select MODULE_FATFS_VFS if MODULE_VFS_DEFAULT
select MODULE_USBUS if TEST_KCONFIG && !PACKAGE_TINYUSB
select MODULE_USBUS_CDC_ACM if MODULE_USBUS
select MODULE_USB_BOARD_RESET if MODULE_USBUS_CDC_ACM || MODULE_TINYUSB_CLASS_CDC
select MODULE_USB_BOARD_RESET if KCONFIG_USB && TEST_KCONFIG
config FORCE_USB_STDIO
default y
menu "Sipeed Longan Nano Board Configuration"
@ -42,9 +43,4 @@ menu "Sipeed Longan Nano Board Configuration"
endmenu
choice STDIO_IMPLEMENTATION
default MODULE_STDIO_CDC_ACM if MODULE_USBUS
default MODULE_STDIO_TINYUSB_CDC_ACM if PACKAGE_TINYUSB
endchoice
source "$(RIOTBOARD)/common/gd32v/Kconfig"

View File

@ -16,5 +16,8 @@ config BOARD_STM32F429I_DISCO
# Put other features for this board (in alphabetical order)
select HAS_HIGHLEVEL_STDIO
config FORCE_USB_STDIO
default y
source "$(RIOTBOARD)/common/stm32/Kconfig"
source "$(RIOTBOARD)/stm32f429i-disc1/Kconfig"

View File

@ -1,3 +0,0 @@
CONFIG_MODULE_USBUS=y
CONFIG_MODULE_USBUS_CDC_ACM=y
CONFIG_MODULE_STDIO_CDC_ACM=y

View File

@ -35,13 +35,8 @@ config BOARD_STM32F4DISCOVERY
select HAVE_SAUL_GPIO
select MODULE_USBUS if TEST_KCONFIG && !PACKAGE_TINYUSB
select MODULE_USBUS_CDC_ACM if TEST_KCONFIG && !PACKAGE_TINYUSB
choice STDIO_IMPLEMENTATION
default MODULE_STDIO_CDC_ACM if MODULE_USBUS
default MODULE_STDIO_TINYUSB_CDC_ACM if PACKAGE_TINYUSB
endchoice
config FORCE_USB_STDIO
default y
source "$(RIOTBOARD)/common/stm32/Kconfig"

View File

@ -1,9 +1,3 @@
include $(RIOTBOARD)/common/arduino-zero/Makefile.features
FEATURES_PROVIDED += highlevel_stdio
# This configuration enables modules that are only available when using Kconfig
# module modelling
ifeq (1, $(TEST_KCONFIG))
KCONFIG_ADD_CONFIG += $(RIOTBOARD)/common/samdx1-arduino-bootloader/samdx1-arduino-bootloader.config
endif

View File

@ -21,3 +21,6 @@ config BOARD_YARM
select HAS_PERIPH_UART
select HAS_PERIPH_USBDEV
select HAS_RIOTBOOT
config FORCE_USB_STDIO
default y

View File

@ -1,3 +0,0 @@
CONFIG_MODULE_USBUS=y
CONFIG_MODULE_USBUS_CDC_ACM=y
CONFIG_MODULE_STDIO_CDC_ACM=y

View File

@ -94,5 +94,6 @@ rsource "Kconfig.esp32"
rsource "Kconfig.esp32c3"
rsource "Kconfig.esp32s3"
rsource "Kconfig.esp32s2"
rsource "stdio_usb_serial_jtag/Kconfig"
source "$(RIOTCPU)/esp_common/Kconfig"

View File

@ -188,6 +188,4 @@ endif
# enable bootloader reset over USB, requires CDC ACM to be used
ifneq (,$(filter usbus_cdc_acm tinyusb_class_cdc,$(USEMODULE)))
USEMODULE += usb_board_reset
include $(RIOTMAKE)/tools/usb_board_reset.mk
endif

View File

@ -3,6 +3,10 @@ FLASH_CHIP = $(CPU_FAM)
export ESP32_SDK_DIR ?= $(PKGDIRBASE)/esp32_sdk
ifneq (,$(filter usb_board_reset,$(USEMODULE)))
include $(RIOTMAKE)/tools/usb_board_reset.mk
endif
# Serial flasher config as used by the ESP-IDF, be careful when overriding them.
# They have to be exported to use same values in subsequent makefiles.
ifeq (esp32,$(CPU_FAM))

View File

@ -0,0 +1,9 @@
choice STDIO_IMPLEMENTATION
config MODULE_STDIO_USB_SERIAL_JTAG
bool "STDIO via ESP32 Debug USB Serial/JTAG interface"
depends on TEST_KCONFIG
depends on CPU_FAM_ESP32C3 || CPU_FAM_ESP32S3
select MODULE_TSRB
endchoice

View File

@ -1,6 +1,6 @@
PKG_NAME=kconfiglib
PKG_URL=https://github.com/ulfalizer/Kconfiglib
PKG_VERSION=061e71f7d78cb057762d88de088055361863deff
PKG_URL=https://github.com/RIOT-OS/Kconfiglib
PKG_VERSION=110688d78edba9fa7eb09cbe001c62fbbee86abf
PKG_LICENSE=ISC
include $(RIOTBASE)/pkg/pkg.mk

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 Inria
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
config APPLICATION
bool
default y
depends on TEST_KCONFIG
select MODULE_PERIPH_ADC if HAS_PERIPH_ADC
select MODULE_PERIPH_SPI if HAS_PERIPH_SPI

View File

@ -34,4 +34,7 @@ TESTRUNNER_RESET_AFTER_TERM ?= 1
# failing on native with floating point exception (#15870)
TEST_ON_CI_BLACKLIST = native
# avoid running Kconfig by default
SHOULD_RUN_KCONFIG ?=
include $(RIOTBASE)/Makefile.include

View File

@ -0,0 +1 @@
CONFIG_PACKAGE_MICROPYTHON=y

View File

@ -51,6 +51,7 @@ rsource "lz4/Kconfig"
rsource "mbedtls/Kconfig"
rsource "micro-ecc/Kconfig"
rsource "microcoap/Kconfig"
rsource "micropython/Kconfig"
rsource "minmea/Kconfig"
rsource "monocypher/Kconfig"
rsource "mynewt-core/Kconfig"

14
pkg/micropython/Kconfig Normal file
View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 Inria
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
config PACKAGE_MICROPYTHON
bool "MicroPython port package"
depends on TEST_KCONFIG
select MODULE_XTIMER
select MODULE_ZTIMER_USEC
select MODULE_STDIN

View File

@ -15,6 +15,20 @@ config HAS_TINYUSB_HOST
help
Indicates that the hardware supports tinyUSB host stack
config REQUIRES_TINYUSB_DEVICE
bool
help
Indicates that the application requires tinyUSB stack
config ERROR_TINYUSB_DEVICE
bool
default y if REQUIRES_TINYUSB_DEVICE && !MODULE_TINYUSB_DEVICE
help
The USB implmentation is required to be tinyUSB but cannot be set
choice USB_IMPLEMENTATION
default PACKAGE_TINYUSB if REQUIRES_TINYUSB_DEVICE
menuconfig PACKAGE_TINYUSB
bool "TinyUSB stack package"
depends on TEST_KCONFIG
@ -117,6 +131,7 @@ config MODULE_TINYUSB_HW
config MODULE_TINYUSB_DEVICE
bool "Device Stack"
depends on HAS_TINYUSB_DEVICE
select MODULE_TINYUSB_CLASS_CDC if REQUIRES_USB_STDIO
default y
help
Select to enable tinyUSB device stack
@ -242,4 +257,6 @@ config MODULE_RIOTBOOT_TINYUSB_DFU
endif # MODULE_TINYUSB_DEVICE
endif # PACKAGE_TINYUSB
endchoice
rsource "cdc_acm_stdio/Kconfig"

View File

@ -12,7 +12,7 @@ choice STDIO_IMPLEMENTATION
config MODULE_STDIO_TINYUSB_CDC_ACM
bool "CDC ACM (tinyUSB)"
depends on MODULE_TINYUSB_DEVICE
depends on MODULE_TINYUSB_CLASS_CDC
select MODULE_STDIO_AVAILABLE
select MODULE_TINYUSB_CLASS_CDC
endchoice

View File

@ -12,5 +12,5 @@ config MODULE_TINYUSB_NETDEV
select MODULE_LUID
select MODULE_NETDEV_ETH
select MODULE_TINYUSB_CLASS_NET
select MODULE_TINYUSB_DEVICE
select PACKAGE_TINYUSB
select KCONFIG_USB
select REQUIRES_TINYUSB_DEVICE

View File

@ -8,9 +8,20 @@
menu "Standard Input/Output (STDIO)"
depends on TEST_KCONFIG
config FORCE_USB_STDIO
bool "Force a USB based STDIO"
depends on HAS_PERIPH_USBDEV || HAS_TINYUSB_DEVICE
select KCONFIG_USB
select REQUIRES_USB_STDIO
help
To prevent a circular dependency, can force the USB modules to that
STDIO will select some sort of USB based STDIO backend.
choice STDIO_IMPLEMENTATION
bool "STDIO implementation"
default MODULE_STDIO_NATIVE if CPU_ARCH_NATIVE
default MODULE_STDIO_CDC_ACM if MODULE_USBUS && REQUIRES_USB_STDIO
default MODULE_STDIO_TINYUSB_CDC_ACM if MODULE_TINYUSB_DEVICE && REQUIRES_USB_STDIO
default MODULE_STDIO_UART
config MODULE_STDIO_RTT
@ -49,12 +60,6 @@ config MODULE_STDIO_ETHOS
select MODULE_ETHOS_STDIO
select USE_STDOUT_BUFFERED
config MODULE_STDIO_USB_SERIAL_JTAG
bool "STDIO via ESP32 Debug USB Serial/JTAG interface"
depends on TEST_KCONFIG
depends on CPU_FAM_ESP32C3 || CPU_FAM_ESP32S3
select MODULE_TSRB
endchoice
config MODULE_STDIN
@ -91,4 +96,9 @@ config USE_STDOUT_BUFFERED
help
Select this to prefer buffered standard output if provided by the implementation.
config REQUIRES_USB_STDIO
bool
help
Indicates that the STDIO requires some USB implementation to be enabled.
endmenu # Standard Input/Output (STDIO)

View File

@ -53,7 +53,15 @@ extern "C" {
#error Please configure your vendor and product IDs. For development, you may \
set USB_VID=${USB_VID_TESTING} USB_PID=${USB_PID_TESTING}.
#endif
#else
#if CONFIG_USB_VID == INTERNAL_PERIPHERAL_VID && \
CONFIG_USB_PID == INTERNAL_PERIPHERAL_PID
#error Please configure your vendor and product IDs differently than the \
INTERNAL_PERIPHERAL_* settings. For development, you may set \
USB_VID=${USB_VID_TESTING} \
USB_PID=${USB_PID_TESTING}.
#endif
#endif /* !(defined(CONFIG_USB_VID) && defined(CONFIG_USB_PID)) */
/**
* @brief USB peripheral device vendor ID

View File

@ -68,7 +68,8 @@ extern "C" {
* that the USB peripheral is ready for use.
*/
#ifndef CONFIG_USBUS_AUTO_ATTACH
#if !IS_ACTIVE(KCONFIG_MODULE_USBUS)
/* Check for Kconfig usage */
#if !IS_ACTIVE(CONFIG_MODULE_USBUS)
#define CONFIG_USBUS_AUTO_ATTACH 1
#endif
#endif

View File

@ -5,13 +5,24 @@
# directory for more details.
#
menuconfig KCONFIG_USB
bool "Configure USB"
depends on MODULE_USBUS || PACKAGE_TINYUSB
bool "USB device"
depends on HAS_PERIPH_USBDEV || HAS_TINYUSB_DEVICE || MODULE_USBDEV_MOCK
depends on TEST_KCONFIG
help
Configure the USB peripheral via Kconfig.
Enable the USB device peripheral.
if KCONFIG_USB
choice USB_IMPLEMENTATION
bool "USB implementation"
help
Select the USB implementation.
endchoice
rsource "usbus/Kconfig"
menu "Power management"
config USB_MAX_POWER
@ -42,16 +53,26 @@ config USB_SPEC_BCDVERSION_1_1
endchoice
config CUSTOM_USB_VID_PID
bool "Use custom VID and PID"
help
If using in USB in application then one must set a VID and PID.
If RIOT is internally using the USB, say for STDIO, then the VID and
PID depending in the internal peripheral configuration used.
config USB_PID
hex "Product ID"
depends on CUSTOM_USB_VID_PID
range 0x0000 0xFFFF
default 0x7D01
# default 0x7002 if MODULE_RIOTBOOT_DFU
default 0x7001
help
You must provide your own PID.
config USB_VID
hex "Vendor ID"
range 0x0000 0xFFFF
depends on CUSTOM_USB_VID_PID
default 0x1209
help
You must provide your own VID.
@ -109,5 +130,3 @@ comment "WARNING: The serial string is empty!"
depends on USB_SERIAL_STR = "" && USB_CUSTOM_SERIAL_STR
endif # KCONFIG_USB
rsource "usbus/Kconfig"

View File

@ -4,6 +4,7 @@
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
choice USB_IMPLEMENTATION
menuconfig MODULE_USBUS
bool "USB Unified Stack (USBUS)"
@ -13,8 +14,11 @@ menuconfig MODULE_USBUS
select MODULE_EVENT
select MODULE_LUID
select MODULE_FMT
select MODULE_USBUS_CDC_ACM if REQUIRES_USB_STDIO
select MODULE_PERIPH_USBDEV if HAS_PERIPH_USBDEV && !MODULE_USBDEV_MOCK
endchoice
if MODULE_USBUS
config MODULE_AUTO_INIT_USBUS
@ -31,7 +35,7 @@ menuconfig KCONFIG_USEMODULE_USBUS
help
Configure the USBUS module via Kconfig.
if KCONFIG_USEMODULE_USBUS
if KCONFIG_USEMODULE_USBUS || MODULE_USBUS
config USBUS_AUTO_ATTACH
bool "Auto attach"
@ -63,7 +67,7 @@ config USBUS_EP0_SIZE_64
endchoice
endif # KCONFIG_USEMODULE_USBUS
endif # KCONFIG_USEMODULE_USBUS || MODULE_USBUS
rsource "cdc/Kconfig"
rsource "dfu/Kconfig"

View File

@ -11,13 +11,19 @@ menuconfig KCONFIG_USEMODULE_USBUS_CDC_ACM
help
Configure the USBUS CDC ACM module via Kconfig.
if KCONFIG_USEMODULE_USBUS_CDC_ACM
menuconfig MODULE_USBUS_CDC_ACM
bool "Configure USBUS CDC ACM"
depends on MODULE_USBUS
help
Configure the USBUS CDC ACM module via Kconfig.
if MODULE_USBUS_CDC_ACM || KCONFIG_USEMODULE_USBUS_CDC_ACM
config USBUS_CDC_ACM_STDIO_BUF_SIZE_EXP
int "Buffer size for STDIN and STDOUT data (as exponent of 2^n)"
depends on USEMODULE_STDIO_CDC_ACM || MODULE_STDIO_CDC_ACM
default 7
range 0 31
depends on USEMODULE_STDIO_CDC_ACM
help
As buffer size ALWAYS needs to be power of two, this changes this option
represents the exponent of 2^n, which will be used as the size of the
@ -44,18 +50,14 @@ config USBUS_CDC_ACM_BULK_EP_SIZE_64
endchoice
endif # KCONFIG_USEMODULE_USBUS_CDC_ACM
config MODULE_USBUS_CDC_ACM
bool "USB CDC ACM support"
depends on MODULE_USBUS
select MODULE_TSRB
endif # MODULE_USBUS_CDC_ACM
# extend STDIO options
choice STDIO_IMPLEMENTATION
config MODULE_STDIO_CDC_ACM
bool "CDC ACM"
depends on MODULE_USBUS || KCONFIG_USEMODULE_USBUS
depends on MODULE_USBUS_CDC_ACM && !MODULE_TINYUSB_DEVICE
select MODULE_ISRPIPE
select MODULE_STDIO_AVAILABLE

View File

@ -11,7 +11,13 @@ menuconfig KCONFIG_USEMODULE_USBUS_CDC_ECM
help
Configure the USBUS CDC ECM module via Kconfig.
if KCONFIG_USEMODULE_USBUS_CDC_ECM
menuconfig MODULE_USBUS_CDC_ECM
bool "Configure USBUS CDC ECM"
depends on MODULE_USBUS
help
Configure the USBUS CDC ECM module via Kconfig.
if KCONFIG_USEMODULE_USBUS_CDC_ECM || MODULE_USBUS_CDC_ECM
config USBUS_CDC_ECM_CONFIG_SPEED_IND
bool "Configure upload and download speeds independently"
@ -41,4 +47,4 @@ config USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM
This is the link upload speed, defined in bits/second, that the USB
peripheral will report to the host.
endif # KCONFIG_USEMODULE_USBUS_CDC_ECM
endif # KCONFIG_USEMODULE_USBUS_CDC_ECM || MODULE_USBUS_CDC_ECM

View File

@ -9,10 +9,14 @@ menuconfig KCONFIG_USEMODULE_USBUS_DFU
bool "Configure USBUS DFU"
depends on USEMODULE_USBUS_DFU
depends on KCONFIG_USEMODULE_USBUS
menuconfig MODULE_USBUS_DFU
bool "Configure USBUS DFU"
depends on MODULE_USBUS
help
Configure the USBUS DFU module via Kconfig.
if KCONFIG_USEMODULE_USBUS_DFU
if KCONFIG_USEMODULE_USBUS_DFU || MODULE_USBUS_DFU
config USB_DFU_DETACH_TIMEOUT_MS
int
@ -33,4 +37,4 @@ config RIOTBOOT_MAGIC_ADDR
int "DFU magic address"
depends on CUSTOM_RIOTBOOT_MAGIC_ADDR
endif # KCONFIG_USEMODULE_USBUS_DFU
endif # KCONFIG_USEMODULE_USBUS_DFU || MODULE_USBUS_DFU

View File

@ -7,7 +7,6 @@
menuconfig MODULE_USBUS_HID
bool "USB HID support"
depends on TEST_KCONFIG
depends on MODULE_USBUS
select MODULE_ISRPIPE_READ_TIMEOUT

View File

@ -1,5 +1,9 @@
CONFIG_PACKAGE_TINYUSB=y
CONFIG_KCONFIG_USB=y
CONFIG_MODULE_TINYUSB_CLASS_CDC=y
CONFIG_MODULE_STDIO_TINYUSB_CDC_ACM=y
CONFIG_MODULE_SHELL=y
CONFIG_MODULE_SHELL_CMDS_DEFAULT=y
CONFIG_MODULE_PS=y
CONFIG_CUSTOM_USB_VID_PID=y

View File

@ -1,3 +1,6 @@
CONFIG_KCONFIG_USB=y
CONFIG_PACKAGE_TINYUSB=y
CONFIG_MODULE_TINYUSB_CLASS_CDC=y
CONFIG_MODULE_TINYUSB_CLASS_MSC=y
CONFIG_CUSTOM_USB_VID_PID=y

View File

@ -1,4 +1,5 @@
CONFIG_MODULE_AUTO_INIT_USBUS=n
CONFIG_KCONFIG_USB=y
CONFIG_MODULE_USBUS=y
CONFIG_MODULE_FIDO2=y
CONFIG_MODULE_FIDO2_CTAP=y
@ -6,3 +7,5 @@ CONFIG_MODULE_FIDO2_CTAP_TRANSPORT=y
CONFIG_MODULE_FIDO2_CTAP_TRANSPORT_HID=y
CONFIG_PACKAGE_FIDO2_TESTS=y
CONFIG_CUSTOM_USB_VID_PID=y

View File

@ -3,7 +3,10 @@ CONFIG_MODULE_PS=y
CONFIG_MODULE_SHELL=y
CONFIG_MODULE_SHELL_CMDS_DEFAULT=y
CONFIG_MODULE_USB_BOARD_RESET=y
CONFIG_KCONFIG_USB=y
CONFIG_MODULE_USBUS=y
CONFIG_MODULE_USBUS_CDC_ACM=y
CONFIG_MODULE_AUTO_INIT_USBUS=n
CONFIG_CUSTOM_USB_VID_PID=y

View File

@ -1,5 +1,9 @@
CONFIG_MODULE_PS=y
CONFIG_MODULE_SHELL=y
CONFIG_KCONFIG_USB=y
CONFIG_MODULE_USBUS=y
CONFIG_MODULE_USBUS_MSC=y
CONFIG_MODULE_ZTIMER=y
CONFIG_MODULE_ZTIMER_MSEC=y
CONFIG_CUSTOM_USB_VID_PID=y