-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reboot before formatting LittleFS #5900
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tested by pressing diff --git a/src/mesh/StreamAPI.cpp b/src/mesh/StreamAPI.cpp
index 4a42e519..0d36e7a5 100644
--- a/src/mesh/StreamAPI.cpp
+++ b/src/mesh/StreamAPI.cpp
@@ -1,8 +1,13 @@
+#include <flash/flash_nrf5x.h>
#include "StreamAPI.h"
+#include "FSCommon.h"
#include "PowerFSM.h"
#include "RTC.h"
+#include "SPILock.h"
#include "Throttle.h"
#include "configuration.h"
+#include "main.h"
+#include "mesh/NodeDB.h"
#define START1 0x94
#define START2 0xc3
@@ -43,8 +48,46 @@ int32_t StreamAPI::readStream()
// console->printf("rxPtr %d ptr=%d c=0x%x\n", rxPtr, ptr, c);
if (ptr == 0) { // looking for START1
- if (c != START1)
- rxPtr = 0; // failed to find framing
+ if (c != START1) {
+ rxPtr = 0; // failed to find framing
+ switch (c) {
+ case 'a':
+ lfs_assert("StreamAPI");
+ break;
+ case 'd':
+ enterDfuMode();
+ break;
+ case 'e': {
+#ifdef NRF52840_XXAA
+ #define LFS_FLASH_ADDR 0xED000
+#else
+ #define LFS_FLASH_ADDR 0x6D000
+#endif
+#define FLASH_NRF52_PAGE_SIZE 4096
+#define LFS_FLASH_TOTAL_SIZE (7*FLASH_NRF52_PAGE_SIZE)
+ // Erase all sectors of internal flash region for Filesystem.
+ for (uint32_t addr = LFS_FLASH_ADDR; addr < LFS_FLASH_ADDR + LFS_FLASH_TOTAL_SIZE;
+ addr += FLASH_NRF52_PAGE_SIZE) {
+ flash_nrf5x_erase(addr);
+ }
+
+ } break;
+ case 'l': {
+ spiLock->lock();
+ auto filesManifest = getFiles("/", 10);
+ spiLock->unlock();
+ for (const auto &file : filesManifest) {
+ LOG_INFO("%s: %d", file.file_name, file.size_bytes);
+ }
+ } break;
+ case 'r':
+ rebootAtMsec = 2000;
+ break;
+ case 's':
+ nodeDB->saveToDisk();
+ break;
+ }
+ }
} else if (ptr == 1) { // looking for START2
if (c != START2)
rxPtr = 0; // failed to find framing |
thebentern
approved these changes
Jan 20, 2025
Is there a temporary fix that could help us get the device working again in the meantime? |
The nrf_erase tool should clear up this issue for now. You can get it by clicking the little trash can icon in the web flasher. |
👋 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #5896