m9 and rng polishing

This commit is contained in:
liquidraver committed 2026-07-21 22:49:48 +02:00
1 parent 24936cc4e5
commit 076fbb7ff3
6 files changed
+328 -20

No files matched your search

+24 -2
View File
@@ -60,8 +60,30 @@ CONFIG_BT_BUF_EVT_RX_COUNT=14
CONFIG_ESP32_BT_CTLR_LE_SECURITY_ENABLE=y
# ========== Heap ==========
# ESP32 BLE stack requires larger heap (override zephcore_common 2KB default)
CONFIG_HEAP_MEM_POOL_SIZE=32768
# ESP32 BLE stack requires larger heap (override zephcore_common 2KB default).
#
# 32768 was NOT enough and failed non-obviously. The Espressif controller
# allocates its exchange memory through esp_bt_malloc_func(), which the Zephyr
# port maps to k_malloc() (esp_heap_adapter.h, CONFIG_ESP_BT_HEAP_SYSTEM=y) —
# i.e. straight out of this pool. esp_bt_controller_init() asks for 0x7800 =
# 30720 bytes in ONE allocation: 93.75% of a 32 KB pool, leaving 2 KB for block
# overhead and every other k_malloc user that ran before bt_enable(). Boards
# that allocated little before BLE init happened to fit; ThinkNode M9 (display +
# colour overlay, STC8H keypad, LR1110) did not, and the blob asserted inside
# its own allocator instead of returning ESP_ERR_NO_MEM:
#
# BLE assert emi.c 164, param 00000000 00007800 <- (NULL, requested size)
#
# Zephyr's own driver anticipates this and prints "Consider increasing
# CONFIG_HEAP_MEM_POOL_SIZE" (drivers/bluetooth/hci/hci_esp32.c) — but only on
# the graceful path the blob does not take. Every ESP32 board was one
# allocation away from the same failure, so this is raised platform-wide.
#
# Headroom verified by build on all 12 shipped ESP32 boards: the S3/C3/C6 boards
# have 66-135 KB free internal DRAM and absorb this easily. ttgo_tbeam is the
# sole exception (99.45% DRAM, 768 B free) and overrides it back in its
# board.conf — see the note there.
CONFIG_HEAP_MEM_POOL_SIZE=65536
# ========== Flash ==========
# 4MB is standard for XIAO/LilyGo RISC-V boards.
@@ -47,13 +47,26 @@
};
};
/* Reduce CPU clock from 240 MHz to 160 MHz — HAL Kconfig minimum supported */
/* 240 MHz — matches every other ESP32-S3 board in the tree (xiao_esp32s3,
* station_g2, heltec_*). This was 160 MHz with the comment "HAL Kconfig
* minimum supported", which is not correct: hal/espressif/zephyr/Kconfig
* derives ESP_DEFAULT_CPU_FREQ_MHZ straight from this DT property and offers
* 96/120/160/240 with no floor at 160. Nothing on this board requires the
* lower clock (the octal PSRAM runs at 40 MHz off its own divider, and
* station_g2 pairs the same OPI PSRAM with 240 MHz).
*
* Kept deliberate rather than "faster is better": the node is event-driven and
* idles in k_event_wait almost always, so race-to-idle makes the clock a weak
* lever on battery life, while the 320x240 colour panel is the one genuinely
* CPU-bound consumer. 240 also removes this board's only timing anomaly,
* which matters while the CPU-jitter entropy source is under investigation
* (jitter health check failed here — see memory/findings.md). */
&cpu0 {
clock-frequency = <DT_FREQ_M(160)>;
clock-frequency = <DT_FREQ_M(240)>;
};
&cpu1 {
clock-frequency = <DT_FREQ_M(160)>;
clock-frequency = <DT_FREQ_M(240)>;
};
&usb_serial {
@@ -41,3 +41,17 @@ CONFIG_ESPTOOLPY_FLASHMODE_DIO=y
CONFIG_ZEPHCORE_MAX_CONTACTS=140
CONFIG_ZEPHCORE_MAX_CHANNELS=8
CONFIG_ZEPHCORE_OFFLINE_QUEUE_SIZE=128
# BLE controller heap — hold this board at the old 32 KB.
#
# esp32_common.conf raises CONFIG_HEAP_MEM_POOL_SIZE to 65536 because the
# Espressif controller allocates 30720 bytes out of it in one go and 32 KB left
# no margin (see the long note there). This board cannot pay for it: measured
# at 139684/140452 B = 99.45% DRAM, only 768 bytes free, so +32 KB does not
# link. Holding it here keeps T-Beam exactly as it builds today.
#
# NOT a fix — this board still runs the controller on the same 2 KB margin that
# broke ThinkNode M9, and its classic-ESP32 controller draws from the same pool.
# Making T-Beam safe needs DRAM reclaimed (contacts/queue are already trimmed
# above), not a larger number here. Tracked separately.
CONFIG_HEAP_MEM_POOL_SIZE=32768