Skip to content

Commit 8e6a823

Browse files
authored
Merge pull request #183 from f9micro/refine-configure
Simplify configuration system
2 parents 41c6f50 + b9e7ed9 commit 8e6a823

File tree

8 files changed

+81
-73
lines changed

8 files changed

+81
-73
lines changed

kernel/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2013 The F9 Microkernel Project. All rights reserved.
1+
# Copyright (c) 2013,2026 The F9 Microkernel Project. All rights reserved.
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

mk/generic.mk

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,18 @@ OLDCONFIG := $(KCONFIG_DIR)/oldconfig.py
5050
SAVEDEFCONFIG := $(KCONFIG_DIR)/savedefconfig.py
5151

5252
# Kconfiglib commands
53-
cmd_menuconfig = KCONFIG_CONFIG=$(CONFIG) python3 $(MENUCONFIG) $(KCONFIG)
54-
cmd_genconfig = KCONFIG_CONFIG=$(CONFIG) python3 $(GENCONFIG) --header-path include/autoconf.h $(KCONFIG)
55-
cmd_board_defconfig = KCONFIG_CONFIG=$(CONFIG) python3 $(DEFCONFIG) --kconfig $(KCONFIG) board/$*/defconfig
56-
cmd_oldconfig = KCONFIG_CONFIG=$(CONFIG) python3 $(OLDCONFIG) $(KCONFIG)
57-
cmd_savedefconfig = KCONFIG_CONFIG=$(CONFIG) python3 $(SAVEDEFCONFIG) --kconfig $(KCONFIG) --out board/$(BOARD)/defconfig
53+
cmd_menuconfig = KCONFIG_CONFIG=$(CONFIG) $(PYTHON) $(MENUCONFIG) $(KCONFIG)
54+
cmd_genconfig = KCONFIG_CONFIG=$(CONFIG) $(PYTHON) $(GENCONFIG) --header-path include/autoconf.h $(KCONFIG)
55+
cmd_board_defconfig = KCONFIG_CONFIG=$(CONFIG) $(PYTHON) $(DEFCONFIG) --kconfig $(KCONFIG) board/$*/defconfig
56+
cmd_oldconfig = KCONFIG_CONFIG=$(CONFIG) $(PYTHON) $(OLDCONFIG) $(KCONFIG)
57+
cmd_savedefconfig = KCONFIG_CONFIG=$(CONFIG) $(PYTHON) $(SAVEDEFCONFIG) --kconfig $(KCONFIG) --out board/$(BOARD)/defconfig
58+
59+
# Auto-regenerate autoconf.h when .config changes
60+
# Error handling: Remove partial file on failure to force retry on next build
61+
include/autoconf.h: $(CONFIG) $(GENCONFIG)
62+
@echo " GENCONFIG include/autoconf.h (config changed)"
63+
@$(cmd_genconfig) || { rm -f include/autoconf.h; \
64+
echo "ERROR: Failed to generate autoconf.h"; false; }
5865

5966
.PHONY: bare
6067
bare: $(out)/$(PROJECT).bin
@@ -71,16 +78,18 @@ $(out)/%.list: $(out)/%.elf
7178
$(out)/%.elf: $(out)/f9_nosym.elf $(symmap_obj-list)
7279
$(call quiet,elf_relink,LD )
7380

74-
$(out)/f9_nosym.elf: $(objs)
81+
# Build depends on valid autoconf.h
82+
$(out)/f9_nosym.elf: $(objs) include/autoconf.h
7583
$(call quiet,elf,LD )
7684

77-
$(out)/user/%.o:user/%.c
85+
# All compilation depends on autoconf.h being up-to-date
86+
$(out)/user/%.o:user/%.c include/autoconf.h
7887
$(call quiet,c_to_o_user,CC )
7988

80-
$(out)/%.o:%.c
89+
$(out)/%.o:%.c include/autoconf.h
8190
$(call quiet,c_to_o,CC )
8291

83-
$(out)/%.o:%.S
92+
$(out)/%.o:%.S include/autoconf.h
8493
$(call quiet,c_to_o,AS )
8594

