blob: 55d3521b67552c203fdfb43d4d90f57a88b3b23e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/* Read all registers from the FPGA. In some cases, this will be garbage;
* in other cases, it will be the core name and version strings.
*/
#include "stm32f4xx_hal.h"
#include "stm-init.h"
#include "stm-led.h"
#include "stm-fmc.h"
#include "stm-uart.h"
#define CORE_SIZE (0x100)
#define SEGMENT_SIZE (0x40 * CORE_SIZE)
#define SEGMENT_OFFSET_GLOBALS (0 * SEGMENT_SIZE)
#define SEGMENT_OFFSET_HASHES (1 * SEGMENT_SIZE)
#define BOARD_ADDR_BASE (SEGMENT_OFFSET_GLOBALS + (0 * CORE_SIZE))
#define COMM_ADDR_BASE (SEGMENT_OFFSET_GLOBALS + (1 * CORE_SIZE))
#define SHA1_ADDR_BASE (SEGMENT_OFFSET_HASHES + (0 * CORE_SIZE))
#define SHA256_ADDR_BASE (SEGMENT_OFFSET_HASHES + (1 * CORE_SIZE))
#define SHA512_ADDR_BASE (SEGMENT_OFFSET_HASHES + (2 * CORE_SIZE))
static uint32_t read0(uint32_t addr)
{
uint32_t data;
if (fmc_read_32(addr, &data) != 0) {
uart_send_string("fmc_read_32 failed\r\n");
Error_Handler();
}
return data;
}
int main(void)
{
int i;
stm_init();
uart_send_string("Keep calm for Novena boot...\r\n");
// Blink blue LED for six seconds to not upset the Novena at boot.
led_on(LED_BLUE);
for (i = 0; i < 12; i++) {
HAL_Delay(500);
led_toggle(LED_BLUE);
}
// prepare fmc interface
fmc_init();
// turn on green led, turn off other leds
led_on(LED_GREEN);
led_off(LED_YELLOW);
led_off(LED_RED);
led_off(LED_BLUE);
for (uint32_t addr = 0; addr < 0x00080000; addr += 4) {
uint32_t data = read0(addr);
if (data != 0) {
uart_send_hex(addr, 8);
uart_send_string(": ");
uart_send_hex(data, 8);
uart_send_char(' ');
for (int i = 24; i >= 0; i -= 8) {
uint8_t c = (data >> i) & 0xff;
if (c < 0x20 || c > 0x7e)
uart_send_char('.');
else
uart_send_char(c);
}
uart_send_string("\r\n");
}
}
uart_send_string("Done.\r\n");
return 0;
}
|