mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Build arduino code (for AVR) and allow test in qemu
This commit is contained in:
parent
7c9d56ee69
commit
6b2063c6ab
4 changed files with 24 additions and 8 deletions
14
Dockerfile
14
Dockerfile
|
|
@ -3,6 +3,11 @@ ENV LANG C.UTF-8
|
||||||
ENV LC_ALL C.UTF-8
|
ENV LC_ALL C.UTF-8
|
||||||
RUN apt-get -y update
|
RUN apt-get -y update
|
||||||
|
|
||||||
|
# tzdata
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
ENV TZ=Etc/UTC
|
||||||
|
RUN apt-get install -y tzdata
|
||||||
|
|
||||||
# for unity test
|
# for unity test
|
||||||
RUN apt-get install -y ruby xxd
|
RUN apt-get install -y ruby xxd
|
||||||
|
|
||||||
|
|
@ -13,8 +18,8 @@ RUN apt-get install -y gcc-riscv64-unknown-elf build-essential
|
||||||
RUN apt-get install -y curl
|
RUN apt-get install -y curl
|
||||||
RUN curl https://raw.githubusercontent.com/tristanisham/zvm/master/install.sh | bash
|
RUN curl https://raw.githubusercontent.com/tristanisham/zvm/master/install.sh | bash
|
||||||
ENV ZVM_INSTALL /root/.zvm/self
|
ENV ZVM_INSTALL /root/.zvm/self
|
||||||
ENV PATH="$PATH:/root/.zvm/bin:/root/.zvm/self"
|
ENV PATH "$PATH:/root/.zvm/bin:/root/.zvm/self"
|
||||||
ENV export PATH="$/.zvm/bin"
|
ENV PATH "$PATH:/root/.zvm/bin"
|
||||||
RUN zvm i 0.15.2
|
RUN zvm i 0.15.2
|
||||||
|
|
||||||
# rust
|
# rust
|
||||||
|
|
@ -22,3 +27,8 @@ RUN apt-get install -y rustup libclang1
|
||||||
RUN rustup default stable
|
RUN rustup default stable
|
||||||
RUN rustup target add riscv32im-unknown-none-elf
|
RUN rustup target add riscv32im-unknown-none-elf
|
||||||
RUN apt-get install -y libclang1
|
RUN apt-get install -y libclang1
|
||||||
|
|
||||||
|
# arduino
|
||||||
|
RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
|
||||||
|
RUN arduino-cli core install arduino:avr
|
||||||
|
RUN apt-get install -y qemu-system-misc
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ int main(int argc, char *argv[]) {
|
||||||
* [host](host) vm host which loads a binary and runs to completion, handling multiple syscall types
|
* [host](host) vm host which loads a binary and runs to completion, handling multiple syscall types
|
||||||
* [host-mini](host-mini) minimal vm host (shown above), with baked in bytecode
|
* [host-mini](host-mini) minimal vm host (shown above), with baked in bytecode
|
||||||
* [host-parallel](host-parallel) parallel vm host running multiple vm instances concurrently, with baked in bytecode
|
* [host-parallel](host-parallel) parallel vm host running multiple vm instances concurrently, with baked in bytecode
|
||||||
* [host-arduino](host-arduino) vm host as Arduino sketch (tested on Arduino Uno ATmega328P, uses 9950 bytes of flash/1254 bytes RAM)
|
* [host-arduino](host-arduino) vm host as Arduino sketch (`make test` to run AVR code in qemu)
|
||||||
* [apps/helloworld](apps/helloworld) C hello world program
|
* [apps/helloworld](apps/helloworld) C hello world program
|
||||||
* [apps/conio](apps/conio) C console IO demo
|
* [apps/conio](apps/conio) C console IO demo
|
||||||
* [apps/lissajous](apps/lissajous) C console lissajous curve (showing softfp, floating point)
|
* [apps/lissajous](apps/lissajous) C console lissajous curve (showing softfp, floating point)
|
||||||
|
|
@ -112,7 +112,7 @@ Then, from inside the docker shell
|
||||||
|
|
||||||
## Native build
|
## Native build
|
||||||
|
|
||||||
The example VM hosts should all build with any C compiler. To build all of the examples in `apps`, you will need a RISC-V cross compiler, Zig 0.15.2 and Rust (stable).
|
The example VM hosts should all build with any C compiler. To build all of the examples in `apps`, you will need a RISC-V cross compiler, Zig 0.15.2 and Rust (stable). To build the example `host-arduino` you will need `arduino-cli`.
|
||||||
|
|
||||||
## Quickstart API
|
## Quickstart API
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
# The purpose of this Makefile is to auto-generate the Arduino example
|
# Auto-generate the Arduino example
|
||||||
# Arduino cannot set -DUVM32_MEMORY_SIZE, so add a config file
|
# Arduino cannot set -DUVM32_MEMORY_SIZE, so add a config file
|
||||||
# Arduino expects .cpp files
|
# Arduino expects .cpp files
|
||||||
|
|
||||||
make:
|
# make test, runs in qemu
|
||||||
|
|
||||||
|
all:
|
||||||
echo '#include "config.h"' > uvm32.cpp
|
echo '#include "config.h"' > uvm32.cpp
|
||||||
cat ../uvm32/uvm32.c >> uvm32.cpp
|
cat ../uvm32/uvm32.c >> uvm32.cpp
|
||||||
cp ../uvm32/uvm32.h uvm32.h
|
cp ../uvm32/uvm32.h uvm32.h
|
||||||
|
|
@ -10,6 +12,10 @@ make:
|
||||||
cp ../common/uvm32_common_custom.h uvm32_common_custom.h
|
cp ../common/uvm32_common_custom.h uvm32_common_custom.h
|
||||||
cp ../common/uvm32_sys.h uvm32_sys.h
|
cp ../common/uvm32_sys.h uvm32_sys.h
|
||||||
xxd -i ../precompiled/mandel.bin | sed -e "s/unsigned char/const unsigned char/" > mandel.h
|
xxd -i ../precompiled/mandel.bin | sed -e "s/unsigned char/const unsigned char/" > mandel.h
|
||||||
|
arduino-cli compile -b arduino:avr:uno -e
|
||||||
|
|
||||||
|
test: all
|
||||||
|
qemu-system-avr -machine uno -bios build/arduino.avr.uno/host-arduino.ino.elf -nographic -serial mon:stdio
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f uvm32.cpp uvm32.h mini-rv32ima.h uvm32_common_custom.h uvm32_sys.h mandel.h
|
rm -rf uvm32.cpp uvm32.h mini-rv32ima.h uvm32_common_custom.h uvm32_sys.h mandel.h build
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
// Arduino cannot do -DUVM32_MEMORY_SIZE, so set this explicitly
|
// Arduino cannot do -DUVM32_MEMORY_SIZE, so set this explicitly
|
||||||
#define UVM32_MEMORY_SIZE 1024
|
#define UVM32_MEMORY_SIZE 512
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue