diff --git a/doc/getting-started/apl-nuc.rst b/doc/getting-started/apl-nuc.rst index dce8ccae0..eb0b9126e 100644 --- a/doc/getting-started/apl-nuc.rst +++ b/doc/getting-started/apl-nuc.rst @@ -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/.config``, where ```` is the +``hypervisor/arch/x86/configs/.config``, where ```` 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 diff --git a/hypervisor/arch/x86/Kconfig b/hypervisor/arch/x86/Kconfig index c87f2c695..737896a9a 100644 --- a/hypervisor/arch/x86/Kconfig +++ b/hypervisor/arch/x86/Kconfig @@ -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 diff --git a/hypervisor/arch/x86/configs/sbl.config b/hypervisor/arch/x86/configs/apl-mrb.config similarity index 70% rename from hypervisor/arch/x86/configs/sbl.config rename to hypervisor/arch/x86/configs/apl-mrb.config index 95eb0d1ad..67a59849a 100644 --- a/hypervisor/arch/x86/configs/sbl.config +++ b/hypervisor/arch/x86/configs/apl-mrb.config @@ -1,2 +1,3 @@ +CONFIG_BOARD="apl-mrb" # CONFIG_PLATFORM_UEFI is not set CONFIG_PLATFORM_SBL=y diff --git a/hypervisor/arch/x86/configs/apl-nuc.config b/hypervisor/arch/x86/configs/apl-nuc.config new file mode 120000 index 000000000..b341a134e --- /dev/null +++ b/hypervisor/arch/x86/configs/apl-nuc.config @@ -0,0 +1 @@ +nuc6cayh.config \ No newline at end of file diff --git a/hypervisor/arch/x86/configs/nuc6cayh.config b/hypervisor/arch/x86/configs/nuc6cayh.config new file mode 100644 index 000000000..7ffdde65e --- /dev/null +++ b/hypervisor/arch/x86/configs/nuc6cayh.config @@ -0,0 +1,3 @@ +CONFIG_BOARD="NUC6CAYH" +CONFIG_PLATFORM_UEFI=y +# CONFIG_PLATFORM_SBL is not set diff --git a/hypervisor/arch/x86/configs/uefi.config b/hypervisor/arch/x86/configs/up2.config similarity index 74% rename from hypervisor/arch/x86/configs/uefi.config rename to hypervisor/arch/x86/configs/up2.config index 972451df6..a3f620724 100644 --- a/hypervisor/arch/x86/configs/uefi.config +++ b/hypervisor/arch/x86/configs/up2.config @@ -1,2 +1,3 @@ +CONFIG_BOARD="UP2" CONFIG_PLATFORM_UEFI=y # CONFIG_PLATFORM_SBL is not set diff --git a/hypervisor/scripts/kconfig/kconfig.mk b/hypervisor/scripts/kconfig/kconfig.mk index 4a24f301e..aa48bb41c 100644 --- a/hypervisor/scripts/kconfig/kconfig.mk +++ b/hypervisor/scripts/kconfig/kconfig.mk @@ -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 diff --git a/scripts/kconfig/defconfig.py b/scripts/kconfig/defconfig.py index 855561d8f..c090fadcc 100644 --- a/scripts/kconfig/defconfig.py +++ b/scripts/kconfig/defconfig.py @@ -12,28 +12,45 @@ import sys, os import kconfiglib def usage(): - sys.stdout.write("%s: \n" % sys.argv[0]) + sys.stdout.write("%s: \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()