From 0c57c746ccc000b00e29816ee6c58bcb7a18e745 Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Sat, 16 Jul 2016 15:02:54 +0200 Subject: Use -mmcu=attiny828 instead of -mmcu=avr25. This fixes building on Ubuntu 16.04 at least. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ec919f8..0bed033 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC = avr-gcc -CFLAGS = -std=gnu99 -Wpedantic -Wall -Werror -mmcu=avr25 -D__AVR_ATtiny828__ +CFLAGS = -std=gnu99 -Wpedantic -Wall -Werror -mmcu=attiny828 -D__AVR_ATtiny828__ OBJCOPY = avr-objcopy all: tamper.hex -- cgit v1.2.3 From 94b848d9dcd6ee0eb7c3eab817ca2c64971b35a3 Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Sat, 16 Jul 2016 15:03:44 +0200 Subject: mkm_wipe: Toggle CS to conclude spi_set_operation. --- tamper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tamper.c b/tamper.c index d1d5c04..9169895 100644 --- a/tamper.c +++ b/tamper.c @@ -213,8 +213,12 @@ mkm_wipe() spi_setup(1); mkm_grab(); + mkm_chip_select(1); spi_set_operation(SPI_OPERATION_SEQUENCE); + mkm_chip_select(0); + + mkm_chip_select(1); spi_write(SPI_WRITE); spi_write(0); /* Address, high byte. */ spi_write(0); /* Address, low byte. */ -- cgit v1.2.3 From b1abec4fb2478057da8e0e6788b015ce16e4985b Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Sat, 16 Jul 2016 15:04:09 +0200 Subject: Release MKM to the FPGA on initialization. --- tamper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tamper.c b/tamper.c index 9169895..e3d12af 100644 --- a/tamper.c +++ b/tamper.c @@ -254,6 +254,8 @@ main() for (int i = 0; i < 16000; i++); AVR_LED_PORT &= ~0x0f; + mkm_release(); + while (1) { if (panic_p()) -- cgit v1.2.3 From 574aea07d7d0eeddae965a80d9f1e6a3a42f2645 Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Sat, 16 Jul 2016 15:05:23 +0200 Subject: The sleep mode seems to not work yet. It seems the AVR reboots on exiting sleep mode. --- tamper.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tamper.c b/tamper.c index e3d12af..e2b2127 100644 --- a/tamper.c +++ b/tamper.c @@ -261,8 +261,12 @@ main() if (panic_p()) mkm_wipe(); - if (!panic_p()) - sleep(); + /* Sleep is not working right at the moment (the AVR seems to be reset + when brought out of sleep mode by a press on the panic button). + + if (!panic_p()) + sleep(); + */ } return 0; -- cgit v1.2.3 From ec079fc63e74e90fe7a159d2e06a7c4cb17fe6b2 Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Sat, 16 Jul 2016 15:05:49 +0200 Subject: Flash blue LED to indicate MKM wipe completed. --- tamper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tamper.c b/tamper.c index e2b2127..477198e 100644 --- a/tamper.c +++ b/tamper.c @@ -225,10 +225,17 @@ mkm_wipe() for (int i = 0; i < 0x1fff; i++) /* 8192 bytes (64Kbit). */ spi_write(0); mkm_chip_select(0); + mkm_release(); spi_setup(0); AVR_LED_PORT &= ~_BV(AVR_LED_RED_BIT); + + /* Flash blue LED three times to indicate wipe is done */ + for (int x = 0; x < 6; x++) { + AVR_LED_PORT ^= _BV(AVR_LED_BLUE_BIT); + for (int i = 0; i < 3200; i++); + } } static inline void -- cgit v1.2.3