-
Notifications
You must be signed in to change notification settings - Fork 2
/
littlefs.ps1
46 lines (42 loc) · 1.75 KB
/
littlefs.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
if (-Not (Test-Path "$PSScriptRoot\tools\esptool.exe")) {
Write-Host "Downloading ESPTool" -ForegroundColor Green
New-Item -ItemType directory -Path .\tools -ErrorAction SilentlyContinue
Invoke-WebRequest -Uri "https://dl.espressif.com/dl/esptool-4dab24e-windows.zip" -OutFile "$PSScriptRoot\tools\esptool-4dab24e-windows.zip" -Debug
$shell = new-object -com Shell.Application
$zip = $shell.NameSpace("$PSScriptRoot\tools\esptool-4dab24e-windows.zip")
foreach($item in $zip.items())
{
$shell.Namespace("$PSScriptRoot\tools\").copyhere($item)
}
}
$portArray = ([System.IO.Ports.SerialPort]::GetPortNames() | select -first 1)
$binArray = Get-ChildItem "$PSScriptRoot" -Filter *fs*.bin
if($binArray.Count -gt 0)
{
Write-Host "`nBinary detected`n" -ForegroundColor Yellow
for ($i=1; $i -le $binArray.Count; $i++) {
Write-Host "$($i)) $($binArray[$i-1])" -ForegroundColor Green
}
}else{
Write-Host "`nNo Binary detected - You need to build from source`n" -ForegroundColor Yellow
return
}
$binSelect = Read-Host -Prompt "`nSelect file to flash (Example: 1)"
if($binSelect -le $binArray.Count)
{
$binFile = $($binArray[$binSelect-1])
write-Host $binFile
if($portArray.Count -gt 0)
{
ForEach ($comPort in $portArray)
{
Start-Process -FilePath "$PSScriptRoot\tools\esptool.exe" -ArgumentList "--port $($comPort) --baud 115200 write_flash 0x100000 $($binFile)" -NoNewWindow -Wait
}
}else{
Write-Host "`nRS232-TTL adapter NOT detected - FAILED`n" -ForegroundColor Red
}
}else {
Write-Host "`n$($binSelect) is not a valid value`n" -ForegroundColor Red
}