Page 1 of 1

16M D1 Mini Pro + SDK 2.2.1

Posted: Sat Aug 22, 2020 1:00 pm
by mcauser
Trying to flash the latest MicroPython to a 16M Wemos D1 Mini Pro.
Hit a problem where it would get stuck in a boot loop.

Initially, I thought it was a problem with make deploy not including the write esp_init_data_default.bin to 0xffc000 in the esptool.py command, like I had done manually before.

When I added the latest esp_init_data_default_v08.bin to the write_flash command and it worked.

Code: Select all

esptool.py --port /dev/tty.SLAB_USBtoUART --baud 460800 erase_flash
make
cp esp-open-sdk/ESP8266_NONOS_SDK-2.2.1/bin/esp_init_data_default_v08.bin build-GENERIC/
esptool.py --port /dev/tty.SLAB_USBtoUART --baud 460800 write_flash -fm dio -fs 16MB 0 build-GENERIC/firmware-combined.bin 0xffc000 build-GENERIC/esp_init_data_default_v08.bin
Tried again without the write to 0xffc000 and it gets stuck in a boot loop.

Further investigation revealed back in 2016, the init data was actually added in (esp_init_data.c).

The commit from 2016:
https://github.com/micropython/micropyt ... ad60e7e832
SDK 2.0.0 goes into boot loop if a firmware is programmed over erased flash
Looks like that is what I am seeing now my fresh esp-open-sdk build using SDK 2.2.1, as the init data has changed.

In the SDK 2.2.1 zip there are 2 init datas in /bin:
* esp_init_data_default_v05.bin
* esp_init_data_default_v08.bin

When comparing SDK 2.2.1 with SDK 2.2.0 and SDK 2.1.0, the v05.bin matches the original esp_init_data_default.bin and what is in esp8266/esp_init_data.c. The v08.bin has a few differences.

esp_init_data.c and esp_init_data_default_v05.bin
0500 0402 0505 0502 0500 0405 0504 0505
04fe fdff f0f0 f0e0 e0e0 e10a ffff f800
f8f8 524e 4a44 4038 0000 0101 0203 0405
0100 0000 0000 0200 0000 0000 0000 0000
e10a 0000 0000 0000 0000 0193 4300 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0100 0000 0000 0000 0000 0000 0000

esp_init_data_default_v08.bin
0508 0402 0505 0502 0500 0405 0504 0505
04fe fdff f0f0 f0e0 e0e0 e10a ffff f800
f8f8 4e4a 4640 3c38 0000 0101 0203 0405
0100 0000 0000 0200 0000 0000 0000 0000
e10a 0000 0000 0000 0000 0193 4300 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0100 0000 0000 0000 0000 0000 0000
[/code]

Since the esp8266/esp_init_data.c bytes match esp_init_data_default_v05.bin, and flashing esp_init_data_default_v08.bin with esptool.py worked, I tried updating esp8266/esp_init_data.c with the 8 different bytes from the v08.bin, highlighted above.

Code: Select all

