-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow byte access to PROGMEM without pgm_read macro #6978
Allow byte access to PROGMEM without pgm_read macro #6978
Conversation
This works,
Gives
|
This PR pulls in code from @pvvx's esp8266web server at https://github.com/pvvx/esp8266web (licensed in the public domain) to allow reads of 8 and 16-bit values out of flash without the need for pgm_read_byte/word macros. It installs an exception handler that decodes the faulting instruction and simulates is properly and returns immediately to user code. That said, it is significantly slower (20x?) than using the pgm_read macros properly.
e67cd81
to
abf6d69
Compare
All working now. *(NULL) will generate the proper fault:
Gives
And the crash stack decodes properly to the faulting line:
|
Move the ROM defintions into esp8266_undefined.h, and add ifdef bracketing around the whole header (it's included multiple times). Remove some unneeded, left-over code and comments. Use __asm to make compatible with --std=c++17 Requires 162 bytes of IRAM for the handler.
I am missing the rationale on why this should be done, especially with no compile time switch to turn it off (or why it is on by default in the first place). To me it sounds like to hide bugs (missing too call _P variant somewhere) with introducing a performance problem that will be very difficult to find. At least the option to turn this of needs to bet there, and imho it should be off by default |
Good comments, @dirkmueller. I can see why we'd want to allow for removing it via the menus (besides the ~150 bytes of IRAM). It's a matter of reducing friction and making it easier for new users. We're used to it, but having separate I and D spaces is not very common and leads to confusion with new users. You and I get it, but someone coming from a RPi or who's only over coded in a HLL hasn't a clue. Today, this is a bug:
With this patch it's no longer a bug, it''ll do what it says, albeit slower than if you used The LUA guys handle it by using Espressif handles it in later SDKs by including essentially the same handler (pre3.0 had one). So, as we move to an updated SDK we're going to have it whether we want to or not (unless we forcibly overwrite it). |
While I agree with the benefits, I also tend to agree with @dirkmueller when it comes to hidden loss of performances. |
I guess that's dangerous from an exception handler... Anyway I am good as long as there is a way to turn this off at compile time |
True, as @earlephilhower told me. |
Adds a menu option to disable the handler (default is enabled for beginning users). Add a single debug printout when it is invoked via a scheduled function warning that performance may suffer.
I've added a menu option (default on) to disable the handler and a single printout when in debug mode. I think a link to a "how to use progmem" page would be good to dump as well, but I haven't found a good one... |
I'm closing this for now. The response has been pretty consistently unhappy. In the future SDKs, where this is implemented by the blobs, we'll need a different method to remove it than this, so we should look at it fresh when that happens. |
This PR pulls in code from @pvvx's esp8266web server at
https://github.com/pvvx/esp8266web (licensed in the public domain)
to allow reads of 8 and 16-bit values out of flash without the need
for pgm_read_byte/word macros. It installs an exception handler that
decodes the faulting instruction and simulates is properly and returns
immediately to user code. That said, it is significantly slower (20x?)
than using the pgm_read macros properly.