Skip to content

Commit

Permalink
Changed timeouts for flash upload to 10 seconds.
Browse files Browse the repository at this point in the history
  • Loading branch information
Threetwosevensixseven committed Feb 21, 2020
1 parent 4506f56 commit b36cffc
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 101 deletions.
2 changes: 1 addition & 1 deletion build/builddot.bat
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if %cspect% equ 0 goto NoCSpect
pskill.exe -t cspect.exe
hdfmonkey.exe put C:\spec\cspect-next-2gb.img ..\dot\espupdate dot
hdfmonkey.exe put C:\spec\cspect-next-2gb.img ..\dot\espupdate dot\extra
hdfmonkey.exe put C:\spec\cspect-next-2gb.img autoexec.bas nextzxos\autoexec.bas
::hdfmonkey.exe put C:\spec\cspect-next-2gb.img autoexec.bas nextzxos\autoexec.bas
hdfmonkey.exe put C:\spec\cspect-next-2gb.img "..\fw\ESP8266_FULL_V3.3_SPUGS\ESP8266_FULL_V3.3_SPUGS.nxesp" "Mine\MY FW.nxesp"
cd C:\spec\CSpect2_12_1
CSpect.exe -w2 -zxnext -nextrom -basickeys -exit -brk -tv %serarg%-mmc=..\cspect-next-2gb.img
Expand Down
Binary file modified dot/ESPUPDATE
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions fw/ESP8266_FULL_V3.3_SPUGS/RTOS_v330_2100/dump.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
:: Set current directory
@echo off
C:
CD %~dp0

:: You need a full Python install, added to the PATH.
:: If esptool.py complains about 'no module named serial.tools.list_ports'
:: you may need to upgrade pyserial with: pip install pyserial

@echo on

python ..\esptool.py --chip esp8266 --port COM5 --baud 115200 read_flash 0 0x100000 "RTOS_v330_2100.facdump"

@echo off

pause
93 changes: 18 additions & 75 deletions src/asm/esp.asm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ pend

Baud proc Table:
b115200: dw $8173, $8178, $817F, $8204, $820D, $8215, $821E, $816A
//b1152000: dw $8018, $8019, $801A, $801A, $801B, $801C, $801D, $8017
pend

Timings: proc Table:
Expand Down Expand Up @@ -170,67 +169,6 @@ ReadLoop: ld a, high UART_GetStatus ; Are there any characte
jr ReadLoop ; then check if there are more data bytes ready to read
pend

/*ESPSendTestBytes proc ; Send 256 bytes to UART, with values 0..255
ld h, 0
ld bc, $133B ; UART Tx port also gives the UART status when read
WaitNotBusy: in a, (c) ; Read the UART status
and 2 ; and check the busy bit (bit 1)
jr nz, WaitNotBusy ; If busy, keep trying until not busy
ld a, h ; Otherwise read the next byte of the text to be sent
out (c), a ; and end it to the UART TX port
inc h
jr nz, WaitNotBusy
ret
pend*/

/*ESPRead proc
ld a, (FRAMES)
add a, 5
ld (TimeoutFrame), a
ld bc, UART_GetStatus
ei
WaitNotBusy: ld a, high UART_GetStatus ; Are there any characters waiting?
in a, (c) ; This inputs from the 16-bit address UART_GetStatus
rrca ; Check UART_mRX_DATA_READY flag in bit 0
jp c, HasData ; Read Data if Available
ld a, (FRAMES)
TimeoutFrame equ $+1: cp SMC
jp nz, WaitNotBusy ; Try again for at least another N frames (5)
di
ret ; Return if N frames (5) has elapsed with no data
HasData: inc b ; Otherwise Read the byte
in a, (c) ; from the UART Rx port
push bc
call PrintAHex
pop bc
dec b
jr WaitNotBusy ; then check if there are more data bytes ready to read
pend*/

/*ESPReadPrint proc
ld a, (FRAMES)
add a, 5
ld (TimeoutFrame), a
ld bc, UART_GetStatus
ei
WaitNotBusy: ld a, high UART_GetStatus ; Are there any characters waiting?
in a, (c) ; This inputs from the 16-bit address UART_GetStatus
rrca ; Check UART_mRX_DATA_READY flag in bit 0
jp c, HasData ; Read Data if Available
ld a, (FRAMES)
TimeoutFrame equ $+1: cp SMC
jp nz, WaitNotBusy ; Try again for at least another N frames (5)
di
ret ; Return if N frames (5) has elapsed with no data
HasData: inc b ; Otherwise Read the byte
in a, (c) ; from the UART Rx port
push bc
call PrintChar
pop bc
dec b
jr WaitNotBusy ; then check if there are more data bytes ready to read
pend*/

