Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ target_sources(app PRIVATE
)

zephyr_library_include_directories(app PUBLIC
${sof_module}/src/arch/xtensa/include
${sof_module}/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../src/arch/xtensa/include
${CMAKE_CURRENT_SOURCE_DIR}/../src/include
)
8 changes: 8 additions & 0 deletions app/boards/qemu_xtensa_dc233c.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: BSD-3-Clause
CONFIG_IPC_MAJOR_4=y
CONFIG_ZTEST=y
CONFIG_MM_DRV=y
CONFIG_ZEPHYR_NATIVE_DRIVERS=y

# Ensure the kernel can exit QEMU on shutdown/panic
CONFIG_REBOOT=y
12 changes: 12 additions & 0 deletions app/boards/qemu_xtensa_dc233c_mmu.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: BSD-3-Clause
CONFIG_IPC_MAJOR_4=y
CONFIG_USERSPACE=y
CONFIG_ZTEST=y
CONFIG_TEST_USERSPACE=y
CONFIG_MM_DRV=y
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
CONFIG_SOF_USERSPACE_LL=y
CONFIG_SOF_BOOT_TEST_STANDALONE=y

# Ensure the kernel can exit QEMU on shutdown/panic
CONFIG_REBOOT=y
1 change: 1 addition & 0 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ CONFIG_SCHED_CPU_MASK=y
CONFIG_SYS_CLOCK_TICKS_PER_SEC=15000
CONFIG_DAI=y
CONFIG_HEAP_MEM_POOL_SIZE=2048
CONFIG_SPIN_VALIDATE=n
28 changes: 27 additions & 1 deletion app/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
*/

#include <zephyr/kernel.h>

#include <sof/boot_test.h>
#include <zephyr/logging/log.h>

LOG_MODULE_REGISTER(main, LOG_LEVEL_DBG);

/* define qemu boot tests if any qemu target is defined, add targets to end */
#if defined(CONFIG_BOARD_QEMU_XTENSA_DC233C) ||\
defined(CONFIG_BOARD_QEMU_XTENSA_DC233C_MMU)
#define QEMU_BOOT_TESTS
#endif

/**
* Should be included from sof/schedule/task.h
* but triggers include chain issue
Expand Down Expand Up @@ -50,10 +57,29 @@ static int sof_app_main(void)
return 0;
}

#if CONFIG_SOF_BOOT_TEST && defined(QEMU_BOOT_TESTS)
/* cleanly exit qemu so CI can continue and check test results */
static inline void qemu_xtensa_exit(int status) {
register int syscall_id __asm__ ("a2") = 1; /* SYS_exit is 1 */
register int exit_status __asm__ ("a3") = status;

__asm__ __volatile__ (
"simcall\n"
:
: "r" (syscall_id), "r" (exit_status)
: "memory"
);
}
#endif

#if CONFIG_ZTEST
void test_main(void)
{
sof_app_main();
#if CONFIG_SOF_BOOT_TEST && defined(QEMU_BOOT_TESTS)
sof_run_boot_tests();
qemu_xtensa_exit(0);
#endif
}
#else
int main(void)
Expand Down
8 changes: 8 additions & 0 deletions scripts/set_xtensa_params.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ case "$platform" in
HOST="xtensa-mt8365-elf"
TOOLCHAIN_VER="RG-2018.9-linux"
;;
qemu_xtensa | qemu_xtensa_mmu)
PLATFORM="$1"
XTENSA_CORE=""
HOST="xtensa-zephyr-elf"
TOOLCHAIN_VER=""
;;
*)
>&2 printf 'Unknown xtensa platform=%s\n' "$platform"
return 1
Expand All @@ -166,6 +172,8 @@ esac

# For Zephyr unit tests
case "$platform" in
qemu_xtensa | qemu_xtensa_mmu)
ZEPHYR_TOOLCHAIN_VARIANT='zephyr';;
imx8*|mtl|lnl)
ZEPHYR_TOOLCHAIN_VARIANT='xt-clang';;
*) # The previous, main case/esac already caught invalid input.
Expand Down
Loading