aboutsummaryrefslogtreecommitdiff
path: root/projects/board-test/fmc-probe.c
diff options
context:
space:
mode:
Diffstat (limited to 'projects/board-test/fmc-probe.c')
-rw-r--r--projects/board-test/fmc-probe.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/projects/board-test/fmc-probe.c b/projects/board-test/fmc-probe.c
new file mode 100644
index 0000000..55d3521
--- /dev/null
+++ b/projects/board-test/fmc-probe.c
@@ -0,0 +1,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;
+}