Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console connection lost #6

Open
FransM opened this issue Feb 22, 2024 · 18 comments
Open

console connection lost #6

FransM opened this issue Feb 22, 2024 · 18 comments

Comments

@FransM
Copy link

FransM commented Feb 22, 2024

ESP32 S3 wifi version

After boot I can connect to the console using ttyACM1 with baud rate 115200.
However the connection is dropped after 2.5 minute.

The shell is not closed; If I start this shell script:

while true
do
date
sleep 1
done

The script remains running. When I reconnect to the console it is still printing the date. but after 2.5 minute the connection is dropped again.

No idea what causes this.

It seems that with more activity on the console (me typing) the timeout happens faster.

@jcmvbkbc
Copy link
Owner

What kind of esp board do you have? What terminal program do you use? Do you see anything in the dmesg when disconnection happens?

I can connect to the console using ttyACM1

Do I understand it correctly that this happens with unchanged firmware/etc partition and you connect to the UART, not to the USB/JTAG port?

@FransM
Copy link
Author

FransM commented Feb 22, 2024

I have this board:
https://www.aliexpress.com/item/1005006060932309.html?spm=a2g0o.order_list.order_list_main.22.21ef1802z44nzB
It is widely available on AliExpress

It seems to be similar to this espressif board:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1-v1.0.html

although it has a different layout.

