From 3665c3e245ebbd5d5bc1ca4383eae313df31bda2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20=C3=85gren?= Date: Mon, 3 Feb 2025 09:38:53 +0100 Subject: [PATCH] PoC: testfw: Check that SPI flash is available in firmware mode --- hw/application_fpga/Makefile | 4 +++- hw/application_fpga/fw/testfw/main.c | 11 +++++++++++ hw/application_fpga/fw/tk1/flash.h | 3 +-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hw/application_fpga/Makefile b/hw/application_fpga/Makefile index 1281b35..2a011ca 100644 --- a/hw/application_fpga/Makefile +++ b/hw/application_fpga/Makefile @@ -147,7 +147,9 @@ TESTFW_OBJS = \ $(P)/fw/testfw/main.o \ $(P)/fw/testfw/start.o \ $(P)/fw/tk1/proto.o \ - $(P)/fw/tk1/lib.o + $(P)/fw/tk1/lib.o \ + $(P)/fw/tk1/spi.o \ + $(P)/fw/tk1/flash.o IRQPOC_OBJS = \ $(P)/fw/irqpoc/main.o \ diff --git a/hw/application_fpga/fw/testfw/main.c b/hw/application_fpga/fw/testfw/main.c index 0ec2a6a..66a5b41 100644 --- a/hw/application_fpga/fw/testfw/main.c +++ b/hw/application_fpga/fw/testfw/main.c @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-only */ +#include "../tk1/flash.h" #include "../tk1/lib.h" #include "../tk1/proto.h" #include "../tk1/types.h" @@ -239,6 +240,16 @@ int main(void) anyfailed = 1; } + uint8_t jedec_id[3]; + puts("\r\nReading SPI flash capacity...\r\n"); + flash_release_powerdown(); + flash_read_jedec_id(jedec_id); + + if (jedec_id[2] != 0x14) { + failmsg("Expected SPI flash capacity: 0x14 (1 MByte)"); + anyfailed = 1; + } + // Test FW_RAM. puts("\r\nTesting FW_RAM (takes 15s on hw)...\r\n"); for (unsigned int i = 0; i < TK1_MMIO_FW_RAM_SIZE; i++) { diff --git a/hw/application_fpga/fw/tk1/flash.h b/hw/application_fpga/fw/tk1/flash.h index cad6f07..1c60cc5 100644 --- a/hw/application_fpga/fw/tk1/flash.h +++ b/hw/application_fpga/fw/tk1/flash.h @@ -4,9 +4,8 @@ #ifndef TKEY_FLASH_H #define TKEY_FLASH_H +#include "types.h" #include -#include -#include #define WRITE_ENABLE 0x06 #define WRITE_DISABLE 0x04