From 274f347d90b40c63cfcc3643411c57756577079f Mon Sep 17 00:00:00 2001 From: Toby Jaffey Date: Mon, 8 Dec 2025 10:35:42 +0000 Subject: [PATCH] Break console io example out into own app --- apps/Makefile | 2 ++ apps/conio/Makefile | 27 +++++++++++++++++++++++++++ apps/conio/conio.c | 15 +++++++++++++++ apps/helloworld/helloworld.c | 10 ---------- precompiled/conio.bin | Bin 0 -> 150 bytes 5 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 apps/conio/Makefile create mode 100644 apps/conio/conio.c create mode 100755 precompiled/conio.bin diff --git a/apps/Makefile b/apps/Makefile index 82fd82a..133cabb 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -4,6 +4,7 @@ all: docker build -t ${DOCKER_IMAGE} . (cd sketch && make) (cd helloworld && make) + (cd conio && make) (cd zig-mandel && make) (cd zigtris && make) (cd rust-hello && make) @@ -12,6 +13,7 @@ all: clean: (cd sketch && make clean) (cd helloworld && make clean) + (cd conio && make clean) (cd zig-mandel && make clean) (cd zigtris && make clean) (cd rust-hello && make clean) diff --git a/apps/conio/Makefile b/apps/conio/Makefile new file mode 100644 index 0000000..5f7714c --- /dev/null +++ b/apps/conio/Makefile @@ -0,0 +1,27 @@ +PROJECT:=conio + +DOCKER_IMAGE=riscv-dev +DOCKER_CMD:=docker run --rm -v ${PWD}../../../:/data -w /data/apps/${PROJECT} ${DOCKER_IMAGE} +PREFIX:=${DOCKER_CMD} riscv64-unknown-elf- +CFLAGS+=-I../../common +CFLAGS+=-fno-stack-protector +CFLAGS+=-static-libgcc -fdata-sections -ffunction-sections +CFLAGS+=-g -Os -march=rv32ima_zicsr -mabi=ilp32 -static +LDFLAGS:= -T ../linker.ld -nostdlib -Wl,--gc-sections +LIBS:= #-lgcc # needed for softfp + +SRCS=${PROJECT}.c ../crt0.S + +all: + ${PREFIX}gcc -o ${PROJECT}.elf ${CFLAGS} ${LDFLAGS} ${SRCS} ${LIBS} + $(PREFIX)objcopy ${PROJECT}.elf -O binary ${PROJECT}.bin + +disasm: all + $(PREFIX)objdump -S -d -f ${PROJECT}.elf + +test: all + ../../host/host ${PWD}/${PROJECT}.bin + +clean: + rm -f ${PROJECT}.o ${PROJECT}.elf ${PROJECT}.bin + diff --git a/apps/conio/conio.c b/apps/conio/conio.c new file mode 100644 index 0000000..fdc83c5 --- /dev/null +++ b/apps/conio/conio.c @@ -0,0 +1,15 @@ +#define USE_MAIN +#include "uvm32_target.h" + +void main(void) { + uint32_t c; + println("Press a key!"); + while(c = getc()) { + if (c != 0xFFFFFFFF) { + print("Got: "); + printx(c); + println(""); + } + } +} + diff --git a/apps/helloworld/helloworld.c b/apps/helloworld/helloworld.c index 6d248a4..90cf4b9 100644 --- a/apps/helloworld/helloworld.c +++ b/apps/helloworld/helloworld.c @@ -5,15 +5,5 @@ void main(void) { for (int i=0;i<10;i++) { printd(i); } -#if 0 - uint32_t c; - while(c = getc()) { - if (c != 0xFFFFFFFF) { - print("Got: "); - printx(c); - println(""); - } - } -#endif } diff --git a/precompiled/conio.bin b/precompiled/conio.bin new file mode 100755 index 0000000000000000000000000000000000000000..97cdf8b081cd1be5a1b1891c45064074fff74faf GIT binary patch literal 150 zcmY#Z6J&VLz`!_}qd~Zs0Rqff85)FHSve+iYygW1vw!$6%*wzpnL|JXq-JtED?{=W zR)+Kj28PEi&;LQyb57=109HSl