自动生成升级固件(bootloader).bat 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 bootloader名字
  27. set BOOTLOADER_NAME=%DFU_CONFIG_FILE_NAME%\central_and_peripheral_bootloader.hex
  28. rem 生成DFU文件的名字
  29. set DFU_FILE_NAME=%DFU_CONFIG_FILE_NAME%\bootloader_dfu_package.zip
  30. rem 清除之前的DFU文件和编译的HEX文件
  31. if exist %DFU_FILE_NAME% del %DFU_FILE_NAME%
  32. if exist %BUILD_HEX_NAME% del %BUILD_HEX_NAME%
  33. findstr /c:"BleNameHoldOn_ENANBLE 1" %USR_CONFIG_PACH%>nul
  34. if %errorlevel% equ 0 set /a BleNameHoldOn_ENANBLE_flag=1
  35. findstr /c:"BLE_DFU_ENANBLE 1" %USR_CONFIG_PACH%>nul
  36. if %errorlevel% equ 0 set /a BLE_DFU_ENANBLE_flag=1
  37. findstr /c:"JS_RTT_DEBUG_EN 1" %USR_CONFIG_PACH%>nul
  38. if %errorlevel% equ 0 set /a RTT_DEBUG_EN_flag=1
  39. findstr /c:"USEFIFO 1" %USR_CONFIG_PACH%>nul
  40. if %errorlevel% equ 0 set /a USE_FIFO_FLAG=1
  41. if %BLE_DFU_ENANBLE_flag% equ 1 (
  42. if %BleNameHoldOn_ENANBLE_flag% equ 0 (
  43. echo=
  44. echo 正在执行编译固件----------------
  45. echo=
  46. %UV% -j0 -b %UV_PRO_PATH% -l %cd%\build_log.txt
  47. if exist %BUILD_HEX_NAME% (
  48. nrfutil pkg generate --hw-version 52 --bootloader-version 0x03 --bootloader %BOOTLOADER_NAME% --sd-req 0xcb --key-file .\dfu_readme\private_cp.key %DFU_FILE_NAME%
  49. echo=
  50. echo 文件生成成功
  51. echo=
  52. echo ================固件信息============================
  53. echo | set /p="硬件版本 "
  54. findstr "\<HARDWARE_VERSION" %USR_CONFIG_PACH%
  55. echo | set /p="软件版本 "
  56. findstr "\<SOFTWARE_VERSION" %USR_CONFIG_PACH%
  57. if %RTT_DEBUG_EN_flag% equ 1 (
  58. echo RTT波形显示已经打开!!!!!!!!
  59. )
  60. if %USE_FIFO_FLAG% equ 1 (
  61. echo BLE发送,采用FIFO方式发送
  62. )
  63. echo | set /p="待机功耗时间间隔(ms) "
  64. findstr /c:"#define StandByPower_Interval" %USR_CONFIG_PACH%
  65. echo | set /p="心跳时间间隔(ms) "
  66. findstr /c:"#define HeartTime_Interval" %USR_CONFIG_PACH%
  67. echo | set /p="低功耗时间间隔(ms) "
  68. findstr /c:"#define LowPower_Interval" %USR_CONFIG_PACH%
  69. echo ===================================================
  70. echo=
  71. pause
  72. )
  73. )
  74. )
  75. echo !!!!!!!!!编译工程失败!!!!!!!!!!!!
  76. echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  77. if %BLE_DFU_ENANBLE_flag% equ 0 (
  78. echo 工程没有开启固件升级的功能,请确认
  79. )
  80. if %BleNameHoldOn_ENANBLE_flag% equ 1 (
  81. echo 工程已经开启蓝牙名字的固定功能,请确认
  82. )
  83. echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  84. echo=
  85. pause