Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
another test, long loop for long tests
- Loading branch information
Showing
2 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |