You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may be something I don't grok about how the UART and the wifi chip interact. Here's the setup NOT using wifi:
I have a PicoProbe connected to SWD and to UART0 (GP0 and GP1). Anything I printf comes across just great, and the serial connection survives a chip flash or reset. For example, I can do this:
it's magic - the board resets and I have serial maintained across the link.
UNLESS I also use anything in pico_cyw43_arch_lwip_threadsafe_background - even blinking the LED. What happens is that I have to kill and restart the serial connection to get it to work again.
I'm not deep enough into this all to understand, but it seems like something in that library is resetting the UART somehow?
Anyone able to explain this? The code is below
/** * Copyright (c) 2024 Gregory C Herlein * Derived from sample code at https://www.iopress.info/index.php/books/master-the-raspberry-pi-pico-in-c-wifi-with-lwip-mbedtls/9-programs/73-picocprogramswifi?showall=1 * SPDX-License-Identifier: BSD-3-Clause */#include"pico/stdlib.h"#include<stdint.h>#include<stdbool.h>#include<stdio.h>#include<string.h>#include"pico/stdlib.h"#include"pico/binary_info.h"#include"pico/cyw43_arch.h"#include"credentials.h"intsetup(uint32_tcountry, constchar*ssid, constchar*pass, uint32_tauth)
{
if (cyw43_arch_init_with_country(country))
{
return1;
}
cyw43_arch_enable_sta_mode();
if (cyw43_arch_wifi_connect_blocking(ssid, pass, auth))
{
return2;
}
printf("IP: %s\n",
ip4addr_ntoa(netif_ip_addr4(netif_default)));
printf("Mask: %s\n",
ip4addr_ntoa(netif_ip_netmask4(netif_default)));
printf("Gateway: %s\n",
ip4addr_ntoa(netif_ip_gw4(netif_default)));
printf("Host Name: %s\n",
netif_get_hostname(netif_default));
}
intmain()
{
uint32_tauth=CYW43_AUTH_WPA2_MIXED_PSK;
// workaround for a hardware debug problem// https://forums.raspberrypi.com/viewtopic.php?t=363914// also in openocd you need to us -c "set USE_CORE 0" before rp2040.cfg is loaded per https://github.com/raspberrypi/debugprobe/issues/45timer_hw->dbgpause=0;
sleep_ms(150);
stdio_init_all();
setup(country, ssid, pass, auth);
while (true)
{
printf("on\n");
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
sleep_ms(500);
printf("off\n");
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
sleep_ms(500);
}
}
I have to kill and restart the serial connection to get it to work again.
"kill and restart" from the Pico W side, from the Pico Probe side, or from the PC-side?
How are you powering the Pico W and Pico Probe? If they're both being powered from the same USB port, I wonder if the additional power draw from the WiFi chip is causing a brownout? (Perhaps raspberrypi/debugprobe#148 is relevant here? )
Does this happen with the standard pico-examples? I certainly never reset my serial connection. Are you using Windows or Linux? What does the "reset" command do?
UPDATE: I don't see this from other test code, so this may be something weird in my setup or example code. If so, I really apologize. I'm capturing the state of things here just in case, but other test programs using the same libraries are NOT exhibiting this behavior. I hope I didn't waste your time.
I am on Linux, no Windows in my house. On the serial side, I use screen from a Linux terminal. When I say "reset" I mean "ctrl-a k y" to end the screen session, then restart screen at the Linux command line. NOT at the Pico.
The PicoProbe is on it's own USB port, separate from the Pico. I usually power the Pico from a USB power supply, not plugged into a computer.
My experience is that at least on Ubuntu if I connect the Pico and PicoProbe to the computer AND use the USB serial connection to the computer AND do a reset or flash the Pico over the probe THEN I have to restart screen (e.g. "ctrl-a k y" to end the screen session, then restart screen). That's no matter what I run.
IF I power the Pico from a USB power supply AND connect the PicoProbe to the computer AND use the UART serial connection to the computer AND do a reset or flash the Pico over the probe THEN serial just keeps on going, no restart of the screen session required.
Same exact configuration, computer, wiring, installation of the SDK, everything. I'll chase this a little later today and see if I can find something. I hate dangling unexplained things.
This may be something I don't grok about how the UART and the wifi chip interact. Here's the setup NOT using wifi:
I have a PicoProbe connected to SWD and to UART0 (GP0 and GP1). Anything I printf comes across just great, and the serial connection survives a chip flash or reset. For example, I can do this:
openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000" -c "init ; reset halt ; rp2040.core1 arp_reset assert 0 ; rp2040.core0 arp_reset assert 0 ; exit"
it's magic - the board resets and I have serial maintained across the link.
UNLESS I also use anything in pico_cyw43_arch_lwip_threadsafe_background - even blinking the LED. What happens is that I have to kill and restart the serial connection to get it to work again.
I'm not deep enough into this all to understand, but it seems like something in that library is resetting the UART somehow?
Anyone able to explain this? The code is below
(Edited by lurch to put the code inside triple-backticks)
The text was updated successfully, but these errors were encountered: