Skip to content Skip to sidebar Skip to footer

[Solved] ESP8266 NodeMCU Error Time out waiting for packet header In Ubuntu Linux

FatalError: Failed to connect to ESP8266 : Timed out waiting for packet header Linux

esptool.FatalError: Failed to connect to ESP8266 Error Time out waiting for packet header In Ubuntu Linux - In this article I want to share how to fix the Error ESP8266 cannot be programmed using the Arduino IDE. Here I use NodeMCU V3, for the serial usb used on the board is CH340G.

When I upload the program code, I get an error as shown in the following image.

[Solved] ESP8266 Error Time out waiting for packet header In Ubuntu Linux

I've been looking for a solution to this problem and in the end I tried to reinstall the driver that I got from the CH340 official page, but apparently I got the error again during the installation process like this:

neon@neon:~/Downloads/CH341SER_LINUX$ make
\make -C /lib/modules/5.4.0-89-generic/build  M=/home/neon/Downloads/CH341SER_LINUX  
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-89-generic'
  CC [M]  /home/neon/Downloads/CH341SER_LINUX/ch34x.o
/home/neon/Downloads/CH341SER_LINUX/ch34x.c: In function ‘ch34x_close’:
/home/neon/Downloads/CH341SER_LINUX/ch34x.c:562:2: error: unknown type name ‘wait_queue_t’; did you mean ‘wait_event’?
  562 |  wait_queue_t wait;
      |  ^~~~~~~~~~~~
      |  wait_event
/home/neon/Downloads/CH341SER_LINUX/ch34x.c:573:24: error: passing argument 1 of ‘init_waitqueue_entry’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  573 |  init_waitqueue_entry( &wait, current );
      |                        ^~~~~
      |                        |
      |                        int *
In file included from ./include/linux/mmzone.h:10,
                 from ./include/linux/gfp.h:6,
                 from ./include/linux/slab.h:15,
                 from /home/neon/Downloads/CH341SER_LINUX/ch34x.c:21:
./include/linux/wait.h:79:66: note: expected ‘struct wait_queue_entry *’ but argument is of typeint *’
   79 | ic inline void init_waitqueue_entry(struct wait_queue_entry *wq_entry, struct task_struct *p)
      |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

/home/neon/Downloads/CH341SER_LINUX/ch34x.c:574:36: error: passing argument 2 of ‘add_wait_queue’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  574 |  add_wait_queue( &tty->write_wait, &wait );
      |                                    ^~~~~
      |                                    |
      |                                    int *
In file included from ./include/linux/mmzone.h:10,
                 from ./include/linux/gfp.h:6,
                 from ./include/linux/slab.h:15,
                 from /home/neon/Downloads/CH341SER_LINUX/ch34x.c:21:
./include/linux/wait.h:163:86: note: expected ‘struct wait_queue_entry *’ but argument is of typeint *’
  163 | wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
      |                                             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

/home/neon/Downloads/CH341SER_LINUX/ch34x.c:578:5: error: implicit declaration of function ‘signal_pending’ [-Werror=implicit-function-declaration]
  578 |     signal_pending(current) || port->serial->disconnected )
      |     ^~~~~~~~~~~~~~
/home/neon/Downloads/CH341SER_LINUX/ch34x.c:585:39: error: passing argument 2 of ‘remove_wait_queue’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  585 |  remove_wait_queue( &tty->write_wait, &wait );
      |                                       ^~~~~
      |                                       |
      |                                       int *
In file included from ./include/linux/mmzone.h:10,
                 from ./include/linux/gfp.h:6,
                 from ./include/linux/slab.h:15,
                 from /home/neon/Downloads/CH341SER_LINUX/ch34x.c:21:
./include/linux/wait.h:165:89: note: expected ‘struct wait_queue_entry *’ but argument is of typeint *’
  165 | wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
      |                                             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

/home/neon/Downloads/CH341SER_LINUX/ch34x.c: In function ‘wait_modem_info’:
/home/neon/Downloads/CH341SER_LINUX/ch34x.c:756:3: error: implicit declaration of function ‘interruptible_sleep_on’ [-Werror=implicit-function-declaration]
  756 |   interruptible_sleep_on( &priv->delta_msr_wait );
      |   ^~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:270: /home/neon/Downloads/CH341SER_LINUX/ch34x.o] Error 1
make[1]: *** [Makefile:1762: /home/neon/Downloads/CH341SER_LINUX] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-89-generic'
make: *** [Makefile:5: default] Error 2

A little frustrated, I tried to look at the NodeMCU hardware, maybe there is a damaged component, why the data can't be uploaded. But all looks good.

I also connected a 10uF capacitor to the EN and GND pins. but the result is still an error.

So I feel this is a driver error. Maybe the linux I'm using doesn't match the kernel.

Here I am using Linux Mint 21.04 XFCE. After searching for so long I finally found a driver that someone had modified.


How to Fix ESP8266 Error Time Out Waiting For Packet Header

To fix this, I did a driver installation from that file. Files can be downloaded by clicking the following download button:

or

After the download is complete, please extract the file. Then open a terminal and navigate to the extracted folder. do the command make and sudo make load. As shown in the following:

neon@neon:~/Downloads/CH341SER_LINUX$ make
make -C /lib/modules/5.4.0-89-generic/build  M=/home/neon/Downloads/CH341SER_LINUX  
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-89-generic'
  CC [M]  /home/neon/Downloads/CH341SER_LINUX/ch341.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC [M]  /home/neon/Downloads/CH341SER_LINUX/ch341.mod.o
  LD [M]  /home/neon/Downloads/CH341SER_LINUX/ch341.ko
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-89-generic'
neon@neon:~/Downloads/CH341SER_LINUX$ sudo make load
[sudo] password for neon:        
modprobe usbserial
insmod ch341.ko
After that, open Arduino IDE, select Port and upload the program to Node MCU ESP8266 and Done.

6 comments for "[Solved] ESP8266 NodeMCU Error Time out waiting for packet header In Ubuntu Linux"

  1. Awesome! thank you for sharing this its been a problem I've been wrestling with for nearly 2 days

    ReplyDelete
  2. Thanks. This worked for me also. Had to install make and gcc since Ubuntu doesn't install those by default. Also needed to 'sudo rmmod ch341' when the file was already found. It uploads to the Generic ESP8266 OK now.

    ReplyDelete
  3. You can just `sudo apt install linux-generic-hwe-20.04-edge` and it gets you the 5.11 kernel on 20.04 which also fixes the issue (at least for me).

    ReplyDelete
    Replies
    1. Thanks for your comment. This will be useful.

      Delete