-
Notifications
You must be signed in to change notification settings - Fork 8k
samples: tflite-micro: add micro_speech application with OpenAMP on i.MX8MP #96657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(micro_speech_openamp) | ||
|
||
# These samples use local static initialization. Since Zephyr doesn't support the | ||
# C++ ABI for thread-safe initialization of local statics and the constructors don't | ||
# appear to require thread safety, we turn it off in the C++ compiler. | ||
set(NO_THREADSAFE_STATICS $<TARGET_PROPERTY:compiler-cpp,no_threadsafe_statics>) | ||
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:${NO_THREADSAFE_STATICS}>) | ||
|
||
# Define common paths | ||
set(OPTIONAL_TFLITE_DIR $ENV{ZEPHYR_BASE}/../optional/modules/lib/tflite-micro/signal) | ||
|
||
file( | ||
GLOB | ||
app_sources | ||
src/* | ||
src/inference/* | ||
) | ||
|
||
target_include_directories( | ||
app | ||
PRIVATE | ||
src | ||
${ZEPHYR_TFLITE_MICRO_MODULE_DIR}/signal | ||
${ZEPHYR_TFLITE_MICRO_MODULE_DIR}/signal/micro/kernels/ | ||
${ZEPHYR_TFLITE_MICRO_MODULE_DIR}/signal/src | ||
${LIBMETAL_INCLUDE_DIR} | ||
${OPENAMP_INCLUDE_DIR} | ||
${PLATFORM_DIR} | ||
) | ||
|
||
target_sources( | ||
app | ||
PRIVATE | ||
${app_sources} | ||
|
||
# Signal processing | ||
${OPTIONAL_TFLITE_DIR}/src/fft_auto_scale.cc | ||
${OPTIONAL_TFLITE_DIR}/src/max_abs.cc | ||
${OPTIONAL_TFLITE_DIR}/src/msb_32.cc | ||
${OPTIONAL_TFLITE_DIR}/src/energy.cc | ||
${OPTIONAL_TFLITE_DIR}/src/filter_bank.cc | ||
${OPTIONAL_TFLITE_DIR}/src/pcan_argc_fixed.cc | ||
${OPTIONAL_TFLITE_DIR}/src/filter_bank_log.cc | ||
${OPTIONAL_TFLITE_DIR}/src/log.cc | ||
${OPTIONAL_TFLITE_DIR}/src/filter_bank_spectral_subtraction.cc | ||
|
||
# Micro kernels | ||
${OPTIONAL_TFLITE_DIR}/micro/kernels/energy.cc | ||
${OPTIONAL_TFLITE_DIR}/micro/kernels/fft_auto_scale_common.cc | ||
${OPTIONAL_TFLITE_DIR}/micro/kernels/filter_bank_square_root_common.cc | ||
${OPTIONAL_TFLITE_DIR}/micro/kernels/filter_bank_spectral_subtraction.cc | ||
${OPTIONAL_TFLITE_DIR}/micro/kernels/filter_bank.cc | ||
${OPTIONAL_TFLITE_DIR}/micro/kernels/pcan.cc | ||
${OPTIONAL_TFLITE_DIR}/micro/kernels/filter_bank_log.cc | ||
) | ||
|
||
if ("${BOARD_ARCH}" STREQUAL "xtensa") | ||
target_sources( | ||
app | ||
PRIVATE | ||
|
||
# Xtensa kernels | ||
${OPTIONAL_TFLITE_DIR}/micro/kernels/xtensa/fft_auto_scale_kernel.cc | ||
${OPTIONAL_TFLITE_DIR}/micro/kernels/xtensa/filter_bank_square_root.cc | ||
${OPTIONAL_TFLITE_DIR}/micro/kernels/xtensa/xtensa_square_root.S | ||
) | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CONFIG_LOG_PRINTK=n | ||
CONFIG_IPM_IMX_MAX_DATA_SIZE_16=n | ||
CONFIG_IPM_IMX_MAX_DATA_SIZE_4=y | ||
CONFIG_OPENAMP_WITH_DCACHE=y | ||
|
||
#vendor-specific resource table | ||
CONFIG_OPENAMP_VENDOR_RSC_TABLE=y | ||
CONFIG_OPENAMP_VENDOR_RSC_TABLE_FILE="nxp_resource_table.c" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2023 NXP | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copyright should be |
||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/ { | ||
chosen { | ||
/* | ||
* shared memory reserved for the inter-processor communication | ||
*/ | ||
zephyr,ipc_shm = &dspsram3; | ||
zephyr,ipc = &mailbox0; | ||
}; | ||
|
||
dspsram3: memory@942f0000 { | ||
compatible = "mmio-sram"; | ||
reg = <0x942f0000 0x110000>; | ||
}; | ||
}; | ||
|
||
&mailbox0 { | ||
status = "okay"; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# tflite | ||
CONFIG_CPP=y | ||
CONFIG_STD_CPP17=y | ||
CONFIG_TENSORFLOW_LITE_MICRO=y | ||
CONFIG_MAIN_STACK_SIZE=6144 # tflm arena size | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add the comment on top of the config:
|
||
CONFIG_REQUIRES_FLOAT_PRINTF=y | ||
|
||
# rpmsg | ||
CONFIG_KERNEL_BIN_NAME="micro_speech_openamp" | ||
CONFIG_PRINTK=n | ||
CONFIG_IPM=y | ||
CONFIG_HEAP_MEM_POOL_SIZE=5120 # rpmsg buffers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the same as above:
I also believe this can be decreased, but didn't check which value is accepted |
||
CONFIG_OPENAMP=y | ||
CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF=8 | ||
CONFIG_OPENAMP_RSC_TABLE=y | ||
CONFIG_OPENAMP_MASTER=n | ||
CONFIG_SHELL=n | ||
|
||
# logging | ||
CONFIG_LOG=y | ||
CONFIG_LOG_DEFAULT_LEVEL=3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
sample: | ||
description: Micro Speech OpenAMP Sample | ||
name: micro speech openamp | ||
common: | ||
tags: tensorflow | ||
modules: | ||
- tflite-micro | ||
harness: console | ||
harness_config: | ||
type: multi_line | ||
ordered: false | ||
regex: | ||
- "Detected: (yes|no|silence|unknown)" | ||
tests: | ||
sample.tensorflow.micro_speech_openamp: | ||
platform_allow: | ||
- imx8mp_evk/mimx8ml8/adsp | ||
integration_platforms: | ||
- imx8mp_evk/mimx8ml8/adsp | ||
tags: tensorflow, openamp, ipc, audio |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CONFIG_LOG_PRINTK=n | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove all these snippets files. |
||
CONFIG_IPM_IMX_MAX_DATA_SIZE_16=n | ||
CONFIG_IPM_IMX_MAX_DATA_SIZE_4=y | ||
CONFIG_OPENAMP_WITH_DCACHE=y | ||
CONFIG_SHELL=n | ||
|
||
#vendor-specific resource table | ||
CONFIG_OPENAMP_VENDOR_RSC_TABLE=y | ||
CONFIG_OPENAMP_VENDOR_RSC_TABLE_FILE="nxp_resource_table.c" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove file |
||
* Copyright 2024 NXP | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/ { | ||
chosen { | ||
/* | ||
* shared memory reserved for the inter-processor communication | ||
*/ | ||
zephyr,ipc_shm = &dspsram3; | ||
zephyr,ipc = &mailbox0; | ||
}; | ||
|
||
dspsram3: memory@942f0000 { | ||
compatible = "mmio-sram"; | ||
reg = <0x942f0000 0x110000>; | ||
}; | ||
}; | ||
|
||
&mailbox0 { | ||
status = "okay"; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: nxp-openamp-imx8-adsp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove file |
||
boards: | ||
/imx8qxp_mek\/mimx8qx6\/adsp|imx8qm_mek\/mimx8qm6\/adsp/: | ||
append: | ||
EXTRA_DTC_OVERLAY_FILE: nxp-openamp-imx8-adsp.overlay | ||
EXTRA_CONF_FILE: nxp-openamp-imx8-adsp.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be
if("${ARCH}" STREQUAL "xtensa")