Skip to content

cyw43_arch_threadsafe_background bugs preventing deinit() / init() #980

@Memotech-Bill

Description

@Memotech-Bill

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions