ct-Open-Source / tuya-convert

A collection of scripts to flash Tuya IoT devices to alternative firmwares
MIT License
4.58k stars 497 forks source link

dnsmasq problem when installing tuya-convert on two Linux Mint machines #1040

Open hagenbuch opened 2 years ago

hagenbuch commented 2 years ago

I am trying to flash four newly bought Nous A1 - that had no contact to the app so far.

Therefor, I tried to install tuya-convert on a desktop (Intel NUC with wifi) and a Lenovo laptop, both failed with the message:

dnsmasq (2.80-1.1ubuntu1.4) wird eingerichtet ...
Created symlink /etc/systemd/system/multi-user.target.wants/dnsmasq.service → /lib/systemd/system/dnsmasq.service.
Job for dnsmasq.service failed because the control process exited with error code.
See "systemctl status dnsmasq.service" and "journalctl -xe" for details.
invoke-rc.d: initscript dnsmasq, action "start" failed.
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
     Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2022-02-24 12:28:52 CET; 5ms ago
    Process: 120537 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
    Process: 120538 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=2)

Feb 24 12:28:52 ande-hac systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Feb 24 12:28:52 ande-hac dnsmasq[120537]: dnsmasq: Syntaxprüfung OK.
Feb 24 12:28:52 ande-hac dnsmasq[120538]: dnsmasq: failed to create listening socket for port 53: Die Adresse wird bereits verwendet
Feb 24 12:28:52 ande-hac dnsmasq[120538]: failed to create listening socket for port 53: Die Adresse wird bereits verwendet
Feb 24 12:28:52 ande-hac dnsmasq[120538]: Start fehlgeschlagen
Feb 24 12:28:52 ande-hac systemd[1]: dnsmasq.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Feb 24 12:28:52 ande-hac systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
Feb 24 12:28:52 ande-hac systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.

Although I've not installed dnsmasq before, it complains about a port 53 "in use". Not sure why..?

They https://github.com/ct-Open-Source/tuya-convert/pull/838 say it might not be a problem but I still get in the loop

Starting smart config pairing procedure
Waiting for the device to install the intermediate firmware
Put device in EZ config mode (blinking fast)
Sending SSID                  vtrust-flash
Sending wifiPassword          
Sending token                 00000000
Sending secret                0101
................
SmartConfig complete.
Resending SmartConfig Packets
.................
[...]
.................
SmartConfig complete.
Resending SmartConfig Packets
...........
Timed out while waiting for the device to (re)connect
======================================================
Attempting to diagnose the issue...
No ESP82xx based devices connected according to your wifi log.
Here is a list of all the MAC addresses that connected:

If you see your IoT device in this list, it is not an ESP82xx based device.
Otherwise, another issue may be preventing it from connecting.
For additional information, check the *.log files inside the scripts folder.
Please include these logs when opening a new issue on our GitHub issue tracker.
======================================================
Do you want to try flashing another device? [y/N] 

These are my logs:

MQTT:

ande@ande-hac:~/tuya-convert$ cat scripts/smarthack-mqtt.log 
[130880.294249]~DLT~122403~INFO     ~FIFO /tmp/dlt cannot be opened. Retrying later...
1645703474: mosquitto version 1.6.9 starting
1645703474: Using default config.
1645703474: Opening ipv4 listen socket on port 1883.
1645703474: Opening ipv6 listen socket on port 1883.
^C1645703564: mosquitto version 1.6.9 terminating
[130980.235213]~DLT~122403~WARNING  ~Lost log messages in user buffer when exiting: 9
[   78.045761]~DLT~ 2274~INFO     ~FIFO /tmp/dlt cannot be opened. Retrying later...
1645703689: mosquitto version 1.6.9 starting
1645703689: Using default config.
1645703689: Opening ipv4 listen socket on port 1883.
1645703689: Opening ipv6 listen socket on port 1883.
^C1645703967: mosquitto version 1.6.9 terminating
[  365.492876]~DLT~ 2274~WARNING  ~Lost log messages in user buffer when exiting: 9

PSK:

ande@ande-hac:~/tuya-convert$ cat scripts/smarthack-psk.log 
^CTraceback (most recent call last):
  File "./psk-frontend.py", line 113, in <module>
    main()
  File "./psk-frontend.py", line 106, in main
    r,_,_ =  select.select(readables, [], [])
