nRF52 companion freezes on every received advert when /adv_blobs is corrupt
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- c
- Domain
- embedded-iot
Research direction
Start with examples/companion_radio/DataStore.cpp, especially DataStore::putBlobByKey() at lines 518–554, and trace how it scans and rewrites /adv_blobs on ExtraFS. Check how MAX_BLOBRECS and file read, seek, and write failures are handled. The issue does not include a deterministic reproduction or a copy of the corrupt file, so first determine how corruption can be detected safely; done means the companion handles a corrupt cache without freezing while preserving valid adverts.
Written by the indexing model from the issue text.
Description
What happens
A RAK4631 BLE companion (RAK_4631_companion_radio_ble, built from companion-v1.17.1 plus 3 merge commits) froze about 1 to 2 minutes after every boot. USB serial and BLE both stopped responding, and only a reset brought it back. Each freeze started right after a valid advert was received, inside DataStore::putBlobByKey() (examples/companion_radio/DataStore.cpp:518-554).
After deleting and recreating /adv_blobs once at boot, the same firmware handled adverts normally. It then ran for 34 minutes in a car with BLE connected the whole time and no freeze.
Where it stops
I added debug lines around the CC310 verification and before and after each step of the advert path. These are the 3 freezes with that logging, on 27 November 2026:
| Time | Last line printed | Where it stopped |
|---|---|---|
| 07:52 | Mesh::onRecvPacket(): valid advertisement received! |
after verify, no step markers yet |
| 07:56 | blob scanned pos=9360 |
in file.write() |
| 08:00 | blob opened ok=1 |
in the scan loop (file.read()) |
Identity::verify() returned CRYS_OK in all 3, and sasiAsymCryptoMutex was 0 before and after. #3849 is not in this build. I applied it locally for these 3 runs, and the freezes still happened.
For the 08:00 freeze I cannot tell whether one file.read() call never returned, or whether the while loop kept getting full records back without reaching the end.
To rule out the SoftDevice flash path, I replaced xSemaphoreTake(_sem, portMAX_DELAY) in flash_nrf5x.c wait_for_async_flash_op_completion() with a 2 s timeout and logging. During a freeze it never fired. The loop task is not waiting for a flash event: it stays inside LittleFS while it walks /adv_blobs.
Device history
/adv_blobslives on ExtraFS (EXTRAFS=1,MAX_BLOBRECS 100, so about 18 kB).putBlobByKey()rewrites one record for every valid advert received.- The companion is used daily for over an hour as a mobile scanner. It runs from a car USB port with no battery, so power is cut whenever the car is switched off, also while it may be writing.
What I did not do
- I did not keep a copy of the corrupt file. The fix build deleted it before I dumped it, so I cannot show what state the file was in.
- I have not reproduced the corruption on purpose. Power loss during
putBlobByKey()and flash wear are both possible causes, and I have not ruled either out. - I did not test #3254 (atomic saves) or #3441 against this case.
Reproduce
I have no deterministic way to reproduce it yet. On the affected device, every boot froze on the first advert that reached putBlobByKey(), until /adv_blobs was recreated.
Question
Should the companion detect a corrupt /adv_blobs and recreate it, given that it only caches raw adverts for the Share function? Options:
- a) Add a bounded scan in
putBlobByKey(): stop afterMAX_BLOBRECSrecords, and recreate the file if a read or seek fails. This only helps if the loop is what keeps running, not if a single LittleFS call blocks. - b) Handle it as part of #3254.
- c) Leave it until the corruption can be reproduced.
- Dominant language
- C
- Stars
- 3.9k
- Forks
- 1.5k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 56
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from meshcore-dev/MeshCore
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
meshcore-dev/MeshCore#4015 ·
Maintainers usually reply within 2 days
-
CMD_SET_DEFAULT_FLOOD_SCOPE leaves an older, longer name's tail after the new namePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
meshcore-dev/MeshCore#3891 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
meshcore-dev/MeshCore#3826 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
meshcore-dev/MeshCore#3825 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
meshcore-dev/MeshCore#3781 ·
Maintainers usually reply within 2 days
All issues in meshcore-dev/MeshCore
Similar issues
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
389ds/389-ds-base#8251 ·
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cpp#645 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ROCm/hrx-system#3628 ·
Maintainers usually reply within 1 day