ESP32 idf合并多个bin文件为完整固件shell脚本

  • 环境:Linux
  • 芯片:esp32c6

编译后会生成一个flash_args文件,里面有bin文件的烧录信息(文件名、烧录地址),直接使用这里的参数进行合并即可:

#!/bin/bash

idf_path=$HOME/esp/esp-idf

# Check if idf.py exists in the PATH
if command -v idf.py &> /dev/null; then
    echo "idf.py is already in your PATH."
else
    # Export idf.py if not found
    if [ -x "${idf_path}/tools/idf.py" ]; then
        . $HOME/esp/esp-idf/export.sh
        echo "Exported idf.py to PATH."
    else
        echo "Error: idf.py not found in ${idf_path}/tools directory."
        exit 1
    fi
fi

# Read flash_args from file
if [ -f ./build/flash_args ]; then
    cd build/
    flash_args=$(cat flash_args)

    # Get the latest Git commit hash
    git_commit_hash=$(git rev-parse --short HEAD)

    # Construct the output filename with the Git commit hash
    # output_filename="DL1_esp32_full_firmware_${git_commit_hash}.bin"
    output_filename="esp32_full_firmware.bin"

    # Construct esptool.py command with the read flash_args and output filename
    esptool.py --chip esp32c6 merge_bin -o "${output_filename}" ${flash_args}
    printf "\nmerge bin completed, md5sum:\n"
    md5sum "${output_filename}"

    # Copy the merged binary to the bin directory
    cp "${output_filename}" ../../firmware/

    # Change back to the original directory
    cd ..
else
    echo "Error: flash_args file not found."
    exit 1
fi

  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值