Skip to content

Commit

Permalink
esp32c3_supermini: Fix: Switch from SRAM0 to SRAM1 to correct heap ca…
Browse files Browse the repository at this point in the history
…lculations

This resolves incorrect heap calculations in malloc_prepare() caused
by using sram0. The calculation of

```
HEAP_SIZE = KB(CONFIG_SRAM_SIZE) - (HEAP_BASE - CONFIG_SRAM_BASE_ADDRESS)
 => 16kb - (0x3fc8d230 - 0x4037c000) => 7115kb
```

produces an invalid heap size. SRAM0 only supports IBUS addresses,
whereas HEAP_BASE is derived from SRAM1's DBUS addresses, which are
incompatible. Switching to SRAM1 corrects the calculation and ensures
alignment with other ESP32C3 SoCs:

```
HEAP_SIZE = 384kb - (0x3fc8d1f0 - 0x3fc80000) => 331kb
```

Compiling basic/minimal with CONFIG_ASSERT=y would previously trigger
the following assertion:

```
ASSERTION FAIL [bytes / 8U <= 0x7fffU] @ WEST_TOPDIR/zephyr/lib/heap/heap.c:491
        heap size is too big
```

This change prevents that error.

Signed-off-by: Raphael Zimmerer <[email protected]>
  • Loading branch information
killekulla committed Jan 20, 2025
1 parent ebbdb10 commit 9eb6d44
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion boards/others/esp32c3_supermini/esp32c3_supermini.dts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
compatible = "espressif,esp32c3_supermini";

chosen {
zephyr,sram = &sram0;
zephyr,sram = &sram1;
zephyr,console = &usb_serial;
zephyr,shell-uart = &usb_serial;
zephyr,flash = &flash0;
Expand Down

0 comments on commit 9eb6d44

Please sign in to comment.