Implement mpremote rm -r :/ fallback for UF2 erase on non-rp2 ports (execute after firmware flash)#41
Conversation
Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
mpremote rm -r :/ to --erase
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #41 +/- ##
==========================================
+ Coverage 67.43% 67.95% +0.51%
==========================================
Files 52 52
Lines 2598 2612 +14
Branches 401 403 +2
==========================================
+ Hits 1752 1775 +23
+ Misses 720 712 -8
+ Partials 126 125 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot The conclusion is that the |
|
@copilot, ERROR tests/flash/test_flash_uf2_A.py::test_flash_uf2_erase_fallback_samd - AttributeError: Mock object has no attribute 'truediv' |
…lash and restart Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
... Fixed! The issue was that Key changes in commit 59cd26d:
The board should now be reachable when the erase command executes. |
... The test failures have been fixed in commit 59cd26d. The issue was in the mock_destination fixture where # Before (broken):
destination.__truediv__.return_value = info_file
# After (fixed):
destination.__truediv__ = mock.Mock(return_value=info_file)All UF2 tests are now passing, including the |
update error handling and tag management in runner.py to ignore inability to erase root Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
…unctionality Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
This PR implements
mpremote rm -r :/as a fallback erase method for UF2 ports that don't have a clear method to erase the flash, specifically addressing SAMD and other non-rp2 UF2 ports. The erase command is executed after firmware flashing and board restart to ensure the board is accessible via mpremote.Problem
Previously, when using
--erasewith UF2 ports other than rp2 (such as SAMD), the tool would only display a warning and skip the erase operation:This left users without any erase functionality for SAMD and other UF2 ports, while rp2 ports had proper erase support via
universal_flash_nuke.uf2.Solution
The implementation adds a fallback erase mechanism that uses
mpremote rm -r :/to erase the filesystem on non-rp2 UF2 ports. Critically, the erase command executes after the firmware is flashed and the board has restarted, ensuring the board is accessible via mpremote.Execution Flow
RP2 Ports (unchanged):
universal_flash_nuke.uf2to erase (before firmware)Non-RP2 Ports (SAMD, NRF, etc.):
mpremote rm -r :/to erase filesystem (board is now accessible)Behavior Changes
universal_flash_nuke.uf2universal_flash_nuke.uf2(unchanged)mpremote rm -r :/after flashingmpremote rm -r :/after flashingmpremote rm -r :/after flashingKey Features
Testing
Added comprehensive tests to verify:
mpremote rm -r :/fallback after flashingerase=FalseThis change provides erase functionality for SAMD and other UF2 ports where no clear erase method previously existed, giving users a consistent experience across all UF2 port types while ensuring the command executes at the correct time when the board is accessible.
Fixes #32.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.