cli-install.bat 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. @echo off
  2. setlocal EnableDelayedExpansion
  3. set CLI_TEMP=%TEMP%\arduino-cli
  4. set CONFIG_FILE=--config-file .\arduino-cli.yaml
  5. set DEFAULT_BOARD_FQBN=esp32:esp32:esp32cam
  6. set SELECTED_BOARD=%DEFAULT_BOARD_FQBN%
  7. set CLI_FOUND_FOLLOW_UP=0
  8. set COMPILE_FLAG=..\compile.flag
  9. echo.
  10. :checkCLI
  11. if not exist "arduino-cli.exe" (
  12. echo The "arduino-cli.exe" file cannot be found. Please download it manually from the following link:
  13. echo https://arduino.github.io/arduino-cli/latest/installation/#download
  14. set /a CLI_FOUND_FOLLOW_UP+=1
  15. if %CLI_FOUND_FOLLOW_UP% geq 2 (
  16. echo If you're still having issues, feel free to open a ticket at the following link:
  17. echo https://github.com/CodyTolene/Flipper-Zero-Camera-Suite/issues
  18. )
  19. pause
  20. goto :checkCLI
  21. )
  22. if %CLI_FOUND_FOLLOW_UP% geq 1 (
  23. echo File "arduino-cli.exe" found. Continuing...
  24. )
  25. echo Checking configs...
  26. arduino-cli %CONFIG_FILE% config set directories.data %CLI_TEMP%\data
  27. arduino-cli %CONFIG_FILE% config set directories.downloads %CLI_TEMP%\downloads
  28. arduino-cli %CONFIG_FILE% config set directories.user %CLI_TEMP%\user %*
  29. echo Fetching assets...
  30. if not exist "%CLI_TEMP%" (
  31. arduino-cli %CONFIG_FILE% core update-index
  32. arduino-cli %CONFIG_FILE% core install esp32:esp32
  33. ) else (
  34. echo Assets already installed. Skipping...
  35. )
  36. echo Ready for installation...
  37. set /p USE_DEFAULT_BOARD="Install to default AI-Thinker ESP32-CAM board with FQBN '%DEFAULT_BOARD_FQBN%'? (Y/N): "
  38. if /i "%USE_DEFAULT_BOARD%"=="N" (
  39. set /p SHOW_BOARDS="Display all possible ESP32 board names and FQBN's? (Y/N): "
  40. if /i "!SHOW_BOARDS!"=="Y" (
  41. echo.
  42. arduino-cli board listall
  43. )
  44. set /p SELECTED_BOARD="Please enter your board FQBN. For example '%DEFAULT_BOARD_FQBN%' with no quotes: "
  45. )
  46. if exist "%COMPILE_FLAG%" (
  47. set /p RECOMPILE="A previous firmware build was found, would you like to use it? (Y/N): "
  48. if /i "!RECOMPILE!"=="N" (
  49. goto :compileFirmware
  50. )
  51. ) else (
  52. :compileFirmware
  53. echo Compiling firmware, this will take a moment...
  54. arduino-cli %CONFIG_FILE% compile --fqbn !SELECTED_BOARD! ..\firmware.ino
  55. if %ERRORLEVEL% EQU 0 (
  56. echo Compile complete. Ready to upload.
  57. type nul > %COMPILE_FLAG%
  58. ) else (
  59. echo Compilation failed. Please correct the errors and try again.
  60. exit /b
  61. )
  62. )
  63. echo.
  64. arduino-cli board list
  65. echo Please find your Flipper Zero USB port from the list above (may show as unknown).
  66. set /p PORT_NUMBER="Enter it here. For example 'COM3' capitalized with no quotes: "
  67. echo.
  68. echo Your ESP32-CAM is ready to be flashed. Please follow the instructions below.
  69. :uploadFirmware
  70. echo.
  71. echo 1. Make sure your ESP32-CAM module is unplugged from your Flipper Zero.
  72. echo 2. Make sure you've grounded your IO0 pin on your ESP32-CAM module to the correct GND pin.
  73. echo 3. Plug your ESP32-CAM module with the reset button pressed right after going to the next step.
  74. echo 4. When "Connecting..." is displayed unpress the reset button.
  75. echo 5. It is common for this to fail a few times, keep trying and double check your connections.
  76. echo.
  77. pause
  78. echo.
  79. echo Preparing firmware upload...
  80. arduino-cli %CONFIG_FILE% upload -p %PORT_NUMBER% --fqbn !SELECTED_BOARD! ..\firmware.ino
  81. if %ERRORLEVEL% NEQ 0 (
  82. echo.
  83. set /p UPLOAD_TRY_AGAIN="Upload failed, would you like to retry? (Y/N): "
  84. if /i "!UPLOAD_TRY_AGAIN!"=="Y" (
  85. goto :uploadFirmware
  86. )
  87. )
  88. echo.
  89. echo Fin. Happy programming friend.
  90. echo.
  91. pause
  92. exit /b