Skip to content
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

Try to fix the build error of ax620e platform #141

Merged
merged 9 commits into from
May 27, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: build
name: build_620a

# Controls when the workflow will run
on:
Expand Down Expand Up @@ -44,6 +44,6 @@ jobs:
tar -xf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
export PATH=$PATH:gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/
arm-linux-gnueabihf-gcc -v
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/arm-linux-gnueabihf.toolchain.cmake -DBSP_MSP_DIR=${ax_bsp}/ ..
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/arm-linux-gnueabihf.toolchain.cmake -DBSP_MSP_DIR=${ax_bsp}/ -DAXERA_TARGET_CHIP=ax620a ..
make -j8
make install
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: build_620e
name: build_620q_uclibc

# Controls when the workflow will run
on:
Expand Down Expand Up @@ -29,20 +29,20 @@ jobs:
- name: prepare opencv-library
run: |
mkdir -p ./3rdparty
wget https://github.com/AXERA-TECH/ax-samples/releases/download/v0.1/opencv-arm-linux-gnueabihf-gcc-7.5.0.zip
unzip opencv-arm-linux-gnueabihf-gcc-7.5.0.zip -d ./3rdparty
wget https://github.com/AXERA-TECH/ax-samples/releases/download/v0.6/opencv-arm-uclibc-linux.zip
unzip opencv-arm-uclibc-linux.zip -d ./3rdparty

- name: build
run: |
mkdir build
cd build
git clone https://github.com/AXERA-TECH/ax620q_bsp_sdk.git
export ax_bsp=$PWD/ax620q_bsp_sdk/msp/out/arm_glibc/
export ax_bsp=$PWD/ax620q_bsp_sdk/msp/out/arm_uclibc/
echo $ax_bsp
wget http://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
tar -xf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
export PATH=$PATH:gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/
arm-linux-gnueabihf-gcc -v
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/arm-linux-gnueabihf.toolchain.cmake -DBSP_MSP_DIR=${ax_bsp}/ -DAXERA_TARGET_CHIP=ax620e ..
wget https://github.com/AXERA-TECH/ax620q_bsp_sdk/releases/download/v2.0.0/arm-AX620E-linux-uclibcgnueabihf_V3_20240320.tgz
tar -zxf arm-AX620E-linux-uclibcgnueabihf_V3_20240320.tgz
export PATH=$PATH:arm-AX620E-linux-uclibcgnueabihf/bin/
arm-AX620E-linux-uclibcgnueabihf-gcc -v
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/arm-AX620E-linux-uclibcgnueabihf.toolchain.cmake -DBSP_MSP_DIR=${ax_bsp}/ -DAXERA_TARGET_CHIP=ax620q ..
make -j8
make install
48 changes: 48 additions & 0 deletions .github/workflows/build_630c_glibc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This is a basic workflow to help you get started with Actions

name: build_630c_glibc

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Runs a set of commands using the runners shell
- name: prepare opencv-library
run: |
mkdir -p ./3rdparty
wget https://github.com/AXERA-TECH/ax-samples/releases/download/v0.1/opencv-aarch64-linux-gnu-gcc-7.5.0.zip
unzip opencv-aarch64-linux-gnu-gcc-7.5.0.zip -d ./3rdparty

- name: build
run: |
mkdir build
cd build
git clone https://github.com/AXERA-TECH/ax620q_bsp_sdk.git
export ax_bsp=$PWD/ax620q_bsp_sdk/msp/out/arm64_glibc/
echo $ax_bsp
wget 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
tar -xf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz
export PATH=$PATH:gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin/
aarch64-none-linux-gnu-gcc -v
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/aarch64-none-linux-gnu.toolchain.cmake -DBSP_MSP_DIR=${ax_bsp}/ -DAXERA_TARGET_CHIP=ax630c ..
make -j8
make install
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/check.cmake")
# one should have a name finally
project(AXERA-Samples)

# set default chip as as ax620a
# set default chip as as ax650
# TODO: set as an option
if (NOT AXERA_TARGET_CHIP)
set (AXERA_TARGET_CHIP "ax620a")
set (AXERA_TARGET_CHIP "ax650")
endif ()

