Unable to run even simplest program on 2 different ESP8266 boards (Arduino framework)

Boards are: Lolin D1 mini lite and Espduino ESP8266 ESP-WROOM-02

Compilation and upload finishes without any problems but even simplest programs won’t run.
Built in LED won’t blink, nothing comes out on serial monitor, GPIOs won’t change state from HI to LO and back (I’ve checked with voltmeter).

Even if I upload empty program (empty setup and loop functions) and reset the board, serial monitor shows:

ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v00040710
~ld

From Arduino IDE v1.8.13 everything works perfectly.

I’m using PlatformIO with VS Code for my projects with ESP32 and Arduino framework and it just works.

I’ve tried changing various options in platformio.ini file so they match build options from Arduino IDE but haven’t had success.

Current platformio.ini:

[env:d1_mini_lite]
platform = espressif8266
board = d1_mini_lite
framework = arduino
board_build.mcu = esp8266
board_build.f_flash = 40000000L
board_build.flash_mode = dout
monitor_speed = 74800
upload_speed = 921600
build_flags = 
    -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
    -D VTABLES_IN_FLASH

What can be wrong here?

And with which Arduino IDE → Tools settings is that?

Default for the “Lolin D1 mini lite”.

Arduino IDE spits this in log window:

Archiving built core (caching) in: /tmp/arduino_cache_762034/core/core_esp8266_esp8266_d1_mini_lite_xtal_80,vt_flash,exception_disabled,stacksmash_disabled,ssl_all,mmu_3232,non32xfer_fast,eesz_1M64,ip_lm2f,dbg_Disabled,lvl_None____,wipe_none,baud_921600_caac1cf7d2a03f9d48f111209a817e6c.a
. Variables and constants in RAM (global, static), used 28104 / 80192 bytes (35%)
???   SEGMENT  BYTES    DESCRIPTION
????????? DATA     1496     initialized variables
????????? RODATA   920      constants       
????????? BSS      25688    zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 59667 / 65536 bytes (91%)
???   SEGMENT  BYTES    DESCRIPTION
????????? ICACHE   32768    reserved space for flash instruction cache
????????? IRAM     26899    code in IRAM    
. Code in flash (default, ICACHE_FLASH_ATTR), used 232100 / 1048576 bytes (22%)
???   SEGMENT  BYTES    DESCRIPTION
????????? IROM     232100   code in flash   
esptool.py v3.0
Serial port /dev/ttyUSB1
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: dc:4f:22:2c:42:6c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0340
Compressed 265568 bytes to 195680...
Writing at 0x00000000... (8 %)
Writing at 0x00004000... (16 %)
Writing at 0x00008000... (25 %)
Writing at 0x0000c000... (33 %)
Writing at 0x00010000... (41 %)
Writing at 0x00014000... (50 %)
Writing at 0x00018000... (58 %)
Writing at 0x0001c000... (66 %)
Writing at 0x00020000... (75 %)
Writing at 0x00024000... (83 %)
Writing at 0x00028000... (91 %)
Writing at 0x0002c000... (100 %)
Wrote 265568 bytes (195680 compressed) at 0x00000000 in 4.4 seconds (effective 481.5 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

I’ve tried to make PlatformIO options as similar as this, fiddled with flash size and other options but couldn’t make it work.

Interesting that it detects 4MB when the partition table is set for 1MB flash max, reading from here.

None of this should be necessary since these are already the defaults.

Does the serial monitor work when you flash the firmware with PlatformIO, but use only the serial monitor (Tools → Serial Monitor) from the Arduino IDE?

I’ve uploaded the “CheckFlashConfig” sketch I found somewhere and this is what it spits out:

Flash real id:   0016405E
Flash real size: 4194304 bytes

Flash ide  size: 4194304 bytes
Flash ide speed: 40000000 Hz
Flash ide mode:  DOUT
Flash Chip configuration ok.

So that’s why I tried to set up some options to match these.
I’ve tried various flash and filesystem options:

;board_build.ldscript = eagle.flash.4m.ld
;board_build.ldscript = eagle.flash.auto.ld
;board_build.ldscript = eagle.flash.4m1m.ld
;board_build.ldscript = eagle.flash.1m64.ld
;board_build.filesystem = littlefs

None of them worked.

Does the serial monitor work when you flash the firmware with PlatformIO, but use only the serial monitor (Tools → Serial Monitor) from the Arduino IDE?

If I understood your last question, I’ve flashed simple program that blinks LED and prints some characters to the Serial using PlatformIO. Upload went OK, so it says …
LED doesn’t blink at all.
In PlatformIO’s serial monitor only text I can see is that crash report from the initial post after reset and none of the stuff that program sends.
When I then launch Arduino IDE and its serial monitor set to same baud rate I get exactly the same result: crash report after reset and nothing else.

Just a small update: I’ve tried reinstalling ESP8266 platform inside PlatformIO from 4.0.1 all the way to 3.0.0 and back.
No change …

Yet another update …

I’ve tried to understand what are PlatformiIO and Arduino IDE v2.x doing differently to see why PlatformIO fails to produce correct image.

Some conclusions are:

  • They both use same version of esptool. I can use any of them to upload generated image. However I upload Arduino IDE image - it works, however I upload PIO image - it doesn’t work.
  • boot images are the same in both Arduino IDE and PIO
  • generated sketch images (ELFs), before linking with the boot image, are different for Arduino IDE and PIO (could be due to different compiler options, haven’t gone into details)
  • if I link generated ELF with the boot ELF manually Arduino or PIO way, if I use Arduino generated ELF it works, if I use PIO generated ELF it doesn’t work
  • I’ve tried tons of build_flags, various versions of ldscripts, platform versions, ALL ESP8266 boards etc. it’s always the same (negative) result
  • I’ve tried all that on 3 different machines, 2 physical running on Fedora Linux and 1 virtual running Win10. Results are the same.

I conclude that PlatformIO-Arduino-ESP8266 combination is broken. PlaftormIO either produces wrong binary code or, more likely, screws up partitioning info.
I’ve tried to inspect ELF header info but I don’t know enough to see if there is something wrong.

Pitty, working in Arduino IDE is pain in the [BEEEP] …

Dundo