esp-rs / esp-flasher-stub

Rust implementation of flasher stub located in esptool
Apache License 2.0
18 stars 10 forks source link

Use RX FIFO threshold to batch copy bytes #24

Open MabezDev opened 1 year ago

MabezDev commented 1 year ago

Currently, the uart is being interrupted on every byte this is not optimal for performance, and especially at higher bauds we make miss single bytes. We should use the AT-CMD feature to detect end the end of slip packets and fetch a packet at a time in the interrupt.

igrr commented 1 year ago

Alternatively, we could rely on rxfifo_full_thrhd to raise an interrupt only when some moderately large number of bytes (e.g. 100 bytes) are in the FIFO? That would still gave enough time for the interrupt handler to copy those bytes out of the FIFO before an overflow happens.

MabezDev commented 1 year ago

Yeah, I think that would work better actually, because our slip packets are quite small.

DNedic commented 1 year ago

@igrr How would this work when the packet exchange ends and there are say 90 bytes left in the FIFO?

igrr commented 1 year ago

The simplest option is probably to enable the RX timeout interrupt. It will fire if no byte has been received for a given number of cycles.