raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.25k stars 838 forks source link

If it is possible to offer a stdio_deinit_all funtion? #1688

Open mxyxbb opened 2 months ago

mxyxbb commented 2 months ago

Background Since I want to printf some information before and after I overclock the rp2040, may I initialize the stdio again as the sys clock has been changed? If I initialize it only once before I overclock the chip, uart baudrate will go wrong after the overclock. If I initialize it only once after I overclock the chip, printf info will not be visiable before the overclock. If I initialize it twice before and after I overclock the chip, the init func will fill up shared irq slots in rp2040 mcu, which cause no shared irq can be used in my user function.

Summary if I call function stdio_init_all() many times, it will fill up shared irq slots in rp2040 mcu, which cause no shared irq can be used in my user function.

error logs: assertion "irq_hander_chain_free_slot_head >= 0" failed: file "H:\shared_files\pico\pico-sdk\src\rp2_common\hardware_irq\irq.c", line 215, function: irq_add_shared_handler

If it is possible to offer a stdio_deinit_all funtion? It seems that same issue occurs here in the tinyusb repo: Calling hcd_init multiple times causes a hard_assert.

peterharperuk commented 2 months ago

Thanks for the explanation. I haven't looked at the stdio code but I would assume it's possible.