ESPClearBuffer: proc
FillLDIR(Buffer, Buffer.Len, 0)
ret
Expand All @@ -242,17 +180,22 @@ ESPReadIntoBuffer proc
ld sp, $8000 ; Put stack in upper 16K so FRAMES gets update
ei
call ESPClearBuffer
ld a, (FRAMES)
WaitNFrames equ $+1: add a, 5
ld (TimeoutFrame), a
ld hl, (FRAMES)
add hl, [WaitNFrames]5
ld (TimeoutFrame), hl
ld bc, UART_GetStatus
ld hl, Buffer
ld de, Buffer.Len
WaitNotBusy: in a, (c) ; This inputs from the 16-bit address UART_GetStatus
rrca ; Check UART_mRX_DATA_READY flag in bit 0
jp c, HasData ; Read Data if available
ld a, (FRAMES)
TimeoutFrame equ $+1: cp SMC
push hl
push bc
ld hl, (FRAMES)
ld bc, [TimeoutFrame]SMC
CpHL(bc)
pop bc
pop hl
jp nz, WaitNotBusy ; Try again for at least another N frames (5)
di
scf ; Set carry to signal error if N frames with no data,
Expand All @@ -268,7 +211,7 @@ HasData: inc b ; Otherwise Read the byt
jr nz, WaitNotBusy ; If so, check if there are more data bytes ready to read,
or a ; otherwise clear carry to signal success,
Return: di
SavedStack equ $+1: ld sp, SMC
ld sp, [SavedStack]SMC
ret ; and return
pend

Expand Down Expand Up @@ -296,7 +239,7 @@ FindFrame: ld a, $C0
dec bc
ld a, (hl) ; Read Op
call SlipUnescape
Opcode equ $+1: cp SMC ; Is expected Op?
cp [Opcode]SMC ; Is expected Op?
jr nz, FindFrame ; If not, find next frame marker
inc hl
dec bc
Expand All @@ -312,22 +255,22 @@ Opcode equ $+1: cp SMC ; Is expected Op?
dec bc
ld a, (hl) ; Read value byte 1
call SlipUnescape
ValWordAddr1 equ $+1: ld (SMC), a ; Save value byte 1
ld ([ValWordAddr1]SMC), a ; Save value byte 1
inc hl
dec bc
ld a, (hl) ; Read value byte 2
call SlipUnescape
ValWordAddr2 equ $+1: ld (SMC), a ; Save value byte 2
ld ([ValWordAddr2]SMC), a ; Save value byte 2
inc hl
dec bc
ld a, (hl) ; Read value byte 3
call SlipUnescape
ValWordAddr3 equ $+1: ld (SMC), a ; Save value byte 3
ld ([ValWordAddr3]SMC), a ; Save value byte 3
inc hl
dec bc
ld a, (hl) ; Read value byte 4
call SlipUnescape
ValWordAddr4 equ $+1: ld (SMC), a ; Save value byte 4
ld ([ValWordAddr4]SMC), a ; Save value byte 4
ld a, e ; Simplistic version of checking DE is at least 2
or d ; Should always be larger hopefully, given the nature or ORing 0, 1 or 2 with the MSB
cp 2 ; TODO: If we get unexpected failures later, revisit this compare
Expand Down Expand Up @@ -448,7 +391,7 @@ NoDataBlock16:
call ESPReadIntoBuffer ; Read the UART dry into the buffer, or at least 1024 bytes
ld a, (SLIP.HeaderOp) ; Validate for the same Op we sent the command for
ld hl, Dummy32 ; We don't want to preserve the value
ValidateProcSMC equ $+1:call ESPValidateCmdProc ; < SMC a = Op, hl = ValWordAddr (carry set means error)
call [ValidateProcSMC]ESPValidateCmdProc ; < SMC a = Op, hl = ValWordAddr (carry set means error)
pop hl ; Retrieve ErrAddr (always, to balance stack)
ret nc ; If no error we can return
jp ErrorProc ; Otherwise signal a fatal error with the passed-in error msg
Expand Down Expand Up @@ -504,7 +447,7 @@ SetUARTBaudProc proc ; hl = BaudTable, de = B
PrintMsg(Msg.SetBaud3) ; " timings"
pop af
add a,a
BaudTable equ $+1: ld hl, SMC ; Restore BaudTable
ld hl, [BaudTable]SMC ; Restore BaudTable
add hl, a
ld e, (hl)
inc hl
Expand Down
18 changes: 9 additions & 9 deletions src/asm/general.asm
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,21 @@ SavedStack equ $+1: ld sp, SMC ; Restore stack
ret
pend

SaveReadTimeoutProc proc ; a = FramesToWait. Since we only really need to call
push af ; ESPReadIntoBuffer with longer timeouts once, it's easier
ld a, (ESPReadIntoBuffer.WaitNFrames) ; to self-modify the timeout routine when needed,
ld (TimeoutBackup), a ; rather than have it always take a timeout parameter.
pop af
Set: ld (ESPReadIntoBuffer.WaitNFrames), a
SaveReadTimeoutProc proc ; hl = FramesToWait. Since we only really need to call
push hl ; ESPReadIntoBuffer with longer timeouts once, it's easier
ld hl, (ESPReadIntoBuffer.WaitNFrames) ; to self-modify the timeout routine when needed,
ld (TimeoutBackup), hl ; rather than have it always take a timeout parameter.
pop hl
Set: ld (ESPReadIntoBuffer.WaitNFrames), hl
ret
pend

RestoreReadTimeoutProc proc ; Counterpart to SaveReadTimeoutProc, restores the
ld a, (TimeoutBackup) ; original timeout.
ld hl, (TimeoutBackup) ; original timeout.
jr SaveReadTimeoutProc.Set
pend

/*WaitKey proc ; Just a debugging routine that allows me to clear
WaitKey proc ; Just a debugging routine that allows me to clear
Border(6) ; my serial logs at a certain point, before logging
ei ; the traffic I'm interested in debugging.
Loop1: xor a
Expand All @@ -195,7 +195,7 @@ Loop2: xor a
Border(7)
di
ret
pend*/
pend

WaitKeyYN proc ; Returns carry set if no, carry clear if yes
ei ; Also prints Y or N followed by CR
Expand Down
2 changes: 1 addition & 1 deletion src/asm/macros.asm
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ ESPSendDataBlockSeq macro(Opcode, DataAddr, ErrAddr); As ESPSendDataBlock(),
mend

SetReadTimeout macro(FramesToWait) ; Parameterised wrapper for the ESP SLIP buffer read timeout
ld a, FramesToWait ; changing routine. Invoke RestoreReadTimeout() afterwards.
ld hl, FramesToWait ; changing routine. Invoke RestoreReadTimeout() afterwards.
call SaveReadTimeoutProc
mend

Expand Down
8 changes: 7 additions & 1 deletion src/asm/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,12 @@ ReadEfuses:
call Wait5Frames
call ESPFlush ; Clear UART buffer
call Wait5Frames
//SetReadTimeout(500)
//call WaitKey
ESPReadReg(0x3ff0005c) ; Read this address
call Wait5Frames
call ESPReadIntoBuffer
//call WaitKey
ESPValidateCmd($0A, eFuse1) ; val = 0x00600194 (on test ESP)

call Wait5Frames
Expand Down Expand Up @@ -518,6 +521,7 @@ PrintMAC:
call Rst16
UploadStub:
PrintMsg(Msg.Stub1)
//SetReadTimeout(50)
; These are the value for uploading the stub:
;
; text_start = 0x4010E000
Expand Down Expand Up @@ -689,9 +693,11 @@ FlashLoop:
ErrorIfCarry(Err.ReadFW)
BlockDataLen equ $+1: ld bc, SMC ; bc = compressed block size (DataLen)
BlockSeqNo equ $+1: ld de, SMC ; de = Seq number (Seq)
SetReadTimeout(500)
ESPSendDataBlockSeq(ESP_FLASH_DEFL_DATA, $C000, Err.FlashUp)
RestoreReadTimeout()

call Wait100Frames ; Pause to allow decompression
//call Wait100Frames ; Pause to allow decompression

ld hl, (BlockHeaderStart)
ld de, (HeaderBlockSize)
Expand Down
2 changes: 1 addition & 1 deletion src/asm/vars.asm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ FWCompLenStr: ds 11
HeaderBlockSize: ds 2 ; MSB is always zero
BlockCount: ds 2
BlockHeaderStart: ds 2
TimeoutBackup: ds 1
TimeoutBackup: ds 2
InProgMode: ds 1

; Features
Expand Down
26 changes: 13 additions & 13 deletions src/asm/version.asm
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
; version.asm
;
; Auto-generated by ZXVersion.exe
; On 19 Feb 2020 at 19:46
; On 21 Feb 2020 at 18:11

BuildNo macro()
db "69"
db "70"
mend

BuildNoValue equ "69"
BuildNoWidth equ 0 + FW6 + FW9
BuildNoValue equ "70"
BuildNoWidth equ 0 + FW7 + FW0



BuildDate macro()
db "19 Feb 2020"
db "21 Feb 2020"
mend

BuildDateValue equ "19 Feb 2020"
BuildDateWidth equ 0 + FW1 + FW9 + FWSpace + FWF + FWe + FWb + FWSpace + FW2 + FW0 + FW2 + FW0
BuildDateValue equ "21 Feb 2020"
BuildDateWidth equ 0 + FW2 + FW1 + FWSpace + FWF + FWe + FWb + FWSpace + FW2 + FW0 + FW2 + FW0



BuildTime macro()
db "19:46"
db "18:11"
mend

BuildTimeValue equ "19:46"
BuildTimeWidth equ 0 + FW1 + FW9 + FWColon + FW4 + FW6
BuildTimeValue equ "18:11"
BuildTimeWidth equ 0 + FW1 + FW8 + FWColon + FW1 + FW1



BuildTimeSecs macro()
db "19:46:47"
db "18:11:50"
mend

BuildTimeSecsValue equ "19:46:47"
BuildTimeSecsWidth equ 0 + FW1 + FW9 + FWColon + FW4 + FW6 + FWColon + FW4 + FW7
BuildTimeSecsValue equ "18:11:50"
BuildTimeSecsWidth equ 0 + FW1 + FW8 + FWColon + FW1 + FW1 + FWColon + FW5 + FW0

0 comments on commit b36cffc

Please sign in to comment.