Chat freely about anything...

User avatar
By Thomas Meier
#85600 Hi guys, I'm new to the ESP8266 and IoT for that matter. The possibilities of home automation has caught my interest and the relative inexpensive hardware to connect the various components in a secure way makes this an attractive way to be creative, tinker with electronics and software alike :)

Got my first controller - a WeMos D1 R1 - and set it up with the latest Arduino IDE. First sketch you hear about anywhere is the blink sketch. So I opened it (after setting up Arduino, board manager etc.), compiled and downloaded it. LED blinks. Text book. All good so far.

Have tried a few more sketches to get a feel for the whole environment but now I'm getting an error message

"esptool.FatalError: Invalid head of packet (0x46)"

Scanning through the log what seems really strange is the message that the crystal frequency was detected at 20.39MHz as opposed to 26MHz.

Could this be a hardware issue or not related to that at all?

Thanks guys


"Arduino: 1.8.10 (Windows 10), Board: "WeMos D1 R1, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, All Flash Contents, 921600"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\tfmei\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\tfmei\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\tfmei\Documents\Arduino\libraries -fqbn=esp8266:esp8266:d1:xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=all,baud=921600 -vid-pid=10C4_EA60 -ide-version=10810 -build-path C:\Users\tfmei\AppData\Local\Temp\arduino_build_369769 -warnings=none -build-cache C:\Users\tfmei\AppData\Local\Temp\arduino_cache_590026 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.mkspiffs.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\2.5.0-4-b40a506 -prefs=runtime.tools.mkspiffs-2.5.0-4-b40a506.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\2.5.0-4-b40a506 -prefs=runtime.tools.python3.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.mklittlefs.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\mklittlefs\2.5.0-4-69bd9e6 -prefs=runtime.tools.mklittlefs-2.5.0-4-69bd9e6.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\mklittlefs\2.5.0-4-69bd9e6 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506 -prefs=runtime.tools.xtensa-lx106-elf-gcc-2.5.0-4-b40a506.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506 -verbose C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\esp8266\examples\Blink\Blink.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\tfmei\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\tfmei\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\tfmei\Documents\Arduino\libraries -fqbn=esp8266:esp8266:d1:xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=all,baud=921600 -vid-pid=10C4_EA60 -ide-version=10810 -build-path C:\Users\tfmei\AppData\Local\Temp\arduino_build_369769 -warnings=none -build-cache C:\Users\tfmei\AppData\Local\Temp\arduino_cache_590026 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.mkspiffs.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\2.5.0-4-b40a506 -prefs=runtime.tools.mkspiffs-2.5.0-4-b40a506.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\2.5.0-4-b40a506 -prefs=runtime.tools.python3.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.mklittlefs.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\mklittlefs\2.5.0-4-69bd9e6 -prefs=runtime.tools.mklittlefs-2.5.0-4-69bd9e6.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\mklittlefs\2.5.0-4-69bd9e6 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506 -prefs=runtime.tools.xtensa-lx106-elf-gcc-2.5.0-4-b40a506.path=C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506 -verbose C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\esp8266\examples\Blink\Blink.ino
Using board 'd1' from platform in folder: C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3
Using core 'esp8266' from platform in folder: C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3
Detecting libraries used...
"C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/include" "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/lwip2/include" "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -ffunction-sections -fdata-sections -fno-exceptions -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10810 -DARDUINO_ESP8266_WEMOS_D1R1 -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1R1\"" -DFLASHMODE_DIO -DESP8266 "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3\\cores\\esp8266" "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3\\variants\\d1" "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769\\sketch\\Blink.ino.cpp" -o nul
Generating function prototypes...
"C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/include" "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/lwip2/include" "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -ffunction-sections -fdata-sections -fno-exceptions -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10810 -DARDUINO_ESP8266_WEMOS_D1R1 -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1R1\"" -DFLASHMODE_DIO -DESP8266 "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3\\cores\\esp8266" "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3\\variants\\d1" "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769\\sketch\\Blink.ino.cpp" -o "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\python3\\3.7.2-post1/python3" "C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/signing.py" --mode header --publickey "C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3\\libraries\\esp8266\\examples\\Blink/public.key" --out "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/core/Updater_Signing.h"
"C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/include" "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/lwip2/include" "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -MMD -ffunction-sections -fdata-sections -fno-exceptions -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10810 -DARDUINO_ESP8266_WEMOS_D1R1 -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1R1\"" -DFLASHMODE_DIO -DESP8266 "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3\\cores\\esp8266" "-IC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3\\variants\\d1" "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769\\sketch\\Blink.ino.cpp" -o "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769\\sketch\\Blink.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\tfmei\AppData\Local\Temp\arduino_cache_590026\core\core_d12412711b5758b355cc654bdd7041da.a
Linking everything together...
"C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506/bin/xtensa-lx106-elf-gcc" -CC -E -P -DVTABLES_IN_FLASH "C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/ld/eagle.app.v6.common.ld.h" -o "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/local.eagle.app.v6.common.ld"
"C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506/bin/xtensa-lx106-elf-gcc" -fno-exceptions -Wl,-Map "-Wl,C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/Blink.ino.map" -g -w -Os -nostdlib -Wl,--no-check-sections -u app_entry -u _printf_float -u _scanf_float -Wl,-static "-LC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/lib" "-LC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/lib/NONOSDK22x_190703" "-LC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/ld" "-LC:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sdk/libc/xtensa-lx106-elf/lib" -Teagle.flash.4m2m.ld -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read -o "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/Blink.ino.elf" -Wl,--start-group "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769\\sketch\\Blink.ino.cpp.o" "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_cache_590026\\core\\core_d12412711b5758b355cc654bdd7041da.a" -lhal -lphy -lpp -lnet80211 -llwip2-536-feat -lwpa -lcrypto -lmain -lwps -lbearssl -laxtls -lespnow -lsmartconfig -lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc -Wl,--end-group "-LC:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769"
"C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\python3\\3.7.2-post1/python3" "C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/elf2bin.py" --eboot "C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/bootloaders/eboot/eboot.elf" --app "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/Blink.ino.elf" --flash_mode dio --flash_freq 40 --flash_size 4M --path "C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506/bin" --out "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/Blink.ino.bin"
Creating BIN file "C:\Users\tfmei\AppData\Local\Temp\arduino_build_369769/Blink.ino.bin" using "C:\Users\tfmei\AppData\Local\Temp\arduino_build_369769/Blink.ino.elf"

