ESP8266-based WiFi serial modem emulator ROM
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

flashloader: Delay 5 seconds before reading input

When the CP2104 USB serial chip on the Feather ESP8266 board sees
the DTR line go low, it causes a reset of the ESP8266. This is
needed for software (esptool) to be able to put the ESP8266 into its
bootloader mode.

Unfortunately this means any serial connection closing causes a
reboot, which has to reset the MCP23S18, which can cause garbage on
its GPIO lines going to the DB25 port.

When sendload is used to upload flashloader, it sends the program
over and then closes the serial connection, causing the WiFiStation
to reboot at the same time flashloader is executing and looking for
input (the size of the program it's about to write to flash). This
can cause flashloader to read bogus size bytes, but then sendload is
used again to upload the actual program being written and now it's
writing the two size bytes to flash plus the entire program being
offset by 2 bytes.

To work around this, delay 5 seconds on startup to ignore any
potential changes on the ack/busy lines.

+21
+21
mailstation/flashloader.asm
··· 22 22 23 23 ; locations relative to v2.54 firmware 24 24 .equ p2shadow, #0xdba2 25 + .equ delay_func, #0x0a5c 25 26 26 27 ; which page (Yahoo! menu slot) to save an uploaded program to 27 28 ; page 0 is 0x0000, page 1 0x4000, page 2, 0x8000, etc. ··· 113 114 ei 114 115 ret 115 116 117 + delay: 118 + push af 119 + push bc 120 + push hl 121 + call #delay_func 122 + pop hl 123 + pop bc 124 + pop af 125 + ret 126 + 116 127 ; get transfer size bytes, then read a flash sector into ram, write it, repeat 117 128 main: 118 129 push ix ··· 121 132 push bc 122 133 push de 123 134 push hl 135 + ld hl, #5000 136 + push hl 137 + call delay ; wait 5 seconds before starting in 138 + pop hl ; case wifistation is rebooting 139 + ld a, #CONTROL_DIR_OUT 140 + out (#CONTROL_DIR), a 141 + xor a 142 + out (#CONTROL_PORT), a 143 + ld a, #DATA_DIR_IN 144 + out (#DATA_DIR), a ; we're going to be receiving 124 145 ld a, #1 ; enable 'new mail' light 125 146 call new_mail 126 147 ld hl, #-8 ; stack bytes for local storage