mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-21 13:08:42 +00:00
kconfig: support board-specific defconfig
The current defconfigs are BIOS-specific which makes it difficult to maintain multiple defconfigs for boards running the same BIOS. This patch re-organizes the defconfigs to be board-specific. A command line option BOARD is introduced to specify a board on which the current build targets at. The original PLATFORM is kept for backward compatibility which redirects to apl-mrb and nuc6cayh for sbl and uefi, respectively. The getting started guide is also updated accordingly. v1 -> v2: * Rewrite 'up2' to 'UP2'. Tracked-On: #1588 Signed-off-by: Junjie Mao <junjie.mao@intel.com> Reviewed-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
parent
8bde372c32
commit
b9d54f4ab3
@ -254,7 +254,7 @@ partition. Follow these steps:
|
||||
|
||||
# systemctl enable weston@cl_sos
|
||||
# systemctl start weston@cl_sos
|
||||
|
||||
|
||||
#. Reboot and select "The ACRN Service OS" to boot, as shown below:
|
||||
|
||||
|
||||
@ -537,7 +537,7 @@ The build results are found in the ``build`` directory.
|
||||
.. note::
|
||||
if you wish to use a different target folder for the build
|
||||
artefacts, set the ``O`` (that is capital letter 'O') to the
|
||||
desired value. Example: ``make O=build-uefi PLATFORM=uefi``.
|
||||
desired value. Example: ``make O=build-nuc BOARD=nuc6cayh``.
|
||||
|
||||
Generating the documentation is decribed in details in the :ref:`acrn_doc`
|
||||
tutorial.
|
||||
@ -551,7 +551,7 @@ and are using it as the current working directory.
|
||||
.. code-block:: none
|
||||
|
||||
$ cd hypervisor
|
||||
$ make PLATFORM=uefi
|
||||
$ make BOARD=nuc6cayh
|
||||
|
||||
The build results are found in the ``build`` directory.
|
||||
|
||||
@ -578,8 +578,8 @@ Generate the hypervisor configurations
|
||||
======================================
|
||||
|
||||
The ACRN hypervisor leverages Kconfig to manage configurations, powered by
|
||||
Kconfiglib. A default configuration is generated based on the platform you have
|
||||
selected via the ``PLATFORM=`` command line parameter. You can make further
|
||||
Kconfiglib. A default configuration is generated based on the board you have
|
||||
selected via the ``BOARD=`` command line parameter. You can make further
|
||||
changes to that default configuration to adjust to your specific
|
||||
requirements.
|
||||
|
||||
@ -592,9 +592,9 @@ found under the target folder of your build.
|
||||
.. code-block:: none
|
||||
|
||||
$ cd hypervisor
|
||||
$ make defconfig PLATFORM=uefi
|
||||
$ make defconfig BOARD=nuc6cayh
|
||||
|
||||
The PLATFORM specified is used to select a defconfig under
|
||||
The BOARD specified is used to select a defconfig under
|
||||
``arch/x86/configs/``. The other command-line based options (e.g. ``RELEASE``)
|
||||
take no effects when generating a defconfig.
|
||||
|
||||
@ -611,7 +611,7 @@ the hypervisor using the updated ``.config``.
|
||||
.. code-block:: none
|
||||
|
||||
$ cd hypervisor
|
||||
$ make defconfig PLATFORM=uefi
|
||||
$ make defconfig BOARD=nuc6cayh
|
||||
$ make menuconfig # Modify the configurations per your needs
|
||||
$ make # Build the hypervisor with the new .config
|
||||
|
||||
@ -628,21 +628,21 @@ Create a new default configuration
|
||||
==================================
|
||||
|
||||
Currently the ACRN hypervisor looks for default configurations under
|
||||
``hypervisor/arch/x86/configs/<PLATFORM>.config``, where ``<PLATFORM>`` is the
|
||||
``hypervisor/arch/x86/configs/<BOARD>.config``, where ``<BOARD>`` is the
|
||||
specified platform. The following steps allow you to create a defconfig for
|
||||
another platform based on a current one.
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
$ cd hypervisor
|
||||
$ make defconfig PLATFORM=uefi
|
||||
$ make defconfig BOARD=nuc6cayh
|
||||
$ make menuconfig # Modify the configurations
|
||||
$ make savedefconfig # The minimized config reside at build/defconfig
|
||||
$ cp build/defconfig arch/x86/configs/xxx.config
|
||||
|
||||
Then you can re-use that configuration by passing the name (``xxx`` in the
|
||||
example above) to 'PLATFORM=':
|
||||
example above) to 'BOARD=':
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
$ make defconfig PLATFORM=xxx
|
||||
$ make defconfig BOARD=xxx
|
||||
|
@ -45,6 +45,16 @@ config PLATFORM
|
||||
default "uefi" if PLATFORM_UEFI
|
||||
default "sbl" if PLATFORM_SBL
|
||||
|
||||
config BOARD
|
||||
string "Target board"
|
||||
help
|
||||
The target board this build runs on top of.
|
||||
|
||||
config DEFCONFIG_LIST
|
||||
string
|
||||
option defconfig_list
|
||||
default "arch/x86/configs/$BOARD.config"
|
||||
|
||||
config RELEASE
|
||||
bool "Release build"
|
||||
default n
|
||||
|
@ -1,2 +1,3 @@
|
||||
CONFIG_BOARD="apl-mrb"
|
||||
# CONFIG_PLATFORM_UEFI is not set
|
||||
CONFIG_PLATFORM_SBL=y
|
1
hypervisor/arch/x86/configs/apl-nuc.config
Symbolic link
1
hypervisor/arch/x86/configs/apl-nuc.config
Symbolic link
@ -0,0 +1 @@
|
||||
nuc6cayh.config
|
3
hypervisor/arch/x86/configs/nuc6cayh.config
Normal file
3
hypervisor/arch/x86/configs/nuc6cayh.config
Normal file
@ -0,0 +1,3 @@
|
||||
CONFIG_BOARD="NUC6CAYH"
|
||||
CONFIG_PLATFORM_UEFI=y
|
||||
# CONFIG_PLATFORM_SBL is not set
|
@ -1,2 +1,3 @@
|
||||
CONFIG_BOARD="UP2"
|
||||
CONFIG_PLATFORM_UEFI=y
|
||||
# CONFIG_PLATFORM_SBL is not set
|
@ -30,9 +30,27 @@ endif
|
||||
endif
|
||||
|
||||
-include $(HV_OBJDIR)/$(HV_CONFIG_MK)
|
||||
$(eval $(call override_config,PLATFORM,sbl))
|
||||
|
||||
# Backward-compatibility for PLATFORM=(sbl|uefi)
|
||||
# * PLATFORM=sbl is equivalent to BOARD=apl-mrb
|
||||
# * PLATFORM=uefi is equivalent to BOARD=apl-nuc (i.e. NUC6CAYH)
|
||||
ifndef BOARD
|
||||
ifeq ($(PLATFORM),sbl)
|
||||
BOARD=apl-mrb
|
||||
else ifeq ($(PLATFORM),uefi)
|
||||
BOARD=apl-nuc
|
||||
endif
|
||||
endif
|
||||
|
||||
$(eval $(call override_config,BOARD,apl-mrb))
|
||||
$(eval $(call override_config,RELEASE,n))
|
||||
|
||||
ifdef BOARD
|
||||
TARGET_BOARD=$(BOARD)
|
||||
else
|
||||
TARGET_BOARD=$(CONFIG_BOARD)
|
||||
endif
|
||||
|
||||
$(eval $(call check_dep_exec,python3,KCONFIG_DEPS))
|
||||
$(eval $(call check_dep_py3lib,kconfiglib,KCONFIG_DEPS))
|
||||
|
||||
@ -59,8 +77,8 @@ $(HV_OBJDIR)/$(HV_CONFIG_H): $(HV_OBJDIR)/$(HV_CONFIG)
|
||||
.PHONY: defconfig
|
||||
defconfig: $(KCONFIG_DEPS)
|
||||
@mkdir -p $(HV_OBJDIR)
|
||||
@python3 $(KCONFIG_DIR)/defconfig.py Kconfig \
|
||||
arch/x86/configs/$(CONFIG_PLATFORM).config \
|
||||
@BOARD=$(TARGET_BOARD) \
|
||||
python3 $(KCONFIG_DIR)/defconfig.py Kconfig \
|
||||
$(HV_OBJDIR)/$(HV_CONFIG)
|
||||
|
||||
# Use silentoldconfig to forcefully update the current .config, or generate a
|
||||
@ -73,9 +91,9 @@ defconfig: $(KCONFIG_DEPS)
|
||||
.PHONY: oldconfig
|
||||
oldconfig: $(KCONFIG_DEPS)
|
||||
@mkdir -p $(HV_OBJDIR)
|
||||
@python3 $(KCONFIG_DIR)/silentoldconfig.py Kconfig \
|
||||
@BOARD=$(TARGET_BOARD) \
|
||||
python3 $(KCONFIG_DIR)/silentoldconfig.py Kconfig \
|
||||
$(HV_OBJDIR)/$(HV_CONFIG) \
|
||||
PLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z)=y \
|
||||
RELEASE=$(RELEASE)
|
||||
|
||||
# Minimize the current .config. This target can be used to generate a defconfig
|
||||
|
@ -12,28 +12,45 @@ import sys, os
|
||||
import kconfiglib
|
||||
|
||||
def usage():
|
||||
sys.stdout.write("%s: <Kconfig file> <defconfig> <path to .config>\n" % sys.argv[0])
|
||||
sys.stdout.write("%s: <Kconfig file> <path to .config>\n" % sys.argv[0])
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 4:
|
||||
if len(sys.argv) < 3:
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
target_board = os.environ['BOARD']
|
||||
|
||||
kconfig_path = sys.argv[1]
|
||||
if not os.path.isfile(kconfig_path):
|
||||
sys.stderr.write("Cannot find file %s\n" % kconfig_path)
|
||||
sys.exit(1)
|
||||
|
||||
defconfig_path = sys.argv[2]
|
||||
if not os.path.isfile(defconfig_path):
|
||||
sys.stderr.write("Cannot find file %s\n" % defconfig_path)
|
||||
kconfig = kconfiglib.Kconfig(kconfig_path)
|
||||
defconfig_path = kconfig.defconfig_filename
|
||||
if not defconfig_path or not os.path.isfile(defconfig_path):
|
||||
sys.stderr.write("No defconfig found for board %s.\n" % target_board)
|
||||
sys.exit(1)
|
||||
|
||||
sys.stdout.write("Default configuration based on %s.\n" % defconfig_path)
|
||||
kconfig = kconfiglib.Kconfig(kconfig_path)
|
||||
kconfig.load_config(defconfig_path)
|
||||
kconfig.write_config(sys.argv[3])
|
||||
sys.stdout.write("Configuration written to %s.\n" % sys.argv[3])
|
||||
|
||||
config_path = sys.argv[2]
|
||||
if os.path.isfile(config_path):
|
||||
# No need to change .config if it is already equivalent to the specified
|
||||
# default.
|
||||
kconfig_current = kconfiglib.Kconfig(kconfig_path)
|
||||
kconfig_current.load_config(config_path)
|
||||
same_config = True
|
||||
for sym in kconfig_current.syms:
|
||||
if kconfig_current.syms[sym].str_value != kconfig.syms[sym].str_value:
|
||||
same_config = False
|
||||
break
|
||||
if same_config:
|
||||
sys.exit(0)
|
||||
|
||||
sys.stdout.write("Default configuration based on %s.\n" % defconfig_path)
|
||||
kconfig.write_config(config_path)
|
||||
sys.stdout.write("Configuration written to %s.\n" % config_path)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user