nrf 调用nrfjprog 工具 windows脚本jlink烧写

@echo off
set arg1=%1

:: # Check to make sure nrfjprog is installed before moving on
WHERE >nul 2>nul nrfjprog
IF %ERRORLEVEL% NEQ 0 (
ECHO "nrfjprog was not found in PATH, please install using windows installed as found on nordicsemi.com"
goto :end
)
WHERE >nul 2>nul mergehex
IF %ERRORLEVEL% NEQ 0 (
ECHO "mergehex was not found in PATH, please install using windows installed as found on nordicsemi.com"
goto :end
)

SET S132=s132_nrf52_6.1.0_softdevice.hex
SET BOOTLOADER=Beacon_IDCard_SecureBootloader_s132_v1.0.hex
SET APPLICATION=Beacon_IDCard_App_v1.0.hex

echo "## Looking to make sure %S132% exists"
if not exist %S132% (
echo "#### s132 hex file does not exist! Make sure the softdevice is in the same folder as this script!"
goto :end
)
echo.

echo "## Looking to make sure %BOOTLOADER% exists"
if not exist %BOOTLOADER% (
echo "#### Bootloader hex file does not exist! Please make sure its compiled, copied, and renamed into this folder!"
goto :end
)
echo.

echo "## Looking to make sure %APPLICATION% exists"
if not exist %APPLICATION% (
echo "#### Application hex file does not exist! Please make sure its compiled, copied, and renamed into this folder!"
goto :end
)
echo.

echo "## Erasing everything from chip"
nrfjprog --eraseall -f nrf52
echo.

echo "## Merging S132 and bootloader, then flashing it to nRF52; make sure the Device is powered on and connected to the PC"
mergehex -m %S132% %BOOTLOADER% -o merged_SD_bootloader_v1.0.hex
nrfjprog --program merged_SD_bootloader_v1.0.hex -f nrf52 --chiperase
echo.

echo "## Creating bootloader settings based on Beacon_IDCard_App_v1.0.hex"
nrfutil settings generate --family NRF52 --application Beacon_IDCard_App_v1.0.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 --no-backup BLsettings_v1.0.hex
echo.

echo "## Merging bootloader settings and app.hex into merged_App_BLSettings_v1.0.hex"
mergehex -m Beacon_IDCard_App_v1.0.hex BLsettings_v1.0.hex -o merged_App_BLSettings_v1.0.hex
echo.

nrfjprog --program merged_App_BLSettings_v1.0.hex -f nrf52 --sectorerase

echo "## Writing Major/Minor at UICR"
nrfjprog --memwr 0x10001080 -f nrf52 --val %arg1%
echo.

echo "## Reading Major/Minor at UICR"
nrfjprog --memrd 0x10001080 -f nrf52
echo.

echo "## Please power cycling the device and then with nRF Connect, make sure the device is advertising"
nrfjprog.exe -f nrf52 --reset
echo.



:end
pause

你可能感兴趣的:(nrf 调用nrfjprog 工具 windows脚本jlink烧写)