mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
software: add memtest
This commit is contained in:
parent
e42a42ce40
commit
379a48bb31
3 changed files with 108 additions and 0 deletions
50
software/memtest/Makefile
Normal file
50
software/memtest/Makefile
Normal file
|
@ -0,0 +1,50 @@
|
|||
M2DIR=../..
|
||||
include $(M2DIR)/software/common.mak
|
||||
|
||||
OBJECTS=isr.o main.o
|
||||
|
||||
all: memtest.bin
|
||||
|
||||
# pull in dependency info for *existing* .o files
|
||||
-include $(OBJECTS:.o=.d)
|
||||
|
||||
%.bin: %.elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
chmod -x $@
|
||||
|
||||
memtest.elf: $(OBJECTS) libs
|
||||
|
||||
%.elf:
|
||||
$(LD) $(LDFLAGS) \
|
||||
-T $(M2DIR)/software/libbase/linker-sdram.ld \
|
||||
-N -o $@ \
|
||||
$(M2DIR)/software/libbase/crt0.o \
|
||||
$(OBJECTS) \
|
||||
-L$(M2DIR)/software/libbase \
|
||||
-L$(M2DIR)/software/libcompiler-rt \
|
||||
-lbase -lcompiler-rt
|
||||
chmod -x $@
|
||||
|
||||
main.o: main.c
|
||||
$(compile-dep)
|
||||
|
||||
%.o: %.c
|
||||
$(compile-dep)
|
||||
|
||||
%.o: %.S
|
||||
$(assemble)
|
||||
|
||||
libs:
|
||||
$(MAKE) -C $(M2DIR)/software/libcompiler-rt
|
||||
$(MAKE) -C $(M2DIR)/software/libbase
|
||||
|
||||
load: memtest.bin
|
||||
$(MAKE) -C $(M2DIR)/tools
|
||||
$(M2DIR)/tools/flterm --port /dev/ttyUSB0 --kernel memtest.bin
|
||||
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJECTS) $(OBJECTS:.o=.d) memtest.elf memtest.bin
|
||||
$(RM) .*~ *~
|
||||
|
||||
.PHONY: all main.o clean libs load
|
14
software/memtest/isr.c
Normal file
14
software/memtest/isr.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <hw/csr.h>
|
||||
#include <irq.h>
|
||||
#include <uart.h>
|
||||
|
||||
void isr(void);
|
||||
void isr(void)
|
||||
{
|
||||
unsigned int irqs;
|
||||
|
||||
irqs = irq_pending() & irq_getmask();
|
||||
|
||||
if(irqs & (1 << UART_INTERRUPT))
|
||||
uart_isr();
|
||||
}
|
44
software/memtest/main.c
Normal file
44
software/memtest/main.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <irq.h>
|
||||
#include <uart.h>
|
||||
#include <time.h>
|
||||
#include <hw/csr.h>
|
||||
#include <hw/flags.h>
|
||||
#include <console.h>
|
||||
|
||||
static void membw_service(void)
|
||||
{
|
||||
static int last_event;
|
||||
unsigned long long int nr, nw;
|
||||
unsigned long long int f;
|
||||
unsigned int rdb, wrb;
|
||||
|
||||
if(elapsed(&last_event, identifier_frequency_read())) {
|
||||
lasmicon_bandwidth_update_write(1);
|
||||
nr = lasmicon_bandwidth_nreads_read();
|
||||
nw = lasmicon_bandwidth_nwrites_read();
|
||||
f = identifier_frequency_read();
|
||||
rdb = nr*f >> (24 - 7);
|
||||
wrb = nw*f >> (24 - 7);
|
||||
printf("read:%4dMbps write:%4dMbps all:%4dMbps\n", rdb/1000000, wrb/1000000, (rdb + wrb)/1000000);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
irq_setmask(0);
|
||||
irq_setie(1);
|
||||
uart_init();
|
||||
|
||||
puts("Memory testing software built "__DATE__" "__TIME__"\n");
|
||||
|
||||
time_init();
|
||||
|
||||
while(1) {
|
||||
membw_service();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue