-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Bad hostname after going to the REPL when using mdns #10048
Comments
I have revised my tests and actually it seems now that the issue manifests on S2 and S3 too, as soon as you enter the REPL. I missed that previously as I relied on stopping the code without pressing a key to enter the REPL apparently. This happened without being related to timing. Before code.py
While code.py is running or after ctrl-C
After entering the REPL (here the name is empty)
After letting this run in the REPL for a couple of seconds while True: print("hello")
That issue with version.json might be a specific Web Workflow issue that could be mitigated there. Or an issue with deiniting of the mdns server on reload when it's supposed to still be in use by the web workflow. |
I'm seeing the exact same behavior. Often times the hostname will be a single control character (I've seen 0x01: SOH - Start of Header, 0x02: STX - Start of Text) as well as random strings as show above. This prevents me from loading into the web workflow code editor. Depending on the state I can occasionally just refresh the browser (WITHOUT restarting the device) and the hostname will change allowing me to get a hostname without an invalid character. But it seems like usually when it's set to SOH or STX refreshing does not change the hostname and I need to manually reset the device. |
The Eventually, in Okay, now we're getting somewhere. We call
|
I suspect this is a mismatch of my expectations of how the IDF works. I thought it duplicated the given string and then held onto it: https://github.com/espressif/esp-idf/blob/0461e2ff88369c3da0d4caced31e8488f53376cd/components/esp_netif/lwip/esp_netif_lwip.c#L1689 However, there is some tricky task stuff here that may mean we sometimes corrupt the hostname before it is copied. Maybe we need to read it back until it matches after setting it? |
Okay just so I'm on the same page, we're looking at: circuitpython/ports/espressif/common-hal/wifi/__init__.c Lines 212 to 217 in ed0e640
You're saying that the call to |
The underlying async call looks like it would be happening here: https://github.com/espressif/esp-idf/blob/0461e2ff88369c3da0d4caced31e8488f53376cd/components/esp_netif/lwip/esp_netif_lwip.c#L212-L227 |
Yup, that was my conclusion too. It looks like it should work. :-) Maybe this is an IDF bug. Maybe LWIP does a second delay. I know the MDNS code does this a lot where it issues a message to another thread to set a value. Reading it doesn't and reads memory directly. |
I've never built and run my own circuitpython firmware. How difficult is the process if I wanted to do something simple like add a check right after the |
It's not that hard if you are familiar with software development on Linux. See https://learn.adafruit.com/building-circuitpython. |
I've made it a bit farther but I'm not sure what the next steps are. I've got everything building and I was hoping to use the ESP_LOG library. I've added some logs but I'm not sure how I can capture this output. For reference: fed68b4 I'm using an https://circuitpython.org/board/adafruit_qtpy_esp32s3_nopsram/ and this is the only CircuitPython device I currently have. Any suggestions? |
CircuitPython version and board name
Code/REPL
Behavior
When the mdns hostname is set just before the code ends, it ends up being scrambled with random data, (looking like a dangling pointer). This is solved by not leaving code.py, or seemingly adding some seconds of sleep before the end. Although for example with a 5 seconds sleep I still get a bad mdns after power cycle, sometimes.
I could not repro on an S2 or S3 QTPY, it seems limited to the C3.
It happens with 9.0.0 but not 8.2.10
version.json
(accessed via IP) be invalid json if the characters are bad.wifi.radio.hostname
however still reports the default hostname. For example:cpy-d_xiao_esp32c3-d4f98d03fbec
There seems to be other issues related to mdns since 9.0, but they don't seem to be the same, though they might have the same underlying cause.
Description
No response
Additional information
Board properly reported from the home page of another board as

test-name
:Default hostname reported by the wifi module:
But has a bad name in web workflow:

If the name causes a bad json:

One such json (varies on reloads):
The text was updated successfully, but these errors were encountered: