v1.20.0.rc7: BLE causes crash and file corruption #265
Description
Wipy crashes and may corrupt the file system when trying to write a file after enabling BLE.
Pycom module: WiPy 3.0
Firmware: v1.20.0.rc7
File system: Both FatFS and LittleFS
I have reduced the issue down to the following simple example main.py:
import utime
from network import Bluetooth
print("create file...")
with open('/flash/test.txt', 'w+') as f:
f.write('some data')
print("setup BLE...")
bluetooth = Bluetooth()
bluetooth.set_advertisement(name = "BleTest")
bluetooth.advertise(True)
print("write data...")
writeCount = 0
while True:
utime.sleep(1)
writeCount = writeCount + 1
print("count: "+str(writeCount))
with open('/flash/test.txt', 'w') as f:
f.write('some data')
The above main.py code works using firmware versions 1.18.x. But with version 1.20.x (or 1.19.x) it will cause a crash dump on the first or second write attempt after enabling the BLE. Simply remove the bluetooth.advertise(True)
line and the file writing works fine on 1.20.x.
After the crash, FatFS file systems are often left corrupted. Some files may be missing and there may be a bunch "junk" folders. Often have to re-flash the firmware and erase the flash to fix this issue as further attempts to write to the file system cause more crashes. The crash occurs using either FatFS or LittleFS. However, LittleFS appears to be less susceptible to the file corruption.
I'm really looking forward to some of the improvements in firmware version 1.20.x. Support for light sleep. Improved power consumption. Improved framebuf support. etc. But this firmware is unusable if I can't write to files while using BLE.