diff --git a/kernel/Kconfig b/kernel/Kconfig index 3f12d910..4f8baa9b 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -1,4 +1,4 @@ -# Copyright (c) 2013 The F9 Microkernel Project. All rights reserved. +# Copyright (c) 2013,2026 The F9 Microkernel Project. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/mk/generic.mk b/mk/generic.mk index 5dbff476..ec242b4d 100644 --- a/mk/generic.mk +++ b/mk/generic.mk @@ -50,11 +50,18 @@ OLDCONFIG := $(KCONFIG_DIR)/oldconfig.py SAVEDEFCONFIG := $(KCONFIG_DIR)/savedefconfig.py # Kconfiglib commands -cmd_menuconfig = KCONFIG_CONFIG=$(CONFIG) python3 $(MENUCONFIG) $(KCONFIG) -cmd_genconfig = KCONFIG_CONFIG=$(CONFIG) python3 $(GENCONFIG) --header-path include/autoconf.h $(KCONFIG) -cmd_board_defconfig = KCONFIG_CONFIG=$(CONFIG) python3 $(DEFCONFIG) --kconfig $(KCONFIG) board/$*/defconfig -cmd_oldconfig = KCONFIG_CONFIG=$(CONFIG) python3 $(OLDCONFIG) $(KCONFIG) -cmd_savedefconfig = KCONFIG_CONFIG=$(CONFIG) python3 $(SAVEDEFCONFIG) --kconfig $(KCONFIG) --out board/$(BOARD)/defconfig +cmd_menuconfig = KCONFIG_CONFIG=$(CONFIG) $(PYTHON) $(MENUCONFIG) $(KCONFIG) +cmd_genconfig = KCONFIG_CONFIG=$(CONFIG) $(PYTHON) $(GENCONFIG) --header-path include/autoconf.h $(KCONFIG) +cmd_board_defconfig = KCONFIG_CONFIG=$(CONFIG) $(PYTHON) $(DEFCONFIG) --kconfig $(KCONFIG) board/$*/defconfig +cmd_oldconfig = KCONFIG_CONFIG=$(CONFIG) $(PYTHON) $(OLDCONFIG) $(KCONFIG) +cmd_savedefconfig = KCONFIG_CONFIG=$(CONFIG) $(PYTHON) $(SAVEDEFCONFIG) --kconfig $(KCONFIG) --out board/$(BOARD)/defconfig + +# Auto-regenerate autoconf.h when .config changes +# Error handling: Remove partial file on failure to force retry on next build +include/autoconf.h: $(CONFIG) $(GENCONFIG) + @echo " GENCONFIG include/autoconf.h (config changed)" + @$(cmd_genconfig) || { rm -f include/autoconf.h; \ + echo "ERROR: Failed to generate autoconf.h"; false; } .PHONY: bare bare: $(out)/$(PROJECT).bin @@ -71,16 +78,18 @@ $(out)/%.list: $(out)/%.elf $(out)/%.elf: $(out)/f9_nosym.elf $(symmap_obj-list) $(call quiet,elf_relink,LD ) -$(out)/f9_nosym.elf: $(objs) +# Build depends on valid autoconf.h +$(out)/f9_nosym.elf: $(objs) include/autoconf.h $(call quiet,elf,LD ) -$(out)/user/%.o:user/%.c +# All compilation depends on autoconf.h being up-to-date +$(out)/user/%.o:user/%.c include/autoconf.h $(call quiet,c_to_o_user,CC ) -$(out)/%.o:%.c +$(out)/%.o:%.c include/autoconf.h $(call quiet,c_to_o,CC ) -$(out)/%.o:%.S +$(out)/%.o:%.S include/autoconf.h $(call quiet,c_to_o,AS ) $(build-utils): $(out)/%:%.c diff --git a/mk/toolchain.mk b/mk/toolchain.mk index f472dad5..7fd2231f 100644 --- a/mk/toolchain.mk +++ b/mk/toolchain.mk @@ -16,6 +16,9 @@ NM = $(CROSS_COMPILE)nm BUILDCC = $(HOST_COMPILE)gcc +# Python interpreter for build scripts (Kconfig tools, test runners) +PYTHON ?= python3 + # Misc Information GIT_HEAD = $(shell git rev-parse HEAD) MACH_TYPE = $(shell uname -m) diff --git a/platform/Kconfig b/platform/Kconfig index dce18bf0..70f26035 100644 --- a/platform/Kconfig +++ b/platform/Kconfig @@ -1,4 +1,4 @@ -# Copyright (c) 2013 The F9 Microkernel Project. All rights reserved. +# Copyright (c) 2013-2016,2026 The F9 Microkernel Project. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/user/Kconfig b/user/Kconfig index 7c5a88af..1a51b6dc 100644 --- a/user/Kconfig +++ b/user/Kconfig @@ -1,18 +1,63 @@ -# Copyright (c) 2015-2017 The F9 Microkernel Project. All rights reserved. +# Copyright (c) 2015-2017,2026 The F9 Microkernel Project. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. menu "User Space" -config BUILD_USER_APPS - bool "Build user applications for F9 microkernel" +choice + prompt "User Application" + default USER_APP_TESTS + help + Select which user application to build and run. + Only one application can be active at a time to avoid + memory contention and resource conflicts. + +config USER_APP_TESTS + bool "Test Suite (Automated Testing)" + help + Machine-parseable test suite for automated CI/CD. + + Commands: + make run-tests - Run test suite + make run-tests FAULT=mpu - Run MPU fault test + make run-tests FAULT=canary - Run stack canary test + + Test suite verifies IPC, threads, scheduler, timer, memory, + and notification subsystems. Recommended for development and CI/CD. + +config USER_APP_PINGPONG + bool "Pingpong Demo" + help + Simple IPC demonstration with two threads exchanging messages. + Useful for testing basic IPC functionality and as a minimal example. + +config USER_APP_NONE + bool "No user application" + help + Do not build any user application. Kernel-only build. + Useful for kernel development and KDB debugging. + +endchoice + +# Hardware-specific test cases (requires user application) +menu "Hardware Test Cases" + depends on USER_APP_TESTS || USER_APP_PINGPONG + +config LCD_TEST + bool "LCD Test Cases" default n - ---help--- - Enable this options to will compile userspace apps - into f9-kernel, This may let you unable to use kdb. + help + LCD hardware test cases for boards with LCD support. + Available when user application is enabled. -source "user/Kconfig.apps" +config EXTI_INTERRUPT_TEST + bool "EXTI interrupt test case" + default n + depends on EXTI0_USER_IRQ && EXTI1_USER_IRQ + help + External interrupt (EXTI) test for hardware validation. + Requires EXTI0 and EXTI1 user IRQ support. -source "user/Kconfig.tests" +endmenu endmenu diff --git a/user/Kconfig.apps b/user/Kconfig.apps deleted file mode 100644 index c060ac14..00000000 --- a/user/Kconfig.apps +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2016 The F9 Microkernel Project. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -menu "Apps" - depends on BUILD_USER_APPS - -config PINGPONG - bool "Pingpong game" - default n - -endmenu diff --git a/user/Kconfig.tests b/user/Kconfig.tests deleted file mode 100644 index 08e43392..00000000 --- a/user/Kconfig.tests +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) 2016 The F9 Microkernel Project. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -menu "Test Cases" - depends on BUILD_USER_APPS - -config EXTI_INTERRUPT_TEST - bool "EXTI interrupt test case" - default n - depends on EXTI0_USER_IRQ && EXTI1_USER_IRQ - -config LCD_TEST - bool "LCD Test Cases" - default n - -config TESTS - bool "Test Suite" - default n - help - Machine-parseable test suite for automated CI/CD. - - Commands: - make run-tests - Run test suite - make run-tests FAULT=mpu - Run MPU fault test - make run-tests FAULT=canary - Run stack canary test - - Test suite verifies IPC, threads, timer, and KIP. - Fault tests verify MPU protection and stack overflow detection. - - For reliable results, disable other user apps (L4_TEST, - PINGPONG) when running tests to avoid memory contention. - -endmenu diff --git a/user/apps/build.mk b/user/apps/build.mk index dfd638e1..aaaa5058 100644 --- a/user/apps/build.mk +++ b/user/apps/build.mk @@ -2,22 +2,19 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -ifdef CONFIG_BUILD_USER_APPS - user-apps-dirs = "" -ifdef CONFIG_PINGPONG +ifdef CONFIG_USER_APP_PINGPONG user-apps-dirs += \ pingpong endif -ifdef CONFIG_LCD_TEST +ifdef CONFIG_USER_APP_TESTS user-apps-dirs += \ - lcd_test + tests endif -ifdef CONFIG_TESTS +ifdef CONFIG_LCD_TEST user-apps-dirs += \ - tests -endif + lcd_test endif