10 static inline uint32_t read32(const void *addr
)
12 return *(volatile uint32_t *)addr
;
15 static inline void write32(void *addr
, uint32_t value
)
17 *(volatile uint32_t *)addr
= value
;
27 uint32_t zero0
; // reserved
28 uint32_t zero1
; // reserved
34 void memcpy(void *dest
, void *src
, size_t n
) {
36 //cast src and dest to char*
37 char *src_char
= (char *)src
;
38 char *dest_char
= (char *)dest
;
40 dest_char
[i
] = src_char
[i
]; //copy contents byte by byte
43 void uart_writeuint32(uint32_t val
) {
44 const char lut
[] = { '0', '1', '2', '3', '4', '5', '6', '7',
45 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
46 uint8_t *val_arr
= &val
;
49 for (i
= 0; i
< 4; i
++) {
50 putchar(lut
[(val_arr
[3-i
] >> 4) & 0xF]);
51 putchar(lut
[val_arr
[3-i
] & 0xF]);
60 const int kNumIterations
= 65536;
63 volatile uint32_t *ram
= 0x10000000;
65 puts("Firmware launched...\n");
67 puts("DRAM init... ");
69 struct gramProfile profile
= {
71 0x320, 0x6, 0x200, 0x0
76 struct gramProfile profile2
;
77 gram_init(&ctx
, &profile
, (void*)0x10000000,
83 for (size_t i
= 0; i
< 8; i
++) {
85 gram_load_calibration(&ctx
, &profile2
);
86 gram_reset_burstdet(&ctx
);
87 for (size_t j
= 0; j
< 128; j
++) {
90 if (gram_read_burstdet(&ctx
, 0)) {
99 for (size_t i
= 0; i
< 8; i
++) {
100 profile2
.rdly_p1
= i
;
101 gram_load_calibration(&ctx
, &profile2
);
102 gram_reset_burstdet(&ctx
);
103 for (size_t j
= 0; j
< 128; j
++) {
106 if (gram_read_burstdet(&ctx
, 1)) {
114 puts("Auto calibrating... ");
115 res
= gram_generate_calibration(&ctx
, &profile2
);
116 if (res
!= GRAM_ERR_NONE
) {
118 gram_load_calibration(&ctx
, &profile
);
120 gram_load_calibration(&ctx
, &profile2
);
124 puts("Auto calibration profile:");
126 uart_writeuint32(profile2
.rdly_p0
);
128 uart_writeuint32(profile2
.rdly_p1
);
131 puts("DRAM test... \n");
132 for (size_t i
= 0; i
< kNumIterations
; i
++) {
133 ram
[i
] = 0xDEAF0000 | i
*4;
136 for (size_t i
= 0; i
< kNumIterations
; i
++) {
137 if (ram
[i
] != (0xDEAF0000 | i
*4)) {
139 uart_writeuint32(&ram
[i
]);
141 uart_writeuint32(ram
[i
]);
146 puts("Test canceled (more than 10 errors)\n");