- improved test
git-svn-id: http://moon:8086/svn/mips@41 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
+70
-10
@@ -1,5 +1,8 @@
|
||||
#include "libsys_boot.h"
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(*a))
|
||||
#define SDRAM_SIZE (32*1024*1024)
|
||||
|
||||
void handler3(void)
|
||||
{
|
||||
volatile uint32_t *pUART0_stat = (uint32_t*)SYS_UART_STAT;
|
||||
@@ -14,13 +17,29 @@ void handler3(void)
|
||||
|
||||
void main()
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t i, j;
|
||||
uint32_t data;
|
||||
uint8_t led = 0;
|
||||
volatile uint32_t *pUART0_stat = (uint32_t*)SYS_UART_STAT;
|
||||
volatile uint32_t *pGPIO = (uint32_t*)SYS_GPIO_0_DATA;
|
||||
volatile uint32_t *pGPIODIR = (uint32_t*)SYS_GPIO_0_DIR;
|
||||
volatile uint32_t *pSDRAM = (uint32_t*)FLASH_BASE_MEM;
|
||||
volatile uint32_t *pSDRAM32 = (uint32_t*)FLASH_BASE_MEM;
|
||||
volatile uint16_t *pSDRAM16 = (uint16_t*)FLASH_BASE_MEM;
|
||||
volatile uint8_t *pSDRAM8 = (uint8_t*)FLASH_BASE_MEM;
|
||||
|
||||
uint32_t test_pattern [] =
|
||||
{
|
||||
0x00000000,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0x0000FF00,
|
||||
0x00FF0000,
|
||||
0xFF000000,
|
||||
0x10101010,
|
||||
0x01010101,
|
||||
0x55AA55AA,
|
||||
0xAA55AA55
|
||||
};
|
||||
|
||||
CP0_SR_write(0x0060000D);
|
||||
*pGPIODIR = GPIO_0_DFLT_DIR;
|
||||
@@ -38,22 +57,63 @@ void main()
|
||||
sputs("Iteration # ");print_word(led);sputs("\n");
|
||||
|
||||
*pGPIO = led;
|
||||
data = 0x10011111;
|
||||
for (i=0; i < 16; i++)
|
||||
|
||||
sputs("Testing SDRAM (pattern)\n");
|
||||
for (j=0; j < ARRAY_SIZE(test_pattern); j++)
|
||||
{
|
||||
pSDRAM[i] = data;
|
||||
data += 0x10011111;
|
||||
for (i=0; i < SDRAM_SIZE/4; i++)
|
||||
{
|
||||
pSDRAM32[i] = test_pattern[j];
|
||||
}
|
||||
DCACHE_invalidate_all();
|
||||
for (i=0; i < SDRAM_SIZE/4; i++)
|
||||
{
|
||||
data = pSDRAM32[i];
|
||||
if (data != test_pattern[j])
|
||||
{
|
||||
sputs("\n");
|
||||
sputs("Pattern "); print_word(test_pattern[j]); sputs("\n");
|
||||
sputs("Error at address "); print_word(i); sputs("\n");
|
||||
sputs("Read "); print_word(data); sputs("\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
sputs(".");
|
||||
}
|
||||
sputs("\n");
|
||||
|
||||
sputs("Testing SDRAM (32-bit write)\n");
|
||||
data = 0x00010203;
|
||||
for (i=0; i < 256/4; i++)
|
||||
{
|
||||
pSDRAM32[i] = data;
|
||||
data += 0x04040404;
|
||||
}
|
||||
DCACHE_invalidate_all();
|
||||
for (i=0; i < 16; i++)
|
||||
memdump((uint8_t*)pSDRAM32, 0, 16, 256);
|
||||
sputs("\n");
|
||||
|
||||
sputs("Testing SDRAM (16-bit write)\n");
|
||||
data = 0x0001;
|
||||
for (i=0; i < 256/2; i++)
|
||||
{
|
||||
sputs("SDRAM");print_word(pSDRAM[i]);sputs("\n");
|
||||
pSDRAM16[i] = data;
|
||||
data += 0x0202;
|
||||
}
|
||||
DCACHE_invalidate_all();
|
||||
memdump((uint8_t*)pSDRAM16, 0, 16, 256);
|
||||
sputs("\n");
|
||||
|
||||
if(led == 0)
|
||||
sputs("Testing SDRAM (8-bit write)\n");
|
||||
data = 0x00;
|
||||
for (i=0; i < 256; i++)
|
||||
{
|
||||
memdump((uint8_t*)pSDRAM, 0, 16, 256);
|
||||
pSDRAM8[i] = data;
|
||||
data += 0x01;
|
||||
}
|
||||
DCACHE_invalidate_all();
|
||||
memdump((uint8_t*)pSDRAM8, 0, 16, 256);
|
||||
sputs("\n");
|
||||
|
||||
led = (led+1) % 64;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user