From 24a27f39fe9b6d06d667982f6b9773781b0352fa Mon Sep 17 00:00:00 2001 From: mariusmonton Date: Mon, 18 Feb 2019 23:28:46 +0100 Subject: [PATCH] another test, long loop for long tests --- tests/C/long_test1/Makefile | 52 +++++++++++++++++++++++++ tests/C/long_test1/long_test1.c | 68 +++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 tests/C/long_test1/Makefile create mode 100644 tests/C/long_test1/long_test1.c diff --git a/tests/C/long_test1/Makefile b/tests/C/long_test1/Makefile new file mode 100644 index 0000000..7e1030b --- /dev/null +++ b/tests/C/long_test1/Makefile @@ -0,0 +1,52 @@ +TARGET = long_test1 + +TARGET_ARCH=riscv32 + +CC = riscv32-unknown-elf-gcc + +# compiling flags here +CFLAGS = -Wall -I. -O0 -static -march=rv32imac -mabi=ilp32 --specs=nosys.specs + + +LINKER = riscv32-unknown-linux-gnu-gcc +# linking flags here +LDFLAGS = -I. --entry main -L/opt/riscv/riscv32-unknown-elf/lib/ -T ld_script.ld +LIBS = $(EXTRA_LIBS) + + +# change these to proper directories where each file should be +SRCDIR = ./ +OBJDIR = . +BINDIR = ./ +INCDIR = -I. +LIBDIR = -L. + + +SOURCES := $(wildcard $(SRCDIR)/*.c) +INCLUDES := $(wildcard $(INCDIR)/*.h) +OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o) + +rm = rm -f + + +$(BINDIR)/$(TARGET): $(OBJECTS) +# $(LINKER) $(OBJECTS) $(LDFLAGS) $(LIBS) $(LIBDIR) -o $@ + riscv32-unknown-linux-gnu-objdump -d $< > dump + objcopy -Oihex $< $(TARGET).hex +# @echo "Linking complete!" + +$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c + @echo "Compiling "$<" ..." +# $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@ + $(CC) $(CFLAGS) $(INCDIR) $< -o $@ + @echo "Done!" + +.PHONY: clean +clean: + @$(rm) $(OBJECTS) *.hex dump + @echo "Cleanup complete!" + +.PHONY: remove +remove: clean + @$(rm) $(BINDIR)/$(TARGET) + @echo "Executable removed!" diff --git a/tests/C/long_test1/long_test1.c b/tests/C/long_test1/long_test1.c new file mode 100644 index 0000000..d2d8a70 --- /dev/null +++ b/tests/C/long_test1/long_test1.c @@ -0,0 +1,68 @@ +#include +#include + +#define TRACE (*(unsigned char *)0x40000000) +int _read(int file, char* ptr, int len) { + return 0; +} + +int _close(int fd){ + return 0; +} + +int _fstat_r(int fd) { + return 0; +} + +int _lseek_r(struct _reent *ptr, FILE *fp, long offset, int whence){ + return 0; +} + +int _isatty_r(struct _reent *ptr, int fd) { + return 0; +} + +int _write(int file, const char *ptr, int len) { + int x; + + for (x = 0; x < len; x++) { + TRACE = *ptr++; + } + + return (len); +} + +int main(void) { + + int aux[5] = {0, 1, 2, 3, 4}; + int aux2[5]; + int counter = 0; + + printf("Long test Start\n"); + + + while(1) { + + memcpy(aux2, aux, sizeof(int)*5); + counter++; + + for(int i = 0; i < 5; i++) { + if (aux[i] != aux2[i]) { + printf("ERROR %d\n", i); + asm volatile ("ecall"); + } + } + + if (counter > 10000) { + printf(".\n"); + counter = 0; + } + } + printf("OK!\n"); + + + + asm volatile ("ecall"); + + return 0; +}