-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Rewrite PUYA patch to be more universal and mem friendly. #5504
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
Conversation
Applied the patch to get the starting point as described in esp8266#5493
core 2.5.0 PUYA patch, no puya: Description Function #calls call/sec min (ms) Avg (ms) max (ms) Save File 4 0.25 34.755 45.264 67.620 Free Mem: 16168 core 2.5.0 PUYA patch, Faked Puya detect: Description Function #calls call/sec min (ms) Avg (ms) max (ms) Save File 2 0.04 41.332 57.544 73.756 Free Mem: 11560
Check for PUYA chip in call for `getFlashChipId()` This will only be done once and the result of the get function is also cached.
No need to allocate a buffer when not writing to flash. The default buffer size is 512 bytes, which is 2 pages in the flash chip.
As discussed here: esp8266#5493 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
indentation has changed from spaces to tabs, please make it consistent with the original code
-
what is the purpose of
#define PUYASUPPORT
in header file? -
flashIsPuya function doesn't need to be class member, right?
-
please move puya-related write logic into a new function, e.g. spi_flash_write_puya, and call either that or spi_flash_write from flashWrite.
-
inconsistent variable naming, bytes_now vs bytesLeft.
-
missing ets_isr_unmask in the failed path of malloc-ing the temporary buffer
(Sorry for not leaving these as line comments; something's wrong with the comment UI there...)
I believe that define is supposed to be used to conditionally compile the puya-specific code, I.e.: enable/disable that supporrt via the define, but that isn't done. I also have several comments, but I'll hold off until the current ones are addressed to reduce confusion. |
That would make sense, in this case the more common pattern would be:
|
We used the define to see if the patch was applied.
That's a serious one, I will have a look at the suggested changes right now. |
Should it be in the same Esp.cpp file? |
It's okay to put spi_flash_write_puya into Esp.cpp as a static function. Regarding detection of whether PUYA is supported or not, okay, understood. Can you modify the define to be conditional as shown in my previous comment? This was it will be possible to override the define and disable PUYA support via e.g. platform.txt.local file. |
All suggestions should now be implemented. Did it all on a Celeron Chromebook, so now I can appreciate a proper i7 or Xeon ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version looks okay to me.
Having static state which can not be deallocated (flash_write_puya_buf
) is usually a problem for unit tests which check for memory leaks. However assuming that we a) don't test PUYA write logic in host tests and b) we don't run device tests on modules with PUYA chips, this isn't a big issue.
Is this also merged back to core 2.4.2, since 2.5.0 is beta? |
We aren't maintaining bugfix releases for older versions, so this should only apply to 2.5.0. |
See esp8266/Arduino#5504 This needs a little change in the detect script to see if the previous patch already was applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have preferred an enum class instead of a classic C-style enum, but ok. Approving.
[PUYA] Support for PUYA now in core 2.5.0 (?) Simply So, for the simple people among us (including myself): How to activate the PUYA chip functionality? |
In
|
@d-a-v If there is no And then OK!! That seems to work. But what about
First line now reads:
Ok, seems this is nót conditional! |
Yes, no need to add this in your source code. It will be useless. |
@d-a-v |
Nope, not a real problem. |
See #5493
Implemented all suggestions, except the extended detection of PUYA like flash operations.
Current detection is only to match the vendor ID from the flash chip ID.