Skip to content
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

ArtiFX on ESP8266 #31

Open
lost-hope opened this issue Apr 6, 2023 · 6 comments
Open

ArtiFX on ESP8266 #31

lost-hope opened this issue Apr 6, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@lost-hope
Copy link
Collaborator

lost-hope commented Apr 6, 2023

Feature Request:
Add ArtiFX support for ESP8266 platform

Additional Info:
When adding the ArtiFX usermod to the env of the ESP8266, the main issue seems to be that the function esp_get_free_heap_size() is not present for ESP8266 (https://github.com/espressif/ESP8266_RTOS_SDK/blob/35375c17be0b7837239c330d9a411a0ad46196b8/components/esp8266/source/system_api.c#L378)
That function itself needs the heap_caps_get_free_size function (https://github.com/espressif/ESP8266_RTOS_SDK/blob/35375c17be0b7837239c330d9a411a0ad46196b8/components/heap/src/esp_heap_caps.c#L69)
That function uses two global variables, that need to be properly initialized: g_heap_region_num and g_heap_region most of it seems to be initialized here (https://github.com/espressif/ESP8266_RTOS_SDK/blob/35375c17be0b7837239c330d9a411a0ad46196b8/components/heap/port/esp8266/esp_heap_init.c#L21)

@lost-hope lost-hope added the enhancement New feature or request label Apr 6, 2023
@softhack007
Copy link
Collaborator

ESP.getFreeHeap() should also exists on 8266. It delivers the same information as esp_get_free_heap_size(), but it's part of the standard framework.

@MoonModules
Copy link
Owner

ESP.getFreeHeap worked! And some other changes and I am able to compile it, but then the result of ESP.getFreeHeap is

setup 8552 bytes free
open /wledv033.json 8128 ✓
definitionTree 0 => 8088 ✓
deserializeJson() of definition failed with code NoMemory
Setup not successful

Around 8K free while on ESP32 around 100K free, and that is what ARTI-FX needs (maybe like 50k works...)

Is it possible to allocate more heap?

@lost-hope
Copy link
Collaborator Author

lost-hope commented Apr 7, 2023

yep seems to work:
I added a small ifdef at beginning of arti_wled.h:

#ifdef ESP32
#define FREE_SIZE esp_get_free_heap_size() // ESP32 is set in wled context: small trick to set WLED context
#define ARTI_PLATFORM ARTI_ARDUINO         // else on Windows/Linux/Mac...
#endif

#ifdef ESP8266
#define ARTI_PLATFORM ARTI_ARDUINO // else on Windows/Linux/Mac...
#define FREE_SIZE ESP.getFreeHeap()
#endif

and encased the `#define FREE_SIZE esp_get_free_heap_size()``in arti.h in a ifndef, so it does not override the other setting.

i am getting an error for no convertFromJson function in ArduinoJson-v6. how did you manage to circumvent that?

@MoonModules
Copy link
Owner

I did something similar (used ARDUINO_ARCH_ESP32/ESP8266 instead of ESP32/ESP8266), plus had to change the way strings are send to Serial/File. Will commit in half an hour I guess...

@MoonModules
Copy link
Owner

Committed! https://discord.com/channels/700041398778331156/1060959116526362634/1093848593489739879

Please test both on esp8266 (likely crash due to low mem but maybe you can increase mem alloc some way) and on esp32 (using USER_PRINTF now, so ARTI-FX can also be tracked in Net Print)

@MoonModules
Copy link
Owner

This asChar stuff is also something to look at, this caused me grey hairs last year when I made Arti, Serial.print looks so vulnerable for crashes, I got it now stable for ESP32 using .asstd::string().c_str(), which uses the string type as 'bridge' but if I use the direct way: .as<const char *>() then it crashes on ESP32. For ESP8266 I now have turn it off completely (#define asChar(x) "", .asstd::string().c_str() caused compile errors) so all ERROR_ARTI and DEBUG_ARTI will print nothing for asChar parts (to be on the save side) but would be nice if print

Screenshot 2023-04-07 at 14 05 46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants