From 85f8543e17101d4d0eaba72a740b88210c61e8f2 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 30 Aug 2020 08:01:09 -0400 Subject: [PATCH] avrspi: first steps After having done my initial handshaking, I thought the rest of the job was only a matter of implementing the protocol, but I was wrong. There were many issues to fix before I could reliably communicate with my 328P, mostly timing. Now, I seem to be able to reliably extract fuse information, but only in batch mode (that is, run "asp$ aspfl@" directly, then running "(spid)" before running the next command). If I try to interact with the chip in a single asp$ session, I sometimes get wrong values (but no sync error! that's worrying...). --- blk/001 | 4 ++-- blk/690 | 7 +++++++ blk/691 | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 blk/690 create mode 100644 blk/691 diff --git a/blk/001 b/blk/001 index 1198ed5..f07f2c4 100644 --- a/blk/001 +++ b/blk/001 @@ -11,6 +11,6 @@ MASTER INDEX 490 TRS-80 Recipe 520 Fonts 550 TI-84+ Recipe 580 RC2014 Recipe 600-619 unused 620 Sega Master System Recipe -650 AVR assembler 690-729 unused -730 8086 assembler +650 AVR assembler 690 AVR SPI programmer +700-729 unused 730 8086 assembler 800 8086 boot code 830 PC/AT recipe diff --git a/blk/690 b/blk/690 new file mode 100644 index 0000000..0a3ade7 --- /dev/null +++ b/blk/690 @@ -0,0 +1,7 @@ +AVR SPI programmer + +This program allows you to access AVR chips Flash memory, EEPROM +and fuses using a SPI relay. This requires drivers that imple- +ment the SPI Relay protocol. + +Load range: B691-BXXX diff --git a/blk/691 b/blk/691 new file mode 100644 index 0000000..cb76f2f --- /dev/null +++ b/blk/691 @@ -0,0 +1,14 @@ +: _cmd ( b4 b3 b2 b1 -- r4 ) + (spix) DROP DUP (spix) DROP SWAP (spix) = ( b4 f ) + SWAP (spix) SWAP ( r4 f ) NOT IF ABORT" AVR err" THEN ; +: asp$ ( -- ) + ( RESET pulse ) (spie) (spid) (spie) + ( wait 20ms ) 2000 0 DO LOOP + ( enable prog ) 0 0 0x53 0xac _cmd DROP ; +: asprdy ( -- f ) 0 0 0 0xf0 _cmd NOT ; +: aspfl@ ( -- lfuse ) 0 0 0 0x50 _cmd ; +: aspfh@ ( -- hfuse ) 0 0 0x08 0x58 _cmd ; +: aspfe@ ( -- efuse ) 0 0 0x00 0x58 _cmd ; +: aspfl! ( lfuse -- ) 0 0xa0 0xac _cmd ; +: aspfh! ( hfuse -- ) 0 0xa8 0xac _cmd ; +: aspfe! ( efuse -- ) 0 0xa4 0xac _cmd ;