frankjoshua / rosserial_arduino_lib

58 stars 46 forks source link

Crashes on message serialization with ESP8266 #8

Closed logos-electromechanical closed 5 years ago

logos-electromechanical commented 5 years ago

All (or almost all) of the defined messages use constant strings as part of the message contents. These strings are currently stored in SPI flash and memcpy'd into outgoing buffers during serialization. Since the SPI flash can only be read in 4-byte aligned chunks, this causes fatal exceptions on ESP8266 Arduino Core v2.5.2 and Arduino IDE 1.8.10. I have two proposed solutions:

-- Store all of the relevant strings in RAM. This definitely works, and is easy to implement. This may deplete RAM on applications that have lots of different message types compiled in. It's also not particularly elegant.

-- Write a modified memcpy and call it as appropriate when the address of the string to be copied is located in SPI flash. There may be other places that I didn't find where this causes problems, so this has the risk of not entirely fixing the issue.

Thoughts? If I don't hear anything, I will probably open a PR for the first solution, since it's straightforward and easy to test.

frankjoshua commented 5 years ago

I maintain this but haven't written any of the code. So do what you think is best and I'll accept the pull request.

logos-electromechanical commented 5 years ago

Ok, I'm going to write it as a conditional compile against ESP8266. It's not a problem for AVRs or SAMDs, and I suspect it's not an issue for ESP32s.