set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O1 -Wall -s -fPIC -Wunused-function")
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@

- [Benchmark](benchmark/) 常见开源模型推理耗时统计,基于 *AXera-Pi* 、 *AXera-Pi Pro* 、*AXera-Pi Zero* 实测。

## 联动项目
## 关联项目

- [ax-pipeline](https://github.com/AXERA-TECH/ax-pipeline) 该项目基于 *AXera-Pi* 、 *AXera-Pi Pro* 、*AXera-Pi Zero* 展示 ISP、图像处理、NPU、编码、显示 等功能模块软件调用方法,方便社区开发者进行快速评估和二次开发自己的多媒体应用
- NPU 工具链在线文档
- [Pulsar](https://pulsar-docs.readthedocs.io/zh_CN/latest/)(Support AX630A/AX620A/AX620U)
- [Pulsar2](https://pulsar2-docs.readthedocs.io/zh_CN/latest/)(Support AX650A/AX650N/AX630C/AX620Q)
- [Pulsar](https://pulsar-docs.readthedocs.io/zh_CN/latest/)(Support AX630A/AX620A/AX620U)
- [Pulsar2](https://pulsar2-docs.readthedocs.io/zh_CN/latest/)(Support AX650A/AX650N/AX630C/AX620Q)

## 技术讨论

Expand Down
45 changes: 45 additions & 0 deletions cmake/ax620e.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# AXERA is pleased to support the open source community by making ax-samples available.
#
# Copyright (c) 2022, AXERA Semiconductor (Shanghai) Co., Ltd. All rights reserved.
#
# Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# https://opensource.org/licenses/BSD-3-Clause
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#
# Author: ls.wang
#

function(axera_example example_name)
add_executable(${example_name})

foreach (file IN LISTS ARGN)
target_sources(${example_name} PRIVATE ${file})
endforeach ()

target_include_directories(${example_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${BSP_MSP_DIR}/include)

# opencv
target_include_directories(${example_name} PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(${example_name} PRIVATE ${OpenCV_LIBS})

# ax_engine
target_link_libraries(${example_name} PRIVATE ax_engine)

# sdk
target_link_libraries(${example_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT} ax_interpreter ax_sys ax_ivps)
target_link_directories(${example_name} PRIVATE ${BSP_MSP_DIR}/lib)

target_compile_options (${example_name} PUBLIC $<$<COMPILE_LANGUAGE:C,CXX>: -O3>)

if (AXERA_TARGET_CHIP MATCHES "ax630c")
install(TARGETS ${example_name} DESTINATION ax630c)
elseif (AXERA_TARGET_CHIP MATCHES "ax620q")
install(TARGETS ${example_name} DESTINATION ax620q)
endif()
endfunction()
34 changes: 7 additions & 27 deletions cmake/ax650.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,22 @@ function(axera_example example_name)
target_sources(${example_name} PRIVATE ${file})
endforeach ()

target_include_directories(${example_name}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${BSP_MSP_DIR}/include
)
target_include_directories(${example_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${BSP_MSP_DIR}/include)

# opencv
target_include_directories(${example_name} PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(${example_name} PRIVATE ${OpenCV_LIBS})

# ax_engine
target_link_libraries(${example_name}
PRIVATE
ax_engine
)
target_link_libraries(${example_name} PRIVATE ax_engine)

# sdk
target_link_libraries(${example_name}
PRIVATE
${CMAKE_THREAD_LIBS_INIT}
ax_interpreter
ax_sys ax_ivps
)
target_link_directories(${example_name}
PRIVATE
${BSP_MSP_DIR}/lib
)

target_compile_options (${example_name}
PUBLIC
$<$<COMPILE_LANGUAGE:C,CXX>: -O3>
)
target_link_libraries(${example_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT} ax_interpreter ax_sys ax_ivps)
target_link_directories(${example_name} PRIVATE ${BSP_MSP_DIR}/lib)

target_compile_options (${example_name} PUBLIC $<$<COMPILE_LANGUAGE:C,CXX>: -O3>)

if (AXERA_TARGET_CHIP MATCHES "ax650")
install(TARGETS ${example_name} DESTINATION ax650)
elseif (AXERA_TARGET_CHIP MATCHES "ax620e")
install(TARGETS ${example_name} DESTINATION ax620e)
endif()
endfunction()
2 changes: 1 addition & 1 deletion docs/AX620Q.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- CPU
- Dual-core Cortex A53
- NPU
- 8Tops@INT4 or 2Tops@INT8
- 9.6Tops@INT4 or 2.4Tops@INT8
- ISP
- 5Mp@30fps
- AI-ISP/T-ISP
Expand Down
2 changes: 1 addition & 1 deletion docs/AX650N.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- CPU
- Octa-core Cortex A55
- NPU
- 43.2Tops@INT4 or 10.8Tops@INT8
- 72Tops@INT4 or 18Tops@INT8
- DSP
- Dual VDSP
- ISP
Expand Down
31 changes: 15 additions & 16 deletions docs/compile_620e.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ ax-samples 的源码编译目前有两种实现路径:

## 交叉编译

当前SDK版本(v2.0.2)中支持 64位、32位 两种不同的编译器版本,下面示例分别基于 AX630C 的 64 位环境与 AX620Q 的 32 位环境进行说明。
当前SDK版本(v2.0.0_P7)中支持 64位、32位 两种不同的编译器版本,下面示例分别基于 AX630C 的 64 位环境与 AX620Q 的 32 位环境进行说明。

- [AX630C](#AX630C(64位,aarch64-linux))
- [AX620Q](#AX620Q(32位,arm-linux))
- [AX620Q](#AX620Q(32位,arm-uclibc-linux))

### AX630C(64位,aarch64-linux)

Expand Down Expand Up @@ -57,7 +57,7 @@ tar -zxvf msp.tgz
解压完成后将文件夹内此 `msp/out` 目录设置到临时环境变量,具体操作如下:

```
export ax_bsp=${ax620e_bsp_sdk PATH}/msp/out
export ax_bsp=${ax620e_bsp_sdk PATH}/msp/out/arm64_glibc
```

#### 源码编译
Expand All @@ -67,17 +67,17 @@ git clone 下载源码,进入 ax-samples 根目录,创建 cmake 编译任务
git clone https://github.com/AXERA-TECH/ax-samples.git
cd ax-samples
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/aarch64-none-linux-gnu.toolchain.cmake -DBSP_MSP_DIR=${ax_bsp}/ -DAXERA_TARGET_CHIP=ax620e ..
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/aarch64-none-linux-gnu.toolchain.cmake -DBSP_MSP_DIR=${ax_bsp}/ -DAXERA_TARGET_CHIP=ax630c ..
make -j6
make install
```

编译完成后,生成的可执行示例存放在 `ax-samples/build/install/ax620e/` 路径下:
编译完成后,生成的可执行示例存放在 `ax-samples/build/install/ax630c/` 路径下:

```bash
ax-samples/build$ tree install
install
└── ax620e
└── ax630c
├── ax_classification
├── ax_crowdcount
├── ax_depth_anything
Expand All @@ -99,32 +99,31 @@ install
└── ax_yolox
```

### AX620Q(32位,arm-linux)
### AX620Q(32位,arm-uclibc-linux)

#### 3rdparty 准备

- 下载预编译好的 [OpenCV 库文件](https://github.com/AXERA-TECH/ax-samples/releases/download/v0.1/opencv-arm-linux-gnueabihf-gcc-7.5.0.zip);
- 下载预编译好的 [OpenCV 库文件](https://github.com/AXERA-TECH/ax-samples/releases/download/v0.6/opencv-arm-uclibc-linux.zip);
- 在 ax-samples 创建 3rdparty 文件,并将下载好的 OpenCV 库文件压缩包解压到该文件夹中,文件夹目录结构如下所示

```bash
ax-samples$ tree -L 3
.
├── 3rdparty
│   └── opencv-arm-linux
│   └── opencv-arm-uclibc-linux
│   ├── bin
│   ├── build_opencv.sh
│   ├── include
│   ├── lib
│   └── share
```

#### 编译环境
- cmake 版本大于等于 3.13
- AX620E 配套的交叉编译工具链 `arm-linux-gnueabihf-gxx` 已添加到环境变量中
- AX620E 配套的交叉编译工具链 `arm-AX620E-linux-uclibcgnueabihf-gxx` 已添加到环境变量中

#### 安装交叉编译工具链

- Arm32 Linux 交叉编译工具链 [获取地址](http://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz)
- Arm32 Linux 交叉编译工具链 [获取地址](https://github.com/AXERA-TECH/ax620q_bsp_sdk/releases/download/v2.0.0/arm-AX620E-linux-uclibcgnueabihf_V3_20240320.tgz)

#### 依赖库准备

Expand All @@ -139,7 +138,7 @@ tar -zxvf msp.tgz
解压完成后将文件夹内此 `msp/out` 目录设置到临时环境变量,具体操作如下:

```
export ax_bsp=${ax620e_bsp_sdk PATH}/msp/out
export ax_bsp=${ax620e_bsp_sdk PATH}/msp/out/arm_uclibc
```

#### 源码编译
Expand All @@ -149,17 +148,17 @@ git clone 下载源码,进入 ax-samples 根目录,创建 cmake 编译任务
git clone https://github.com/AXERA-TECH/ax-samples.git
cd ax-samples
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/arm-linux-gnueabihf.toolchain.cmake -DBSP_MSP_DIR=${ax_bsp}/ -DAXERA_TARGET_CHIP=ax620e ..
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/arm-AX620E-linux-uclibcgnueabihf.toolchain.cmake -DBSP_MSP_DIR=${ax_bsp}/ -DAXERA_TARGET_CHIP=ax620q ..
make -j6
make install
```

编译完成后,生成的可执行示例存放在 `ax-samples/build/install/ax620e/` 路径下:
编译完成后,生成的可执行示例存放在 `ax-samples/build/install/ax620q/` 路径下:

```bash
ax-samples/build$ tree install
install
└── ax620e
└── ax620q
├── ax_classification
├── ax_crowdcount
├── ax_depth_anything
Expand Down
14 changes: 11 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ if(AXERA_TARGET_CHIP MATCHES "ax650")
endif()

add_definitions(-DAXERA_TARGET_CHIP_AX650)
elseif(AXERA_TARGET_CHIP MATCHES "ax620e")
elseif(AXERA_TARGET_CHIP MATCHES "ax630c")
if(NOT OpenCV_DIR)
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/3rdparty/opencv-arm-linux/lib/cmake/opencv4)
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/3rdparty/opencv-aarch64-linux/lib/cmake/opencv4)
endif()

add_definitions(-DAXERA_TARGET_CHIP_AX620E)
elseif(AXERA_TARGET_CHIP MATCHES "ax620q")
if(NOT OpenCV_DIR)
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/3rdparty/opencv-arm-uclibc-linux/lib/cmake/opencv4)
endif()

add_definitions(-DAXERA_TARGET_CHIP_AX620E)
elseif(AXERA_TARGET_CHIP MATCHES "ax620a")
if(NOT OpenCV_DIR)
Expand All @@ -56,7 +62,9 @@ include_directories(.)

if(AXERA_TARGET_CHIP MATCHES "ax650")
add_subdirectory(${CMAKE_SOURCE_DIR}/examples/ax650)
elseif(AXERA_TARGET_CHIP MATCHES "ax620e")
elseif(AXERA_TARGET_CHIP MATCHES "ax630c")
add_subdirectory(${CMAKE_SOURCE_DIR}/examples/ax620e)
elseif(AXERA_TARGET_CHIP MATCHES "ax620q")
add_subdirectory(${CMAKE_SOURCE_DIR}/examples/ax620e)
elseif(AXERA_TARGET_CHIP MATCHES "ax620a")
add_subdirectory(${CMAKE_SOURCE_DIR}/examples/ax620)
Expand Down
2 changes: 1 addition & 1 deletion examples/ax620e/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
find_package(Threads)
find_package(OpenCV REQUIRED)

include("${CMAKE_SOURCE_DIR}/cmake/ax650.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/ax620e.cmake")

axera_example(ax_classification ax_classification_steps.cc)

Expand Down
Loading
Loading