embassy-rs / embassy

Modern embedded framework, using Rust and async.
https://embassy.dev
Apache License 2.0
4.84k stars 653 forks source link

embassy-net hangs creating TcpSocket with feature dns #2866

Closed aughey closed 2 months ago

aughey commented 2 months ago

This is with embassy-net 0.4.0

This is running on a rp2040w

Have an application that works without issue connecting to numeric IP addresses without dns. Simply enabling feature dns causes the application to hang when calling TcpSocket::new() with the same tx and rx buffers.

I double-checked the A-B test, and simply enabling the DNS feature causes the application to hang. I am not attempting to query the DNS, simply create the TcpSocket after net initialization.

If I do try to query an address using DNS, the query does work, but the TCPSocket still hangs the device.

Dirbaio commented 2 months ago

do you have a debug probe to view logs? or are you viewing them through embassy-usb-logger or similar? If it's the latter, it's probably a panic instead of a hang, and you'd be able to see the panic message if you had a debug probe.

Most likely reason is you have to increase the max socket count in embassy-net's StackResources. The panic message would've told you that :)

aughey commented 2 months ago

I suspect you're right and increasing the SOCK generic argument from 2 to 4 did seem to fix it.

I have now enabled the embassy-usb-logger, but I did not see a panic message. This is secondary to my original question, but how do I enable panic messages to be sent through the usb logger?

Dirbaio commented 2 months ago

embassy-usb-logger can't send panic messages. When a panic occurs, the firmware is crashed and can't keep USB working. The only way to get panic messages out is to use a debug probe, because that can stay working independently of the firmware.

I recommend you get a 2nd Pico and put this firmware on it https://github.com/raspberrypi/debugprobe . Works very well, is very cheap.