Skip to content

Commit

Permalink
Fix insufficient memory on some platforms
Browse files Browse the repository at this point in the history
[Problem]
The MEM_SIZE is hard-corded, but on some platforms, memory is
insufficient.
Perhaps we should allow user to config accordingly

[Solution]
Expose an environment variable, CONFIG_MEM_SIZE, to allow user config
the memory size with it

[Test]
* before
$> make
$> ./build/rv32emu ./build/hello.elf
rv32emu: src/riscv.c:199: rv_create: Assertion `attr->mem' failed.
Aborted (core dumped)

* after
$> CONFIG_MEM_SIZE=0x40000000 make
$> ./build/rv32emu ./build/hello.elf
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
inferior exit code 0

[Reference]
[#488](#448)
  • Loading branch information
zyex030640417 committed May 27, 2024
1 parent a968310 commit 3f48e09
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ LDFLAGS += -flto=thin
endif
endif

# Allow user to config the memory size accordingly
ifdef CONFIG_MEM_SIZE
CFLAGS += -DMEM_SIZE=$(CONFIG_MEM_SIZE)
endif

# Disable Intel's Control-flow Enforcement Technology (CET)
CFLAGS += $(CFLAGS_NO_CET)

Expand Down

0 comments on commit 3f48e09

Please sign in to comment.