- 环境: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