基于AM67A的嵌入式语音识别功能实现(一):镜像烧写和虚拟机编译环境搭建

一、AM67A镜像烧写
  1. 镜像烧写

使用rufus进行AM67A的镜像tisdk-edgeai-image-j722s-evm.wic.xz 烧写,版本为10.00.00.08。

使用读卡器读取sd卡(推荐32G),打开rufus软件,依次选择设备,镜像文件,点击开始,等待100%后完成。

  1. sd卡方式启动

将sd卡插入板子卡槽,设置为sd卡启动模式(拨码默认情况就是),上电。

注意:推荐电源60-65w,若过低,可能无法正常启动系统

  1. 端口设置IP

    工具:自带的 USB 电缆(Type-A 转 Micro-B)、MobaXterm软件

    文档:J722SXH01%20评估模块.pdf、AM67A设计文件/SPRR495B/PROC170E1_RP/PROC170E1(002)_SCH.pdf

    1. USB 电缆连上时,旁边黄色指示灯亮起,若不常亮,可能驱动未安装成功,手动下载驱动程序([此处](VCP Drivers - FTDI))
    2. 存在4个com口,一般选择第3个,波特率设置为115200,[可参考设置教程](MobaXterm 串口连接开发板|极客笔记);
    3. 连上后无打印日志,可能是电源电压不够,选用60w以上的;
    4. 使用root登录,无密码
  2. 网络设置

    1)创建/etc/systemd/network/05-static.network文件,修改eth0的ip为192.168.1.44

    注意:若不成功,可能是/etc/systemd/network文件夹下含已配置文件,删除或修改;

    [Match] 
    Name=eth0  
    
    [Network] 
    Address=192.168.1.44/24 
    Gateway=192.168.1.1 
    DNS=114.114.114.114
    

    注意:若直连,设置IP在同一网段即可,192.168.1.xxx;若路由器,网关也设置为192.168.1.1

    2)验证通信

    在PC上ping开发板:

    ping 192.168.1.44
    

    在开发板上ping PC:

    ping 192.168.1.xxx
    

    3)查看网络服务状态

    systemctl status systemd-networkd.service
    

    ssh默认开启,下次启动可使用ssh访问;

    注意:若能ping通但无法SSH,重启板子试试

二、虚拟机编译环境搭建

生成板端推理需要用到model-artifacts和models(若已有,可跳过这一步)

虚拟机上docker搭建
  1. 克隆仓库,并指定版本10_00_04_00与板端10.00.00.08对应
   git clone https://github.com/TexasInstruments/edgeai-tidl-tools.git
   cd edgeai-tidl-tools
   git checkout 10_00_04_00
  1. 安装docker
   source ./scripts/docker/setup_docker.sh
  1. 根据Dockerfile 构建名为 x86_ubuntu_22 的 docker 镜像
   source ./scripts/docker/build_docker.sh

注意1:报错 Get “https://registry-1.docker.io/v2/”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) 时,换用[国内镜像网站](🔥截止目前,国内仍然可用docker镜像加速器汇总(2025年5月) - Kelen)

1).在/etc/docker/目录下创建daemon.json文件

2).内容为:

{
    "registry-mirrors": [
        "https://docker.xuanyuan.me"
    ]
}

3).重启Docker:

sudo systemctl daemon-reload
sudo systemctl restart docker

注意2:报错连不上https://github.com/TexasInstruments/edgeai-caffe2onnx/archive/refs/heads/tidl.zip时,可手动下载压缩包,解压后放在主目录/edgeai-tidl-tools下

1).修改/edgeai-tidl-tools/scripts/docker/目录下的Dockerfile文件

ARG CAFFE2ONNX_LOCAL=  # 新增参数,用于指定本地文件路径

RUN apt-get install -y python3 python3-pip python3-setuptools unzip  # 添加unzip

# 新增:处理本地caffe2onnx安装
COPY edgeai-caffe2onnx-tidl /tmp/edgeai-caffe2onnx  # 假设是已解压的文件夹(如果提示找不到路径,去掉所有的中文注释)
RUN pip3 install /tmp/edgeai-caffe2onnx && \
    rm -rf /tmp/edgeai-caffe2onnx

2).注释掉主目录/edgeai-tidl-tools下的requirement_pc.txt中关于此依赖项安装语句

# https://github.com/TexasInstruments/edgeai-caffe2onnx/archive/refs/heads/tidl.zip  # 已手动安装

