feat(bugfix): Fix the bug of moving model

This commit is contained in:
Wang Wang Wang 2021-12-30 11:06:15 +08:00
parent cf041108cb
commit 5950a00ed6
3 changed files with 68 additions and 13 deletions

View File

@ -102,17 +102,71 @@ elseif(${IDF_TARGET} STREQUAL "esp32s3")
voice_set_xiaole_esp32s3
"-Wl,--end-group")
set(MVMODEL_EXE ${COMPONENT_PATH}/model/movemodel.py)
add_custom_command(
OUTPUT ${COMPONENT_DIR}/model/target/_MODEL_INFO_
COMMENT "Running move model..."
COMMAND python ${MVMODEL_EXE} -d1 ${PROJECT_DIR} -d2 ${COMPONENT_PATH}
DEPENDS ${COMPONENT_DIR}/model/
VERBATIM)
set(MVMODEL_EXE ${COMPONENT_PATH}/model/movemodel.py)
add_custom_command(
OUTPUT ${COMPONENT_DIR}/model/target/_MODEL_INFO_
COMMENT "Running move model..."
COMMAND python ${MVMODEL_EXE} -d1 ${PROJECT_DIR} -d2 ${COMPONENT_PATH}
DEPENDS ${COMPONENT_DIR}/model/
VERBATIM)
add_custom_target(model DEPENDS ${COMPONENT_DIR}/model/target/_MODEL_INFO_)
add_dependencies(${COMPONENT_LIB} model)
if(CONFIG_MODEL_IN_SPIFFS AND CONFIG_USE_WAKENET)
spiffs_create_partition_image(model ${COMPONENT_DIR}/model/target FLASH_IN_PROJECT DEPENDS ${COMPONENT_DIR}/model/target/_MODEL_INFO_)
add_custom_target(model DEPENDS ${COMPONENT_DIR}/model/target/_MODEL_INFO_)
add_dependencies(${COMPONENT_LIB} model)
idf_build_get_property(idf_path IDF_PATH)
set(spiffsgen_py ${PYTHON} ${idf_path}/components/spiffs/spiffsgen.py)
get_filename_component(base_dir_full_path ${COMPONENT_DIR}/model/target/ ABSOLUTE)
partition_table_get_partition_info(size "--partition-name model" "size")
partition_table_get_partition_info(offset "--partition-name model" "offset")
partition_table_get_partition_info(offset "--partition-name model" "offset")
if("${size}" AND "${offset}" AND CONFIG_MODEL_IN_SPIFFS AND CONFIG_USE_WAKENET)
set(image_file ${CMAKE_BINARY_DIR}/model.bin)
if(CONFIG_SPIFFS_USE_MAGIC)
set(use_magic "--use-magic")
endif()
if(CONFIG_SPIFFS_USE_MAGIC_LENGTH)
set(use_magic_len "--use-magic-len")
endif()
if(CONFIG_SPIFFS_FOLLOW_SYMLINKS)
set(follow_symlinks "--follow-symlinks")
endif()
# Execute SPIFFS image generation; this always executes as there is no way to specify for CMake to watch for
# contents of the base dir changing.
add_custom_target(spiffs_model_bin ALL
COMMAND ${spiffsgen_py} ${size} ${base_dir_full_path} ${image_file}
--page-size=${CONFIG_SPIFFS_PAGE_SIZE}
--obj-name-len=${CONFIG_SPIFFS_OBJ_NAME_LEN}
--meta-len=${CONFIG_SPIFFS_META_LENGTH}
${follow_symlinks}
${use_magic}
${use_magic_len}
DEPENDS ${COMPONENT_DIR}/model/target/_MODEL_INFO_
)
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
${image_file})
idf_component_get_property(main_args esptool_py FLASH_ARGS)
idf_component_get_property(sub_args esptool_py FLASH_SUB_ARGS)
# Last (optional) parameter is the encryption for the target. In our
# case, spiffs is not encrypt so pass FALSE to the function.
esptool_py_flash_target(model-flash "${main_args}" "${sub_args}" ALWAYS_PLAINTEXT)
esptool_py_flash_to_partition(model-flash "model" "${image_file}")
add_dependencies(model-flash spiffs_model_bin)
esptool_py_flash_to_partition(flash "model" "${image_file}")
add_dependencies(flash spiffs_model_bin)
else()
set(message "Failed to create SPIFFS image for partition 'model'. "
"Check project configuration if using the correct partition table file.")
endif()
endif()

View File

@ -1 +1 @@
907ef48d59b832c8bcab4b838b3c2e16d951388a
373accde54f0d357f03e2dcf6b0fb4deb9aee7e9

View File

@ -76,7 +76,8 @@ print(multinet_model)
target_model = model_path + '/target'
shutil.rmtree(target_model)
if os.path.exists(target_model):
shutil.rmtree(target_model)
os.makedirs(target_model)
if wakenet_model != 'null':
shutil.copytree(model_path + '/wakenet_model/' + wakenet_model, target_model+'/'+wakenet_model)