another test, long loop for long tests

This commit is contained in:
mariusmonton 2019-02-18 23:28:46 +01:00
parent 5ad8ced434
commit 24a27f39fe
2 changed files with 120 additions and 0 deletions

View File

@ -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!"

View File

@ -0,0 +1,68 @@
#include <string.h>
#include <stdio.h>
#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;
}