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

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

View file

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

View file

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

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