自动生成升级固件.bat 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. @echo off
  2. rem The process of generating DFU files
  3. set name="yingying"
  4. set BLE_DFU_ENANBLE_flag=0
  5. set BleNameHoldOn_ENANBLE_flag=0
  6. set BleNameHoldOn_ENANBLE_flag=0
  7. set RTT_DEBUG_EN_flag=0
  8. set USE_FIFO_FLAG=0
  9. chcp 65001
  10. echo=
  11. echo **********************生成DFU文件*****************
  12. echo=
  13. cd ..
  14. rem KEIL工具的安装目录
  15. set UV=C:\Keil_v5\UV4\UV4.exe
  16. rem 当前目录
  17. set Front_PRO_PATH=%cd%
  18. rem 工程目录
  19. set UV_PRO_PATH=%Front_PRO_PATH%\pca10040\s132\arm5_no_packs\ble_app_uart_c_pca10040_s132.uvprojx
  20. rem 工程编译的输出目录
  21. set BUILD_HEX_NAME=%Front_PRO_PATH%\pca10040\s132\arm5_no_packs\_build\nrf52832_xxaa.hex
  22. rem 工程使能DFU的文件名字
  23. set USR_CONFIG_PACH=%Front_PRO_PATH%\system\usr_config.h
  24. rem 存放dfu文件和设置的目录
  25. set DFU_CONFIG_FILE_NAME=%cd%\dfu_readme
  26. rem 生成DFU文件的名字
  27. set DFU_FILE_NAME=%DFU_CONFIG_FILE_NAME%\app_dfu_package.zip
  28. rem 清除之前的DFU文件和编译的HEX文件
  29. if exist %DFU_FILE_NAME% del %DFU_FILE_NAME%
  30. if exist %BUILD_HEX_NAME% del %BUILD_HEX_NAME%
  31. findstr /c:"BleNameHoldOn_ENANBLE 1" %USR_CONFIG_PACH%>nul
  32. if %errorlevel% equ 0 set /a BleNameHoldOn_ENANBLE_flag=1
  33. findstr /c:"BLE_DFU_ENANBLE 1" %USR_CONFIG_PACH%>nul
  34. if %errorlevel% equ 0 set /a BLE_DFU_ENANBLE_flag=1
  35. findstr /c:"JS_RTT_DEBUG_EN 1" %USR_CONFIG_PACH%>nul
  36. if %errorlevel% equ 0 set /a RTT_DEBUG_EN_flag=1
  37. findstr /c:"USEFIFO 1" %USR_CONFIG_PACH%>nul
  38. if %errorlevel% equ 0 set /a USE_FIFO_FLAG=1
  39. if %BLE_DFU_ENANBLE_flag% equ 1 (
  40. if %BleNameHoldOn_ENANBLE_flag% equ 0 (
  41. echo=
  42. echo 正在执行编译固件----------------
  43. echo=
  44. %UV% -j0 -b %UV_PRO_PATH% -l %cd%\build_log.txt
  45. if exist %BUILD_HEX_NAME% (
  46. nrfutil pkg generate --hw-version 52 --application-version 2 --application %BUILD_HEX_NAME% --sd-req 0xcb --key-file .\dfu_readme\private_cp.key %DFU_FILE_NAME%
  47. echo=
  48. echo 文件生成成功
  49. echo=
  50. echo ================固件信息============================
  51. echo | set /p="硬件版本 "
  52. findstr "\<HARDWARE_VERSION" %USR_CONFIG_PACH%
  53. echo | set /p="软件版本 "
  54. findstr "\<SOFTWARE_VERSION" %USR_CONFIG_PACH%
  55. if %RTT_DEBUG_EN_flag% equ 1 (
  56. echo RTT波形显示已经打开!!!!!!!!
  57. )
  58. if %USE_FIFO_FLAG% equ 1 (
  59. echo BLE发送,采用FIFO方式发送
  60. )
  61. echo | set /p="待机功耗时间间隔(ms) "
  62. findstr /c:"#define StandByPower_Interval" %USR_CONFIG_PACH%
  63. echo | set /p="心跳时间间隔(ms) "
  64. findstr /c:"#define HeartTime_Interval" %USR_CONFIG_PACH%
  65. echo | set /p="低功耗时间间隔(ms) "
  66. findstr /c:"#define LowPower_Interval" %USR_CONFIG_PACH%
  67. echo ===================================================
  68. echo=
  69. pause
  70. )
  71. )
  72. )
  73. echo !!!!!!!!!编译工程失败!!!!!!!!!!!!
  74. echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  75. if %BLE_DFU_ENANBLE_flag% equ 0 (
  76. echo 工程没有开启固件升级的功能,请确认
  77. )
  78. if %BleNameHoldOn_ENANBLE_flag% equ 1 (
  79. echo 工程已经开启蓝牙名字的固定功能,请确认
  80. )
  81. echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  82. echo=
  83. pause