Compare commits

...
2 changed files with 18 additions and 0 deletions
+5
View File
@@ -32,6 +32,7 @@ from esphome.storage_json import StorageJSON
from . import gpio # noqa: F401
from .const import (
COMPONENT_BK72XX,
COMPONENT_LN882X,
CONF_GPIO_RECOVER,
CONF_LOGLEVEL,
CONF_SDK_SILENT,
@@ -490,6 +491,10 @@ async def component_to_code(config):
# Not enabled on RTL87xx/LN882x — costs more heap than it saves there.
cg.add_build_flag("-DconfigSUPPORT_STATIC_ALLOCATION=1")
# LN882x: a zero-size allocation must not trip the SDK's assert (see ln882x_zero_malloc.c).
if config[CONF_COMPONENT_ID] == COMPONENT_LN882X:
cg.add_build_flag("-Wl,--wrap=pvPortMalloc")
# RTL8710B needs FreeRTOS 8.2.3+ for xTaskNotifyGive/ulTaskNotifyTake
# required by AsyncTCP 3.4.3+ (https://github.com/esphome/esphome/issues/10220)
# RTL8720C (ambz2) requires FreeRTOS 10.x so this only applies to RTL8710B
@@ -0,0 +1,13 @@
// LN882x: a zero-size pvPortMalloc trips the SDK's malloc-failed LN_ASSERT; ask for 1 byte instead.
#ifdef USE_LN882X
#include <stddef.h>
void *__real_pvPortMalloc(size_t size); // NOLINT(readability-identifier-naming)
void *__wrap_pvPortMalloc(size_t size) { // NOLINT(readability-identifier-naming)
return __real_pvPortMalloc(size == 0 ? 1 : size);
}
#endif // USE_LN882X