avr: bootloader partially works now but stops after 3 messages...

This commit is contained in:
Martin Preuss
2025-01-20 23:47:13 +01:00
parent 0d7aca0060
commit 0a10d136d5
23 changed files with 398 additions and 1260 deletions

View File

@@ -16,7 +16,7 @@
; ---------------------------------------------------------------------------
; @routine flashWaitForGivenMsg
; @routine ioWaitForGivenMsg
; Wait for incoming msg with given command
;
; @return CFLAG set if okay (packet received), cleared on error
@@ -25,28 +25,28 @@
; @param r20 time in seconds to wait for a message
; @clobbers: r16, r17, r20, X (r18, r19, r22)
flashWaitForGivenMsg:
flashWaitForGivenMsg_loop:
ioWaitForGivenMsg:
ioWaitForGivenMsg_loop:
push r16
rcall flashRawWaitForValidMsg ; (r16, r17, r18, r19, r22, X)
rcall ioRawWaitForValidMsg ; (r16, r17, r18, r19, r22, X)
pop r16
brcc flashWaitForGivenMsg_end
brcc ioWaitForGivenMsg_end
ldi xl, LOW(flashRecvBuffer)
ldi xh, HIGH(flashRecvBuffer)
adiw xh:xl, COM2_MSG_OFFS_CMD
ld r17, X
sbiw xh:xl, COM2_MSG_OFFS_CMD
cp r16, r17
breq flashWaitForGivenMsg_gotIt
breq ioWaitForGivenMsg_gotIt
cpi r16, CPRO_CMD_FLASH_END
breq flashWaitForGivenMsg_gotIt
breq ioWaitForGivenMsg_gotIt
dec r20
brne flashWaitForGivenMsg_loop
brne ioWaitForGivenMsg_loop
clc
rjmp flashWaitForGivenMsg_end
flashWaitForGivenMsg_gotIt:
rjmp ioWaitForGivenMsg_end
ioWaitForGivenMsg_gotIt:
sec
flashWaitForGivenMsg_end:
ioWaitForGivenMsg_end:
ret
; @end