1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/pkg
bors[bot] 784692e64a
Merge #19086 #19672
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>
2023-05-31 14:04:21 +00:00
..
arduino_adafruit_sensor pkg/arduino_adafruit_sensor: add Adafruit Unified Sensor Driver 2022-12-15 18:36:05 +01:00
arduino_api pkg: remove -std=c++11 2022-01-13 17:50:59 +01:00
arduino_sdi_12 pkg/arduino_sdi_12: bump version, fix patches 2022-10-25 10:26:43 +02:00
c25519 pkg/pkg.mk: silence info if QUIETER 2022-06-01 10:54:01 +02:00
cayenne-lpp pkg/*/Kconfig: Add simple kconfig pkgs 2021-04-08 16:34:36 +02:00
ccn-lite pkg/ccn-lite: Fix use after free bug 2022-11-11 22:16:47 +01:00
cifra pkg/cifra: fix build error with redefined assert 2021-12-23 11:04:42 +01:00
cmsis pkg: add support for CMSIS via a package 2023-05-14 21:08:27 +02:00
cn-cbor pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
corejson pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
cryptoauthlib pkg/cryptoauthlib: Fix compilation with -Wformat-nonliteral 2023-02-27 12:31:03 +01:00
driver_atwinc15x0 pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
driver_bme680 treewide: replace occurrences of tests/driver_ with new path 2023-05-06 15:38:21 +02:00
driver_sx126x sys/ztimer/kconfig: enable xtimer compat only with timer backend 2021-12-02 09:38:06 +01:00
edhoc-c pkg/edhoc-c: add QQ 2022-06-01 10:48:34 +02:00
elk pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
emlearn pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
esp32_sdk pkg/esp32_sdk: patches for compilation with gcc 12.2 2023-04-05 13:46:25 +02:00
esp32_sdk_lib_bt_esp32 pkg/esp32_sdk_lib_bt_esp32: add BLE library for ESP32 2022-08-24 09:03:38 +02:00
esp32_sdk_lib_bt_esp32c3 pkg/esp32_sdk_lib_bt_esp32c3: add BLE library for ESP32-C3 2022-08-24 18:02:21 +02:00
esp32_sdk_lib_phy pkg/esp32_sdk_lib_phy: bump version 2022-06-05 11:53:31 +02:00
esp32_sdk_lib_wifi pkg/esp32_sdk_lib_wifi: bump version 2022-06-05 11:53:31 +02:00
esp8266_sdk pkg/esp8266_sdk: fix version string generation 2023-01-10 20:22:40 +01:00
etl pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
fatfs pkg/fatfs: bump to r0.15 2023-03-05 00:46:06 +01:00
fff core/irq: Add C++ wrapper 2023-01-13 13:58:07 +01:00
fido2_tests sys/fido2: remove unnecessary module import from Makefile.dep 2022-01-31 16:49:38 +01:00
flashdb pkg: add FlashDB 2023-02-27 18:12:13 +01:00
flatbuffers pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
gecko_sdk pkg/gecko_sdk: disable cast-align globally 2023-05-15 12:20:06 +02:00
gemmlowp pkg: add Kconfig support for flatbuffers/ruy/tflite-micro 2022-04-27 10:53:50 +02:00
hacl pkg/hacl: documentation link update 2022-04-25 16:05:28 +02:00
heatshrink sys/doc.txt: add sys_compression doxygen group 2023-02-27 15:09:08 +01:00
jerryscript Merge pull request #18562 from MrKevinWeiss/pr/removemips 2022-09-30 10:47:09 +02:00
jsmn pkg/*/Kconfig: Add simple kconfig pkgs 2021-04-08 16:34:36 +02:00
libb2 pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
libbase58 pkg/libbase58: add Kconfig support 2023-05-19 15:40:44 +02:00
libcose treewide: replace remaining occurrences of tests/pkg_* 2023-05-06 07:55:03 +02:00
libfixmath tests/pkg_libfixmath_unittests: adapt test to upstream changes 2023-01-20 17:42:54 +01:00
libhydrogen pkg/libhydrogen: silence gcc 11.2.0 false posive stringop-overflow 2022-09-27 09:36:23 +02:00
libschc libschc: initial import 2023-02-22 09:10:03 +01:00
libsocketcan pkg/socketcan: add to resolve i386 support on Ubuntu 2022-04-20 11:49:33 +02:00
littlefs Merge pull request #18672 from benpicco/vfs-abs_path 2022-09-30 16:42:57 +02:00
littlefs2 pkg/littlefs2: bump version to 2.6 2023-05-23 22:38:56 +02:00
lora-serialization pkg/*/Kconfig: Add simple kconfig pkgs 2021-04-08 16:34:36 +02:00
lorabasics pkg/lorabasics: fix unused parameters warning 2022-08-18 01:05:31 +02:00
lua core/lib: Add macros/utils.h header 2023-01-07 09:47:44 +01:00
lv_drivers pkg/lv_drivers: replace LittlevGL to LVGL 2023-05-08 15:00:52 +02:00
lvgl build-system: Allow out of tree BUILD_DIR 2023-05-16 22:23:03 +02:00
lwext4 pkg/lwext4: add lwEXT4 2023-02-25 14:01:20 +01:00
lwip drivers/mrf24j40: add support for IEEE 802.15.4 Radio HAL 2023-01-19 15:31:06 +01:00
lz4 sys/doc.txt: add sys_compression doxygen group 2023-02-27 15:09:08 +01:00
mbedtls treewide: replace remaining occurrences of tests/pkg_* 2023-05-06 07:55:03 +02:00
micro-ecc pkg/*/Kconfig: Add simple kconfig pkgs 2021-04-08 16:34:36 +02:00
microcoap pkg/*/Kconfig: Add simple kconfig pkgs 2021-04-08 16:34:36 +02:00
micropython pkg/micropython: model in Kconfig 2023-05-30 11:00:25 +02:00
minmea pkg/minmea: bump version 2023-01-20 15:25:25 +01:00
monocypher pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
mynewt-core Merge pull request #18029 from haukepetersen/verbump_nimble_nrfx2022 2022-06-10 04:11:26 +02:00
nanocbor pkg/nanocbor: bump version 2022-08-31 16:29:03 +02:00
nanopb pkg/nanopb: bump version to 0.4.7 2023-01-20 14:37:09 +01:00
nanors pkg/nanors: bump version 2023-03-13 11:49:39 +01:00
nimble pkg/nimble/autoadv: fix flag comparisons 2023-02-02 15:45:00 +01:00
nmsis_sdk pkg/nmsis_sdk: add NMSIS SDK for Nuclei-based MCUs 2023-01-24 00:52:02 +01:00
nrfx pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
openthread pkg/openthread: set event callback before netdev init 2023-05-04 18:26:33 +02:00
openwsn treewide: replace remaining occurrences of tests/pkg_* 2023-05-06 07:55:03 +02:00
paho-mqtt Merge #18962 #18999 #19034 2022-12-11 12:03:28 +00:00
qcbor pkg/qcbor: update doc about path to test application 2023-05-06 07:55:02 +02:00
qdsa pkg/qdsa: add -Wno-cast-align 2021-12-03 10:12:37 +01:00
qr-code-generator pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
relic pkg/relic: bump to current master (e3f82e36 from 08.11.21) 2021-11-08 23:18:30 +01:00
ruy pkg: add Kconfig support for flatbuffers/ruy/tflite-micro 2022-04-27 10:53:50 +02:00
semtech-loramac pkg/semtech-loramac/doc: sx1261 and sx1262 are also supported 2023-04-30 21:56:52 +02:00
spiffs vfs: drop unused abs_path parameter 2022-09-29 22:01:37 +02:00
talking_leds pkg: remove -std=c++11 2022-01-13 17:50:59 +01:00
tflite-micro pkg/tflite-micro: fix compilation with GCC >= 12.x 2022-11-11 09:01:02 +01:00
tiny-asn1 pkg/tiny-asn1: Update tiny-asn1 package 2021-10-02 21:27:40 +02:00
tinycbor pkg/tinycbor: bump version 2022-02-02 14:44:50 +01:00
tinycrypt pkg/tinycryp: supress llvm warning 2021-09-07 09:35:00 +02:00
tinydtls Merge #19346 #19512 #19513 #19514 2023-04-26 15:40:08 +00:00
tinyusb pkg/tinyusb: Rework the tinyUSB kconfig model 2023-05-31 12:55:52 +02:00
tinyvcdiff codespell: fix remaining issues 2022-09-16 14:00:35 +02:00
tlsf doc: fix unbalaced grouping 2022-09-14 15:05:25 +02:00
tweetnacl pkg/*/Kconfig: Add simple kconfig pkgs 2021-04-08 16:34:36 +02:00
u8g2 pkg/u8g2: bump version 2023-02-27 16:00:21 +01:00
ubasic cpu/mips: Remove all mips 2022-09-27 13:42:37 +02:00
ucglib treewide: make all modules use Kconfig ZTIMER_USEC indirection 2022-03-17 14:33:07 +01:00
umorse pkg: silent make commands with RIOT_CI_BUILD=1 2021-03-12 16:05:18 +01:00
utensor pkg/utensor: fix uninitialized variable 2022-11-09 22:47:08 +01:00
uwb-core makefiles/cflags.inc.mk: Add -Wno-missing-field-initializers to CXXFLAGS 2022-10-27 14:28:06 +02:00
uwb-dw1000 pkg/uwb-dw1000: read ch5 pg_delay stored in OTP 2022-04-25 13:32:59 +02:00
uzlib sys/doc.txt: add sys_compression doxygen group 2023-02-27 15:09:08 +01:00
wakaama Merge pull request #18096 from Teufelchen1/feat/port_parsing 2022-09-19 13:40:53 +02:00
wamr pkg/wamr: Update to WAMR-1.1.1 2022-11-29 13:28:46 +01:00
wolfssl pkg: fix remaining broken paths to tests 2023-05-13 19:08:39 +02:00
yxml pkg/yxml: add git mirror url 2021-10-01 14:44:10 +02:00
doc.txt build-system: Allow out of tree BUILD_DIR 2023-05-16 22:23:03 +02:00
Kconfig pkg/micropython: model in Kconfig 2023-05-30 11:00:25 +02:00
local.mk pkg/pkg.mk: better distinguish between source and build directory 2020-06-26 09:25:43 +02:00
Makefile.git pkg/Makefile.git: adapt example to new organization 2020-06-26 09:25:44 +02:00
Makefile.http pkg: add PKG_LICENSE to templates 2020-01-06 00:37:47 +01:00
pkg.mk pkg/pkg.mk: silence info if QUIETER 2022-06-01 10:54:01 +02:00