diff --git a/components/3rd_party/openssl/CMakeLists.txt b/components/3rd_party/openssl/CMakeLists.txt index 9bef30f3..5806a9a9 100644 --- a/components/3rd_party/openssl/CMakeLists.txt +++ b/components/3rd_party/openssl/CMakeLists.txt @@ -79,7 +79,7 @@ if(compile_from_src) if(NOT ADD_INCLUDE) # compile from source code execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE arch) string(REGEX REPLACE "([^-]+)-.*" "\\1" arch "${arch}") - if(PLATFORM_MAIXCAM) + if(PLATFORM_MAIXCAM OR PLATFORM_MAIXCAM2) string(LENGTH "${CONFIG_TOOLCHAIN_PREFIX}" toolchain_prefix_len) math(EXPR toolchain_prefix_len "${toolchain_prefix_len} - 1") string(SUBSTRING "${CONFIG_TOOLCHAIN_PREFIX}" 0 ${toolchain_prefix_len} host_prefix) diff --git a/components/3rd_party/python3/CMakeLists.txt b/components/3rd_party/python3/CMakeLists.txt index 4f77ed24..3a0c39fb 100644 --- a/components/3rd_party/python3/CMakeLists.txt +++ b/components/3rd_party/python3/CMakeLists.txt @@ -86,6 +86,10 @@ if(CONFIG_PYTHON_VERSION_MAJOR STREQUAL "0") set(CONFIG_PYTHON_VERSION_MAJOR "3") set(CONFIG_PYTHON_VERSION_MINOR "11") set(CONFIG_PYTHON_VERSION_PATCH "6") + elseif(PLATFORM_MAIXCAM2) + set(CONFIG_PYTHON_VERSION_MAJOR "3") + set(CONFIG_PYTHON_VERSION_MINOR "13") + set(CONFIG_PYTHON_VERSION_PATCH "2") else() message(FATAL_ERROR "no default python version for this board, please set it manually in menuconfig") endif() @@ -110,7 +114,7 @@ if(NOT compile_for_host) set(py_ver_short "${CONFIG_PYTHON_VERSION_MAJOR}.${CONFIG_PYTHON_VERSION_MINOR}") # use prebuilt python for maixcam - if(PLATFORM_MAIXCAM AND NOT CONFIG_COMPONENTS_COMPILE_FROM_SOURCE) + if(PLATFORM_MAIXCAM AND NOT CONFIG_COMPONENTS_COMPILE_FROM_SOURCE AND NOT CONFIG_PYTHON_COMPILE_FROM_SOURCE) if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/python_target_install") set(python_lib_dir "${CMAKE_CURRENT_LIST_DIR}/python_target_install") elseif(CONFIG_TOOLCHAIN_PATH MATCHES "musl") @@ -124,6 +128,21 @@ if(NOT compile_for_host) endif() endif() + # use prebuilt python for maixcam2 + if(PLATFORM_MAIXCAM2 AND NOT CONFIG_COMPONENTS_COMPILE_FROM_SOURCE AND NOT CONFIG_PYTHON_COMPILE_FROM_SOURCE) + if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/python_target_install") + set(python_lib_dir "${CMAKE_CURRENT_LIST_DIR}/python_target_install") + else() + set(python_lib_dir "${DL_EXTRACTED_PATH}/python3/python3.13_maixcam2") + endif() + if(python_lib_dir) + set(python_dl_lib ${python_lib_dir}/lib/libpython${py_ver_short}.so) + list(APPEND ADD_INCLUDE ${python_lib_dir}/include/python${py_ver_short}) + list(APPEND ADD_DYNAMIC_LIB ${python_dl_lib}) + set_property(SOURCE ${python_dl_lib} PROPERTY GENERATED 1) + endif() + endif() + if(NOT ADD_INCLUDE) # compile from source code # check host python version, if equal to target python version, use host python, or compile python for host and target set(py_version_cmd COMMAND ${python} --version) @@ -166,7 +185,7 @@ if(NOT compile_for_host) set(python_target_install_dir "${CMAKE_BINARY_DIR}/python_target_install") if(PLATFORM_M2DOCK) set(host_prefix "arm-openwrt-linux") - elseif(PLATFORM_MAIXCAM) + elseif(PLATFORM_MAIXCAM OR PLATFORM_MAIXCAM2) string(LENGTH "${CONFIG_TOOLCHAIN_PREFIX}" toolchain_prefix_len) math(EXPR toolchain_prefix_len "${toolchain_prefix_len} - 1") string(SUBSTRING "${CONFIG_TOOLCHAIN_PREFIX}" 0 ${toolchain_prefix_len} host_prefix) @@ -187,7 +206,7 @@ if(NOT compile_for_host) set(python_unzip_path "${DL_EXTRACTED_PATH}/python_srcs") set(python_src_path "${python_unzip_path}/Python-${python_version_str}") - set(zlib_src_path "${DL_EXTRACTED_PATH}/zlib/zlib-1.3") + set(zlib_src_path "${DL_EXTRACTED_PATH}/zlib/zlib-1.3.1") set(zlib_install_path "${python_target_install_dir}") set(openssl_src_path "${DL_EXTRACTED_PATH}/openssl/openssl-3.0.12") set(openssl_install_path "${python_target_install_dir}") diff --git a/components/3rd_party/python3/Kconfig b/components/3rd_party/python3/Kconfig index b7d912be..390678a1 100644 --- a/components/3rd_party/python3/Kconfig +++ b/components/3rd_party/python3/Kconfig @@ -1,20 +1,28 @@ # Python version major minor patch -menu "Python version" - config PYTHON_VERSION_MAJOR - int "python package major version" - default 0 +menu "Python Configs" + config PYTHON_COMPILE_FROM_SOURCE + bool "compile python from source code" + default false help - Python package major version, 0 means auto select according to board + Compile Python lib from source code + menu "Python version" - config PYTHON_VERSION_MINOR - int "python package minor version" - default 0 - help - Python package minor version + config PYTHON_VERSION_MAJOR + int "python package major version" + default 0 + help + Python package major version, 0 means auto select according to board - config PYTHON_VERSION_PATCH - int "python package patch version" - default 0 - help - Python package patch version + config PYTHON_VERSION_MINOR + int "python package minor version" + default 0 + help + Python package minor version + + config PYTHON_VERSION_PATCH + int "python package patch version" + default 0 + help + Python package patch version + endmenu endmenu diff --git a/components/3rd_party/python3/component.py b/components/3rd_party/python3/component.py index b1bd71ac..2fffd1e7 100644 --- a/components/3rd_party/python3/component.py +++ b/components/3rd_party/python3/component.py @@ -4,15 +4,21 @@ def add_file_downloads(confs : dict) -> list: @param confs kconfig vars, dict type @return list type, items is dict type ''' - if (not confs.get("PLATFORM_MAIXCAM", None)) or confs.get("CONFIG_COMPONENTS_COMPILE_FROM_SOURCE", None): + if confs.get("CONFIG_COMPONENTS_COMPILE_FROM_SOURCE", None) or confs.get("CONFIG_PYTHON_COMPILE_FROM_SOURCE", None): version = f"{confs['CONFIG_PYTHON_VERSION_MAJOR']}.{confs['CONFIG_PYTHON_VERSION_MINOR']}.{confs['CONFIG_PYTHON_VERSION_PATCH']}" + if confs.get("PLATFORM_MAIXCAM", None): + version = "3.11.6" + elif confs.get("PLATFORM_MAIXCAM2", None): + version = "3.13.2" if version == "0.0.0": return [] url = f"https://www.python.org/ftp/python/{version}/Python-{version}.tar.xz" if version == "3.11.6": sha256sum = "92e14b22e708612c6e280931cc247b4266da9a6bac8459edf25bfb4cebcbac66" + elif version == "3.13.2": + sha256sum = "d984bcc57cd67caab26f7def42e523b1c015bbc5dc07836cf4f0b63fa159eb56" else: - raise Exception(f"version {version} not support") + raise Exception(f"version {version} not support, please sha256sum of {url} add in 3rd_party/python3/component.py") sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] filename = f"Python-{version}.tar.xz" path = f"python_srcs" @@ -33,11 +39,11 @@ def add_file_downloads(confs : dict) -> list: 'rename': rename }, { - 'url': 'https://zlib.net/zlib-1.3.tar.xz', + 'url': 'https://zlib.net/zlib-1.3.1.tar.xz', 'urls': [], 'sites': ['https://zlib.net/'], - 'sha256sum': '8a9ba2898e1d0d774eca6ba5b4627a11e5588ba85c8851336eb38de4683050a7', - 'filename': 'zlib-1.3.tar.xz', + 'sha256sum': '38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32', + 'filename': 'zlib-1.3.1.tar.xz', 'path': 'zlib' }, { @@ -49,33 +55,49 @@ def add_file_downloads(confs : dict) -> list: 'path': 'openssl' } ] - if "musl" not in confs["CONFIG_TOOLCHAIN_PATH"]: - return [] - # version = f"{confs['CONFIG_OMV_VERSION_MAJOR']}.{confs['CONFIG_OMV_VERSION_MINOR']}.{confs['CONFIG_OMV_VERSION_PATCH']}" - version = "3.11.6" - url = f"https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/python3_lib_maixcam_musl_3.11.6.tar.xz" - if version == "3.11.6": - sha256sum = "92e14b22e708612c6e280931cc247b4266da9a6bac8459edf25bfb4cebcbac66" - else: - raise Exception(f"version {version} not support") - sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] - filename = f"python3_lib_maixcam_musl_3.11.6.tar.xz" - path = f"python3" - check_file = f'python3_lib_maixcam_musl_3.11.6' - rename = {} - - return [ - { - 'url': f'{url}', - 'urls': [], - 'sites': sites, - 'sha256sum': sha256sum, - 'filename': filename, - 'path': path, - 'check_files': [ - check_file - ], - 'rename': rename - } - ] + elif confs.get("PLATFORM_MAIXCAM", None): + if "musl" not in confs["CONFIG_TOOLCHAIN_PATH"]: + return [] + # version = f"{confs['CONFIG_OMV_VERSION_MAJOR']}.{confs['CONFIG_OMV_VERSION_MINOR']}.{confs['CONFIG_OMV_VERSION_PATCH']}" + version = "3.11.6" + url = f"https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/python3_lib_maixcam_musl_3.11.6.tar.xz" + if version == "3.11.6": + sha256sum = "92e14b22e708612c6e280931cc247b4266da9a6bac8459edf25bfb4cebcbac66" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] + filename = f"python3_lib_maixcam_musl_3.11.6.tar.xz" + path = f"python3" + check_file = f'python3_lib_maixcam_musl_3.11.6' + rename = {} + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + elif confs.get("PLATFORM_MAIXCAM2", None): + filename = "python3.13.2_maixcam2_gcc11.4.0.tar.xz" + sha256 = "a37165fddf7401b3932b94a10e9cbb166d9ee825e34e23a27de2dadcacce411a" + check_file = "bin" + return [{ + 'url': f'https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/{filename}', + 'urls': [], + 'sites': ['https://github.com/sipeed/MaixCDK/releases/download/v0.0.0'], + 'sha256sum': sha256, + 'filename': filename, + 'path': 'python3/python3.13_maixcam2', + 'check_files': [ + check_file + ], + }] + return [] diff --git a/components/network/CMakeLists.txt b/components/network/CMakeLists.txt index 3b60674a..7f43f38a 100644 --- a/components/network/CMakeLists.txt +++ b/components/network/CMakeLists.txt @@ -3,7 +3,7 @@ list(APPEND ADD_INCLUDE "include") append_srcs_dir(ADD_SRCS "src") list(APPEND ADD_REQUIREMENTS basic) -if(PLATFORM_MAIXCAM OR PLATFORM_LINUX) +if(PLATFORM_MAIXCAM OR PLATFORM_LINUX OR PLATFORM_MAIXCAM2) list(APPEND ADD_INCLUDE "port/linux") append_srcs_dir(ADD_SRCS "port/linux") else() diff --git a/components/nn/include/maix_nn_classifier.hpp b/components/nn/include/maix_nn_classifier.hpp index 59536f77..22781408 100644 --- a/components/nn/include/maix_nn_classifier.hpp +++ b/components/nn/include/maix_nn_classifier.hpp @@ -173,10 +173,10 @@ namespace maix::nn return err::ERR_ARGS; } _inputs = _model->inputs_info(); - if(inputs[0].shape[3] <= 4) // nhwc - _input_size = image::Size(inputs[0].shape[2], inputs[0].shape[1]); + if(_inputs[0].shape[3] <= 4) // nhwc + _input_size = image::Size(_inputs[0].shape[2], _inputs[0].shape[1]); else - _input_size = image::Size(inputs[0].shape[3], inputs[0].shape[2]); + _input_size = image::Size(_inputs[0].shape[3], _inputs[0].shape[2]); return err::ERR_NONE; } diff --git a/platforms/maixcam2.yaml b/platforms/maixcam2.yaml index c6506fb1..243856b0 100644 --- a/platforms/maixcam2.yaml +++ b/platforms/maixcam2.yaml @@ -1,19 +1,39 @@ toolchain: + - name: Cross compile AArch64 Linux GNU toolchain + id: cross-gcc-11.3 + default: true + cross: true + host-os: linux + host-arch: x86_64 + url: https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz + urls: + sites: + - https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads + sha256sum: 50cdef6c5baddaa00f60502cc8b59cc11065306ae575ad2f51e412a9b2a90364 + filename: arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz + path: toolchains/maixcam2 + check_files: + - arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-gcc + bin_path: toolchains/maixcam2/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/bin + prefix: aarch64-none-linux-gnu- + c_flags: "" + cxx_flags: "" + - name: Cross compile AArch64 Linux GNU toolchain id: cross-gcc-9.2 cross: true host-os: linux host-arch: x86_64 - default: true url: https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz urls: sites: - - https://developer.arm.com/downloads/-/gnu-a + - https://developer.arm.com/downloads/-/gnu-a sha256sum: 8dfe681531f0bd04fb9c53cf3c0a3368c616aa85d48938eebe2b516376e06a66 filename: gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz path: toolchains/maixcam2 + check_files: + - gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-gcc bin_path: toolchains/maixcam2/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin prefix: aarch64-none-linux-gnu- c_flags: "" cxx_flags: "" - diff --git a/tools/cmake/build.py b/tools/cmake/build.py index 2cf09897..e7b6ca2a 100644 --- a/tools/cmake/build.py +++ b/tools/cmake/build.py @@ -185,6 +185,7 @@ def rebuild(build_path, configs, toolchain_info, verbose): "sha256sum": toolchain_info['sha256sum'], "filename": toolchain_info['filename'], "path": toolchain_info['path'], + "check_files": toolchain_info.get("check_files", []) } ] download_extract_files(dl_info)