PF-build.sh 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. #!/bin/bash
  2. # This bash script is used to compile automatically the Prusa firmware with a dedicated build environment and settings
  3. #
  4. # Supported OS: Windows 10, Linux64 bit
  5. # Beta OS: Linux32 bit
  6. #
  7. # Linux:
  8. #
  9. # Windows:
  10. # To execute this script you gonna need few things on your Windows machine
  11. #
  12. # Linux Subsystem Ubuntu
  13. # 1. Follow these instructions
  14. # 2. Open Ubuntu bash and get latest updates with 'apt-get update'
  15. # 3. Install zip with 'apt-get install zip'
  16. # 4. Install python3 with 'apt-get install python3'
  17. # 5. Add command 'ln -sf /usr/bin/python3.5 /usr/bin/python' to link python3 to python.
  18. # Do not install 'python' as python 2.x has end of life see https://pythonclock.org/
  19. # 6. Add at top of ~/.bashrc following lines by using 'sudo nano ~/.bashrc'
  20. #
  21. # export OS="Linux"
  22. # export JAVA_TOOL_OPTIONS="-Djava.net.preferIPv4Stack=true"
  23. # export GPG_TTY=$(tty)
  24. #
  25. # and confirm them. Restart Ubuntu bash
  26. #
  27. # Or GIT-BASH
  28. # 1. Download and install the correct (64bit or 32bit) Git version https://git-scm.com/download/win
  29. # 2. Also follow these instructions https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058
  30. # 3. Download and install 7z-zip from its official website.
  31. # By default, it is installed under the directory /c/Program Files/7-Zip in Windows 10 as my case.
  32. # 4. Run git Bash under Administrator privilege and navigate to the directory /c/Program Files/Git/mingw64/bin,
  33. # you can run the command ln -s /c/Program Files/7-Zip/7z.exe zip.exe
  34. #
  35. # Useful things to edit and compare your custom Firmware
  36. # 1. Download and install current and correct (64bit or 32bit) Notepad++ version https://notepad-plus-plus.org/download
  37. # 2. Another great tool to compare your custom mod and stock firmware is WinMerge http://winmerge.org/downloads/?lang=en
  38. #
  39. # Example for MK3: open git bash and change to your Firmware directory
  40. # <username>@<machine name> MINGW64 /<drive>/path
  41. # bash build.sh 1_75mm_MK3-EINSy10a-E3Dv6full
  42. #
  43. # Example for MK25: open git bash and change to your directory
  44. # gussner@WIN01 MINGW64 /d/Data/Prusa-Firmware/MK3
  45. # bash build.sh 1_75mm_MK25-RAMBo13a-E3Dv6full
  46. #
  47. # The compiled hex files can be found in the folder above like from the example
  48. # gussner@WIN01 MINGW64 /d/Data/Prusa-Firmware
  49. # FW351-Build1778-1_75mm_MK25-RAMBo13a-E3Dv6full.hex
  50. #
  51. # Why make Arduino IDE portable?
  52. # To have a distinguished Prusa Firmware build environment I decided to use Arduino IDE in portable mode.
  53. # - Changes made to other Arduino instances do not change anything in this build environment.
  54. # By default Arduino IDE uses "users" and shared library folders which is useful as soon you update the Software.
  55. # But in this case we need a stable and defined build environment, so keep it separated it kind of important.
  56. # Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE
  57. # it will use the default Arduino IDE folders and so can corrupt the build environment.
  58. #
  59. # Version: 1.0.6-Build_37
  60. # Change log:
  61. # 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt'
  62. # 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown
  63. # 17 Jan 2019, 3d-gussner, Build_3, Check for OS Windows or Linux and use the right build environment
  64. # 10 Feb 2019, ropaha, Pull Request, Select variant from list while using build.sh
  65. # 10 Feb 2019, ropaha, change FW_DEV_VERSION automatically depending on FW_VERSION RC/BETA/ALPHA
  66. # 10 Feb 2019, 3d-gussner, 1st tests with English only
  67. # 10 Feb 2019, ropaha, added compiling of all variants and English only
  68. # 10 Feb 2019, 3d-gussner, Set OUTPUT_FOLDER for hex files
  69. # 11 Feb 2019, 3d-gussner/ropaha, Minor changes and fixes
  70. # 11 Feb 2019, 3d-gussner, Ready for RC
  71. # 12 Feb 2019, 3d-gussner, Check if wget and zip are installed. Thanks to Bernd to point it out
  72. # 12 Feb 2019, 3d-gussner, Changed OS check to OSTYPE as it is not supported on Ubuntu
  73. # Also added different BUILD_ENV folders depending on OS used so Windows
  74. # Users can use git-bash AND Windows Linux Subsystems at the same time
  75. # Cleanup compiler flags is only depends on OS version.
  76. # 12 Feb 2019, 3d-gussner, Added additional OSTYPE check
  77. # 15 feb 2019, 3d-gussner, Added zip files for miniRAMbo multi language hex files
  78. # 15 Feb 2019, 3d-gussner, Added more checks if
  79. # Compiled Hex-files
  80. # Configuration_prusa.h
  81. # language build files
  82. # multi language firmware files exist and clean them up
  83. # 15 Feb 2019, 3d-gussner, Fixed selection GOLD/UNKNOWN DEV_STATUS for ALL variants builds, so you have to choose only once
  84. # 15 Feb 2019, 3d-gussner, Added some colored output
  85. # 15 Feb 2019, 3d-gussner, troubleshooting and minor fixes
  86. # 16 Feb 2019, 3d-gussner, Script can be run using arguments
  87. # $1 = variant, example "1_75mm_MK3-EINSy10a-E3Dv6full.h" at this moment it is not possible to use ALL
  88. # $2 = multi language OR English only [ALL/EN_ONLY]
  89. # $3 = development status [GOLD/RC/BETA/ALPHA/DEVEL/DEBUG]
  90. # If one argument is wrong a list of valid one will be shown
  91. # 13 Mar 2019, 3d-gussner, MKbel updated the Linux build environment to version 1.0.2 with an Fix maximum firmware flash size.
  92. # So did I
  93. # 11 Jul 2019, deliopoulos,Updated to v1.0.6 as Prusa needs a new board definition for Firmware 3.8.x86_64
  94. # - Split the Download of Windows Arduino IDE 1.8.5 and Prusa specific part
  95. # --> less download volume needed and saves some time
  96. #
  97. # 13 Jul 2019, deliopoulos,Splitting of Arduino IDE and Prusa parts also for Linux64
  98. # 13 Jul 2019, 3d-gussner, Added Linux 32-bit version (untested yet)
  99. # MacOS could be added in future if needs
  100. # 14 Jul 2019, 3d-gussner, Update preferences and make it really portable
  101. # 15 Jul 2019, 3d-gussner, New PF-build-env GitHub branch
  102. # 16 Jul 2019, 3d-gussner, New Arduino_boards GitHub fork
  103. # 17 Jul 2019, 3d-gussner, Final tests under Windows 10 and Linux Subsystem for Windows
  104. # 18 Jul 2019, 3d-gussner, Added python check
  105. # 18 Jul 2019, deliopoulos, No need more for changing 'platform.txt' file as it comes with the Arduino Boards.
  106. # 18 Jul 2019, deliopoulos, Modified 'PF_BUILD_FILE_URL' to use 'BUILD_ENV' variable
  107. # 22 Jul 2019, 3d-gussner, Modified checks to check folder and/or installation output exists.
  108. # 22 Jul 2019, 3d-gussner, Added check if Arduino IDE 1.8.5 boards have been updated
  109. # 22 Jul 2019, 3d-gussner, Changed exit numbers 1-13 for prepare build env 21-28 for prepare compiling 31-36 compiling
  110. # 22 Jul 2019, 3d-gussner, Changed BOARD_URL to DRracers repository after he pulled my PR https://github.com/DRracer/Arduino_Boards/pull/1
  111. # 23 Jul 2019, 3d-gussner, Changed Build-env path to "PF-build-dl" as requested in PR https://github.com/prusa3d/Prusa-Firmware/pull/2028
  112. # Changed Hex-files folder to PF-build-hex as requested in PR
  113. # 23 Jul 2019, 3d-gussner, Added Finding OS version routine so supporting new OS should get easier
  114. # 26 Jul 2019, 3d-gussner, Change JSON repository to prusa3d after PR https://github.com/prusa3d/Arduino_Boards/pull/1 was merged
  115. # 23 Sep 2019, 3d-gussner, Prepare PF-build.sh for coming Prusa3d/Arduino_Boards version 1.0.2 Pull Request
  116. # 17 Oct 2019, 3d-gussner, Changed folder and check file names to have separated build environments depending on Arduino IDE version and
  117. # board-versions.
  118. # 15 Dec 2019, 3d-gussner, Prepare for switch to Prusa3d/PF-build-env repository
  119. # 15 Dec 2019, 3d-gussner, Fix Arduino user preferences for the chosen board.
  120. # 17 Dec 2019, 3d-gussner, Fix "timer0_fract = 0" warning by using Arduino_boards v1.0.3
  121. # 28 Apr 2020, 3d-gussner, Added RC3 detection
  122. # 03 May 2020, deliopoulos, Accept all RCx as RC versions
  123. # 05 May 2020, 3d-gussner, Make a copy of `not_tran.txt`and `not_used.txt` as `not_tran_$VARIANT.txt`and `not_used_$VARIANT.txt`
  124. # After compiling All multi-language variants it makes it easier to find missing or unused translations.
  125. # 12 May 2020, DRracer , Cleanup double MK2/s MK25/s `not_tran` and `not_used` files
  126. # 13 May 2020, leptun , If cleanup files do not exist don't try to.
  127. # 01 Oct 2020, 3d-gussner, Bug fix if using argument EN_ONLY. Thank to @leptun for pointing out.
  128. # Change Build number to script commits 'git rev-list --count HEAD PF-build.sh'
  129. # 02 Oct 2020, 3d-gussner, Add UNKNOWN as argument option
  130. # 05 Oct 2020, 3d-gussner, Disable pause and warnings using command line with all needed arguments
  131. # Install needed apps under linux if needed.
  132. # Clean PF-Firmware build when changing git branch
  133. # 02 Nov 2020, 3d-gussner, Check for "gawk" on Linux
  134. # Add argument to change build number automatically to current commit or define own number
  135. # Update exit numbers 1-13 for prepare build env 21-29 for prepare compiling 30-36 compiling
  136. # 08 Jan 2021, 3d-gussner, Comment out 'sudo' auto installation
  137. # Add '-?' '-h' help option
  138. # 27 Jan 2021, 3d-gussner, Add `-c`, `-p` and `-n` options
  139. # 27 Feb 2021, 3d-gussner, Add './lang-community.sh' and update exits
  140. #### Start check if OSTYPE is supported
  141. OS_FOUND=$( command -v uname)
  142. case $( "${OS_FOUND}" | tr '[:upper:]' '[:lower:]') in
  143. linux*)
  144. TARGET_OS="linux"
  145. ;;
  146. msys*|cygwin*|mingw*)
  147. # or possible 'bash on windows'
  148. TARGET_OS='windows'
  149. ;;
  150. nt|win*)
  151. TARGET_OS='windows'
  152. ;;
  153. *)
  154. TARGET_OS='unknown'
  155. ;;
  156. esac
  157. # Windows
  158. if [ $TARGET_OS == "windows" ]; then
  159. if [ $(uname -m) == "x86_64" ]; then
  160. echo "$(tput setaf 2)Windows 64-bit found$(tput sgr0)"
  161. Processor="64"
  162. elif [ $(uname -m) == "i386" ]; then
  163. echo "$(tput setaf 2)Windows 32-bit found$(tput sgr0)"
  164. Processor="32"
  165. else
  166. echo "$(tput setaf 1)Unsupported OS: Windows $(uname -m)"
  167. echo "Please refer to the notes of build.sh$(tput sgr0)"
  168. exit 1
  169. fi
  170. # Linux
  171. elif [ $TARGET_OS == "linux" ]; then
  172. if [ $(uname -m) == "x86_64" ]; then
  173. echo "$(tput setaf 2)Linux 64-bit found$(tput sgr0)"
  174. Processor="64"
  175. elif [[ $(uname -m) == "i386" || $(uname -m) == "i686" ]]; then
  176. echo "$(tput setaf 2)Linux 32-bit found$(tput sgr0)"
  177. Processor="32"
  178. else
  179. echo "$(tput setaf 1)Unsupported OS: Linux $(uname -m)"
  180. echo "Please refer to the notes of build.sh$(tput sgr0)"
  181. exit 1
  182. fi
  183. else
  184. echo "$(tput setaf 1)This script doesn't support your Operating system!"
  185. echo "Please use Linux 64-bit or Windows 10 64-bit with Linux subsystem / git-bash"
  186. echo "Read the notes of build.sh$(tput sgr0)"
  187. exit 1
  188. fi
  189. sleep 2
  190. #### End check if OSTYPE is supported
  191. #### Prepare bash environment and check if wget, zip and other needed things are available
  192. # Check wget
  193. if ! type wget > /dev/null; then
  194. echo "$(tput setaf 1)Missing 'wget' which is important to run this script"
  195. echo "Please follow these instructions https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058 to install wget$(tput sgr0)"
  196. exit 2
  197. fi
  198. # Check for zip
  199. if ! type zip > /dev/null; then
  200. if [ $TARGET_OS == "windows" ]; then
  201. echo "$(tput setaf 1)Missing 'zip' which is important to run this script"
  202. echo "Download and install 7z-zip from its official website https://www.7-zip.org/"
  203. echo "By default, it is installed under the directory /c/Program Files/7-Zip in Windows 10 as my case."
  204. echo "Run git Bash under Administrator privilege and"
  205. echo "navigate to the directory /c/Program Files/Git/mingw64/bin,"
  206. echo "you can run the command $(tput setaf 2)ln -s /c/Program Files/7-Zip/7z.exe zip.exe$(tput sgr0)"
  207. exit 3
  208. elif [ $TARGET_OS == "linux" ]; then
  209. echo "$(tput setaf 1)Missing 'zip' which is important to run this script"
  210. echo "install it with the command $(tput setaf 2)'sudo apt-get install zip'$(tput sgr0)"
  211. #sudo apt-get update && apt-get install zip
  212. exit 3
  213. fi
  214. fi
  215. # Check python ... needed during language build
  216. if ! type python > /dev/null; then
  217. if [ $TARGET_OS == "windows" ]; then
  218. echo "$(tput setaf 1)Missing 'python3' which is important to run this script"
  219. exit 4
  220. elif [ $TARGET_OS == "linux" ]; then
  221. echo "$(tput setaf 1)Missing 'python' which is important to run this script"
  222. echo "As Python 2.x will not be maintained from 2020 please,"
  223. echo "install it with the command $(tput setaf 2)'sudo apt-get install python3'."
  224. echo "Check which version of Python3 has been installed using 'ls /usr/bin/python3*'"
  225. echo "Use 'sudo ln -sf /usr/bin/python3.x /usr/bin/python' (where 'x' is your version number) to make it default.$(tput sgr0)"
  226. #sudo apt-get update && apt-get install python3 && ln -sf /usr/bin/python3 /usr/bin/python
  227. exit 4
  228. fi
  229. fi
  230. # Check gawk ... needed during language build
  231. if ! type gawk > /dev/null; then
  232. if [ $TARGET_OS == "linux" ]; then
  233. echo "$(tput setaf 1)Missing 'gawk' which is important to run this script"
  234. echo "install it with the command $(tput setaf 2)'sudo apt-get install gawk'."
  235. #sudo apt-get update && apt-get install gawk
  236. exit 5
  237. fi
  238. fi
  239. #### End prepare bash / Linux environment
  240. # Check for options/flags
  241. while getopts v:l:d:b:f:x:r:o:c:p:n:?h flag
  242. do
  243. case "${flag}" in
  244. v) variant_flag=${OPTARG};;
  245. l) language_flag=${OPTARG};;
  246. d) devel_flag=${OPTARG};;
  247. b) build_flag=${OPTARG};;
  248. f) board_flash_flag=${OPTARG};;
  249. x) board_mem_flag=${OPTARG};;
  250. o) output_flag=${OPTARG};;
  251. c) clean_flag=${OPTARG};;
  252. p) prusa_flag=${OPTARG};;
  253. n) new_build_flag=${OPTARG};;
  254. ?) help_flag=1;;
  255. h) help_flag=1;;
  256. esac
  257. done
  258. #echo "variant_flag: $variant_flag";
  259. #echo "language_flag: $language_flag";
  260. #echo "devel_flag: $devel_flag";
  261. #echo "build_flag: $build_flag";
  262. #echo "output_flag: $output_flag";
  263. #echo "board_mem_flag: $board_mem_flag";
  264. #echo "board_flash_flag: $board_flash_flag";
  265. #echo "help_flag: $help_flag"
  266. #echo "clean_flag: $clean_flag"
  267. #echo "prusa_flag: $prusa_flag"
  268. #echo "new_build_flag: $new_build_flag"
  269. #
  270. # '?' 'h' argument usage and help
  271. if [ "$help_flag" == "1" ] ; then
  272. echo "***************************************"
  273. echo "* PF-build.sh Version: 1.0.6-Build_33 *"
  274. echo "***************************************"
  275. echo "Arguments:"
  276. echo "$(tput setaf 2)-v$(tput sgr0) Variant '$(tput setaf 2)All$(tput sgr0)' or variant file name"
  277. echo "$(tput setaf 2)-l$(tput sgr0) Languages '$(tput setaf 2)ALL$(tput sgr0)' for multi language or '$(tput setaf 2)EN_ONLY$(tput sgr0)' for English only"
  278. echo "$(tput setaf 2)-d$(tput sgr0) Devel build '$(tput setaf 2)GOLD$(tput sgr0)', '$(tput setaf 2)RC$(tput sgr0)', '$(tput setaf 2)BETA$(tput sgr0)', '$(tput setaf 2)ALPHA$(tput sgr0)', '$(tput setaf 2)DEBUG$(tput sgr0)', '$(tput setaf 2)DEVEL$(tput sgr0)' and '$(tput setaf 2)UNKNOWN$(tput sgr0)'"
  279. echo "$(tput setaf 2)-b$(tput sgr0) Build/commit number '$(tput setaf 2)Auto$(tput sgr0)' needs git or a number"
  280. echo "$(tput setaf 2)-o$(tput sgr0) Output '$(tput setaf 2)1$(tput sgr0)' force or '$(tput setaf 2)0$(tput sgr0)' block output and delays"
  281. echo "$(tput setaf 2)-c$(tput sgr0) Do not clean up lang build'$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' yes"
  282. echo "$(tput setaf 2)-p$(tput sgr0) Keep Configuration_prusa.h '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' yes"
  283. echo "$(tput setaf 2)-n$(tput sgr0) New fresh build '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' yes"
  284. echo "$(tput setaf 2)-?$(tput sgr0) Help"
  285. echo "$(tput setaf 2)-h$(tput sgr0) Help"
  286. echo
  287. echo "Brief USAGE:"
  288. echo " $(tput setaf 2)./PF-build.sh$(tput sgr0) [-v] [-l] [-d] [-b] [-o] [-c] [-p] [-n]"
  289. echo
  290. echo "Example:"
  291. echo " $(tput setaf 2)./PF-build.sh -v All -l ALL -d GOLD$(tput sgr0)"
  292. echo " Will build all variants as multi language and final GOLD version"
  293. echo
  294. echo " $(tput setaf 2) ./PF-build.sh -v 1_75mm_MK3S-EINSy10a-E3Dv6full.h -b Auto -l ALL -d GOLD -o 1 -c 1 -p 1 -n 1$(tput sgr0)"
  295. echo " Will build MK3S multi language final GOLD firmware "
  296. echo " with current commit count number and output extra information,"
  297. echo " not delete lang build temporary files, keep Configuration_prusa.h and build with new fresh build folder."
  298. echo
  299. exit 6
  300. fi
  301. #Check if Build is selected with argument '-f'
  302. if [ ! -z "$board_flash_flag" ] ; then
  303. if [ "$board_flash_flag" == "256" ] ; then
  304. BOARD_FLASH="0x3FFFF"
  305. BOARD_maximum_size="253952"
  306. echo "Board flash size : $board_flash_flag Kb, $BOARD_maximum_size bytes, $BOARD_FLASH (hex)"
  307. elif [ "$board_flash_flag" == "384" ] ; then
  308. BOARD_FLASH="0x5FFFF"
  309. BOARD_maximum_size="385024"
  310. echo "Board flash size : $board_flash_flag Kb, $BOARD_maximum_size bytes, $BOARD_FLASH (hex)"
  311. elif [ "$board_flash_flag" == "512" ] ; then
  312. BOARD_FLASH="0x7FFFF"
  313. BOARD_maximum_size="516096"
  314. echo "Board flash size : $board_flash_flag Kb, $BOARD_maximum_size bytes, $BOARD_FLASH (hex)"
  315. elif [ "$board_flash_flag" == "1024" ] ; then
  316. BOARD_FLASH="0xFFFFF"
  317. BOARD_maximum_size="1040384"
  318. echo "Board flash size : $board_flash_flag Kb, $BOARD_maximum_size bytes, $BOARD_FLASH (hex)"
  319. elif [[ "$board_flash_flag" == "32M" || "$board_flash_flag" == "32768" ]] ; then
  320. BOARD_FLASH="0x1FFFFFF"
  321. BOARD_maximum_size="33546240"
  322. echo "Board flash size : 32 Mb, $BOARD_maximum_size bytes, $BOARD_FLASH (hex)"
  323. else
  324. echo "Unsupported board flash size chosen. Only '256', '384', '512', '1024' and '32M' are allowed."
  325. exit 7
  326. fi
  327. fi
  328. #Check if Build is selected with argument '-x'
  329. if [ ! -z "$board_mem_flag" ] ; then
  330. if [ "$board_mem_flag" == "8" ] ; then
  331. BOARD_MEM="0x21FF"
  332. echo "Board mem size : $board_mem_flag Kb, $BOARD_MEM (hex)"
  333. elif [ "$board_mem_flag" == "64" ] ; then
  334. BOARD_MEM="0xFFFF"
  335. echo "Board mem size : $board_mem_flag Kb, $BOARD_MEM (hex)"
  336. else
  337. echo "Unsupported board mem size chosen. Only '8', '64' are allowed."
  338. exit 8
  339. fi
  340. fi
  341. #### Set build environment
  342. ARDUINO_ENV="1.8.13"
  343. BUILD_ENV="1.0.6"
  344. BOARD="prusa_einsy_rambo"
  345. BOARD_PACKAGE_NAME="PrusaResearch"
  346. BOARD_VERSION="1.0.3"
  347. #BOARD_URL="https://raw.githubusercontent.com/3d-gussner/Arduino_Boards/master/IDE_Board_Manager/package_prusa3d_index.json"
  348. BOARD_URL="https://raw.githubusercontent.com/prusa3d/Arduino_Boards/master/IDE_Board_Manager/package_prusa3d_index.json"
  349. BOARD_FILENAME="prusa3dboards"
  350. #BOARD_FILE_URL="https://raw.githubusercontent.com/3d-gussner/Arduino_Boards/master/IDE_Board_Manager/prusa3dboards-1.0.3.tar.bz2"
  351. BOARD_FILE_URL="https://raw.githubusercontent.com/prusa3d/Arduino_Boards/master/IDE_Board_Manager/prusa3dboards-1.0.3.tar.bz2"
  352. #PF_BUILD_FILE_URL="https://github.com/3d-gussner/PF-build-env-1/releases/download/$BUILD_ENV-WinLin/PF-build-env-WinLin-$BUILD_ENV.zip"
  353. PF_BUILD_FILE_URL="https://github.com/prusa3d/PF-build-env/releases/download/$BUILD_ENV-WinLin/PF-build-env-WinLin-$BUILD_ENV.zip"
  354. LIB="PrusaLibrary"
  355. SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
  356. # List few useful data
  357. echo
  358. echo "Script path :" $SCRIPT_PATH
  359. echo "OS :" $OS
  360. echo "OS type :" $TARGET_OS
  361. echo ""
  362. echo "Arduino IDE :" $ARDUINO_ENV
  363. echo "Build env :" $BUILD_ENV
  364. echo "Board :" $BOARD
  365. if [ ! -z "$BOARD_FLASH" ] ; then
  366. echo "Board flash :" $BOARD_FLASH
  367. fi
  368. if [ ! -z "$BOARD_MEM" ] ; then
  369. echo "Board mem :" $BOARD_MEM
  370. fi
  371. echo "Package name:" $BOARD_PACKAGE_NAME
  372. echo "Board v. :" $BOARD_VERSION
  373. echo "Specific Lib:" $LIB
  374. echo ""
  375. #### Start prepare building environment
  376. #Check if build exists and creates it if not
  377. if [ ! -d "../PF-build-dl" ]; then
  378. mkdir ../PF-build-dl || exit 9
  379. fi
  380. cd ../PF-build-dl || exit 10
  381. BUILD_ENV_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
  382. # Check if PF-build-env-<version> exists and downloads + creates it if not
  383. # The build environment is based on the supported Arduino IDE portable version with some changes
  384. if [ ! -d "../PF-build-env-$BUILD_ENV" ]; then
  385. echo "$(tput setaf 6)PF-build-env-$BUILD_ENV is missing ... creating it now for you$(tput sgr 0)"
  386. mkdir ../PF-build-env-$BUILD_ENV
  387. sleep 5
  388. fi
  389. # Download and extract supported Arduino IDE depending on OS
  390. # Windows
  391. if [ $TARGET_OS == "windows" ]; then
  392. if [ ! -f "arduino-$ARDUINO_ENV-windows.zip" ]; then
  393. echo "$(tput setaf 6)Downloading Windows 32/64-bit Arduino IDE portable...$(tput setaf 2)"
  394. sleep 2
  395. wget https://downloads.arduino.cc/arduino-$ARDUINO_ENV-windows.zip || exit 11
  396. echo "$(tput sgr 0)"
  397. fi
  398. if [[ ! -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor" && ! -e "../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]]; then
  399. echo "$(tput setaf 6)Unzipping Windows 32/64-bit Arduino IDE portable...$(tput setaf 2)"
  400. sleep 2
  401. unzip arduino-$ARDUINO_ENV-windows.zip -d ../PF-build-env-$BUILD_ENV || exit 11
  402. mv ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor
  403. echo "# arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt
  404. echo "$(tput sgr0)"
  405. fi
  406. fi
  407. # Linux
  408. if [ $TARGET_OS == "linux" ]; then
  409. # 32 or 64 bit version
  410. if [ ! -f "arduino-$ARDUINO_ENV-linux$Processor.tar.xz" ]; then
  411. echo "$(tput setaf 6)Downloading Linux $Processor Arduino IDE portable...$(tput setaf 2)"
  412. sleep 2
  413. wget --no-check-certificate https://downloads.arduino.cc/arduino-$ARDUINO_ENV-linux$Processor.tar.xz || exit 11
  414. echo "$(tput sgr 0)"
  415. fi
  416. if [[ ! -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor" && ! -e "../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]]; then
  417. echo "$(tput setaf 6)Unzipping Linux $Processor Arduino IDE portable...$(tput setaf 2)"
  418. sleep 2
  419. tar -xvf arduino-$ARDUINO_ENV-linux$Processor.tar.xz -C ../PF-build-env-$BUILD_ENV/ || exit 11
  420. mv ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor
  421. echo "# arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt
  422. echo "$(tput sgr0)"
  423. fi
  424. fi
  425. # Make Arduino IDE portable
  426. if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/ ]; then
  427. mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/
  428. fi
  429. if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/ ]; then
  430. mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable
  431. fi
  432. if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/output/ ]; then
  433. mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/output
  434. fi
  435. if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/ ]; then
  436. mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages
  437. fi
  438. if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/sketchbook/ ]; then
  439. mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/sketchbook
  440. fi
  441. if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/sketchbook/libraries/ ]; then
  442. mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/sketchbook/libraries
  443. fi
  444. if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/staging/ ]; then
  445. mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/staging
  446. fi
  447. # Change Arduino IDE preferences
  448. if [ ! -e ../PF-build-env-$BUILD_ENV/Preferences-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt ]; then
  449. echo "$(tput setaf 6)Setting $ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor Arduino IDE preferences for portable GUI usage...$(tput setaf 2)"
  450. sleep 2
  451. echo "update.check"
  452. sed -i 's/update.check = true/update.check = false/g' ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt
  453. echo "board"
  454. sed -i "s/board = uno/board = $BOARD/g" ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt
  455. echo "editor.linenumbers"
  456. sed -i 's/editor.linenumbers = false/editor.linenumbers = true/g' ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt
  457. echo "boardsmanager.additional.urls"
  458. echo "boardsmanager.additional.urls=$BOARD_URL" >>../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt
  459. echo "build.verbose=true" >>../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt
  460. echo "compiler.cache_core=false" >>../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt
  461. echo "compiler.warning_level=all" >>../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt
  462. echo "# Preferences-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/Preferences-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt
  463. echo "$(tput sgr0)"
  464. fi
  465. # Download and extract Prusa Firmware related parts
  466. # Download and extract PrusaResearchRambo board
  467. if [ ! -f "$BOARD_FILENAME-$BOARD_VERSION.tar.bz2" ]; then
  468. echo "$(tput setaf 6)Downloading Prusa Research AVR MK3 RAMBo EINSy build environment...$(tput setaf 2)"
  469. sleep 2
  470. wget $BOARD_FILE_URL || exit 9
  471. fi
  472. if [[ ! -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr/$BOARD_VERSION" || ! -e "../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]]; then
  473. echo "$(tput setaf 6)Unzipping $BOARD_PACKAGE_NAME Arduino IDE portable...$(tput setaf 2)"
  474. sleep 2
  475. tar -xvf $BOARD_FILENAME-$BOARD_VERSION.tar.bz2 -C ../PF-build-env-$BUILD_ENV/ || exit 10
  476. if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME ]; then
  477. mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME
  478. fi
  479. if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME ]; then
  480. mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME
  481. fi
  482. if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware ]; then
  483. mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware
  484. fi
  485. if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr ]; then
  486. mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr
  487. fi
  488. mv ../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr/$BOARD_VERSION
  489. echo "# $BOARD_FILENAME-$BOARD_VERSION" >> ../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt
  490. echo "$(tput sgr 0)"
  491. fi
  492. # Download and extract Prusa Firmware specific library files
  493. if [ ! -f "PF-build-env-WinLin-$BUILD_ENV.zip" ]; then
  494. echo "$(tput setaf 6)Downloading Prusa Firmware build environment...$(tput setaf 2)"
  495. sleep 2
  496. wget $PF_BUILD_FILE_URL || exit 12
  497. echo "$(tput sgr 0)"
  498. fi
  499. if [ ! -e "../PF-build-env-$BUILD_ENV/PF-build-env-$BUILD_ENV-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]; then
  500. echo "$(tput setaf 6)Unzipping Prusa Firmware build environment...$(tput setaf 2)"
  501. sleep 2
  502. unzip -o PF-build-env-WinLin-$BUILD_ENV.zip -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor || exit 12
  503. echo "# PF-build-env-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor-$BUILD_ENV" >> ../PF-build-env-$BUILD_ENV/PF-build-env-$BUILD_ENV-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt
  504. echo "$(tput sgr0)"
  505. fi
  506. # Check if User updated Arduino IDE 1.8.5 boardsmanager and tools
  507. if [ -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/arduino/tools" ]; then
  508. echo "$(tput setaf 6)Arduino IDE boards / tools have been manually updated...$"
  509. echo "Please don't update the 'Arduino AVR boards' as this will prevent running this script (tput setaf 2)"
  510. sleep 2
  511. fi
  512. if [ -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2" ]; then
  513. echo "$(tput setaf 6)PrusaReasearch compatible tools have been manually updated...$(tput setaf 2)"
  514. sleep 2
  515. echo "$(tput setaf 6)Copying Prusa Firmware build environment to manually updated boards / tools...$(tput setaf 2)"
  516. sleep 2
  517. cp -f ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/hardware/tools/avr/avr/lib/ldscripts/avr6.xn ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/lib/ldscripts/avr6.xn
  518. echo "# PF-build-env-portable-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor-$BUILD_ENV" >> ../PF-build-env-$BUILD_ENV/PF-build-env-portable-$BUILD_ENV-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt
  519. echo "$(tput sgr0)"
  520. fi
  521. if [ -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2" ]; then
  522. echo "$(tput setaf 1)Arduino IDE tools have been updated manually to a non supported version!!!"
  523. echo "Delete ../PF-build-env-$BUILD_ENV and start the script again"
  524. echo "Script will not continue until this have been fixed $(tput setaf 2)"
  525. sleep 2
  526. echo "$(tput sgr0)"
  527. exit 13
  528. fi
  529. #### End prepare building
  530. #### Start
  531. cd $SCRIPT_PATH
  532. # Check if git is available
  533. if type git > /dev/null; then
  534. git_available="1"
  535. fi
  536. #
  537. # '-v' argument defines which variant of the Prusa Firmware will be compiled
  538. if [ -z "$variant_flag" ] ; then
  539. # Select which variant of the Prusa Firmware will be compiled, like
  540. PS3="Select a variant: "
  541. while IFS= read -r -d $'\0' f; do
  542. options[i++]="$f"
  543. done < <(find Firmware/variants/ -maxdepth 1 -type f -name "*.h" -print0 )
  544. select opt in "${options[@]}" "All" "Quit"; do
  545. case $opt in
  546. *.h)
  547. VARIANT=$(basename "$opt" ".h")
  548. VARIANTS[i++]="$opt"
  549. break
  550. ;;
  551. "All")
  552. VARIANT="All"
  553. VARIANTS=${options[*]}
  554. break
  555. ;;
  556. "Quit")
  557. echo "You chose to stop"
  558. exit 20
  559. ;;
  560. *)
  561. echo "$(tput setaf 1)This is not a valid variant$(tput sgr0)"
  562. ;;
  563. esac
  564. done
  565. else
  566. if [ -f "$SCRIPT_PATH/Firmware/variants/$variant_flag" ] ; then
  567. VARIANTS=$variant_flag
  568. elif [ "$variant_flag" == "All" ] ; then
  569. while IFS= read -r -d $'\0' f; do
  570. options[i++]="$f"
  571. done < <(find Firmware/variants/ -maxdepth 1 -type f -name "*.h" -print0 )
  572. VARIANT="All"
  573. VARIANTS=${options[*]}
  574. else
  575. echo "$(tput setaf 1)Argument $variant_flag could not be found in Firmware/variants please choose a valid one.$(tput sgr0)"
  576. echo "Only $(tput setaf 2)'All'$(tput sgr0) and file names below are allowed as variant '-v' argument.$(tput setaf 2)"
  577. ls -1 $SCRIPT_PATH/Firmware/variants/*.h | xargs -n1 basename
  578. echo "$(tput sgr0)"
  579. exit 21
  580. fi
  581. fi
  582. #'-l' argument defines if it is an English only version. Known values EN_ONLY / ALL
  583. #Check default language mode
  584. MULTI_LANGUAGE_CHECK=$(grep --max-count=1 "^#define LANG_MODE *" $SCRIPT_PATH/Firmware/config.h|sed -e's/ */ /g'|cut -d ' ' -f3)
  585. if [ -z "$language_flag" ] ; then
  586. PS3="Select a language: "
  587. echo
  588. echo "Which lang-build do you want?"
  589. select yn in "Multi languages" "English only"; do
  590. case $yn in
  591. "Multi languages")
  592. LANGUAGES="ALL"
  593. break
  594. ;;
  595. "English only")
  596. LANGUAGES="EN_ONLY"
  597. break
  598. ;;
  599. *)
  600. echo "$(tput setaf 1)This is not a valid language$(tput sgr0)"
  601. ;;
  602. esac
  603. done
  604. else
  605. if [[ "$language_flag" == "ALL" || "$language_flag" == "EN_ONLY" ]] ; then
  606. LANGUAGES=$language_flag
  607. else
  608. echo "$(tput setaf 1)Language argument is wrong!$(tput sgr0)"
  609. echo "Only $(tput setaf 2)'ALL'$(tput sgr0) or $(tput setaf 2)'EN_ONLY'$(tput sgr0) are allowed as language '-l' argument!"
  610. exit 22
  611. fi
  612. fi
  613. #Check if DEV_STATUS is selected via argument '-d'
  614. if [ ! -z "$devel_flag" ] ; then
  615. if [[ "$devel_flag" == "GOLD" || "$devel_flag" == "RC" || "$devel_flag" == "BETA" || "$devel_flag" == "ALPHA" || "$devel_flag" == "DEVEL" || "$devel_flag" == "DEBUG" || "$devel_flag" == "UNKNOWN" ]] ; then
  616. DEV_STATUS_SELECTED=$devel_flag
  617. else
  618. echo "$(tput setaf 1)Development argument is wrong!$(tput sgr0)"
  619. echo "Only $(tput setaf 2)'GOLD', 'RC', 'BETA', 'ALPHA', 'DEVEL', 'DEBUG' or 'UNKNOWN' $(tput sgr0) are allowed as devel '-d' argument!$(tput sgr0)"
  620. exit 23
  621. fi
  622. fi
  623. #Check if Build is selected via argument '-b'
  624. if [ ! -z "$build_flag" ] ; then
  625. if [[ "$build_flag" == "Auto" && "$git_available" == "1" ]] ; then
  626. echo "Build changed to $build_flag"
  627. BUILD=$(git rev-list --count HEAD)
  628. elif [[ $build_flag =~ ^[0-9]+$ ]] ; then
  629. BUILD=$build_flag
  630. else
  631. echo "$(tput setaf 1)Build number argument is wrong!$(tput sgr0)"
  632. echo "Only $(tput setaf 2)'Auto' (git needed) or numbers $(tput sgr0) are allowed as build '-b' argument!$(tput sgr0)"
  633. exit 24
  634. fi
  635. echo "New Build number is: $BUILD"
  636. fi
  637. # check if script has been started with arguments
  638. if [[ "$#" -eq "0" || "$output_flag" == 1 ]] ; then
  639. OUTPUT=1
  640. else
  641. OUTPUT=0
  642. fi
  643. #echo "Output is:" $OUTPUT
  644. #Check git branch has changed
  645. if [ ! -z "git_available" ]; then
  646. BRANCH=""
  647. CLEAN_PF_FW_BUILD=0
  648. else
  649. BRANCH=$(git branch --show-current)
  650. echo "Current branch is:" $BRANCH
  651. if [ ! -f "$SCRIPT_PATH/../PF-build.branch" ]; then
  652. echo "$BRANCH" >| $SCRIPT_PATH/../PF-build.branch
  653. echo "created PF-build.branch file"
  654. else
  655. PRE_BRANCH=$(cat "$SCRIPT_PATH/../PF-build.branch")
  656. echo "Previous branch was:" $PRE_BRANCH
  657. if [ ! "$BRANCH" == "$PRE_BRANCH" ] ; then
  658. CLEAN_PF_FW_BUILD=1
  659. echo "$BRANCH" >| $SCRIPT_PATH/../PF-build.branch
  660. fi
  661. fi
  662. fi
  663. #Set BUILD_ENV_PATH
  664. cd ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor || exit 25
  665. BUILD_ENV_PATH="$( pwd -P )"
  666. cd ../..
  667. #Checkif BUILD_PATH exists and if not creates it
  668. if [ ! -d "Prusa-Firmware-build" ]; then
  669. mkdir Prusa-Firmware-build || exit 26
  670. fi
  671. #Set the BUILD_PATH for Arduino IDE
  672. cd Prusa-Firmware-build || exit 27
  673. BUILD_PATH="$( pwd -P )"
  674. #Check git branch has changed
  675. if [ "$CLEAN_PF_FW_BUILD" == "1" ]; then
  676. read -t 10 -p "Branch changed, cleaning Prusa-Firmware-build folder"
  677. rm -r *
  678. else
  679. echo "Nothing to clean up"
  680. fi
  681. for v in ${VARIANTS[*]}
  682. do
  683. VARIANT=$(basename "$v" ".h")
  684. # Find firmware version in Configuration.h file and use it to generate the hex filename
  685. FW=$(grep --max-count=1 "\bFW_VERSION\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d '"' -f2|sed 's/\.//g')
  686. if [ -z "$BUILD" ] ; then
  687. # Find build version in Configuration.h file and use it to generate the hex filename
  688. BUILD=$(grep --max-count=1 "\bFW_COMMIT_NR\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d ' ' -f3)
  689. else
  690. # Find and replace build version in Configuration.h file
  691. BUILD_ORG=$(grep --max-count=1 "\bFW_COMMIT_NR\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d ' ' -f3)
  692. echo "Original build number: $BUILD_ORG"
  693. sed -i -- "s/^#define FW_COMMIT_NR.*/#define FW_COMMIT_NR $BUILD/g" $SCRIPT_PATH/Firmware/Configuration.h
  694. fi
  695. # Check if the motherboard is an EINSY and if so only one hex file will generated
  696. MOTHERBOARD=$(grep --max-count=1 "\bMOTHERBOARD\b" $SCRIPT_PATH/Firmware/variants/$VARIANT.h | sed -e's/ */ /g' |cut -d ' ' -f3)
  697. # Check development status
  698. DEV_CHECK=$(grep --max-count=1 "\bFW_VERSION\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d '"' -f2|sed 's/\.//g'|cut -d '-' -f2)
  699. if [ -z "$DEV_STATUS_SELECTED" ] ; then
  700. if [[ "$DEV_CHECK" == *"RC"* ]] ; then
  701. DEV_STATUS="RC"
  702. elif [[ "$DEV_CHECK" == "ALPHA" ]]; then
  703. DEV_STATUS="ALPHA"
  704. elif [[ "$DEV_CHECK" == "BETA" ]]; then
  705. DEV_STATUS="BETA"
  706. elif [[ "$DEV_CHECK" == "DEVEL" ]]; then
  707. DEV_STATUS="DEVEL"
  708. elif [[ "$DEV_CHECK" == "DEBUG" ]]; then
  709. DEV_STATUS="DEBUG"
  710. else
  711. DEV_STATUS="UNKNOWN"
  712. echo
  713. echo "$(tput setaf 5)DEV_STATUS is UNKNOWN. Do you wish to set DEV_STATUS to GOLD?$(tput sgr0)"
  714. PS3="Select YES only if source code is tested and trusted: "
  715. select yn in "Yes" "No"; do
  716. case $yn in
  717. Yes)
  718. DEV_STATUS="GOLD"
  719. DEV_STATUS_SELECTED="GOLD"
  720. break
  721. ;;
  722. No)
  723. DEV_STATUS="UNKNOWN"
  724. DEV_STATUS_SELECTED="UNKNOWN"
  725. break
  726. ;;
  727. *)
  728. echo "$(tput setaf 1)This is not a valid DEV_STATUS$(tput sgr0)"
  729. ;;
  730. esac
  731. done
  732. fi
  733. else
  734. DEV_STATUS=$DEV_STATUS_SELECTED
  735. fi
  736. #Prepare hex files folders
  737. if [ ! -d "$SCRIPT_PATH/../PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD" ]; then
  738. mkdir -p $SCRIPT_PATH/../PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD || exit 28
  739. fi
  740. OUTPUT_FOLDER="PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD"
  741. if [ "$BOARD" != "prusa_einsy_rambo" ]; then
  742. if [ ! -d "$SCRIPT_PATH/../PF-build-hex/FW$FW-Build$BUILD/$BOARD" ]; then
  743. mkdir -p $SCRIPT_PATH/../PF-build-hex/FW$FW-Build$BUILD/$BOARD || exit 28
  744. fi
  745. OUTPUT_FOLDER="PF-build-hex/FW$FW-Build$BUILD/$BOARD"
  746. fi
  747. #Check if exactly the same hexfile already exists
  748. if [[ -f "$SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.hex" && "$LANGUAGES" == "ALL" ]]; then
  749. echo ""
  750. ls -1 $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.hex | xargs -n1 basename
  751. echo "$(tput setaf 6)This hex file to be compiled already exists! To cancel this process press CRTL+C and rename existing hex file.$(tput sgr 0)"
  752. if [ $OUTPUT == "1" ] ; then
  753. read -t 10 -p "Press Enter to continue..."
  754. fi
  755. elif [[ -f "$SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-EN_ONLY.hex" && "$LANGUAGES" == "EN_ONLY" ]]; then
  756. echo ""
  757. ls -1 $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-EN_ONLY.hex | xargs -n1 basename
  758. echo "$(tput setaf 6)This hex file to be compiled already exists! To cancel this process press CRTL+C and rename existing hex file.$(tput sgr 0)"
  759. if [ $OUTPUT == "1" ] ; then
  760. read -t 10 -p "Press Enter to continue..."
  761. fi
  762. fi
  763. if [[ -f "$SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.zip" && "$LANGUAGES" == "ALL" ]]; then
  764. echo ""
  765. ls -1 $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.zip | xargs -n1 basename
  766. echo "$(tput setaf 6)This zip file to be compiled already exists! To cancel this process press CRTL+C and rename existing hex file.$(tput sgr 0)"
  767. if [ $OUTPUT == "1" ] ; then
  768. read -t 10 -p "Press Enter to continue..."
  769. fi
  770. fi
  771. #List some useful data
  772. echo "$(tput setaf 2)$(tput setab 7) "
  773. echo "Variant :" $VARIANT
  774. echo "Firmware :" $FW
  775. echo "Build # :" $BUILD
  776. echo "Dev Check :" $DEV_CHECK
  777. echo "DEV Status :" $DEV_STATUS
  778. echo "Motherboard:" $MOTHERBOARD
  779. echo "Board flash:" $BOARD_FLASH
  780. echo "Board mem :" $BOARD_MEM
  781. echo "Languages :" $LANGUAGES
  782. echo "Hex-file Folder:" $OUTPUT_FOLDER
  783. echo "$(tput sgr0)"
  784. #Prepare Firmware to be compiled by copying variant as Configuration_prusa.h
  785. if [ ! -f "$SCRIPT_PATH/Firmware/Configuration_prusa.h" ]; then
  786. cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 29
  787. else
  788. echo "$(tput setaf 6)Configuration_prusa.h already exist it will be overwritten in 10 seconds by the chosen variant.$(tput sgr 0)"
  789. if [ $OUTPUT == "1" ] ; then
  790. read -t 10 -p "Press Enter to continue..."
  791. fi
  792. cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 29
  793. fi
  794. #Prepare Configuration.h to use the correct FW_DEV_VERSION to prevent LCD messages when connecting with OctoPrint
  795. sed -i -- "s/#define FW_DEV_VERSION FW_VERSION_UNKNOWN/#define FW_DEV_VERSION FW_VERSION_$DEV_STATUS/g" $SCRIPT_PATH/Firmware/Configuration.h
  796. # set FW_REPOSITORY
  797. sed -i -- 's/#define FW_REPOSITORY "Unknown"/#define FW_REPOSITORY "Prusa3d"/g' $SCRIPT_PATH/Firmware/Configuration.h
  798. #Prepare English only or multi-language version to be build
  799. if [ $LANGUAGES == "EN_ONLY" ]; then
  800. echo " "
  801. echo "English only language firmware will be built"
  802. sed -i -- "s/^#define LANG_MODE *1/#define LANG_MODE 0/g" $SCRIPT_PATH/Firmware/config.h
  803. echo " "
  804. else
  805. echo " "
  806. echo "Multi-language firmware will be built"
  807. sed -i -- "s/^#define LANG_MODE *0/#define LANG_MODE 1/g" $SCRIPT_PATH/Firmware/config.h
  808. echo " "
  809. fi
  810. # Prepare Board mem and flash modifications
  811. ## Check board mem size
  812. CURRENT_BOARD_MEM=$(grep "#define RAMEND" $BUILD_ENV_PATH/hardware/tools/avr/avr/include/avr/iom2560.h | sed -e's/.* //g'|cut -d ' ' -f3|tr -d $'\n')
  813. if [ $CURRENT_BOARD_MEM != "0x21FF" ] ; then
  814. echo "Board mem has been already modified or not reset"
  815. echo "Current:" $CURRENT_BOARD_MEM
  816. PS3="Select Yes if you want to reset it."
  817. select yn in "Yes" "No"; do
  818. case $yn in
  819. Yes)
  820. echo "Resetting board mem size"
  821. sed -i -- "s/^#define RAMEND .*$/#define RAMEND 0x21FF/g" $BUILD_ENV_PATH/hardware/tools/avr/avr/include/avr/iom2560.h
  822. break
  823. ;;
  824. *)
  825. echo "Continuing with modified mem size"
  826. break
  827. ;;
  828. esac
  829. done
  830. fi
  831. ## Modify board mem size
  832. if [[ ! -z $BOARD_MEM && "$BOARD_MEM" != "0x21FF" ]] ; then
  833. echo "Modifying board memory size (hex):"
  834. echo "Old:" $CURRENT_BOARD_MEM
  835. echo "New:" $BOARD_MEM
  836. read -t 5 -p "To cancel press CRTL+C"
  837. sed -i -- "s/^#define RAMEND 0x21FF/#define RAMEND ${BOARD_MEM}/g" $BUILD_ENV_PATH/hardware/tools/avr/avr/include/avr/iom2560.h
  838. fi
  839. ## Check board flash size
  840. CURRENT_BOARD_FLASH=$(grep "#define FLASHEND" $BUILD_ENV_PATH/hardware/tools/avr/avr/include/avr/iom2560.h | sed -e's/.* //g'|cut -d ' ' -f3|tr -d $'\n')
  841. CURRENT_BOARD_maximum_size=$(grep "prusa_einsy_rambo.upload.maximum_size" $BUILD_ENV_PATH/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr/$BOARD_VERSION/boards.txt |cut -d '=' -f2|tr -d $'\n')
  842. if [[ $CURRENT_BOARD_FLASH != "0x3FFFF" || $CURRENT_BOARD_maximum_size != "253952" ]] ; then
  843. echo "Board flash has been already modified or not reset"
  844. echo "Current flash size:" $CURRENT_BOARD_FLASH
  845. echo "Current max. size:" $CURRENT_BOARD_maximum_size
  846. PS3="Select Yes if you want to reset it."
  847. select yn in "Yes" "No"; do
  848. case $yn in
  849. Yes)
  850. echo "Resetting board flash size"
  851. sed -i -- "s/^#define FLASHEND .*$/#define FLASHEND 0x3FFFF/g" $BUILD_ENV_PATH/hardware/tools/avr/avr/include/avr/iom2560.h
  852. sed -i -- "s/^prusa_einsy_rambo.upload.maximum_size.*/prusa_einsy_rambo.upload.maximum_size=253952/g" $BUILD_ENV_PATH/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr/$BOARD_VERSION/boards.txt
  853. break
  854. ;;
  855. *)
  856. echo "Continuing with modified flash size"
  857. break
  858. ;;
  859. esac
  860. done
  861. fi
  862. ## Modify boad flash size
  863. if [[ ! -z $BOARD_FLASH && "$BOARD_FLASH" != "0x3FFFF" ]] ; then
  864. echo "Modifying board flash size (hex):"
  865. echo "Old flash size:" $CURRENT_BOARD_FLASH
  866. echo "New flash size:" $BOARD_FLASH
  867. echo "Old max. size:" $CURRENT_BOARD_maximum_size
  868. echo "New max. size:" $BOARD_maximum_size
  869. read -t 5 -p "To cancel press CRTL+C"
  870. sed -i -- "s/^#define FLASHEND .*/#define FLASHEND ${BOARD_FLASH}/g" $BUILD_ENV_PATH/hardware/tools/avr/avr/include/avr/iom2560.h
  871. sed -i -- "s/^prusa_einsy_rambo.upload.maximum_size.*/prusa_einsy_rambo.upload.maximum_size=${BOARD_maximum_size}/g" $BUILD_ENV_PATH/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr/$BOARD_VERSION/boards.txt
  872. fi
  873. #Check if compiler flags are set to Prusa specific needs for the rambo board.
  874. # if [ $TARGET_OS == "windows" ]; then
  875. # RAMBO_PLATFORM_FILE="PrusaResearchRambo/avr/platform.txt"
  876. # fi
  877. #### End of Prepare building
  878. #### Start building
  879. export ARDUINO=$BUILD_ENV_PATH
  880. #echo $BUILD_ENV_PATH
  881. #export BUILDER=$ARDUINO/arduino-builder
  882. echo
  883. #read -t 5 -p "Press Enter..."
  884. echo
  885. echo "Start to build Prusa Firmware ..."
  886. echo "Using variant $VARIANT$(tput setaf 3)"
  887. if [ $OUTPUT == "1" ] ; then
  888. sleep 2
  889. fi
  890. #New fresh PF-Firmware-build
  891. if [ "$new_build_flag" == "1" ]; then
  892. rm -r -f $BUILD_PATH/* || exit 36
  893. fi
  894. $BUILD_ENV_PATH/arduino-builder -dump-prefs -debug-level 10 -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 30
  895. $BUILD_ENV_PATH/arduino-builder -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 30
  896. echo "$(tput sgr 0)"
  897. if [ $LANGUAGES == "ALL" ]; then
  898. echo "$(tput setaf 2)"
  899. echo "Building multi language firmware" $MULTI_LANGUAGE_CHECK
  900. echo "$(tput sgr 0)"
  901. if [ $OUTPUT == "1" ] ; then
  902. sleep 2
  903. fi
  904. cd $SCRIPT_PATH/lang
  905. echo "$(tput setaf 3)"
  906. ./config.sh || exit 31
  907. echo "$(tput sgr 0)"
  908. # Check if previous languages and firmware build exist and if so clean them up
  909. if [ -f "lang_en.tmp" ]; then
  910. echo ""
  911. echo "$(tput setaf 6)Previous lang build files already exist these will be cleaned up in 10 seconds.$(tput sgr 0)"
  912. if [ $OUTPUT == "1" ] ; then
  913. read -t 10 -p "Press Enter to continue..."
  914. fi
  915. echo "$(tput setaf 3)"
  916. ./lang-clean.sh
  917. echo "$(tput sgr 0)"
  918. fi
  919. if [ -f "progmem.out" ]; then
  920. echo ""
  921. echo "$(tput setaf 6)Previous firmware build files already exist these will be cleaned up in 10 seconds.$(tput sgr 0)"
  922. if [ $OUTPUT == "1" ] ; then
  923. read -t 10 -p "Press Enter to continue..."
  924. fi
  925. echo "$(tput setaf 3)"
  926. ./fw-clean.sh
  927. echo "$(tput sgr 0)"
  928. fi
  929. # build languages
  930. echo "$(tput setaf 3)"
  931. ./lang-build.sh || exit 32
  932. #Community language support
  933. ./lang-community.sh || exit 33
  934. # Combine compiled firmware with languages
  935. ./fw-build.sh || exit 34
  936. cp not_tran.txt not_tran_$VARIANT.txt
  937. cp not_used.txt not_used_$VARIANT.txt
  938. echo "$(tput sgr 0)"
  939. # Check if the motherboard is an EINSY and if so only one hex file will generated
  940. MOTHERBOARD=$(grep --max-count=1 "\bMOTHERBOARD\b" $SCRIPT_PATH/Firmware/variants/$VARIANT.h | sed -e's/ */ /g' |cut -d ' ' -f3)
  941. # If the motherboard is an EINSY just copy one hexfile
  942. if [ "$MOTHERBOARD" = "BOARD_EINSY_1_0a" ]; then
  943. echo "$(tput setaf 2)Copying multi language firmware for MK3/Einsy board to PF-build-hex folder$(tput sgr 0)"
  944. cp -f firmware.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.hex
  945. else
  946. echo "$(tput setaf 2)Zip multi language firmware for MK2.5/miniRAMbo board to PF-build-hex folder$(tput sgr 0)"
  947. cp -f firmware_cz.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-cz.hex
  948. cp -f firmware_de.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-de.hex
  949. cp -f firmware_es.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-es.hex
  950. cp -f firmware_fr.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-fr.hex
  951. cp -f firmware_it.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-it.hex
  952. cp -f firmware_pl.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-pl.hex
  953. cp -f firmware_nl.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-nl.hex
  954. if [ $TARGET_OS == "windows" ]; then
  955. zip a $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.zip $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-??.hex
  956. rm $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-??.hex
  957. elif [ $TARGET_OS == "linux" ]; then
  958. zip -m -j ../../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.zip ../../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-??.hex
  959. fi
  960. fi
  961. # Cleanup after build
  962. if [[ -z "$clean_flag" || "$clean_flag" == "0" ]]; then
  963. echo "$(tput setaf 3)"
  964. ./fw-clean.sh || exit 35
  965. ./lang-clean.sh || exit 36
  966. echo "$(tput sgr 0)"
  967. fi
  968. else
  969. echo "$(tput setaf 2)Copying English only firmware to PF-build-hex folder$(tput sgr 0)"
  970. cp -f $BUILD_PATH/Firmware.ino.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-EN_ONLY.hex || exit 37
  971. fi
  972. # Cleanup Firmware
  973. if [[ -z "$prusa_flag" || "$prusa_flag" == "0" ]]; then
  974. rm $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 38
  975. fi
  976. if find $SCRIPT_PATH/lang/ -name '*RAMBo10a*.txt' -printf 1 -quit | grep -q 1
  977. then
  978. rm $SCRIPT_PATH/lang/*RAMBo10a*.txt
  979. fi
  980. if find $SCRIPT_PATH/lang/ -name '*MK2-RAMBo13a*' -printf 1 -quit | grep -q 1
  981. then
  982. rm $SCRIPT_PATH/lang/*MK2-RAMBo13a*.txt
  983. fi
  984. if find $SCRIPT_PATH/lang/ -name 'not_tran.txt' -printf 1 -quit | grep -q 1
  985. then
  986. rm $SCRIPT_PATH/lang/not_tran.txt
  987. fi
  988. if find $SCRIPT_PATH/lang/ -name 'not_used.txt' -printf 1 -quit | grep -q 1
  989. then
  990. rm $SCRIPT_PATH/lang/not_used.txt
  991. fi
  992. #New fresh PF-Firmware-build
  993. if [ "$new_build_flag" == "1" ]; then
  994. rm -r -f $BUILD_PATH/* || exit 39
  995. fi
  996. # Restore files to previous state
  997. sed -i -- "s/^#define FW_DEV_VERSION FW_VERSION_$DEV_STATUS/#define FW_DEV_VERSION FW_VERSION_UNKNOWN/g" $SCRIPT_PATH/Firmware/Configuration.h
  998. sed -i -- 's/^#define FW_REPOSITORY "Prusa3d"/#define FW_REPOSITORY "Unknown"/g' $SCRIPT_PATH/Firmware/Configuration.h
  999. if [ ! -z "$BUILD_ORG" ] ; then
  1000. sed -i -- "s/^#define FW_COMMIT_NR.*/#define FW_COMMIT_NR $BUILD_ORG/g" $SCRIPT_PATH/Firmware/Configuration.h
  1001. fi
  1002. echo $MULTI_LANGUAGE_CHECK
  1003. #sed -i -- "s/^#define LANG_MODE * /#define LANG_MODE $MULTI_LANGUAGE_CHECK/g" $SCRIPT_PATH/Firmware/config.h
  1004. sed -i -- "s/^#define LANG_MODE *1/#define LANG_MODE ${MULTI_LANGUAGE_CHECK}/g" $SCRIPT_PATH/Firmware/config.h
  1005. sed -i -- "s/^#define LANG_MODE *0/#define LANG_MODE ${MULTI_LANGUAGE_CHECK}/g" $SCRIPT_PATH/Firmware/config.h
  1006. if [ $OUTPUT == "1" ] ; then
  1007. sleep 5
  1008. fi
  1009. done
  1010. # Switch to hex path and list build files
  1011. cd $SCRIPT_PATH
  1012. cd ..
  1013. echo "$(tput setaf 2) "
  1014. echo " "
  1015. echo "Build done, please use Slic3rPE > 1.41.0 to upload the firmware"
  1016. echo "more information how to flash firmware https://www.prusa3d.com/drivers/ $(tput sgr 0)"
  1017. #### End building