@@ -47,25 +47,84 @@ jobs:
4747 # Invoke-WebRequest -OutFile gcc-win64.zip https://github.com/brechtsanders/winlibs_mingw/releases/download/14.2.0posix-19.1.7-12.0.0-msvcrt-r3/winlibs-x86_64-posix-seh-gcc-14.2.0-mingw-w64msvcrt-12.0.0-r3.zip
4848 # [System.IO.Compression.ZipFile]::ExtractToDirectory("gcc-win64.zip", "C:\")
4949 # }
50+ # - name: Download and Unzip GCCs
51+ # shell: powershell
52+ # run: |
53+ # $ProgressPreference = 'SilentlyContinue'
54+ # Start-Job {
55+ # Set-Location $using:PWD
56+ # Invoke-WebRequest -OutFile gcc-arm-none-eabi-win64-14.zip https://developer.arm.com/-/media/Files/downloads/gnu/14.3.rel1/binrel/arm-gnu-toolchain-14.3.rel1-mingw-w64-x86_64-arm-none-eabi.zip
57+ # New-Item -Path "C:\" -Name "arm-none-eabi-14" -ItemType "Directory"
58+ # Expand-Archive -Path gcc-arm-none-eabi-win64-14.zip -DestinationPath C:\arm-none-eabi-14 -Force
59+ # Remove-Item gcc-arm-none-eabi-win64-14.zip
60+ # }
61+ # Start-Job {
62+ # Set-Location $using:PWD
63+ # Add-Type -Assembly "System.IO.Compression.Filesystem"
64+ # Invoke-WebRequest -OutFile gcc-avr-win64.zip https://github.com/ZakKemble/avr-gcc-build/releases/download/v14.1.0-1/avr-gcc-14.1.0-x64-windows.zip
65+ # [System.IO.Compression.ZipFile]::ExtractToDirectory("gcc-avr-win64.zip", "C:\")
66+ # Remove-Item gcc-avr-win64.zip
67+ # }
68+ # Get-Job | Wait-Job
69+
5070 - name : Download and Unzip GCCs
5171 shell : powershell
5272 run : |
53- $ProgressPreference = 'SilentlyContinue'
54- Start-Job {
55- Set-Location $using:PWD
56- Invoke-WebRequest -OutFile gcc-arm-none-eabi-win64-14.zip https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-mingw-w64-x86_64-arm-none-eabi.zip
57- New-Item -Path "C:\" -Name "arm-none-eabi-14" -ItemType "Directory"
58- Expand-Archive -Path gcc-arm-none-eabi-win64-14.zip -DestinationPath C:\arm-none-eabi-14 -Force
59- Remove-Item gcc-arm-none-eabi-win64-14.zip
73+ # enforce TLS 1.2 & set a browser-like User-Agent to avoid server blocking
74+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
75+ $headers = @{ 'User-Agent' = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/115.0' }
76+
77+ function Try-Download {
78+ param($url, $out)
79+ $maxAttempts = 3
80+ for ($i=1; $i -le $maxAttempts; $i++) {
81+ Try {
82+ Write-Host "Downloading $url (attempt $i/$maxAttempts)"
83+ Invoke-WebRequest -Uri $url -OutFile $out -Headers $headers -ErrorAction Stop -TimeoutSec 600 -Verbose
84+ return $true
85+ } Catch {
86+ Write-Warning "Attempt $i failed: $($_.Exception.Message)"
87+ if ($_.Exception.Response) {
88+ try { Write-Host "Status: $($_.Exception.Response.StatusCode) $($_.Exception.Response.StatusDescription)" } catch {}
89+ try {
90+ $sr = New-Object System.IO.StreamReader ($_.Exception.Response.GetResponseStream())
91+ $body = $sr.ReadToEnd()
92+ Write-Host "Response body (truncated 8k): $($body.Substring(0,[Math]::Min(8192,$body.Length)))"
93+ } catch {}
94+ }
95+ Start-Sleep -Seconds (5 * $i)
96+ }
97+ }
98+ return $false
6099 }
61- Start-Job {
62- Set-Location $using:PWD
63- Add-Type -Assembly "System.IO.Compression.Filesystem"
64- Invoke-WebRequest -OutFile gcc-avr-win64.zip https://github.com/ZakKemble/avr-gcc-build/releases/download/v14.1.0-1/avr-gcc-14.1.0-x64-windows.zip
65- [System.IO.Compression.ZipFile]::ExtractToDirectory("gcc-avr-win64.zip", "C:\")
66- Remove-Item gcc-avr-win64.zip
100+
101+ $armUrl = 'https://developer.arm.com/-/media/Files/downloads/gnu/14.3.rel1/binrel/arm-gnu-toolchain-14.3.rel1-mingw-w64-x86_64-arm-none-eabi.zip'
102+ $armOut = 'gcc-arm-none-eabi-win64-14.zip'
103+ $avrUrl = 'https://github.com/ZakKemble/avr-gcc-build/releases/download/v14.1.0-1/avr-gcc-14.1.0-x64-windows.zip'
104+ $avrOut = 'gcc-avr-win64.zip'
105+
106+ if (-not (Try-Download $armUrl $armOut)) {
107+ Write-Warning "Invoke-WebRequest failed for ARM URL, trying curl fallback (shows HTTP errors)."
108+ $curlCmd = "curl.exe -L -A \"Mozilla/5.0\" --retry 5 --retry-connrefused -o $armOut \"$armUrl\""
109+ Write-Host "Running: $curlCmd"
110+ & cmd /c $curlCmd
111+ if ($LASTEXITCODE -ne 0) { Write-Error "curl failed with code $LASTEXITCODE"; Exit 1 }
112+ }
113+
114+ New-Item -Path 'C:\arm-none-eabi-14' -ItemType Directory -Force
115+ Expand-Archive -Path $armOut -DestinationPath C:\arm-none-eabi-14 -Force
116+ Remove-Item $armOut
117+
118+ if (-not (Try-Download $avrUrl $avrOut)) {
119+ Write-Warning "AVR download failed with Invoke-WebRequest; trying curl fallback."
120+ $curlCmd = "curl.exe -L -A \"Mozilla/5.0\" --retry 5 --retry-connrefused -o $avrOut \"$avrUrl\""
121+ Write-Host "Running: $curlCmd"
122+ & cmd /c $curlCmd
123+ if ($LASTEXITCODE -ne 0) { Write-Error "curl failed with code $LASTEXITCODE"; Exit 1 }
67124 }
68- Get-Job | Wait-Job
125+ Add-Type -Assembly 'System.IO.Compression.FileSystem'
126+ [System.IO.Compression.ZipFile]::ExtractToDirectory($avrOut, 'C:\')
127+ Remove-Item $avrOut
69128
70129 # No need for this anymore
71130 # dir C:\mingw64
0 commit comments