And I indeed connect to the uart USB port (the top one when looking at the component side of the board with the esp module facing to the left.
The other USB port is used for powering the board (that is /dev/ttyACM0, the uart is /dev/ttyACM1)

My host system is ubuntu 22.04.
I'm currently using cu to connect to the port as it is command line and therefore easy to restart (just cursor up and enter in bash). But I also tried putty with the same results.

dmesg does not contain info.
This is the tail from /var/log/messages

Jan 1 00:00:07 buildroot kern.info sysctl: * Applying /etc/sysctl.conf ...
Jan 1 00:00:07 buildroot kern.debug kernel: [ 4.152513] with arguments:
Jan 1 00:00:07 buildroot kern.debug kernel: [ 4.155424] /sbin/init
Jan 1 00:00:07 buildroot kern.debug kernel: [ 4.158168] with environment:
Jan 1 00:00:07 buildroot kern.debug kernel: [ 4.161262] HOME=/
Jan 1 00:00:07 buildroot kern.debug kernel: [ 4.163595] TERM=linux
Jan 1 00:00:07 buildroot kern.info sysctl: kernel.default_stack_size = 16384
Jan 1 00:00:11 buildroot daemon.info : starting pid 106, tty '/dev/console': '/sbin/getty -L console 0 vt100 '
Jan 1 00:00:31 buildroot auth.warn login[106]: invalid password for 'UNKNOWN' on 'console'
Jan 1 00:00:35 buildroot auth.info login[106]: root login on 'console'

The last 4 lines are only in /var/log/messages. dmesg ends at the TERM=linux line.

Oh and I have no idea yet how to connect using JTAG. I've received this board just a day ago. If there are other ways to connect via serial please educate me.
My next steps will be to try to get up wifi and then ssh.

@jcmvbkbc
Copy link
Owner

jcmvbkbc commented Feb 22, 2024

I have this board:

something's wrong with that link, the page says 'Sorry, the page you requested can not be found:('

I'm currently using cu to connect to the port

FWIW I use minicom

dmesg does not contain info.

I meant dmesg on your host where the terminal program is running.

Oh and I have no idea yet how to connect using JTAG. I've received this board just a day ago. If there are other ways to connect via serial please educate me.

It's not really a JTAG, there's a combined USB Serial/JTAG peripheral in the esp32s3 and if you put the line
earlycon=esp32s3acm,mmio32,0x60038000 console=ttyGS3 debug rw root=mtd:rootfs no_hash_pointers
into the /etc/cmdline and reboot the kernel will use that instead of the UART0 for the console. On the ESP32-S3-DevKitC-1 board that would be the right connector (marked as USB).

@jcmvbkbc
Copy link
Owner

I'm currently using cu to connect to the port

I've installed cu and tried the following command line: cu -s 115200 -f -l ttyUSB0, been connected for 10 minutes, no issues so far.

@FransM
Copy link
Author

FransM commented Feb 22, 2024

Maybe this ali link will work for you
aliexpress esp32-s3 devboard

The board itself keeps running after disconnecting serial. It was up for 3 hrs, then I changed /etc/cmdline as you instructed and rebooted. The board and the connection are now up fro 12 min without any issue.

Still struggling a bit on how to enable wifi (preferably in a way that survives reboot)
I've filled in the network section in wpa_supplicant.conf but it does not connect.
I get:

/etc # wpa_supplicant -i espsta0 -c /etc/wpa_supplicant.conf -D nl80211
Successfully initialized wpa_supplicant
espsta0: SME: Trying to authenticate with 08:bf:b8:94:4f:08 (SSID='M-net' freq=2412 MHz)
E (1109403) wifi:null wpa_sta_ap_set_rsnxe
espsta0: CTRL-EVENT-DISCONNECTED bssid=08:bf:b8:94:4f:08 reason=202
BSSID 08:bf:b8:94:4f:08 ignore list count incremented to 2, ignoring for 10 seconds
espsta0: SME: Trying to authenticate with 08:bf:b8:94:4f:08 (SSID='M-net' freq=2412 MHz)
E (1117973) wifi:null wpa_sta_ap_set_rsnxe
espsta0: CTRL-EVENT-DISCONNECTED bssid=08:bf:b8:94:4f:08 reason=202
BSSID 08:bf:b8:94:4f:08 ignore list count incremented to 2, ignoring for 10 seconds
espsta0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="M-net" auth_failures=1 duration=10 reason=CONN_FAILED
espsta0: CTRL-EVENT-SSID-REENABLED id=0 ssid="M-net"
espsta0: SME: Trying to authenticate with 08:bf:b8:94:4f:08 (SSID='M-net' freq=2412 MHz)
E (1133133) wifi:null wpa_sta_ap_set_rsnxe
espsta0: CTRL-EVENT-DISCONNECTED bssid=08:bf:b8:94:4f:08 reason=202
espsta0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="M-net" auth_failures=2 duration=31 reason=CONN_FAILED
BSSID 08:bf:b8:94:4f:08 ignore list count incremented to 2, ignoring for 10 seconds
espsta0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="M-net" auth_failures=3 duration=50 reason=CONN_FAILED

ssid and channel are correct
I've double and triple checked the psk in wpa_supplicant and it is correct (and quoted)

edit: reboot did not help, wpa_supplicant is started but I keep getting
wifi:null wpa_sta_ap_set_rsnxe
messages

@jcmvbkbc
Copy link
Owner

jcmvbkbc commented Feb 22, 2024

Still struggling a bit on how to enable wifi (preferably in a way that survives reboot)

The intended method is writing your settings to /etc/wpa_supplicant.conf. Network bringup scripts will use it.

There's a few examples of wpa_supplicant settings in the manual, including a WPA3 case, see if it helps.

Also here's what I see with the wrong password in the config file in my WPA2 PSK setup:

~ # wpa_supplicant -i espsta0 -c /tmp/wpa_supplicant.conf
Successfully initialized wpa_supplicant
espsta0: SME: Trying to authenticate with bc:a5:11:60:34:18 (SSID='fox den' freq=2462 MHz)
E (730895) wifi:null wpa_sta_ap_set_rsnxe
espsta0: Trying to associate with bc:a5:11:60:34:18 (SSID='fox den' freq=2462 MHz)
espsta0: Associated with bc:a5:11:60:34:18
espsta0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
espsta0: CTRL-EVENT-DISCONNECTED bssid=bc:a5:11:60:34:18 reason=15
espsta0: WPA: 4-Way Handshake failed - pre-shared key may be incorrect
espsta0: CTRL-EVENT-SSID-TEMP-DISABLED id=1 ssid="fox den" auth_failures=1 duration=10 reason=WRONG_KEY
espsta0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
espsta0: CTRL-EVENT-SSID-REENABLED id=1 ssid="fox den"
espsta0: SME: Trying to authenticate with bc:a5:11:60:34:18 (SSID='fox den' freq=2462 MHz)
E (754525) wifi:null wpa_sta_ap_set_rsnxe
espsta0: Trying to associate with bc:a5:11:60:34:18 (SSID='fox den' freq=2462 MHz)
espsta0: Associated with bc:a5:11:60:34:18
espsta0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
espsta0: CTRL-EVENT-DISCONNECTED bssid=bc:a5:11:60:34:18 reason=15
espsta0: WPA: 4-Way Handshake failed - pre-shared key may be incorrect
espsta0: CTRL-EVENT-SSID-TEMP-DISABLED id=1 ssid="fox den" auth_failures=2 duration=24 reason=WRONG_KEY
espsta0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
...

@jcmvbkbc
Copy link
Owner

Maybe this ali link will work for you

It doesn't either. Anyway, I was interested in the kind of UART-to-USB convertor on that board.

The board itself keeps running after disconnecting serial.

I suspect that there may be an issue in the USB part of that connection and dmesg tail on the host side could give some hints about it.

@jcmvbkbc
Copy link
Owner

wpa_supplicant is started but I keep getting
wifi:null wpa_sta_ap_set_rsnxe
messages

This message appears even in case of successful connection, so it does not indicate a problem on its own.

@FransM
Copy link
Author

FransM commented Feb 22, 2024

Found an image of the board on the internet
image
Oh and if you need a better image of a chip I can try to make a photo of my board

Wrt the wifi:
I was unaware of the manual on the ESP-Hosted-NG Git Hub. Will study that.

And thanks for mentioning that the message is not a problem. I was already googling if that could explain the problem.

For the USB port. I;ll try again. The port is now connected to my docking station. I seem to recall that I also tested connecting to the laptop directly, but will reverify and then also check dmesg on host

@FransM
Copy link
Author

FransM commented Feb 22, 2024

Just found this: https://mischianti.org/vcc-gnd-studio-yd-esp32-s3-devkitc-1-clone-high-resolution-pinout-and-specs/
aparently the usb to serial chip is a CH343p

Also some good news.
I swapped cables so the USB uart is connected directly to the laptop.
Now the connection is not dropped, so I suspect the problem was caused by the docking station.

Wrt the wifi: no progress yet.
I've set up a passwordless AP and removed wpa-supplicant.conf.
I can then connect to the ap using
iw dev espsta0 connect OpenAP
According to the (openwrt) router log the board connects.
I then gave it a static IPv4 address using ip addr and a proper ip address and netmask, but if I then run ping to the router there is no response. Wireshark does not show any traffic.

@jcmvbkbc
Copy link
Owner

jcmvbkbc commented Feb 22, 2024

I then gave it a static IPv4 address using ip addr and a proper ip address and netmask, but if I then run ping to the router there is no response.

what do ifconfig and ip route on the esp32s3 say?

@FransM
Copy link
Author

FransM commented Feb 22, 2024

My network is an IPv4 /24 network with network address 192.168.123.0

This is what I got
~ # ip addr 192.168.123.45/24 dev espsta0
ip: invalid argument '192.168.123.45/24' to 'ip'
~ # ip addr add 192.168.123.45/24 dev espsta0
~ # ping 192.168.123.1
PING 192.168.123.1 (192.168.123.1): 56 data bytes
^C
--- 192.168.123.1 ping statistics ---
12 packets transmitted, 0 packets received, 100% packet loss
~ # ^C
~ # ifconfig
espsta0 Link encap:Ethernet HWaddr F4:12:FA:CE:F5:9C
inet addr:192.168.123.45 Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr: fe80::f612:faff:fece:f59c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:352 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1344 (1.3 KiB) TX bytes:1344 (1.3 KiB)

~ # ip route
192.168.123.0/24 dev espsta0 scope link src 192.168.123.45

~ # cat /proc/net/wireless
Inter-| sta-| Quality | Discarded packets | Missed | WE
face | tus | link level noise | nwid crypt frag retry misc | beacon | 22
espsta0: 0000 0 0 0 0 0 0 0 0 0

~ # iw dev espsta0 link
Connected to 0a:bf:b8:94:4f:08 (on espsta0)
SSID: OpenWrt
freq: 2412
RX: 0 bytes (0 packets)
TX: 8000 bytes (25 packets)
signal: -67 dBm

@jcmvbkbc
Copy link
Owner

Something's not right here: looks like your pings went out the lo interface. Also broadcast address on the espsta0 is incorrect.

@FransM
Copy link
Author

FransM commented Feb 22, 2024

Hmm, after doing a disconnect from the open AP on the esp and reconnecting ping starts to work.
The connection to the wpa secured AP does not work

This is my wpa_supplicant.conf file
country=nl
#ctrl_interface=/var/run/wpa_supplicant
ap_scan=1

network={
ssid="M-net"
#psk="EDITED AWAY"
psk=EDITED AWAY
}

@FransM
Copy link
Author

FransM commented Feb 22, 2024

Good news, I finally got it running.
In the router I disabled 802.11w Management Frame Protection

ping time to my router is typically around 20 ms

@jcmvbkbc
Copy link
Owner

In the router I disabled 802.11w Management Frame Protection

You may try to add ieee80211w=2 into the network block of you wpa_supplicant.conf instead.

@FransM
Copy link
Author

FransM commented Feb 23, 2024

If I then in the router set the 802.11w protection to Optional I cannot make the connection, (so with ieee80211w=2 in the network section of wpa_supplicant.conf)
Actually when I changed the router side to have 802.11w protection to disabled again, the esp still would not connect after a reboot. When I commented out the ieee80211w=2 line (and kept 80211w protection to disabled) the esp did connect after a reboot.
I suspect this is something in wpa_supplicant.
Maybe not related bu tin ./build-buildroot-esp32s3/build/wpa_supplicant-2.10/wpa_supplicant/defconfig I did not see an option to enable 80211W

I won't have much time to experiment next week. Will try to come back to this later.

@jcmvbkbc
Copy link
Owner

Thanks for checking anyway.

I suspect this is something in wpa_supplicant.

That's certainly a possibility. I've noticed that the buildroot config has almost all wpa_supplicant options turned off, maybe 802.11w support depends on them. Or maybe it's not fully supported by the esp_hosted_ng. I'd just make a note that it doesn't work for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants