BOOT-TEST: Memory test, terminal writes, GPIO square wave

This commit is contained in:
Klemens Schölhorn 2018-04-19 01:35:02 +02:00
parent 87bb3a5f24
commit 10c26c0f7b
3 changed files with 51 additions and 5 deletions

View File

@ -8,7 +8,7 @@
.globl _prog_start
_prog_start:
smp_pause(s1, s2)
li sp, (PAYLOAD_DEST + 0x7fff000)
li sp, (PAYLOAD_DEST + 0xffff000)
call main
smp_resume(s1, s2)
csrr a0, mhartid

View File

@ -20,7 +20,8 @@ static volatile uint32_t * const uart = (void *)(UART_CTRL_ADDR);
static inline void kputc(char c)
{
volatile uint32_t *tx = &REG32(uart, UART_REG_TXFIFO);
//volatile uint32_t *tx = &REG32(uart, UART_REG_TXFIFO);
volatile uint32_t *tx = (void *) 0x64003000; // Terminal (32 bit)
#ifdef __riscv_atomic
int32_t r;
do {

View File

@ -12,7 +12,7 @@
#define PAYLOAD_SIZE (16 << 11)
#define F_CLK 50000000UL
#define F_CLK 60000000UL
static volatile uint32_t * const spi = (void *)(SPI_CTRL_ADDR);
@ -202,10 +202,55 @@ static int copy(void)
return rc;
}
// leave room for 2 MiB stack (SP = 8FFFF000)
#define RAMTEST_START (uint32_t*)(0x80000000)
#define RAMTEST_END (uint32_t*)(0x8FDFF000)
int main(void)
{
REG32(uart, UART_REG_TXCTRL) = UART_TXEN;
//REG32(uart, UART_REG_TXCTRL) = UART_TXEN;
//GPIO_REG(GPIO_INPUT_EN) = 0xFF;
GPIO_REG(GPIO_OUTPUT_EN) = 0xFF;
GPIO_REG(GPIO_OUTPUT_VAL) = 0xFF;
kprintf("\nFilling RAM from %lx to %lx...\n", RAMTEST_START, RAMTEST_END);
uint32_t counter = 0;
for(uint32_t* ram = RAMTEST_START; ram < RAMTEST_END; ++ram) {
*ram = counter++;
if((counter % 1024) == 0) {
kprintf("\r%lx", ram);
}
}
kprintf("\rChecking RAM...\n");
counter = 0;
uint32_t correct = 0;
uint32_t wrong = 0;
for(uint32_t* ram = RAMTEST_START; ram < RAMTEST_END; ++ram) {
if(*ram != counter) {
kprintf("\rMismatch at %lx: read %x, expected %x\n", ram, *ram, counter);
++wrong;
} else {
++correct;
}
++counter;
if((counter % 1024) == 0) {
kprintf("\r%lx", ram);
}
}
kprintf("\rSummary: %x matches, %x mismatches.\n", correct, wrong);
while(1) {
//uint8_t dip_value = GPIO_REG(GPIO_INPUT_VAL) & 0b01111111;
//kprintf("dip value: %hx, ram value: %c\n", dip_value, ram[dip_value]);
GPIO_REG(GPIO_OUTPUT_VAL) ^= 0xFF;
}
return 0;
/*
kputs("INIT");
sd_poweron();
if (sd_cmd0() ||
@ -221,5 +266,5 @@ int main(void)
kputs("BOOT");
__asm__ __volatile__ ("fence.i" : : : "memory");
return 0;
return 0;*/
}