From e840bfd9e685cc44e0347893d77e82a9975a8878 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 25 Jan 2025 03:16:02 +0100 Subject: [PATCH] avr: t03 runs in basic mode now, flashing of AtTiny841 finally works!! --- avr/devices/t03/0BUILD | 19 ++ avr/devices/t03/boot.asm | 188 +------------- avr/devices/t03/debugboot.asm | 398 +++++++++++++++++++++++++++++ avr/devices/t03/main.asm | 87 ++++--- avr/modules/bootloader/main.asm | 39 ++- avr/modules/flash/eeprom.asm | 64 +++++ avr/modules/flash/flash.asm | 56 ---- avr/modules/flash/flashprocess.asm | 37 ++- avr/modules/flash/io.asm | 9 +- avr/modules/flash/io_uart1.asm | 342 +++++++++++++++++++++++-- avr/modules/flash/wait.asm | 19 +- 11 files changed, 916 insertions(+), 342 deletions(-) create mode 100644 avr/devices/t03/debugboot.asm create mode 100644 avr/modules/flash/eeprom.asm diff --git a/avr/devices/t03/0BUILD b/avr/devices/t03/0BUILD index 4dc1f0b..7351c28 100644 --- a/avr/devices/t03/0BUILD +++ b/avr/devices/t03/0BUILD @@ -39,6 +39,25 @@ + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + debugboot.asm + + + + + + diff --git a/avr/devices/t03/boot.asm b/avr/devices/t03/boot.asm index 3f3d730..a2c6fb1 100644 --- a/avr/devices/t03/boot.asm +++ b/avr/devices/t03/boot.asm @@ -115,7 +115,6 @@ firmwareStart: rjmp main ; will be overwritten when flashing main: -; rjmp debugEchoUart1 rjmp bootLoader ; this routine is in modules/bootloader/main.asm @@ -124,16 +123,16 @@ main: ; *************************************************************************** ; includes -.include "modules/uart_hw/raw_uart1.asm" +;.include "modules/uart_hw/raw_uart1.asm" .include "modules/com2/crc.asm" -.include "common/crc8.asm" .include "common/utils_wait_fixed.asm" .include "common/utils_copy_from_flash.asm" .include "common/utils_copy_sdram.asm" .include "modules/flash/defs.asm" +.include "modules/flash/eeprom.asm" .include "modules/flash/io.asm" .include "modules/flash/io_uart1.asm" -.include "modules/flash/flash.asm" +.include "modules/flash/flash4p.asm" .include "modules/flash/flashprocess.asm" .include "modules/flash/wait.asm" .include "modules/bootloader/main.asm" @@ -158,184 +157,3 @@ systemSetSpeed: - -; debug - -debugEchoUart1: - cli - ; setup stack - .ifdef SPH ; if SPH is defined - ldi r16, High(RAMEND) - out SPH, r16 ; init MSB stack pointer - .endif - ldi r16, Low(RAMEND) - out SPL, r16 ; init LSB stack pointer - - rcall systemSetSpeed - - sbi LED_DDR, LED_PINNUM ; out - cbi LED_PORT, LED_PINNUM ; on - - ; set baudrate -.if clock == 8000000 - ldi r16, 25 ; (19.2Kb/s at 8MHz) - ldi r17, 0 -.endif - -.if clock == 1000000 - ldi r16, 3 ; (19.2Kb/s at 1MHz) - ldi r17, 0 -.endif - - sts UBRR1H, r17 - sts UBRR1L, r16 - - ; set character format (asynchronous USART, 8-bit, one stop bit, no parity) - ldi r16, (3< 7 per loop, max about 1000 + clc ; 1 + ret ; 4 +ioRawWaitForData_gotit: + sec ; 1 + ret ; 4 +; @end + + + + diff --git a/avr/modules/flash/wait.asm b/avr/modules/flash/wait.asm index d73d5ba..d62668c 100644 --- a/avr/modules/flash/wait.asm +++ b/avr/modules/flash/wait.asm @@ -27,7 +27,7 @@ ; - nothing ; OUT: ; - nothing -; REGS: R16 (R18, R22, R24, R25) +; REGS: R16 (R22, R24) flashWaitDependingOnUid: lds r16, flashUid @@ -46,20 +46,17 @@ flashWaitDependingOnUid_l1: ; - R16: number of 100ms loops ; OUT: ; - nothing -; REGS: R16 (R18, R22, R24, R25) +; REGS: R16 (R22, R24) flashWaitForMulti100ms: flashWaitForMulti100ms_loop: - rcall flashWaitFor100ms ; (R18, R22, R24, R25) + rcall flashWaitFor100ms ; (R22, R24) dec r16 brne flashWaitForMulti100ms_loop ret - - - ; --------------------------------------------------------------------------- ; wait for 100 milliseconds. ; @@ -67,13 +64,15 @@ flashWaitForMulti100ms_loop: ; - nothing ; OUT: ; - nothing -; REGS: R18 (R22, R24, R25) +; REGS: R24 (R22) flashWaitFor100ms: - ldi r18, 100 + ldi r24, 100 flashWaitFor100ms_loop: - rcall flashWaitFor1ms ; (R22, R24, R25) - dec r18 + push r24 + rcall flashWaitFor1ms ; (R22, R24) + pop r24 + dec r24 brne flashWaitFor100ms_loop ret