KeyboardInterrupt
^CTraceback (most recent call last):
  File "./psk-frontend.py", line 113, in <module>
    main()
  File "./psk-frontend.py", line 106, in main
    r,_,_ =  select.select(readables, [], [])
KeyboardInterrupt

UDP:

ande@ande-hac:~/tuya-convert$ cat scripts/smarthack-udp.log 
Listening for Tuya broadcast on UDP 6666
Listening for encrypted Tuya broadcast on UDP 6667
^CListening for Tuya broadcast on UDP 6666
Listening for encrypted Tuya broadcast on UDP 6667

WEB:

ande@ande-hac:~/tuya-convert$ cat scripts/smarthack-web.log 
Listening on 10.42.42.1:80
^CReceived SIGINT, exiting...
Listening on 10.42.42.1:80
^CReceived SIGINT, exiting...

WIFI:

ande@ande-hac:~/tuya-convert$ cat scripts/smarthack-wifi.log 
System info
===========
61ba060
Linux ande-hac 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
OpenSSL 1.1.1f  31 Mar 2020
Dnsmasq Version 2.80  Copyright (c) 2000-2018 Simon Kelley
Compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth nettlehash DNSSEC loop-detect inotify dumpfile

Für diese Software wird ABSOLUT KEINE GARANTIE gewährt.
Dnsmasq ist freie Software, und du bist willkommen es weiter zu verteilen
unter den Bedingungen der GNU General Public Lizenz, Version 2 oder 3.
hostapd v2.9
User space daemon for IEEE 802.11 AP management,
IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
Copyright (c) 2002-2019, Jouni Malinen <j@w1.fi> and contributors
Python 3.8.10
===========
Attempting to stop wpa_supplicant
Stopping NetworkManager...
Configuring AP interface...
RTNETLINK answers: File exists
Starting DNSMASQ server...
Starting AP on wlp0s20f3...
Configuration file: /dev/stdin
Using interface wlp0s20f3 with hwaddr 24:41:8c:9e:30:b3 and ssid "vtrust-flash"
wlp0s20f3: interface state UNINITIALIZED->ENABLED
wlp0s20f3: AP-ENABLED 
wlp0s20f3: interface state ENABLED->DISABLED
wlp0s20f3: AP-DISABLED 
wlp0s20f3: CTRL-EVENT-TERMINATING 
nl80211: deinit ifname=wlp0s20f3 disabled_11b_rates=0
AP closed
Stopping DNSMASQ server...
Restarting NetworkManager...
System info
===========
61ba060
Linux ande-hac 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
OpenSSL 1.1.1f  31 Mar 2020
Dnsmasq Version 2.80  Copyright (c) 2000-2018 Simon Kelley
Compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth nettlehash DNSSEC loop-detect inotify dumpfile

Für diese Software wird ABSOLUT KEINE GARANTIE gewährt.
Dnsmasq ist freie Software, und du bist willkommen es weiter zu verteilen
unter den Bedingungen der GNU General Public Lizenz, Version 2 oder 3.
hostapd v2.9
User space daemon for IEEE 802.11 AP management,
IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
Copyright (c) 2002-2019, Jouni Malinen <j@w1.fi> and contributors
Python 3.8.10
===========
Attempting to stop wpa_supplicant
Stopping NetworkManager...
Configuring AP interface...
RTNETLINK answers: File exists
Starting DNSMASQ server...
Starting AP on wlp0s20f3...
Configuration file: /dev/stdin
Using interface wlp0s20f3 with hwaddr 24:41:8c:9e:30:b3 and ssid "vtrust-flash"
wlp0s20f3: interface state UNINITIALIZED->ENABLED
wlp0s20f3: AP-ENABLED 
wlp0s20f3: interface state ENABLED->DISABLED
wlp0s20f3: AP-DISABLED 
wlp0s20f3: CTRL-EVENT-TERMINATING 
nl80211: deinit ifname=wlp0s20f3 disabled_11b_rates=0
AP closed
Stopping DNSMASQ server...
Restarting NetworkManager...

Where could I look to help?

Both machines are Linux Mint version 20.3

Thanks for any hint on this..

Andreas

clmcavaney commented 1 year ago

Not sure if this helps, but I had a similar issue. I am running tuya-convert as a docker container. I had a DNS server running on the host (i.e. which is a Raspberry Pi). As the docker configuration is using "host" networking, there was a conflict when the dnsmasq service in the container attempted to listen on the wifi interface of the Raspberry Pi.

I had to change the DNS server to be more specific for the interfaces that it is listening on.