Closed siliconwitch closed 1 year ago
I might have caused this bug by blocking the bluetooth 🤔
import bluetooth
import time
import urandom
def choices(rng, k=1):
l = []
for _ in range(k):
l.append(urandom.choice(rng))
return l
while True:
if bluetooth.connected():
mtu = bluetooth.max_length()
start = time.ticks_ms()
i = 0
while i < 10:
try:
bluetooth.send(choices(range(0, 256), k=mtu))
i += 1
except:
pass
end = time.ticks_ms()
print(f"Sent {i-1*mtu} bytes in {time.ticks_diff(start , end)}")
I think I found a way to brick Monocle from micropython @josuah 😅
This was a MicroPython bug. Issue at https://github.com/micropython/micropython/issues/11682
It appear to be a desired feature of MicroPython
Should we implement our own Ctrl-C? Or maybe a separate Ctrl-\
that always causes a full firmware reset when hit, directly caught on the bluetooth driver before it reaches MicroPython?
That way, regardless what happens on MicroPython level, we could always recover.
Well, a full firmware reset doesn't work either if it's a saved python file. Ctrl+/ could work, if there's a way we can break the execution loop and return to the REPL
If we try to make use of a keyboard interrupt, we would have implemented the same behavior as Ctrl+C, and would be back to square 1, I suppose...
So maybe we would have to fork micropython or maybe patch it?
Or could we implement a fail-safe reboot mechanism that skips startup files execution.
A bit how in Linux, if something goes wrong in the boot process, passing init=/bin/sh
to the kernel command line gives a way to fix it manually.
Open to suggestions!
The main.py file is uploaded but doesn't show up.
Full log: