Skip to content

NeoKey Trinkey crashes into hardfault handler with example that previously worked #4791

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
kattni opened this issue May 20, 2021 · 4 comments · Fixed by #4798
Closed

NeoKey Trinkey crashes into hardfault handler with example that previously worked #4791

kattni opened this issue May 20, 2021 · 4 comments · Fixed by #4798
Assignees
Milestone

Comments

@kattni
Copy link

kattni commented May 20, 2021

The actual example is significantly longer, but I narrowed it down to the following 10 lines of code to reproduce it. Tested on two different NeoKey Trinkeys running the same firmware.

Limor reported that the original example worked fine a few weeks ago. (If I change the setup order, it works now.)

Firmware

Adafruit CircuitPython 7.0.0-alpha.2-610-g7511e1c78 on 2021-05-20; Adafruit NeoKey Trinkey M0 with samd21e18

Code/REPL

import board
import neopixel
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS

keyboard = Keyboard(usb_hid.devices)
keyboard_layout = KeyboardLayoutUS(keyboard)

pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.1)

Behavior

Save the above example as code.py on a NeoKey Trinkey, and it will enter safe mode with the following info.

Auto-reload is off.
Running in safe mode! Not running saved code.

You are in safe mode because:
CircuitPython core code crashed hard. Whoops!
Crash into the HardFault_Handler.
Please file an issue with the contents of your CIRCUITPY drive at
https://github.com/adafruit/circuitpython/issues

If you setup the NeoPixel before the keyboard, it does not crash into the hardfault handler.

@kattni kattni added the bug label May 20, 2021
@dhalbert dhalbert added this to the 7.0.0 milestone May 21, 2021
@dhalbert
Copy link
Collaborator

I tried this on a Rotary Trinkey pretending to be a NeoKey Trinkey, and it did not crash. My lib/ directory is completely empty, so I am using all the frozen versions, and using _pypixelbuf.

Adafruit CircuitPython 7.0.0-alpha.2-628-g9a7a2bb27-dirty on 2021-05-21; Adafruit NeoKey Trinkey M0 with samd21e18
>>> import board
>>> import neopixel
>>> import usb_hid
>>> from adafruit_hid.keyboard import Keyboard
>>> from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
>>> 
>>> keyboard = Keyboard(usb_hid.devices)
>>> keyboard_layout = KeyboardLayoutUS(keyboard)
>>> 
>>> pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.1)

I also tried it as a file I imported. Note that the version I am using is different. Try it with https://adafruit-circuit-python.s3.amazonaws.com/bin/adafruit_neokey_trinkey_m0/en_US/adafruit-circuitpython-adafruit_neokey_trinkey_m0-en_US-20210521-9a7a2bb.uf2

@kattni
Copy link
Author

kattni commented May 21, 2021

@dhalbert The version you linked still crashes into the hardfault handler for me with that code in code.py. My lib directory was also empty already.

@dhalbert
Copy link
Collaborator

Reproduced! Thanks. It has to be in code.py, so it's timing-related. I think this may be a race condition between fetching usb_hid.devices and USB setup.

@kattni
Copy link
Author

kattni commented May 21, 2021

@dhalbert The original example has a time.sleep(1) to "avoid race conditions on some machines". But it still fails with that in there. FYI.

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.

3 participants