mirror of
https://github.com/esphome/esphome.git
synced 2026-10-08 03:54:03 +00:00
[libretiny] Keep a scan that finds no networks from resetting the LN882x (#20169)
This commit is contained in:
@@ -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,19 @@
|
||||
/*
|
||||
* LN882x: heap_5 returns NULL for a zero-size request, and the SDK's
|
||||
* malloc-failed hook ends in LN_ASSERT(0), which spins until the watchdog
|
||||
* resets the chip. LibreTiny's scan handler asks for zero entries when a scan
|
||||
* finds no networks. Linked with -Wl,--wrap=pvPortMalloc so every allocation
|
||||
* comes through here; drop it once LibreTiny no longer allocates zero entries.
|
||||
*/
|
||||
|
||||
#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
|
||||
Reference in New Issue
Block a user