diff --git a/tools/flash_full_erase.ps1 b/tools/flash_full_erase.ps1 new file mode 100644 index 0000000..2da3d2a --- /dev/null +++ b/tools/flash_full_erase.ps1 @@ -0,0 +1,19 @@ +param( + [string]$Hex = "build\merged.hex" +) + +Set-StrictMode -Version Latest +$ErrorActionPreference = "Stop" + +$RepoRoot = Split-Path -Parent $PSScriptRoot +$HexPath = Join-Path $RepoRoot $Hex + +if (-not (Test-Path -LiteralPath $HexPath)) { + throw "Hex file not found: $HexPath. Build the project first." +} + +Write-Host "[FLASH] FULL ERASE mode" +Write-Host "[FLASH] This wipes application flash, NVS/settings, and BLE bonds." +Write-Host "[FLASH] Programming: $HexPath" + +nrfjprog --program $HexPath --chiperase --verify --reset diff --git a/tools/flash_preserve_settings.ps1 b/tools/flash_preserve_settings.ps1 new file mode 100644 index 0000000..aaaffe4 --- /dev/null +++ b/tools/flash_preserve_settings.ps1 @@ -0,0 +1,29 @@ +param( + [string]$Hex = "build\merged.hex", + [string]$BuildDir = "build" +) + +Set-StrictMode -Version Latest +$ErrorActionPreference = "Stop" + +$RepoRoot = Split-Path -Parent $PSScriptRoot +$HexPath = Join-Path $RepoRoot $Hex +$BuildPath = Join-Path $RepoRoot $BuildDir +$Cmake = "C:\ncs\toolchains\fd21892d0f\opt\bin\cmake.exe" +if (-not (Test-Path -LiteralPath $Cmake)) { + $Cmake = "cmake" +} + +Write-Host "[FLASH] Rebuilding: $BuildPath" +& $Cmake --build $BuildPath + +if (-not (Test-Path -LiteralPath $HexPath)) { + throw "Hex file not found: $HexPath. Build the project first." +} + +Write-Host "[FLASH] PRESERVE mode" +Write-Host "[FLASH] Uses sector erase, so NVS/settings and BLE bonds are preserved if the hex has no records in settings_storage." +Write-Host "[FLASH] settings_storage is expected at 0xFE000-0x100000 for this project." +Write-Host "[FLASH] Programming: $HexPath" + +nrfjprog --program $HexPath --sectorerase --verify --reset