2
0

makeBuildDocs.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/bin/bash
  2. # ================================================================================
  3. # Script for use on build server for generating scripts and documentation that can be distributed with
  4. # the release bundle
  5. # ================================================================================
  6. # Location of partitions.csv relative to this script
  7. partitionsCsv="./partitions.csv"
  8. mkdir -p ./build
  9. # File to output readme instructions to
  10. outputReadme="./build/README.txt"
  11. # File to output bash script to
  12. outputBashScript="./build/writeSequeezeEsp.sh"
  13. # File to output bat script to
  14. outputBatScript="./build/writeSequeezeEsp.bat"
  15. # The name of partitions to ignore from partitions.csv
  16. paritionsToIgnore=(
  17. "nvs"
  18. "phy_init"
  19. )
  20. # Function that maps partition name to actual bin file
  21. # defaults to "[PARTION_NAME_FROM_CSV].bin"
  22. function partitionNameToBinFile {
  23. if [[ "$1" == "otadata" ]]; then
  24. echo "ota_data_initial.bin"
  25. elif [[ "$1" == "ota_0" ]]; then
  26. echo "squeezelite.bin"
  27. else
  28. echo $1.bin
  29. fi
  30. }
  31. # write parameters for esptool.py
  32. writeParameters="$writeParameters write_flash"
  33. writeParameters="$writeParameters --flash_mode dio --flash_freq 80m --flash_size detect"
  34. # bootloader.bin and partitions.bin not in partitions.csv so manually add here
  35. partitionsParameters=" 0x1000 bootloader/bootloader.bin"
  36. partitionsParameters="$partitionsParameters 0x8000 partitions.bin"
  37. # ==============================================================================
  38. # Loop over partitions.csv and add partition bins and offsets to partitionsParameters
  39. {
  40. read;
  41. read;
  42. while read -r line
  43. do
  44. partitionName=$(echo $line | awk -F', ' '{printf "%s", $1}' | tr -d '"')
  45. partitionOffset=$(echo $line | awk -F', ' '{printf "%s", $4}' | tr -d '"')
  46. partitionFile=$(partitionNameToBinFile $partitionName)
  47. if [[ " ${paritionsToIgnore[@]} " =~ " ${partitionName} " ]]; then
  48. continue
  49. fi
  50. partitionsParameters="$partitionsParameters $partitionOffset $partitionFile"
  51. done
  52. } < $partitionsCsv
  53. # Write README Instructions
  54. if [ ! -f "$outputReadme" ]; then
  55. touch $outputReadme
  56. fi
  57. echo "" >> $outputReadme
  58. echo "Below you'll find details on how to flash squeezelite-esp on different platforms" >> $outputReadme
  59. echo "In all cases your squeezelite-esp will start in recovery mode. Setup Wifi and" >> $outputReadme
  60. echo "then click on reboot within the system tab. And the squeezelite-esp should boot" >> $outputReadme
  61. echo "into full mode" >> $outputReadme
  62. echo "" >> $outputReadme
  63. echo "====LINUX====" >> $outputReadme
  64. echo "To flash sequeezelite run the following script:" >> $outputReadme
  65. echo "$outputBashScript [PORT_HERE] [BAUD_RATE]" >> $outputReadme
  66. echo "e.g. $outputBashScript /dev/ttyUSB0 115200" >> $outputReadme
  67. echo "" >> $outputReadme
  68. echo "====WINDOWS====" >> $outputReadme
  69. echo "To flash sequeezelite run the following script:" >> $outputReadme
  70. echo "$outputBatScript [PORT_HERE] [BAUD_RATE]" >> $outputReadme
  71. echo "e.g. $outputBatScript COM11 115200" >> $outputReadme
  72. echo "" >> $outputReadme
  73. echo "If you don't know how to run the BAT file with arguments then you can" >> $outputReadme
  74. echo "edit the bat file in Notepad. Open the file up and edit the following:" >> $outputReadme
  75. echo "Change 'set port=%1' to 'set port=[PORT_HERE]'. E.g. 'set port=COM11'" >> $outputReadme
  76. echo "Change 'set baud=%2' to 'set baud=[BAUD_RATE]'. E.g. 'set baud=115200'" >> $outputReadme
  77. echo "" >> $outputReadme
  78. echo "====MANUAL====" >> $outputReadme
  79. echo "Python esptool.py --port [PORT_HERE] --baud [BAUD_RATE] $writeParameters $partitionsParameters" >> $outputReadme
  80. # Write Linux BASH File
  81. if [ ! -f "$outputBashScript" ]; then
  82. touch $outputBashScript
  83. fi
  84. echo "#!/bin/bash" >> $outputBashScript
  85. echo >> $outputBashScript
  86. echo "port=\$1" >> $outputBashScript
  87. echo "baud=\$2" >> $outputBashScript
  88. linuxFlashCommand="Python esptool.py --port \$port --baud \$baud"
  89. echo "$linuxFlashCommand $writeParameters $partitionsParameters" >> $outputBashScript
  90. # Write Windows BAT File
  91. if [ ! -f "$outputBatScript" ]; then
  92. touch $outputBatScript
  93. fi
  94. echo "echo off" >> $outputBatScript
  95. echo "" >> $outputBatScript
  96. echo "set port=%1" >> $outputBatScript
  97. echo "set baud=%2" >> $outputBatScript
  98. windowsFlashCommand="Python esptool.py --port %port% --baud %baud%"
  99. echo "$windowsFlashCommand $writeParameters $partitionsParameters" >> $outputBatScript