bootloader: Kconfig files in bootloader_components is now part of menuconfig

It is now possible to configure the options (Kconfig) of bootloader components
directly from the menuconfig
pull/7530/head
Omar Chebib 2021-08-11 14:59:16 +08:00
rodzic 2c49af9e75
commit 339454ff19
5 zmienionych plików z 57 dodań i 2 usunięć

Wyświetl plik

@ -0,0 +1,8 @@
menu "Bootloader welcome message"
config EXAMPLE_BOOTLOADER_WELCOME_MESSAGE
string "Bootloader welcome message"
default "Custom bootloader message defined in the KConfig file."
help
Message to print by the custom bootloader when booting up.
endmenu

Wyświetl plik

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdbool.h>
#include "sdkconfig.h"
#include "esp_log.h"
#include "bootloader_init.h"
#include "bootloader_utility.h"
@ -41,7 +42,7 @@ void __attribute__((noreturn)) call_start_cpu0(void)
}
// 2.1 Print a custom message!
esp_rom_printf("[%s] Custom bootloader has been initialized correctly.\n", TAG);
esp_rom_printf("[%s] %s\n", TAG, CONFIG_EXAMPLE_BOOTLOADER_WELCOME_MESSAGE);
// 3. Load the app image for booting
bootloader_utility_load_boot_image(&bs, boot_index);

Wyświetl plik

@ -10,7 +10,10 @@ def test_custom_bootloader_impl_example(env, _): # type: ignore
dut.start_app()
# Expect to read a message from the custom bootloader
dut.expect('Custom bootloader has been initialized correctly.')
# This message is defined in the Kconfig file, retrieve it while deleting
# leading and trailing quotes (")
welcome_message = dut.app.get_sdkconfig()['CONFIG_EXAMPLE_BOOTLOADER_WELCOME_MESSAGE'].strip("\"")
dut.expect(welcome_message)
# Expect to read a message from the user application
dut.expect('Application started!')

Wyświetl plik

@ -112,6 +112,29 @@ function(__kconfig_component_init component_target)
__component_set_property(${component_target} SDKCONFIG_RENAME "${sdkconfig_rename}")
endfunction()
#
# Add bootloader components Kconfig and Kconfig.projbuild files to BOOTLOADER_KCONFIG
# and BOOTLOADER_KCONFIGS_PROJ properties respectively.
#
function(__kconfig_bootloader_component_add component_dir)
idf_build_get_property(bootloader_kconfigs BOOTLOADER_KCONFIGS)
idf_build_get_property(bootloader_kconfigs_proj BOOTLOADER_KCONFIGS_PROJ)
file(GLOB kconfig "${component_dir}/Kconfig")
if(EXISTS "${kconfig}" AND NOT IS_DIRECTORY "${kconfig}")
list(APPEND bootloader_kconfigs "${kconfig}")
endif()
file(GLOB kconfig "${component_dir}/Kconfig.projbuild")
if(EXISTS "${kconfig}" AND NOT IS_DIRECTORY "${kconfig}")
list(APPEND bootloader_kconfigs_proj "${kconfig}")
endif()
idf_build_set_property(BOOTLOADER_KCONFIGS "${bootloader_kconfigs}")
idf_build_set_property(BOOTLOADER_KCONFIGS_PROJ "${bootloader_kconfigs_proj}")
endfunction()
#
# Generate the config files and create config related targets and configure
# dependencies.
@ -137,6 +160,12 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults)
endif()
endforeach()
# Take into account bootloader components configuration files
idf_build_get_property(bootloader_kconfigs BOOTLOADER_KCONFIGS)
idf_build_get_property(bootloader_kconfigs_proj BOOTLOADER_KCONFIGS_PROJ)
list(APPEND kconfigs "${bootloader_kconfigs}")
list(APPEND kconfig_projbuilds "${bootloader_kconfigs_proj}")
# Store the list version of kconfigs and kconfig_projbuilds
idf_build_set_property(KCONFIGS "${kconfigs}")
idf_build_set_property(KCONFIG_PROJBUILDS "${kconfig_projbuilds}")

Wyświetl plik

@ -197,6 +197,20 @@ function(__project_init components_var test_components_var)
__project_component_dir("${CMAKE_CURRENT_LIST_DIR}/components")
endif()
# For bootloader components, we only need to set-up the Kconfig files.
# Indeed, bootloader is currently compiled as a subproject, thus,
# its components are not part of the main project.
# However, in order to be able to configure these bootloader components
# using menuconfig, we need to look for their Kconfig-related files now.
file(GLOB bootloader_component_dirs "${CMAKE_CURRENT_LIST_DIR}/bootloader_components/*")
list(SORT bootloader_component_dirs)
foreach(bootloader_component_dir ${bootloader_component_dirs})
__component_dir_quick_check(is_component ${bootloader_component_dir})
if(is_component)
__kconfig_bootloader_component_add("${bootloader_component_dir}")
endif()
endforeach()
spaces2list(COMPONENTS)
spaces2list(EXCLUDE_COMPONENTS)
idf_build_get_property(component_targets __COMPONENT_TARGETS)