diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index ba1678dd5a60..436ecf5c2851 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -48,6 +48,15 @@ config XTENSA_RESET_VECTOR This is always needed for the simulator. Real boards may already implement this in boot ROM. +if XTENSA_RESET_VECTOR +config RESET_VECTOR_IN_BOOTLOADER + bool "Link reset vector into bootloader" + default n + help + Reset vector code can be either linked in the bootloader or the + application binary. Select "y" to link it into the bootloader. +endif + config XTENSA_USE_CORE_CRT1 bool "Use crt1.S from core" default y diff --git a/arch/xtensa/core/startup/CMakeLists.txt b/arch/xtensa/core/startup/CMakeLists.txt index 1c21781ca72e..29859e755ac6 100644 --- a/arch/xtensa/core/startup/CMakeLists.txt +++ b/arch/xtensa/core/startup/CMakeLists.txt @@ -9,8 +9,11 @@ if(CONFIG_XTENSA_RESET_VECTOR) -mlongcalls ) - zephyr_library_sources( + zephyr_library_sources_ifndef(CONFIG_RESET_VECTOR_IN_BOOTLOADER reset-vector.S + ) + + zephyr_library_sources( memerror-vector.S memctl_default.S ) diff --git a/samples/audio/sof/prj.conf b/samples/audio/sof/prj.conf index 2be9a027b56e..41bfe78400a5 100644 --- a/samples/audio/sof/prj.conf +++ b/samples/audio/sof/prj.conf @@ -3,6 +3,7 @@ CONFIG_SMP=n CONFIG_LOG=y CONFIG_MP_NUM_CPUS=1 CONFIG_BUILD_OUTPUT_BIN=n +CONFIG_RESET_VECTOR_IN_BOOTLOADER=y # Requires heap_info() be implemented, but no Zephyr wrapper CONFIG_DEBUG_MEMORY_USAGE_SCAN=n diff --git a/soc/xtensa/intel_adsp/common/bootloader/CMakeLists.txt b/soc/xtensa/intel_adsp/common/bootloader/CMakeLists.txt index 50e939f120dd..81f96729a74b 100644 --- a/soc/xtensa/intel_adsp/common/bootloader/CMakeLists.txt +++ b/soc/xtensa/intel_adsp/common/bootloader/CMakeLists.txt @@ -26,11 +26,14 @@ add_executable(bootloader boot_entry.S ${ARCH_DIR}/${ARCH}/core/startup/memctl_default.S ${ARCH_DIR}/${ARCH}/core/startup/memerror-vector.S - ${ARCH_DIR}/${ARCH}/core/startup/reset-vector.S boot_loader.c start_address.S ) +target_sources_ifdef(CONFIG_RESET_VECTOR_IN_BOOTLOADER bootloader PRIVATE + ${ARCH_DIR}/${ARCH}/core/startup/reset-vector.S + ) + add_dependencies(bootloader ${SYSCALL_LIST_H_TARGET}) set(zephyr_sdk $ENV{ZEPHYR_SDK_INSTALL_DIR}) @@ -69,7 +72,9 @@ add_custom_command(TARGET bootloader ) set_source_files_properties(boot_entry.S PROPERTIES COMPILE_FLAGS -DASSEMBLY) -set_source_files_properties(${ARCH_DIR}/${ARCH}/core/startup/reset-vector.S PROPERTIES COMPILE_FLAGS -DBOOTLOADER) +if(CONFIG_RESET_VECTOR_IN_BOOTLOADER) + set_source_files_properties(${ARCH_DIR}/${ARCH}/core/startup/reset-vector.S PROPERTIES COMPILE_FLAGS -DBOOTLOADER) +endif() target_compile_options(bootloader PUBLIC -fno-inline-functions -mlongcalls -mtext-section-literals -imacros${CMAKE_BINARY_DIR}/zephyr/include/generated/autoconf.h) diff --git a/soc/xtensa/intel_adsp/common/bootloader/start_address.S b/soc/xtensa/intel_adsp/common/bootloader/start_address.S index fa33ba486418..fae7e3a85a89 100644 --- a/soc/xtensa/intel_adsp/common/bootloader/start_address.S +++ b/soc/xtensa/intel_adsp/common/bootloader/start_address.S @@ -9,3 +9,16 @@ .global _start .equ _start, SOF_TEXT_BASE +#ifndef CONFIG_RESET_VECTOR_IN_BOOTLOADER + .begin literal_prefix .ResetVector + .section .ResetVector.text, "ax" + + .literal_position + + .align 4 + .global __start + +__start: + movi a0, 0 + call0 _start /* jump to _start (in crt1-*.S) */ +#endif diff --git a/soc/xtensa/intel_adsp/common/main_entry.S b/soc/xtensa/intel_adsp/common/main_entry.S index efcebf91ac2e..10614aa0b072 100644 --- a/soc/xtensa/intel_adsp/common/main_entry.S +++ b/soc/xtensa/intel_adsp/common/main_entry.S @@ -27,7 +27,11 @@ _MainEntry: +#ifdef CONFIG_RESET_VECTOR_IN_BOOTLOADER + j _start +#else j __start +#endif .size _MainEntry, . - _MainEntry