avr: t03 runs in basic mode now, flashing of AtTiny841 finally works!!

This commit is contained in:
Martin Preuss
2025-01-25 03:16:02 +01:00
parent 779b37f195
commit e840bfd9e6
11 changed files with 916 additions and 342 deletions

View File

@@ -48,7 +48,6 @@ checkFlash:
rcall ioRawSendMsg ; (r16, r17, X)
ldi r16, CPRO_CMD_FLASH_START
ldi r20, 10 ; wait for up to 10s
rcall ioWaitForGivenMsg ; (r16, r17, r18, r19, r20, r22, X)
brcc checkFlash_end
@@ -81,6 +80,7 @@ checkFlash_end:
; @clobbers r16, r20
flashProcess:
rcall Flash_Init
flashProcess_loop1:
; wait up to 10s for incoming FLASH_DATA message
ldi r16, CPRO_CMD_FLASH_DATA
@@ -94,7 +94,8 @@ flashProcess_loop1:
rcall flashProcessHandleFlashData ; (R0, R1, R15, R16, R17, R18, R19, R20, Z)
rjmp flashProcess_loop1
flashProcess_endReceived:
rjmp flashProcessHandleFlashEnd
rcall flashProcessHandleFlashEnd
sec
flashProcess_end:
ret
; @end
@@ -163,27 +164,18 @@ flashProcessCheckFlashStart_notMe:
; @clobbers R0, R1, R18, Z (R15, R16, R17, R19, R20)
flashProcessHandleFlashData:
adiw xh:xl, FLASH_MSG_OFFS_MSGLEN
ld r18, X ; length (subtract 6)
cpi r18, 6 ; cmd(1), src(1), addr(4)
mov yl, xl
mov yh, xh
adiw yh:yl, FLASH_MSG_OFFS_MSGLEN
ld r17, Y ; length (subtract 6)
cpi r17, 6 ; cmd(1), src(1), addr(4)
brcs flashProcessHandleFlashData_badData
subi r18, 6 ; remaining length
adiw xh:xl, FLASH_PACKET_DATA_OFFS_ADDR-FLASH_MSG_OFFS_MSGLEN
ld zl, X+ ; address (low)
ld zh, X+ ; address (high)
adiw xh:xl, 2 ; ignore high bytes, points to first data byte now
; push zl
; push zh
;flashProcessHandleFlashData_loop:
; ld r0, X+
; ld r1, X+
; rcall Flash_WriteIntoPage ; (R15, R16, Z+)
; subi r18, 2
; brne flashProcessHandleFlashData_loop
; pop zh
; pop zl
; rcall Flash_FinishPage ; (R15, R16, R20)
subi r17, 6 ; remaining length
adiw yh:yl, FLASH_PACKET_DATA_OFFS_ADDR-FLASH_MSG_OFFS_MSGLEN
ld zl, Y+ ; address (low)
ld zh, Y+ ; address (high)
adiw yh:yl, 2 ; ignore high bytes, points to first data byte now
rcall Flash_WriteData ; (R0, R1, R16, R18, R19, R20, R24, R25, X)
clr r16
rjmp flashProcessHandleFlashData_sendResponse
flashProcessHandleFlashData_badData:
@@ -206,6 +198,7 @@ flashProcessHandleFlashData_sendResponse:
; @clobbers r16, X (R17, R18, R19, R20)
flashProcessHandleFlashEnd:
rcall Flash_Fini ; flash pending data
rcall flashWaitFor100ms
clr r16
rcall flashProcessSendFlashResponse ; (R16, R17, R18, R19, R20, X)