Alex Blog

如何利用 Integration Tool 源码以及原始下载的 DEB 包进行编译并生成合适的 DEB 安装包

1. 解压原始 DEB 包

首先,找到一个 test 目录,将从官网下载的DEB 安装包的所有内容解压到这个临时目录。可以看到类似如下的文件结构:

├── DEBIAN
│   └── control
├── etc
│   └── hailo_accelerator_integration_tool
├── usr
│   └── bin
└── var
    └── hailo_accelerator_integration_tool

其中 usr/bin/ 目录里的 hailo-accelerator-integration-tool 为工具的可执行文件,默认依赖 hailort 4.19.0

2. 更新 Hailort 版本

若要支持更高版本的 hailort,避免降级测试,可手动编译并替换 hailo-accelerator-integration-tool

2.1 编译 X86 版本

依然从官网下载对应的源码并解压
我这边以x86 ubuntu 20.04环境编译为基准来进行说明
请尽量以你需要的最低ubuntu版本来编译,否则可能会遇到GLIBC不兼容的问题,实在不行请使用docker进行编译
unzip hailo_accelerator_integration_tool_1.19.0_sources.zip
# 修改 CMakeLists.txt
set(HAILORT_VERSION 4.20.0)
编译可执行文件:
cmake -S . -Bbuild
cmake --build build

若有头文件报错,需手动添加对应头文件目录:

target_include_directories(hailo-accelerator-integration-tool PRIVATE
    ${CMAKE_CURRENT_BINARY_DIR}
    ${CMAKE_SOURCE_DIR}
)

编译完成后,将生成的 build/hailo-accelerator-integration-tool 替换解压目录中的 usr/bin/ 的可执行文件。

2.2 打包新的 DEB 包

dpkg-deb -b ./ hailo_accelerator_integration_tool_1.19.0_amd64_4.20.0.deb

3. 编译 ARM 版本

3.1 安装 ARM64 交叉编译环境

sudo apt update
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

3.2 编译 ARM 版本的 Hailort

# 在 Hailort 源码目录的 CMakeLists.txt 添加:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)

set(CMAKE_C_FLAGS "-march=armv8-a")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")

# 编译命令:
cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=build/deploy
cmake --build build --parallel --target install
使用-DCMAKE_INSTALL_PREFIX的目的为将编译的库与头文件等安装到特定的目录build/deploy

3.3 编译 ARM 版本的 Integration Tool

cmake -S . -Bbuild -DCMAKE_PREFIX_PATH=../hailort_4.20.0/build/deploy/
cmake --build build
类似的, 使用-DCMAKE_PREFIX_PATH的目的,会指定编译器寻找hailort library的目录。

4. 测试项调整(针对无 INA231 芯片的板子)

如果H8的开发板没有 INA231 芯片,需设置 thermal_theta_estimation_testovercurrent_testfalse。此外,thermal_stress_test 中功耗测量部分也需屏蔽功耗获取部分代码:

4.1 修改代码屏蔽功耗测量部分

src/hailort/device.cpp 文件中找到 DeviceTemp Device::get_temperature(uint8_t averaging_factor) 函数,将原代码:

try {
    float power = get_power();
    m_logger->trace("[{}] power and temperature: {} {}:{}", id(), power, avg_t0, avg_t1);
    return DeviceTemp(id(), avg_t0, avg_t1, power);
} catch (PowerReadFailed &ex) {
    m_logger->trace("[{}] temperature: {}:{}", id(), avg_t0, avg_t1);
    return DeviceTemp(id(), avg_t0, avg_t1);
}

修改为:

m_logger->trace("[{}] temperature: {}:{}", id(), avg_t0, avg_t1);
return DeviceTemp(id(), avg_t0, avg_t1);

总结

通过以上步骤,即可生成适合不同 Hailort 版本的 hailo-accelerator-integration-tool 安装包,并优化其对特定硬件的兼容性。

 


已发布

分类

来自

标签:

评论

《 “如何利用 Integration Tool 源码以及原始下载的 DEB 包进行编译并生成合适的 DEB 安装包” 》 有 2 条评论

  1. alex 的头像

    ar x *.deb 可以解压对应的deb包

  2. alex 的头像
    alex

    ar rcs new_package.deb debian-binary control.tar.xz data.tar.xz
    进行打包

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注