| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 | #!/bin/bash# ================================================================================# Script for use on build server for generating scripts and documentation that can be distributed with# the release bundle# ================================================================================# Location of partitions.csv relative to this scriptpartitionsCsv="./partitions.csv"mkdir -p ./build# File to output readme instructions tooutputReadme="./build/README.txt"# File to output bash script tooutputBashScript="./build/writeSequeezeEsp.sh"# File to output bat script tooutputBatScript="./build/writeSequeezeEsp.bat"# The name of partitions to ignore from partitions.csvparitionsToIgnore=(  "nvs"  "phy_init")# Function that maps partition name to actual bin file# defaults to "[PARTION_NAME_FROM_CSV].bin"function partitionNameToBinFile {  if [[ "$1" == "otadata" ]]; then    echo "ota_data_initial.bin"  elif [[ "$1" == "ota_0" ]]; then    echo "squeezelite.bin"  else    echo $1.bin  fi}# write parameters for esptool.pywriteParameters="$writeParameters write_flash"writeParameters="$writeParameters --flash_mode dio --flash_freq 80m --flash_size detect"# bootloader.bin and partitions.bin not in partitions.csv so manually add herepartitionsParameters=" 0x1000 bootloader/bootloader.bin"partitionsParameters="$partitionsParameters 0x8000 partitions.bin"# ==============================================================================# Loop over partitions.csv and add partition bins and offsets to partitionsParameters{  read;  read;  while read -r line  do      partitionName=$(echo $line | awk -F', ' '{printf "%s", $1}' | tr -d '"')      partitionOffset=$(echo $line | awk -F', ' '{printf "%s", $4}' | tr -d '"')      partitionFile=$(partitionNameToBinFile $partitionName)      if [[ " ${paritionsToIgnore[@]} " =~ " ${partitionName} " ]]; then          continue      fi      partitionsParameters="$partitionsParameters $partitionOffset $partitionFile"  done} < $partitionsCsv# Write README Instructionsif [ ! -f "$outputReadme" ]; then  touch $outputReadmefiecho "" >> $outputReadmeecho "Below you'll find details on how to flash squeezelite-esp on different platforms" >> $outputReadmeecho "In all cases your squeezelite-esp will start in recovery mode. Setup Wifi and" >> $outputReadmeecho "then click on reboot within the system tab. And the squeezelite-esp should boot" >> $outputReadmeecho "into full mode" >> $outputReadmeecho "" >> $outputReadmeecho "====LINUX====" >> $outputReadmeecho "To flash sequeezelite run the following script:" >> $outputReadmeecho "$outputBashScript [PORT_HERE] [BAUD_RATE]" >> $outputReadmeecho "e.g. $outputBashScript /dev/ttyUSB0 115200" >> $outputReadmeecho "" >> $outputReadmeecho "====WINDOWS====" >> $outputReadmeecho "To flash sequeezelite run the following script:" >> $outputReadmeecho "$outputBatScript [PORT_HERE] [BAUD_RATE]" >> $outputReadmeecho "e.g. $outputBatScript COM11 115200" >> $outputReadmeecho "" >> $outputReadmeecho "If you don't know how to run the BAT file with arguments then you can" >> $outputReadmeecho "edit the bat file in Notepad. Open the file up and edit the following:" >> $outputReadmeecho "Change 'set port=%1' to 'set port=[PORT_HERE]'. E.g. 'set port=COM11'" >> $outputReadmeecho "Change 'set baud=%2' to 'set baud=[BAUD_RATE]'. E.g. 'set baud=115200'" >> $outputReadmeecho "" >> $outputReadmeecho "====MANUAL====" >> $outputReadmeecho "Python esptool.py --port [PORT_HERE] --baud [BAUD_RATE] $writeParameters $partitionsParameters" >> $outputReadme# Write Linux BASH Fileif [ ! -f "$outputBashScript" ]; then  touch $outputBashScriptfiecho "#!/bin/bash" >> $outputBashScriptecho >> $outputBashScriptecho "port=\$1" >> $outputBashScriptecho "baud=\$2" >> $outputBashScriptlinuxFlashCommand="Python esptool.py --port \$port --baud \$baud"echo "$linuxFlashCommand $writeParameters $partitionsParameters" >> $outputBashScript# Write Windows BAT Fileif [ ! -f "$outputBatScript" ]; then  touch $outputBatScriptfiecho "echo off" >> $outputBatScriptecho "" >> $outputBatScriptecho "set port=%1" >> $outputBatScriptecho "set baud=%2" >> $outputBatScriptwindowsFlashCommand="Python esptool.py --port %port% --baud %baud%"echo "$windowsFlashCommand $writeParameters $partitionsParameters" >> $outputBatScript
 |