"C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\python3\\3.7.2-post1/python3" "C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/signing.py" --mode sign --privatekey "C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3\\libraries\\esp8266\\examples\\Blink/private.key" --bin "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/Blink.ino.bin" --out "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/Blink.ino.bin.signed" --legacy "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/Blink.ino.bin.legacy_sig"
"C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\python3\\3.7.2-post1/python3" "C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3/tools/sizes.py" --elf "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/Blink.ino.elf" --path "C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506/bin"
Executable segment sizes:

IROM : 227612 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 26776 / 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)
DATA : 1252 ) - initialized variables (global, static) in RAM/HEAP
RODATA : 672 ) / 81920 - constants (global, static) in RAM/HEAP
BSS : 24880 ) - zeroed variables (global, static) in RAM/HEAP

"C:\\Users\\tfmei\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-4-b40a506/bin/xtensa-lx106-elf-size" -A "C:\\Users\\tfmei\\AppData\\Local\\Temp\\arduino_build_369769/Blink.ino.elf"
Sketch uses 256312 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 26804 bytes (32%) of dynamic memory, leaving 55116 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM4
Connecting.....
Chip is ESP8266EX
Features: WiFi
WARNING: Detected crystal freq 20.39MHz is quite different to normalized freq 26MHz. Unsupported crystal in use?
Crystal is 26MHz
MAC: 00:08:ff:00:00:00
Uploading stub...
Running stub...
Traceback (most recent call last):
File "C:\Users\tfmei\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/upload.py", line 65, in <module>
esptool.main(cmdline)
File "C:/Users/tfmei/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 2909, in main
esp = esp.run_stub()
File "C:/Users/tfmei/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 637, in run_stub
p = self.read()
File "C:/Users/tfmei/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 292, in read
return next(self._slip_reader)
File "C:/Users/tfmei/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 2057, in slip_reader
raise FatalError('Invalid head of packet (0x%s)' % hexify(b))
esptool.FatalError: Invalid head of packet (0x46)
esptool.FatalError: Invalid head of packet (0x46)"
User avatar
By Thomas Meier
#85630
JurajA wrote:the esptool detects wrong frequency on baud rate mismatch. try lower baud rate

Thanks. If you're referring to the upload speed I have the following values and tried all with the same result. The values are 921600, 57600, 115200, 256000, 512000, 3000000. What's a bit strange is the order of values. The list looks like it's ascending so why would that first value be 921600 which doesn't look like a regular speed anyway... I only have this board for now so I can't check with another one.

When opening the monitor on the COM port it displays gibberish with any baud rate other than 115200 baud but I suppose uploading a sketch (which is where I have the problem) and communicating on the COM port are two different things.
User avatar
By Thomas Meier
#85656
JurajA wrote:the esptool detects wrong frequency on baud rate mismatch. try lower baud rate

If you're referring to the upload speed I have tried all values. What's really strange is the list seems to be sorted in ascending order but the first value is this 921600, followed by 57600, 115200, 256000 etc. so that first value seems out of place...

Also when I open the monitor and change the baud rate of the monitor it displays gibberish when I press Reset for all values except 115000. Probably not related as I have issues with the code upload. Just thought I'd mention it anyway