soc: xtensa/intel_adsp: fix bootloader building under XCC

XCC's own xt-objcopy does not recognize the "--dump-section"
command. So simply copy the objecy file into binary so it can
be included in the final bootloader binary.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2021-07-01 11:49:47 -07:00 committed by Anas Nashif
commit d248a5d4f3
2 changed files with 14 additions and 5 deletions

View file

@ -10,7 +10,7 @@ add_custom_target(
process_elf ALL
DEPENDS base_module
DEPENDS ${ZEPHYR_FINAL_EXECUTABLE}
COMMAND ${CMAKE_OBJCOPY} --dump-section .data=mod-apl.bin $<TARGET_FILE:base_module>
COMMAND ${CMAKE_OBJCOPY} -O binary $<TARGET_OBJECTS:base_module> mod-apl.bin
COMMAND ${CMAKE_OBJCOPY} --add-section .module=mod-apl.bin --set-section-flags .module=load,readonly ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME} ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}.mod
# Adjust final section addresses so they all appear in the cached region.
@ -20,6 +20,6 @@ add_custom_target(
add_custom_target(
process_bootloader ALL
DEPENDS bootloader boot_module
COMMAND ${CMAKE_OBJCOPY} --dump-section .data=mod-boot.bin $<TARGET_FILE:boot_module>
COMMAND ${CMAKE_OBJCOPY} -O binary $<TARGET_OBJECTS:boot_module> mod-boot.bin
COMMAND ${CMAKE_OBJCOPY} --add-section .module=mod-boot.bin --set-section-flags .module=load,readonly $<TARGET_FILE:bootloader> ${CMAKE_BINARY_DIR}/zephyr/bootloader.elf.mod
)

View file

@ -2,13 +2,13 @@
#
# SPDX-License-Identifier: Apache-2.0
#
add_library(base_module base_module.c)
add_library(base_module OBJECT base_module.c)
target_include_directories(base_module PUBLIC
${SOC_DIR}/${ARCH}/${SOC_PATH}/include
../include
)
add_library(boot_module boot_module.c)
add_library(boot_module OBJECT boot_module.c)
target_include_directories(boot_module PUBLIC
${SOC_DIR}/${ARCH}/${SOC_PATH}/include
../include
@ -32,6 +32,9 @@ target_include_directories(bootloader PUBLIC
./
${SOC_DIR}/${ARCH}/${SOC_PATH}/
${SOC_DIR}/${ARCH}/${SOC_PATH}/include
${SOC_DIR}/${ARCH}/${SOC_FAMILY}/common/include
${PROJECT_BINARY_DIR}/include/generated
${ZEPHYR_BASE}/include
)
# TODO: pre-process linker script. How do we use toplevel infrastructure ??
@ -62,7 +65,13 @@ 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)
target_compile_options(bootloader PUBLIC
-fno-inline-functions
-mlongcalls
-mtext-section-literals
-imacros${CMAKE_BINARY_DIR}/zephyr/include/generated/autoconf.h
-D__SIZEOF_LONG__=4
)
target_link_libraries(bootloader PUBLIC -Wl,--no-check-sections -ucall_user_start -Wl,-static -nostdlib)
target_link_libraries(bootloader PRIVATE -T${CMAKE_BINARY_DIR}/zephyr/${bootloader_linker_script}.ld)