(edited esp8266/esp_init_data.c's default_init_data with v08 bytes)
esptool.py --port /dev/tty.SLAB_USBtoUART --baud 460800 erase_flash
make clean
make PORT=/dev/tty.SLAB_USBtoUART deploy
Didn't work. Still stuck in boot loop.
Changing the bytes in static const uint8_t default_init_data[] to v08.bin had no effect. Rollback.

Now, if I write_flash that v08.bin, it reboots and starts working.

Code: Select all

cp esp-open-sdk/ESP8266_NONOS_SDK-2.2.1/bin/esp_init_data_default_v08.bin build-GENERIC/
esptool.py --port /dev/tty.SLAB_USBtoUART --baud 460800 write_flash -fm dio -fs 16MB 0xffc000 build-GENERIC/esp_init_data_default_v08.bin

Code: Select all

MPY: soft reboot
MicroPython v1.12-665-g60f5b941e-dirty on 2020-08-22; ESP module with ESP8266
Type "help()" for more information.

Re: 16M D1 Mini Pro + SDK 2.2.1

Posted: Sat Aug 22, 2020 1:13 pm
by mcauser
Output of make deploy on 16MB D1 mini pro:

Code: Select all

make PORT=/dev/tty.SLAB_USBtoUART deploy
...
LINK build-GENERIC/firmware.elf
   text	   data	    bss	    dec	    hex	filename
 616260	   1020	  66504	 683784	  a6f08	build-GENERIC/firmware.elf
Create build-GENERIC/firmware-combined.bin
esptool.py v2.8
Creating image for ESP8266...
flash     33024
 .text    30876 at 0x40100000
 .data    1020 at 0x3ffe8000
 .rodata  1080 at 0x3ffe8400
padding   3840
irom0text 584304
total     621168
md5       3c82142b7dacefb482738fa91f89879f
Writing build-GENERIC/firmware-combined.bin to the board
esptool.py v2.8
Serial port /dev/tty.SLAB_USBtoUART
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 5c:cf:7f:d0:91:3e
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 16MB
Flash params set to 0x0090
Compressed 621184 bytes to 409591...
Wrote 621184 bytes (409591 compressed) at 0x00000000 in 36.0 seconds (effective 138.0 kbit/s)...
Hash of data verified.

Leaving...
Verifying just-written flash...
(This option is deprecated, flash contents are now always read back after flashing.)
Flash params set to 0x0090
Verifying 0x97a80 (621184) bytes @ 0x00000000 in flash against build-GENERIC/firmware-combined.bin...
-- verify OK (digest matched)
Hard resetting via RTS pin...

Re: 16M D1 Mini Pro + SDK 2.2.1

Posted: Sat Aug 22, 2020 1:18 pm
by mcauser
Tried flashing latest MicroPython to my 4M D1 mini (with SDK 2.2.1).
Worked fine.

Code: Select all

LINK build-GENERIC/firmware.elf
   text	   data	    bss	    dec	    hex	filename
 616260	   1020	  66504	 683784	  a6f08	build-GENERIC/firmware.elf
Create build-GENERIC/firmware-combined.bin
esptool.py v2.8
Creating image for ESP8266...
flash     33024
 .text    30876 at 0x40100000
 .data    1020 at 0x3ffe8000
 .rodata  1080 at 0x3ffe8400
padding   3840
irom0text 584304
total     621168
md5       0547181b2885ab76c3da217825f35510
Writing build-GENERIC/firmware-combined.bin to the board
esptool.py v2.8
Serial port /dev/tty.usbserial-1420
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 60:01:94:0b:e2:08
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0040
Compressed 621184 bytes to 409587...
Wrote 621184 bytes (409587 compressed) at 0x00000000 in 39.5 seconds (effective 125.9 kbit/s)...
Hash of data verified.

Leaving...
Verifying just-written flash...
(This option is deprecated, flash contents are now always read back after flashing.)
Flash params set to 0x0040
Verifying 0x97a80 (621184) bytes @ 0x00000000 in flash against build-GENERIC/firmware-combined.bin...
-- verify OK (digest matched)
Hard resetting via RTS pin...

Re: 16M D1 Mini Pro + SDK 2.2.1

Posted: Sat Aug 22, 2020 1:23 pm
by mcauser
Quick Fix ™ for 16MB ESP8266
* Download and unzip: https://github.com/espressif/ESP8266_NO ... v2.2.1.zip
* Grab the /bin/esp_init_data_default_v08.bin
* make clean / make / make deploy
* Write the esp_init_data_default_v08.bin:

Code: Select all

esptool.py --port /dev/tty.SLAB_USBtoUART --baud 460800 write_flash -fm dio -fs 16MB 0xffc000 esp_init_data_default_v08.bin

Re: 16M D1 Mini Pro + SDK 2.2.1

Posted: Sat Aug 22, 2020 1:46 pm
by mcauser