Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling hcd_init multiple times causes a hard_assert #1628

Closed
1 task done
jmark1m opened this issue Sep 7, 2022 · 1 comment
Closed
1 task done

Calling hcd_init multiple times causes a hard_assert #1628

jmark1m opened this issue Sep 7, 2022 · 1 comment
Labels

Comments

@jmark1m
Copy link

jmark1m commented Sep 7, 2022

Operating System

Others

Board

RP2040 / Pico

Firmware

Pico-SDK 1.4.0

What happened ?

I am using TinyUSB as a HOST in a noisy environment and sometimes I need to reset the USB bus. To do this I call "hcd_init(0)" as part of the reset process.

Previously in TinyUSB version 0.13.0, this wasn't an issue and it allowed me to do this without crashing.

After this was added in TinyUSB 0.14.0,
rp2040: use shared IRQ handlers, so user can also hook the USB IRQ by @kilograham in #1519

it crashes on a hard_assert because of the call to "irq_add_shared_handler()" which was previously "irq_set_exclusive_handler()".

I believe the reason it is crashing is that it is exceeding PICO_MAX_SHARED_IRQ_HANDLERS.

Perhaps irq_remove_handler() should be called first?

How to reproduce ?

I added something like this to my code to confirm it crashed,

for(uint8_t x = 0; x < 20; x++ )
{
printf("calling hcd_init %d\r\n", x);
vTaskDelay(100);
hcd_init(0);
}

Debug Log as txt file

calling hcd_init 1
calling hcd_init 2
calling hcd_init 3
assertion "irq_hander_chain_free_slot_head >= 0" failed: file "/home/markj/pico/pico-sdk/src/rp2_common/hardware_irq/irq.c", line 205, funcr

Screenshots

No response

I have checked existing issues, dicussion and documentation

  • I confirm I have checked existing issues, dicussion and documentation.
jmark1m pushed a commit to jmark1m/tinyusb that referenced this issue Sep 7, 2022
hathach added a commit that referenced this issue Sep 13, 2022
Fix bug #1628 by preventing shared irq slots for filling up
gaoyichuan pushed a commit to canokeys/tinyusb that referenced this issue Oct 15, 2022
@hathach
Copy link
Owner

hathach commented Feb 10, 2023

fixed by pr #1629

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants