whitecatboard / Lua-RTOS-ESP32

Lua RTOS for ESP32
Other
1.18k stars 221 forks source link

Fix for issue #345 #346

Closed Mynogs closed 4 years ago

Mynogs commented 4 years ago

This fixes the bug. But I don't think that was root cause. We may have to adjust further positions in the spi. Greetings André

the0ne commented 4 years ago

Thanks a lot!

On the first view, this looks like a "workaround" instead a fix for the bug. So we should find out why some buffer is too small and by what number. Might very well be the results will be the same as your fix but just reasoned other than "works for me now".

Mynogs commented 4 years ago

This is absoluty a workaround! I think it is necessary to revise the spi driver a little. An approximately 4k spi buffer is used in the Lua library. The same for sending and receiving. This is absolutely permissible for spi. In sys/hw/spi.c, however, a small temporary buffer is created for receiving. And there is the problem. It's about this function: spi_master_op (int deviceid, uint32_t word_size, uint32_t len, uint8_t *in, uint8_t * out) The question is whether here in and out may be the same (that would make the small temporary buffer superfluous). The Word DMA occurs in this function. DMAs will probably work with long words. I suspect the mistake here.