-
Notifications
You must be signed in to change notification settings - Fork 271
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
::onReceive() implementation & calling functions not in IRAM #270
Comments
@mcspr I've pushed changes that should fix what can be done on this side to master. |
Original report crashed in ISR without even touching onReceive callback, stopping on queue::available() I switched the commit in the local copy and rebuilt my test project, but still see at least one (gdb) pipe disassemble 'SoftwareSerial::rxBitISR' | grep -B2 call
0x40100500 <+20>: l32i.n a15, a12, 28
0x40100502 <+22>: s32i.n a0, a1, 44
0x40100504 <+24>: call0 0x40100740 <micros()>
--
0x4010053f <+83>: s32i a6, a1, 0
0x40100542 <+86>: l32r a0, 0x40100374
0x40100545 <+89>: callx0 a0
--
0x40100590 <+164>: mov.n a2, a12
0x40100592 <+166>: l32r a0, 0x40100378
0x40100595 <+169>: callx0 a0
(gdb) x *0x40100374
0x4000e268: Cannot access memory at address 0x4000e268 <<< .ld has PROVIDE ( __umodsi3 = 0x4000e268 );, guess it is ok?
(gdb) x *0x40100378
0x4020bb98 <delegate::detail::DelegateImpl<void*, void>::operator bool() const>: 0x050c4248
(gdb) |
@mcspr You have the source code, which one could that possibly be, I have looked over and over now, every |
Sources are in order, building latest esp8266 git with forcibly reset submodule ~/.p/p/f (master)> git log --oneline -1
d7da591e (HEAD -> master, origin/master, origin/HEAD) Revert ESPSoftwareSerial from v7 to v6
~/.p/p/f (master)> git -C libraries/SoftwareSerial log --oneline -1
254bf85 (HEAD, origin/main) move with rvalue-refs We are just lucky to hit a very special condition under which attributes don't work (in GCC) - templates. So, things go to flash like they would by default. |
Having thought about the issue... Before any call to the specific template, it can be manually instantiated like this template something<Type>(); Attribute seems to be working under these conditions (see Regarding the commit, delegate mentions are completely gone from irom. Binary size goes up, as expected.
|
@mcspr Latest commit, this would be it from my side. Haven't investigated explicit specialization, interesting to know, more trouble than it seems worth in the case at hand (?). If you are OK with the results - the 3rd party issue of possibly needing to fix their onReceive handler non-withstanding - I would push a release. |
Looks fine to me. Also, https://gcc.gnu.org/onlinedocs/gcc/Template-Instantiation.html BTW, there is also |
@mcspr Thanks for all the input. It's not quite intuitive, finding the right class template in Delegate.h, but I am confident I have managed it and now the required bits are neither inlined nor placed outside the IRAM cache address range. |
lgtm based on repeating tests above, thx Main breaking concern v6 -> v7 is onReceive context change, but I am of two minds about it. Meaning, keep the [[deprecated("Don't use this one")]]
void onReceive(Func<void(int)>);
void onReceiveISR(Func<void()>); |
I wasn't aware that anyone had considered using the onReceive() function, let alone implemented its use. I think I stand by this breaking change, which IIRC is clearly mentioned in the descriptions. I would not name the set-handler function Once I am satisfied with the work I am doing on giving users more freedom with strapping pins, I will submit another PR. If you can totally not agree with me opinion, of course, let me know, I'm not completely ideological. |
Just a concern about versioning & deprecation like it is described by semver, since we bundle it with esp8266 Core vs. manual upgrade from library manager. |
@mcspr 3dc3b23, what do you think? Still a hard breaking change between direct version successors, of this lib. Users of the ESP8266 / ESP32 cores oftentimes seem not to use every main branch revision or even every release of the cores, so they would miss a transitional minor or bug fix release of EspSoftwareSerial anyway... |
Any reason not to also have |
It doesn't compile due to overload resolution ambiguity. I don't think it matters at all, though, because I expect nobody uses one without the other - without |
Dear @mcspr , I have also added an example for the use of the RX callback now and measured the possible power savings this allows (aba98fc, esp8266/Arduino#8869). A shameless plug, if the above-mentioned power API PR were merged, I would try to implement the deep sleep with GPIO wakeup as well - strictly speaking this doesn't require the callback, I know - and give measurements. For simplicity, I'm deploying just a USB power meter, not measuring the current input for the pure ESP8266 module alone. |
lgtm? I haven't considered the lowpower application, does sound like a pretty good example to have race condition wise, only pretty minor thing that comes to mind is I think mentioned PRs can be part of 3.2.0, but I don't have any strong opinions yet so pls bear with me |
@mcspr Thanks for looking at everything! |
For those reading here: the discussion has now completely shifted to the issue for merging with ESP8266 Arduino Core esp8266/Arduino#8869 |
As I stated yesterday, follow and join the discussion at the ESP8266 core repository. |
ref. esp8266/Arduino#8830, user reports frequent crashes when using 7.0.0
most likely cause being queue's available(), and the delegate check & call are not in IRAM
suppose one way to solve this is from our side and force things into IRAM manually, but I'd think esp32 would have similar issue when running out of cache
esp8266/Arduino#8834
The text was updated successfully, but these errors were encountered: