raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.73k stars 928 forks source link

stdio_init_all() very slow in sdk 2.0 #1902

Open liubinbj opened 1 month ago

liubinbj commented 1 month ago

in the old sdk 1.x , that function runs very fast, but in sdk 2.0 , it takes about 3s, it's funny. I guess it is a problem!

peterharperuk commented 1 month ago

Is this to connect to usb or uart? Are you running one of the pico-examples?

liubinbj commented 1 month ago

Is this to connect to usb or uart? Are you running one of the pico-examples?

it connect to usb. not examples, but one of my projects.

pico_enable_stdio_usb(skydogge 1) pico_enable_stdio_uart(skydogge 0)

the stdio_init_all() is first line in the main(), but it takes 3 seconds, if use sdk 1.x , it's very fast.

peterharperuk commented 1 month ago

Have you set PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS to 3000? The pico-examples do this. If you have this set and you haven't connected USB it will wait 3s.

liubinbj commented 1 month ago

PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS

don't know that and not set that value, and then I set PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS=0 to test. still have 3s delay, with or without usb connection.

arturo182 commented 1 month ago

Probably best way to analyze would be to connect a debugger and stop execution during those 3s to see what the MCU doin.

peterharperuk commented 1 month ago

Cannot reproduce. for me it takes about 0.5 ms. You'll have to attach an example that demonstrates the issue. The only reason it would take seconds is if it's waiting for usb to connect.