8695
$(build-utils): $(out)/%:%.c

mk/toolchain.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ NM = $(CROSS_COMPILE)nm
1616

1717
BUILDCC = $(HOST_COMPILE)gcc
1818

19+
# Python interpreter for build scripts (Kconfig tools, test runners)
20+
PYTHON ?= python3
21+
1922
# Misc Information
2023
GIT_HEAD = $(shell git rev-parse HEAD)
2124
MACH_TYPE = $(shell uname -m)

platform/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2013 The F9 Microkernel Project. All rights reserved.
1+
# Copyright (c) 2013-2016,2026 The F9 Microkernel Project. All rights reserved.
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

user/Kconfig

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,63 @@
1-
# Copyright (c) 2015-2017 The F9 Microkernel Project. All rights reserved.
1+
# Copyright (c) 2015-2017,2026 The F9 Microkernel Project. All rights reserved.
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

55
menu "User Space"
66

7-
config BUILD_USER_APPS
8-
bool "Build user applications for F9 microkernel"
7+
choice
8+
prompt "User Application"
9+
default USER_APP_TESTS
10+
help
11+
Select which user application to build and run.
12+
Only one application can be active at a time to avoid
13+
memory contention and resource conflicts.
14+
15+
config USER_APP_TESTS
16+
bool "Test Suite (Automated Testing)"
17+
help
18+
Machine-parseable test suite for automated CI/CD.
19+
20+
Commands:
21+
make run-tests - Run test suite
22+
make run-tests FAULT=mpu - Run MPU fault test
23+
make run-tests FAULT=canary - Run stack canary test
24+
25+
Test suite verifies IPC, threads, scheduler, timer, memory,
26+
and notification subsystems. Recommended for development and CI/CD.
27+
28+
config USER_APP_PINGPONG
29+
bool "Pingpong Demo"
30+
help
31+
Simple IPC demonstration with two threads exchanging messages.
32+
Useful for testing basic IPC functionality and as a minimal example.
33+
34+
config USER_APP_NONE
35+
bool "No user application"
36+
help
37+
Do not build any user application. Kernel-only build.
38+
Useful for kernel development and KDB debugging.
39+
40+
endchoice
41+
42+
# Hardware-specific test cases (requires user application)
43+
menu "Hardware Test Cases"
44+
depends on USER_APP_TESTS || USER_APP_PINGPONG
45+
46+
config LCD_TEST
47+
bool "LCD Test Cases"
948
default n
10-
---help---
11-
Enable this options to will compile userspace apps
12-
into f9-kernel, This may let you unable to use kdb.
49+
help
50+
LCD hardware test cases for boards with LCD support.
51+
Available when user application is enabled.
1352

14-
source "user/Kconfig.apps"
53+
config EXTI_INTERRUPT_TEST
54+
bool "EXTI interrupt test case"
55+
default n
56+
depends on EXTI0_USER_IRQ && EXTI1_USER_IRQ
57+
help
58+
External interrupt (EXTI) test for hardware validation.
59+
Requires EXTI0 and EXTI1 user IRQ support.
1560

16-
source "user/Kconfig.tests"
61+
endmenu
1762

1863
endmenu

user/Kconfig.apps

Lines changed: 0 additions & 12 deletions
This file was deleted.

user/Kconfig.tests

Lines changed: 0 additions & 34 deletions
This file was deleted.

user/apps/build.mk

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5-
ifdef CONFIG_BUILD_USER_APPS
6-
75
user-apps-dirs = ""
86

9-
ifdef CONFIG_PINGPONG
7+
ifdef CONFIG_USER_APP_PINGPONG
108
user-apps-dirs += \
119
pingpong
1210
endif
1311

14-
ifdef CONFIG_LCD_TEST
12+
ifdef CONFIG_USER_APP_TESTS
1513
user-apps-dirs += \
16-
lcd_test
14+
tests
1715
endif
1816

19-
ifdef CONFIG_TESTS
17+
ifdef CONFIG_LCD_TEST
2018
user-apps-dirs += \
21-
tests
22-
endif
19+
lcd_test
2320
endif

0 commit comments

Comments
 (0)