Skip to content

“All timers in use” from AudioOut() after 4 soft reloads on PewPew M4 #5057

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

Closed
cwalther opened this issue Jul 25, 2021 · 5 comments · Fixed by #5127
Closed

“All timers in use” from AudioOut() after 4 soft reloads on PewPew M4 #5057

cwalther opened this issue Jul 25, 2021 · 5 comments · Fixed by #5127
Assignees
Milestone

Comments

@cwalther
Copy link

CircuitPython version

Adafruit CircuitPython 7.0.0-alpha.5-42-g0a3c75c43 on 2021-07-25; PewPew M4 with samd51g19

Code/REPL

import audioio, board; a = audioio.AudioOut(board.SPEAKER)

Behavior

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 7.0.0-alpha.5-42-g0a3c75c43 on 2021-07-25; PewPew M4 with samd51g19
>>> import audioio, board; a = audioio.AudioOut(board.SPEAKER)
>>> 
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 7.0.0-alpha.5-42-g0a3c75c43 on 2021-07-25; PewPew M4 with samd51g19
>>> import audioio, board; a = audioio.AudioOut(board.SPEAKER)
>>> 
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 7.0.0-alpha.5-42-g0a3c75c43 on 2021-07-25; PewPew M4 with samd51g19
>>> import audioio, board; a = audioio.AudioOut(board.SPEAKER)
>>> 
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 7.0.0-alpha.5-42-g0a3c75c43 on 2021-07-25; PewPew M4 with samd51g19
>>> import audioio, board; a = audioio.AudioOut(board.SPEAKER)
>>> 
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 7.0.0-alpha.5-42-g0a3c75c43 on 2021-07-25; PewPew M4 with samd51g19
>>> import audioio, board; a = audioio.AudioOut(board.SPEAKER)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: All timers in use
>>>

Description

Creating an audioio.AudioOut instance, then soft-reloading using ^D works four times, the fifth time it raises a RuntimeError: All timers in use. Apparently something is not properly being reset in the soft reload.

This appears to be specific to the PewPew M4, maybe related to its display initialization. I cannot reproduce it on an ItsyBitsy M4 Express using the same firmware version. (It can however be reproduced by installing the PewPew M4 firmware on the ItsyBitsy, for those who don’t have a PewPew M4.)

Additional information

No response

@cwalther cwalther added the bug label Jul 25, 2021
@cwalther
Copy link
Author

git bisect points to 1a076d3 as the commit that introduced the bug. Probably the change of included modules, let me check if I can narrow it down further.

@cwalther
Copy link
Author

It’s the disabling of CIRCUITPY_PWMIO that causes the issue.

It looks like common_hal_audioio_audioout_construct() sets up a timer but audioout_reset() doesn’t reset it and instead relies on pwmout_reset() to do it? Or is someone supposed to call common_hal_audioio_audioout_deinit() on a soft reset and that is not happening?

That’s all the investigation I’m going to do for now. I’m guessing it should be reproducible on any SAMD board with CIRCUITPY_AUDIOIO = 1and CIRCUITPY_PWMIO = 0.

@microdev1
Copy link
Collaborator

Or is someone supposed to call common_hal_audioio_audioout_deinit() on a soft reset and that is not happening?

The ctrl+d routine calls reset_port() which calls module_reset() functions, module module_deinit() functions are not called.

@deshipu
Copy link

deshipu commented Jul 26, 2021

I could work around this by enabling pwmio and disabling analogio instead.

@cwalther
Copy link
Author

In my testing, just enabling pwmio without disabling anything worked. But I didn’t test all languages.

@tannewt tannewt added this to the 7.0.0 milestone Jul 26, 2021
@tannewt tannewt added the audio label Jul 26, 2021
@tannewt tannewt self-assigned this Aug 6, 2021
microdev1 pushed a commit that referenced this issue Aug 14, 2021
This prevents timer leakage on builds without pwmio.

Fixes #5057
nitz pushed a commit to nitz/circuitpython that referenced this issue Aug 16, 2021
This prevents timer leakage on builds without pwmio.

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

Successfully merging a pull request may close this issue.

4 participants