xtensa: don't build and run the reset handler twice

Currently Zephyr links reset-vector.S twice in xtensa builds:
into the bootloader and the main image. It is run at the end
of the boot loader execution and immediately after that again
in the beginning of the main code. This patch adds a
configuration option to select whether to link the file to the
bootloader or to the application. The default is to the
application, as needed e.g. for QEMU, SOF links it to the
bootloader like in native builds.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2021-01-06 12:55:12 +01:00 committed by Anas Nashif
commit ca0e5df219
6 changed files with 38 additions and 3 deletions

View file

@ -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)

View file

@ -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

View file

@ -27,7 +27,11 @@
_MainEntry:
#ifdef CONFIG_RESET_VECTOR_IN_BOOTLOADER
j _start
#else
j __start
#endif
.size _MainEntry, . - _MainEntry