From cfe9048693c8a37b967a28d5bba90b390ff8bfe5 Mon Sep 17 00:00:00 2001 From: Vdragon Date: Wed, 3 Dec 2025 18:58:36 +0100 Subject: [PATCH] zephyr: Add ability to set feature level in conf file. Adds the ability to set feature level in board.conf. Signed-off-by: Vdragon --- ports/zephyr/Kconfig | 24 ++++++++++++++++++++++++ ports/zephyr/mpconfigport.h | 15 +++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/ports/zephyr/Kconfig b/ports/zephyr/Kconfig index beddb2b0b9..c12e4bc854 100644 --- a/ports/zephyr/Kconfig +++ b/ports/zephyr/Kconfig @@ -59,6 +59,30 @@ config MICROPY_USB_DEVICE_PID hex "USB PID" default 0x0001 +choice MICROPY_CONFIG_ROM_LEVEL + prompt "MicroPython Features level" + default MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES + + config MICROPY_CONFIG_ROM_LEVEL_MINIMUM + bool "Disable all optional features" + + config MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES + bool "Only enable core features" + + config MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES + bool "Enable most common features" + + config MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES + bool "Enable convenience features" + + config MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES + bool "Enable all common features" + + config MICROPY_CONFIG_ROM_LEVEL_EVERYTHING + bool "Enable everything" + +endchoice + endmenu # MicroPython Options source "Kconfig.zephyr" diff --git a/ports/zephyr/mpconfigport.h b/ports/zephyr/mpconfigport.h index f52b42fc2f..ceaa6df43c 100644 --- a/ports/zephyr/mpconfigport.h +++ b/ports/zephyr/mpconfigport.h @@ -31,9 +31,20 @@ #include #include -// Use the basic configuration level to get a balance between size and features. -#ifndef MICROPY_CONFIG_ROM_LEVEL +#if defined(CONFIG_MICROPY_CONFIG_ROM_LEVEL_MINIMUM) +#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_MINIMUM) +#elif defined(CONFIG_MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES) +#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES) +#elif defined(CONFIG_MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES) #define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES) +#elif defined(CONFIG_MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES) +#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES) +#elif defined(CONFIG_MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES) +#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES) +#elif defined(CONFIG_MICROPY_CONFIG_ROM_LEVEL_EVERYTHING) +#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EVERYTHING) +#else +#error "Undefined Feature Level" #endif // Usually passed from Makefile