Skip to content

Commit 688cc79

Browse files
committed
zephyr/Makefile: Allow to adjust heap size from make command line.
1 parent 13f7a7b commit 688cc79

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

zephyr/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ BOARD ?= qemu_x86
1515
# Zephyr 1.6.0
1616
OUTDIR_PREFIX = $(BOARD)
1717

18+
# Default heap size is 16KB, which is on conservative side, to let
19+
# it build for smaller boards, but it won't be enough for larger
20+
# applications, and will need to be increased.
21+
MICROPY_HEAP_SIZE = 16384
1822
FROZEN_DIR = scripts
1923

2024
# Zephyr (generated) config files - must be defined before include below
@@ -52,7 +56,7 @@ SRC_QSTR += $(SRC_C)
5256
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
5357

5458
CFLAGS = $(KBUILD_CFLAGS) $(NOSTDINC_FLAGS) $(ZEPHYRINCLUDE) \
55-
-std=gnu99 -DNDEBUG $(INC)
59+
-std=gnu99 -DNDEBUG -DMICROPY_HEAP_SIZE=$(MICROPY_HEAP_SIZE) $(INC)
5660

5761
include ../py/mkrules.mk
5862

zephyr/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
5858
}
5959

6060
static char *stack_top;
61-
static char heap[16 * 1024];
61+
static char heap[MICROPY_HEAP_SIZE];
6262

6363
int real_main(void) {
6464
int stack_dummy;

zephyr/mpconfigport.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
// Include Zephyr's autoconf.h, which should be made first by Zephyr makefiles
2929
#include "autoconf.h"
3030

31+
// Usually passed from Makefile
32+
#ifndef MICROPY_HEAP_SIZE
33+
#define MICROPY_HEAP_SIZE (16 * 1024)
34+
#endif
35+
3136
#define MICROPY_STACK_CHECK (1)
3237
#define MICROPY_ENABLE_GC (1)
3338
#define MICROPY_HELPER_REPL (1)

0 commit comments

Comments
 (0)