Updated flasher script to work with submodules for libraries
This commit is contained in:
parent
03ae4768e7
commit
1d46664233
98
flash.ps1
98
flash.ps1
|
@ -1,58 +1,74 @@
|
|||
param(
|
||||
[String]$COMPort,
|
||||
[switch]$Extras,
|
||||
[switch]$ResetAfterFlash,
|
||||
[String[]]$Libs
|
||||
[String]$COMPort,
|
||||
[switch]$Extras,
|
||||
[switch]$ResetAfterFlash,
|
||||
[String[]]$Libs
|
||||
)
|
||||
|
||||
Function Find-LibraryFile {
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[String]$Library,
|
||||
[String]$SearchPath = $(Get-Location)
|
||||
)
|
||||
return (Get-ChildItem -Path $SearchPath -Recurse -Name "$Library.py").FullName
|
||||
}
|
||||
|
||||
Function Write-AmpyFile {
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[String]$Filename,
|
||||
[String]$COMPort
|
||||
)
|
||||
If ((Get-Command -Name ampy -ErrorAction SilentlyContinue) -eq $false) {
|
||||
Write-Error -Message "Couldn't locate ``ampy`` in environment paths - please run ``pip install adafruit-ampy``." -ErrorAction Stop
|
||||
}
|
||||
ampy -p $COMPort put $Filename
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[String]$Filename,
|
||||
[String]$COMPort
|
||||
)
|
||||
If ((Get-Command -Name ampy -ErrorAction SilentlyContinue) -eq $false) {
|
||||
Write-Error -Message "Couldn't locate ``ampy`` in environment paths - please run ``pip install adafruit-ampy``." -ErrorAction Stop
|
||||
}
|
||||
ampy -p $COMPort put $Filename
|
||||
}
|
||||
|
||||
Function Reset-AmpyDevice {
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[String]$COMPort
|
||||
)
|
||||
If ((Get-Command -Name ampy -ErrorAction SilentlyContinue) -eq $false) {
|
||||
Write-Error -Message "Couldn't locate ``ampy`` in environment paths - please run ``pip install adafruit-ampy``." -ErrorAction Stop
|
||||
}
|
||||
ampy -p $COMPort reset
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[String]$COMPort
|
||||
)
|
||||
If ((Get-Command -Name ampy -ErrorAction SilentlyContinue) -eq $false) {
|
||||
Write-Error -Message "Couldn't locate ``ampy`` in environment paths - please run ``pip install adafruit-ampy``." -ErrorAction Stop
|
||||
}
|
||||
ampy -p $COMPort reset
|
||||
}
|
||||
|
||||
$BaseFiles=(
|
||||
'boot',
|
||||
'main',
|
||||
'uPyConfig'
|
||||
$BaseFiles = (
|
||||
'boot',
|
||||
'main',
|
||||
'uPyConfig'
|
||||
)
|
||||
$ExtraFiles=(
|
||||
'init_sample'
|
||||
$ExtraFiles = (
|
||||
'init_sample'
|
||||
)
|
||||
$CfgFiles=(
|
||||
'wifi_cfg',
|
||||
'webrepl_cfg'
|
||||
$CfgFiles = (
|
||||
'wifi_cfg',
|
||||
'webrepl_cfg'
|
||||
)
|
||||
|
||||
$BaseFiles | % {
|
||||
Write-AmpyFile -Filename "$_.py" -COMPort $COMPort
|
||||
$Lib = Find-LibraryFile -Library $_
|
||||
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort
|
||||
}
|
||||
$CfgFiles | % {
|
||||
If (Get-ChildItem "$_.py" -ErrorAction SilentlyContinue) {
|
||||
Write-AmpyFile -Filename "$_.py" -COMPort $COMPort
|
||||
}
|
||||
If (Get-ChildItem "$_.py" -ErrorAction SilentlyContinue) {
|
||||
Write-AmpyFile -Filename "$_.py" -COMPort $COMPort
|
||||
}
|
||||
}
|
||||
If ($Extras) { $ExtraFiles | % {
|
||||
Write-AmpyFile -Filename "$_.py" -COMPort $COMPort
|
||||
}}
|
||||
If ($Libs.Count -gt 0) { $Libs | %{
|
||||
Write-AmpyFile -Filename "$_.py" -COMPort $COMPort
|
||||
}}
|
||||
If ($ResetAfterFlash) { Reset-AmpyDevice -COMPort $COMPort }
|
||||
If ($Extras) {
|
||||
$ExtraFiles | % {
|
||||
$Lib = Find-LibraryFile -Library $_
|
||||
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort
|
||||
}
|
||||
}
|
||||
If ($Libs.Count -gt 0) {
|
||||
$Libs | % {
|
||||
$Lib = Find-LibraryFile -Library $_
|
||||
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort
|
||||
}
|
||||
}
|
||||
If ($ResetAfterFlash) { Reset-AmpyDevice -COMPort $COMPort }
|
||||
|
|
Loading…
Reference in New Issue