← index #17236Issue #16221
Related · high · value 1.837
QUERY · ISSUE

rp2: Flash writes disrupt UART IRQ

openby Gadgetoidopened 2025-05-01updated 2026-03-12
bugport-rp2

Port, board and/or hardware

rp2

MicroPython version

All.

Reproduction

Attempting to stream data from a UART to Flash - ie: servicing a soft (MicroPython) UART IRQ and writing the UART contents to a file on Flash - will result in lost data.

Using the same code and writing the same data to an SD card works fine.

Expected behaviour

No data should be lost.

Observed behaviour

Flash writes on RP2 disable all interrupts to avoid any code running from Flash while it's being written.

Since the UART copy from its 32 byte buffer into the user-specified (size) ring buffer requires the IRQ to fire, then writing to flash will lose arbitrary portions of incoming UART data since they will never make it to the ring buffer.

Additional Information

It's possible, maybe, that this could be fixed by moving the UART IRQ handler to RAM and being very careful about what it does. IE: This could not interop with a "hard" IRQ since we can't predict what the user might be doing (even if they don't allocate RAM).

AIUI the normal soft UART IRQ is dispatched and handled by MicroPython outside of the IRQ handler so this might just work.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

ports/rp2: "Uncaught exception in IRQ callback handler" when retrieving PIO FIFO value with MSB set

openby mungewellopened 2024-11-13updated 2026-03-25
bugport-rp2

Port, board and/or hardware

Official Pico w/rp2040

MicroPython version

MicroPython v1.24.0 on 2024-10-25; Raspberry Pi Pico with RP2040

Reproduction

uncaught_exception_test.py.txt

Expected behaviour

MPY: soft reboot
0x12345678
0x12345678

Observed behaviour

MPY: soft reboot
Uncaught exception in IRQ callback handler
Traceback (most recent call last):
File "<stdin>", line 33, in irq_handler
MemoryError: memory allocation failed, heap is locked
0x00000000
0x00000000

Additional Information

Some discussion/commentary here:
https://github.com/micropython/micropython/blob/master/ports/rp2/rp2_pio.c#L820

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied