pico-sdk icon indicating copy to clipboard operation
pico-sdk copied to clipboard

cyw43_arch_threadsafe_background bugs preventing deinit() / init()

Open Memotech-Bill opened this issue 3 years ago • 1 comments

I have code which is linked using the CMake cyw43_arch_threadsafe_background link_library. The code can call cyw43_arch_init(), cyw43_arch_deinit() and later cyw43_arch_init() again.

The second call to cyw43_arch_init() hangs.

I have found at least two issues which are responsible for this:

  • In cyw43_arch_threadsafe_background.c routine cyw43_arch_init() includes the line:

gpio_add_raw_irq_handler_with_order_priority(IO_IRQ_BANK0, gpio_irq_handler, CYW43_GPIO_IRQ_HANDLER_PRIORITY);

However cyw43_arch_deinit() is missing the corresponding:

gpio_remove_raw_irq_handler (IO_IRQ_BANK0, gpio_irq_handler);

  • Secondly, in file cyw43_arch_poll.c, the call to lwip_init() is wrapped in code to ensure that it is called only on the first call to cyw43_arch_init():
    static bool done_lwip_init;
    if (!done_lwip_init) {
        lwip_init();
        done_lwip_init = true;
    }

However, the call to lwip_init() in cyw43_arch_threadsafe_background.c is missing a similar wrapper.

Memotech-Bill avatar Aug 19 '22 06:08 Memotech-Bill

See also #968 and #969 ?

lurch avatar Aug 19 '22 10:08 lurch

should be fixed by #1177; please give it a try if you can - i haven't yet tested this particular issue

kilograham avatar Jan 18 '23 01:01 kilograham

#1177 merged into develop

kilograham avatar Jan 24 '23 18:01 kilograham