A simple program that runs inside the Embive interpreter.
- GCC (riscv32-unknown-elf)
- Download the RISC-V toolchain
- Install the dependencies from the README
- Compile and install it:
$ ./configure --prefix=/opt/riscv --with-arch=rv32imaczicsr_zifencei --with-abi=ilp32
$ make -j8
- Add
/opt/riscv/bin
to your PATH
- Nim (v2.2.2 or greater)
- Install latest stable release:
curl https://nim-lang.org/choosenim/init.sh -sSf | sh
- Install latest stable release:
- Compile the project
$ nim build project
- Create a new project
$ cargo new embive-project && cd embive-project
- Add Embive as a dependency
$ cargo add embive
- Copy the example from Embive's docs/readme.
- Change the code to:
const ELF_FILE: &[u8] = include_bytes!("../app.elf");
- Copy the generated
app.elf
(insideout
folder) to your project - Run it:
$ cargo run --release
By default, the stack size is set to 2048 bytes (0x800).
You can change this by modifying the STACK_SIZE
variable in the linker script.
The heap is set at the end of the memory space allocated by the application (after data and stack).
As such, the heap size doesn't need to be known at link time, instead being able to grow as large
as the maximum memory available.
You can calculate the minimum amount of RAM needed by you application with the following equation:
total_ram = data + bss
To get the data
and bss
sizes, you can run:
$ riscv32-unknown-elf-size out/app.elf
- The stack and heap will be reported as part of the bss
The result should be something like this:
text data bss dec hex filename
348 8 2060 2416 970 out/app.elf
For this result, our minimum RAM size would be:
total_ram = 8 + 2060 = 2068 bytes