Teensy 4.0 gets build error after updating from 1.56 to 1.57

I have been using PlatformIO with the Teensy 4.0 extensively with framework-arduinoteensy 1.56 and tool-teensy 1.55, but after updating to framework-arduinoteensy 1.57 and tool-teensy 1.57, I get an error when I try to do a build. On the earlier version, it would build the firmware.hex file and then it would display the memory usage. On the new version, it builds the firmware.hex file, but then it says “Access is denied. *** [size] Error 1”.

Here is the terminal output with v1.56. It has no errors. I’ve edited out the long list of files being compiled.

 *  Executing task: C:\Users\myname\.platformio\penv\Scripts\platformio.exe run 

Processing teensy40 (platform: teensy; board: teensy40; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy40.html
PLATFORM: Teensy (4.16.0) > Teensy 4.0
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 1.94MB Flash 
DEBUG: Current (jlink) External (jlink)
PACKAGES:
 - framework-arduinoteensy @ 1.156.0 (1.56)
 - tool-teensy @ 1.155.0 (1.55)
 - toolchain-gccarmnoneeabi @ 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 104 compatible libraries
Scanning dependencies...
 .
 .
 .
Archiving .pio\build\teensy40\libFrameworkArduino.a
Indexing .pio\build\teensy40\libFrameworkArduino.a
Linking .pio\build\teensy40\firmware.elf
Checking size .pio\build\teensy40\firmware.elf
Calculating size .pio\build\teensy40\firmware.elf
Building .pio\build\teensy40\firmware.hex
teensy_size: Memory Usage on Teensy 4.0:
teensy_size:   FLASH: code:38156, data:8316, headers:8820   free for files:1976324
teensy_size:    RAM1: variables:12704, code:36024, padding:29512   free for local variables:446048
teensy_size:    RAM2: variables:44640  free for malloc/new:479648
=================================================================== [SUCCESS] Took 85.62 seconds ===================================================================
 *  Terminal will be reused by tasks, press any key to close it.

Here is the terminal output with v1.57. It ends with an “Access is denied” error.

 *  Executing task: C:\Users\myname\.platformio\penv\Scripts\platformio.exe run 

Processing teensy40 (platform: teensy; board: teensy40; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------Tool Manager: Installing platformio/framework-arduinoteensy @ ~1.157.0
Tool Manager: Error: Please read https://bit.ly/package-manager-ioerror
Tool Manager: Warning! Package Mirror: HTTPSConnectionPool(host='usc1.contabostorage.com', port=443): Max retries exceeded with url: /250040e607e8431abaff8727621872f9:pioregmirrorus/tools/8f/89/39b622d9fe2c679a048abbd8fe2cecb07f623bfaa74fbe8ad7e746b8919c/framework-arduinoteensy-1.157.220801.tar.gz (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)')))
Tool Manager: Looking for another mirror...
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: framework-arduinoteensy@1.157.220801 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy40.html
PLATFORM: Teensy (4.17.0) > Teensy 4.0
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 1.94MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES:
 - framework-arduinoteensy @ 1.157.220801 (1.57)
 - tool-teensy @ 1.157.0 (1.57)
 - toolchain-gccarmnoneeabi @ 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 104 compatible libraries
Scanning dependencies...
 .
 .
 .
Archiving .pio\build\teensy40\libFrameworkArduino.a
Indexing .pio\build\teensy40\libFrameworkArduino.a
Linking .pio\build\teensy40\firmware.elf
Checking size .pio\build\teensy40\firmware.elf
Calculating size .pio\build\teensy40\firmware.elf
Building .pio\build\teensy40\firmware.hex
Access is denied.
*** [size] Error 1
============================================= [FAILED] Took 356.92 seconds =============================================

 *  The terminal process "C:\Users\myname\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

Note that if I do an upload instead of a build, it does not have any errors. Here’s the terminal output from that:

 *  Executing task: C:\Users\myname\.platformio\penv\Scripts\platformio.exe run --target upload 

Processing teensy40 (platform: teensy; board: teensy40; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy40.html
PLATFORM: Teensy (4.17.0) > Teensy 4.0
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 1.94MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES: 
 - framework-arduinoteensy @ 1.157.220801 (1.57) 
 - tool-teensy @ 1.157.0 (1.57) 
 - toolchain-gccarmnoneeabi @ 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 107 compatible libraries
Scanning dependencies...
 .
 .
 .
Building in release mode
Linking .pio\build\teensy40\firmware.elf
Checking size .pio\build\teensy40\firmware.elf
Building .pio\build\teensy40\firmware.hex
Configuring upload protocol...
AVAILABLE: jlink, teensy-cli, teensy-gui
CURRENT: upload_protocol = teensy-gui
Uploading .pio\build\teensy40\firmware.hex
=============================================================================== [SUCCESS] Took 5.62 seconds ===============================================================================
 *  Terminal will be reused by tasks, press any key to close it.

What does this build error mean?

Can you execute the project task “Clean” and then “Advanced → Verbose Build” and copy copy the error messages and lines before and after the “Access denied” error?

Ok, I did the clean and verbose build and this the output around the error:

MethodWrapper(["checkprogsize"], [".pio\build\teensy40\firmware.elf"])
teensy_size .pio\build\teensy40\firmware.elf
arm-none-eabi-objcopy -O ihex -R .eeprom .pio\build\teensy40\firmware.elf .pio\build\teensy40\firmware.hex
Access is denied.
*** [size] Error 1
============================================================================ [FAILED] Took 5.83 seconds ============================================================================

 *  The terminal process "C:\Users\myname\.platformio\penv\Scripts\platformio.exe 'run', '--verbose', '--environment', 'teensy40'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

I see that the firmware.elf and the firmware.hex files were actually created, so I’m not sure what it means by “Access denied.” Does this output help shed any light on the error?

Do you have any antivirus active that could interfere?

I have antivirus software, but I didn’t change anything between the upgrade to v1.57. I built with v1.56 and it worked, then I did the update to v1.57 and the build failed.

Can you get a clean download of 1.57 and retry? Remove the folders C:\Users\myname\.platformio\packages\framework-arduinoteensy and C:\Users\myname\.platformio\.cache and rebuild the project.

That worked! I deleted framework-arduinoteensy and .cache and when I rebuilt my code, I did not get the “Access denied” error. I actually have two machines, with Win 10 and Win 11 and they both had the same error, but deleting the directories and rebuilding fixed both of them. I don’t understand it, but I’m happy with the result.

By the way, I have a system running Ubuntu as well, but it did not have any problem with the upgrade.

Thanks for the help!