|
@@ -1,6 +1,4 @@
|
|
-#include <stddef.h>
|
|
|
|
-#include <stdint.h>
|
|
|
|
-
|
|
|
|
|
|
+#include "fw.h"
|
|
#include "io.h"
|
|
#include "io.h"
|
|
#include "console.h"
|
|
#include "console.h"
|
|
|
|
|
|
@@ -42,19 +40,18 @@ static inline void write_check(volatile uint32_t *p, uint32_t v)
|
|
|
|
|
|
static void test_sdram(void)
|
|
static void test_sdram(void)
|
|
{
|
|
{
|
|
|
|
+ const unsigned int sdram_words = SDRAM_SIZE >> 2;
|
|
static unsigned int stride = 4;
|
|
static unsigned int stride = 4;
|
|
uint32_t start_time = rdtime();
|
|
uint32_t start_time = rdtime();
|
|
uint32_t w = 0;
|
|
uint32_t w = 0;
|
|
uint32_t n;
|
|
uint32_t n;
|
|
-
|
|
|
|
|
|
|
|
con_printf("Testing SDRAM from 0x%08x to 0x%08x, stride 0x%08x...\r\n",
|
|
con_printf("Testing SDRAM from 0x%08x to 0x%08x, stride 0x%08x...\r\n",
|
|
SDRAM_ADDR, SDRAM_END, stride);
|
|
SDRAM_ADDR, SDRAM_END, stride);
|
|
|
|
|
|
- n = 0;
|
|
|
|
err_char = '-';
|
|
err_char = '-';
|
|
rate_limit = ERROR_RATELIMIT;
|
|
rate_limit = ERROR_RATELIMIT;
|
|
- do {
|
|
|
|
|
|
+ for (n = 1, w = 0; n <= sdram_words; n++) {
|
|
uint32_t a = w + SDRAM_ADDR;
|
|
uint32_t a = w + SDRAM_ADDR;
|
|
volatile uint32_t *p = (volatile uint32_t *)a;
|
|
volatile uint32_t *p = (volatile uint32_t *)a;
|
|
|
|
|
|
@@ -64,36 +61,37 @@ static void test_sdram(void)
|
|
write_check(p, w);
|
|
write_check(p, w);
|
|
write_check(p, A*w + B);
|
|
write_check(p, A*w + B);
|
|
|
|
|
|
- if (!(++n & 0x3ffff)) {
|
|
|
|
|
|
+ if (!(n & 0x3ffff)) {
|
|
CONSOLE = err_char;
|
|
CONSOLE = err_char;
|
|
err_char = '-';
|
|
err_char = '-';
|
|
}
|
|
}
|
|
|
|
|
|
w = (w + stride) & SDRAM_MASK;
|
|
w = (w + stride) & SDRAM_MASK;
|
|
- } while (w);
|
|
|
|
|
|
+ }
|
|
|
|
|
|
con_puts("\r\nReading back to check for aliases...\r\n");
|
|
con_puts("\r\nReading back to check for aliases...\r\n");
|
|
|
|
|
|
rate_limit = ERROR_RATELIMIT;
|
|
rate_limit = ERROR_RATELIMIT;
|
|
- do {
|
|
|
|
|
|
+ for (n = 1, w = 0; n <= sdram_words; n++) {
|
|
uint32_t a = w + SDRAM_ADDR;
|
|
uint32_t a = w + SDRAM_ADDR;
|
|
volatile uint32_t *p = (volatile uint32_t *)a;
|
|
volatile uint32_t *p = (volatile uint32_t *)a;
|
|
|
|
|
|
data_check(p, A*w + B);
|
|
data_check(p, A*w + B);
|
|
|
|
|
|
- if (!(++n & 0x3ffff)) {
|
|
|
|
|
|
+ if (!(n & 0x3ffff)) {
|
|
CONSOLE = err_char;
|
|
CONSOLE = err_char;
|
|
err_char = '-';
|
|
err_char = '-';
|
|
}
|
|
}
|
|
|
|
|
|
w = (w - stride) & SDRAM_MASK;
|
|
w = (w - stride) & SDRAM_MASK;
|
|
- } while (w);
|
|
|
|
|
|
+ }
|
|
|
|
|
|
con_printf("\rSDRAM test complete, time = %u ms\r\n",
|
|
con_printf("\rSDRAM test complete, time = %u ms\r\n",
|
|
(rdtime() - start_time)/(CPU_CLK_HZ/1000));
|
|
(rdtime() - start_time)/(CPU_CLK_HZ/1000));
|
|
|
|
|
|
stride *= 3;
|
|
stride *= 3;
|
|
- stride = ((stride & SDRAM_MASK) ^ (stride >> (SDRAM_ADDR_BITS-2))) & ~3;
|
|
|
|
|
|
+ stride = (stride & SDRAM_MASK) ^ (stride >> (SDRAM_ADDR_BITS-2));
|
|
|
|
+ stride = (stride & ~3) | 4;
|
|
}
|
|
}
|
|
|
|
|
|
void main(void)
|
|
void main(void)
|
|
@@ -102,9 +100,9 @@ void main(void)
|
|
"*** Hello, World! ***\r\n"
|
|
"*** Hello, World! ***\r\n"
|
|
"Firmware compiled on: " __DATE__ " " __TIME__ "\r\n\n";
|
|
"Firmware compiled on: " __DATE__ " " __TIME__ "\r\n\n";
|
|
uint8_t led = 0;
|
|
uint8_t led = 0;
|
|
- uint8_t loops;
|
|
|
|
|
|
+ unsigned int loops;
|
|
|
|
|
|
- con_set_baudrate(115200);
|
|
|
|
|
|
+ con_set_baudrate(2000000);
|
|
set_led(led = 0);
|
|
set_led(led = 0);
|
|
|
|
|
|
while ( 1 ) {
|
|
while ( 1 ) {
|