注意3:在安装依赖项时出现ERROR: Could not find a version that satisfies the requirement torch (from versions: none)的问题,需要调整/edgeai-tidl-tools下的requirement_pc.txt

torch==2.0.1  # 官方支持Python 3.10的稳定版本
torchvision==0.15.2  # 必须与torch版本匹配
onnx==1.13.0
opencv-python==4.8.0.76  # 兼容Python 3.10
numpy==1.23.5  # 1.23.0 存在安全漏洞,建议升级
pyyaml==6.0.1
protobuf==3.20.3  # ONNX 1.13.0 的兼容版本
timm==0.9.2  # 兼容PyTorch 2.0
tflite==2.10.0  # 匹配TensorFlow 2.10
pillow==10.0.0  # 维护版本
flatbuffers==1.12.0  # 保持你的指定版本
requests==2.31.0
pytest==7.4.0
graphviz==0.20.1
# dataclasses==0.8  # Python 3.10已内置,可移除
gluoncv==0.10.5  # 兼容PyTorch 2.0
# https://github.com/TexasInstruments/edgeai-caffe2onnx/archive/refs/heads/tidl.zip

注意4:为提高安装速度,可在Dockerfile中配置清华源

COPY requirements_pc.txt /requirements_pc.txt
RUN bash -c 'if [ $USE_PROXY = "ti" ];then \
                export ftp_proxy=http://webproxy.ext.ti.com:80;\
                export http_proxy=http://webproxy.ext.ti.com:80;\
                export https_proxy=http://webproxy.ext.ti.com:80;\
                export HTTP_PROXY=http://webproxy.ext.ti.com:80\
                export HTTPS_PROXY=http://webproxy.ext.ti.com:80\
                export no_proxy=ti.com;\
                pip3 install pybind11[global] -i https://pypi.tuna.tsinghua.edu.cn/simple;\
                pip3 install -r /requirements_pc.txt -i https://pypi.tuna.tsinghua.edu.cn/simple;\
            else \
                pip3 install pybind11[global] -i https://pypi.tuna.tsinghua.edu.cn/simple;\
                pip3 install -r /requirements_pc.txt -i https://pypi.tuna.tsinghua.edu.cn/simple;\
            fi'
# 如果提示没网,电脑重启后重试
  1. 运行docker镜像
   source ./scripts/docker/run_docker.sh
  1. 进入docker容器后,运行以下命令搭建环境,进行一系列的环境设置、依赖安装和编译工作,需要保证网络配置,如果速度过慢,可以考虑使用代理
 cd /home/root/
 export SOC=am67a
 source ./setup.sh

注意:如果报错https://github.com/NVIDIA/TensorRT /tmp/pip-req-build-w9nv2011 error: RPC failed; 可能是网络问题,重复步骤3,4,5;

# 检查 onnxruntime、tflite 等组件安装情况
python3 -c "import onnxruntime; import tflite_runtime; import cv2; import dlr; print('所有依赖已安装')"

# 检查 onnx-graphsurgeon
python3 -c "import onnx_graphsurgeon; print('onnx-graphsurgeon 已安装')"

# 运行以下命令检查onnx-graphsurgeon版本:
python3 -c "import onnx_graphsurgeon as ogs; print(f'onnx-graphsurgeon 版本: {ogs.__version__}')"
  
如果输出类似:
onnx-graphsurgeon 版本: 0.3.12
说明版本信息正常。
  1. 后续退出后重新进入docker环境,需要设置如下环境变量
cd /home/root/
export SOC=am67a
export TIDL_TOOLS_PATH=$(pwd)/tidl_tools
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TIDL_TOOLS_PATH
export ARM64_GCC_PATH=$(pwd)/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu

7.注意检查ONNXRuntime 是否可用
运行python命令:

python3 -c "import onnxruntime; print(onnxruntime.get_available_providers())"

输出应包含:

['TIDLExecutionProvider', 'CPUExecutionProvider']

如果 TIDLExecutionProvider 不在其中,说明 TIDL plugin 没正确安装或配置。

注意:有时候会出现在执行完 source ./setup.sh 命令后,会检测到ONNXRuntime安装成功,但退出后再进入,又显示调用失败,此现象暂未解决,目前还每次用的时候再装一遍,有时间再新建个虚拟机试试,一定是前面依赖哪里有冲突

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值