From cac611deaee19f967ac3ee1db6a79adb1dbe2c54 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Tue, 25 Mar 2025 00:38:12 +0100 Subject: [PATCH] avr: use NETMSG functions, increase waiting times. --- avr/modules/flash/flashprocess.asm | 30 +++++++++++++++--------------- avr/modules/flash/io.asm | 2 +- avr/modules/flash/io_bitbang.asm | 14 +++++++------- avr/modules/flash/io_uart1.asm | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/avr/modules/flash/flashprocess.asm b/avr/modules/flash/flashprocess.asm index d7f215c..47969dc 100644 --- a/avr/modules/flash/flashprocess.asm +++ b/avr/modules/flash/flashprocess.asm @@ -82,7 +82,7 @@ checkFlash_end: flashProcess: rcall Flash_Init flashProcess_loop1: - ; wait up to 10s for incoming FLASH_DATA message + ; wait up to 20s for incoming FLASH_DATA message ldi r16, CPRO_CMD_FLASH_DATA rcall ioWaitForGivenMsg ; (r16, r17, r18, r19, r20, r22, X) brcc flashProcess_end ; no FLASH_DATA or FLASH_END msg @@ -244,7 +244,7 @@ flashProcessWriteFlashRsp: st X+, r17 ; src address (not used) st X+, r16 ; payload byte sbiw xh:xl, 5 - rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) + rcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) sbiw xh:xl, 6 ret ; @end @@ -259,33 +259,33 @@ flashProcessWriteFlashRsp: flashProcessWriteFlashReady: ldi r16, 0xff - st X+, r16 ; dest address (unused) - ldi r16, 20 ; msg code+src address+18 payload bytes - st X+, r16 ; msg len + st X+, r16 ; dest address (unused) + ldi r16, 20 ; msg code+src address+18 payload bytes + st X+, r16 ; msg len ldi r16, CPRO_CMD_FLASH_READY - st X+, r16 ; msg code + st X+, r16 ; msg code ldi r16, COM2_MAINTENANCE_ADDR - st X+, r16 ; src address + st X+, r16 ; src address ; payload - ldi yh, HIGH(flashUid) ; 4 bytes + ldi yh, HIGH(flashUid) ; 4 bytes ldi yl, LOW(flashUid) ldi r18, 4 - rcall Utils_Copy_SDRAM ; (R17, R18, X, Y) + rcall Utils_Copy_SDRAM ; (R17, R18, X, Y) - ldi zl, LOW(devInfoBlock*2) ; 12 bytes + ldi zl, LOW(devInfoBlock*2) ; 12 bytes ldi zh, HIGH(devInfoBlock*2) ldi r18, 12 - rcall Utils_CopyFromFlash ; (R16, R18, X, Z) + rcall Utils_CopyFromFlash ; (R16, R18, X, Z) - ldi r16, LOW(PAGESIZE*2) ; 2 bytes + ldi r16, LOW(PAGESIZE*2) ; 2 bytes st X+, r16 ldi r16, HIGH(PAGESIZE*2) st X+, r16 - sbiw xh:xl, 22 ; go back to beginning of message - rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) - sbiw xh:xl, 23 ; go back to beginning of message + sbiw xh:xl, 22 ; go back to beginning of message + rcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) + sbiw xh:xl, 23 ; go back to beginning of message ret ; @end diff --git a/avr/modules/flash/io.asm b/avr/modules/flash/io.asm index dae9c22..936e488 100644 --- a/avr/modules/flash/io.asm +++ b/avr/modules/flash/io.asm @@ -25,7 +25,7 @@ ; @clobbers: r16, r17, r20, X (r18, r19, r22) ioWaitForGivenMsg: - ldi r20, 10 ; number of tries + ldi r20, 100 ; number of tries ioWaitForGivenMsg_loop: push r16 push r20 diff --git a/avr/modules/flash/io_bitbang.asm b/avr/modules/flash/io_bitbang.asm index d372382..9789c19 100644 --- a/avr/modules/flash/io_bitbang.asm +++ b/avr/modules/flash/io_bitbang.asm @@ -123,9 +123,9 @@ ioRawSendMsg_attnHigh: ; @clobbers: r16, r17 (r18, r19, r20, r21, r22, X) ioRawWaitForValidMsg: - ldi r16, 0 ; expect ATTN low - ldi r17, 100 - rcall ioWaitForAttnState100ms ; wait for up to 10s + ldi r16, 0 ; expect ATTN low + ldi r17, 200 + rcall ioWaitForAttnState100ms ; wait for up to 20s brcs ioRawWaitForValidMsg_attnLow ret ioRawWaitForValidMsg_attnLow: @@ -137,13 +137,13 @@ ioRawWaitForValidMsg_attnLow: brcs ioRawWaitForValidMsg_packetReceived ret ioRawWaitForValidMsg_packetReceived: - ldi r16, 0xff ; expect ATTN high - ldi r17, 100 - rcall ioWaitForAttnState100ms ; wait for up to 10s + ldi r16, 0xff ; expect ATTN high + ldi r17, 200 + rcall ioWaitForAttnState100ms ; wait for up to 20s brcc ioRawWaitForValidMsg_end ldi xl, LOW(flashRecvBuffer) ldi xh, HIGH(flashRecvBuffer) - rcall com2CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X) + rcall NETMSG_CheckMessageInBuffer ioRawWaitForValidMsg_end: ret ; @end diff --git a/avr/modules/flash/io_uart1.asm b/avr/modules/flash/io_uart1.asm index 60e1d3c..ec9d0d9 100644 --- a/avr/modules/flash/io_uart1.asm +++ b/avr/modules/flash/io_uart1.asm @@ -132,7 +132,7 @@ ioRecvMsg: brcc ioRecvMsg_error push xl push xh - rcall com2CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X) + rcall NETMSG_CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X) pop xh pop xl brcs ioRecvMsg_end