Skip to content

Device crashes when starting with USB connected #15073

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
pdunaj opened this issue Apr 1, 2019 · 6 comments
Closed

Device crashes when starting with USB connected #15073

pdunaj opened this issue Apr 1, 2019 · 6 comments
Assignees
Labels
area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug platform: nRF Nordic nRFx priority: high High impact/importance bug

Comments

@pdunaj
Copy link
Collaborator

pdunaj commented Apr 1, 2019

Describe the bug

ASSERTION FAIL [m_drv_state == NRFX_DRV_STATE_INITIALIZED] @ /home/pdunaj/work/ncs/zephyr/ext/hal/nordic/nrfx/drivers/src/nrfx_usbd.c:1708
void nrfx_usbd_enable(void)                                                                                              
{                                                                                                                        
    NRFX_ASSERT(m_drv_state == NRFX_DRV_STATE_INITIALIZED);

To Reproduce
Steps to reproduce the behavior:
Connect USB cable, observe USB working fine. Reset device - observe device dying.

Expected behavior
Device should be able to work fine when starting with USB connected.

Impact
Showstopper

Screenshots or console output

Environment (please complete the following information):
zephyr ncs: 0bf5263b0522bb5cfac84eefdfdee86dc2c67e3e (upstream d3bb3cf)

Additional context
N/A

@pdunaj pdunaj added bug The issue is a bug, or the PR is fixing a bug area: USB Universal Serial Bus labels Apr 1, 2019
@pdunaj
Copy link
Collaborator Author

pdunaj commented Apr 1, 2019

Hi @pawelzadrozniak , is this something new?

@pdunaj
Copy link
Collaborator Author

pdunaj commented Apr 1, 2019

[00000045] <inf> event_manager: e: module_state_event module:main state:READY
[00000145] <inf> hid_state: Init HID state!
[00000146] <dbg> usb_nrfx.usb_dc_ep_check_cap: ep 81, mps 16, type 3
[00000150] <dbg> usb_nrfx.usb_dc_ep_enable: EP enable: 0.
[00000150] <dbg> usb_nrfx.usb_dc_ep_enable: EP enable: 128.
[00000152] <inf> power_manager: Activate power manager
[00000159] <inf> event_manager: e: module_state_event module:board state:READY
[00000161] <inf> event_manager: e: module_state_event module:buttons state:READY
[00000164] <inf> event_manager: e: module_state_event module:wheel state:READY
[00000167] <inf> event_manager: e: module_state_event module:leds state:READY
[00000169] <inf> event_manager: e: module_state_event module:battery state:READY
[00000172] <inf> event_manager: e: module_state_event module:usb_state state:READY
[00000175] <inf> event_manager: e: led_event led_id:0 mode:ON period:0 color: < 255 0 20 >
[00000180] <inf> event_manager: e: led_event led_id:1 mode:BLINKING period:1000 color: < 150 0 0 >
[00000260] <wrn> bt_hci_core: No ID address. App must call settings_load()
[00000260] <inf> ble_state: Bluetooth initialized
[00000262] <dbg> usb_nrfx.usbd_work_process_pwr_events: USB detected
[00000263] <dbg> usb_nrfx.hf_clock_enable: HF clock start success (-68)
[00000263] <dbg> usb_nrfx.usbd_work_process_pwr_events: USB detected
ASSERTION FAIL [m_drv_state == NRFX_DRV_STATE_INITIALIZED] @ /home/pdunaj/work/ncs/zephyr/ext/hal/nordic/nrfx/drivers/src/nrfx_usbd.c:1708
***** Kernel Panic! *****
Current thread ID = 0x20004174
Faulting instruction address = 0xbc00

@carlescufi
Copy link
Member

@pdunaj can you revert 8604d08 and see if it fixes it?

@jfischer-no
Copy link
Collaborator

It is broken after bdde5fd, #14875.

With current master, the device does not exit the while loop inside nrfx_usbd_enable()

    while (0 == (NRF_USBD_EVENTCAUSE_READY_MASK & nrf_usbd_eventcause_get()))                            
    {                                                                                                    
        /* Empty loop */                                                                                 
    }            

@jfischer-no jfischer-no added the priority: medium Medium impact/importance bug label Apr 1, 2019
@pdunaj
Copy link
Collaborator Author

pdunaj commented Apr 1, 2019

Hi @carlescufi , sure. Will be back in a sec.

@pdunaj
Copy link
Collaborator Author

pdunaj commented Apr 1, 2019

Hi @carlescufi , I reverted bdde5fd98489013b7ac477e8549f218497bf3f06 (seems to be the commit you referred to on the ncs fork) and issue is gone. If we cannot do quick revert and upmerge then I propose to revert it on fork until fix is ready upstream.

@jfischer-no jfischer-no added the platform: nRF Nordic nRFx label Apr 1, 2019
@carlescufi carlescufi added priority: high High impact/importance bug and removed priority: medium Medium impact/importance bug labels Apr 1, 2019
nashif pushed a commit to pawelzadrozniak/zephyr that referenced this issue Apr 2, 2019
Fixes bug introduced in zephyrproject-rtos#14875.
USBDETECTED event is be generated on cable attachment and
when cable is already attached during reset, but not when
the peripheral is re-initialized. When USB-enabled bootloader
is used, target application will not receive this event
and it needs to be generated again. This commit implements
a check against driver being enabled multiple times in case
of application without bootlader starting with cable attached
(both "fake" and "real" events are generated). Such dirty
trick allows bootloader to leave the peripheral in any state
before jumping to target application.

Fixes zephyrproject-rtos#15073

Signed-off-by: Paweł Zadrożniak <[email protected]>
nashif pushed a commit that referenced this issue Apr 2, 2019
Fixes bug introduced in #14875.
USBDETECTED event is be generated on cable attachment and
when cable is already attached during reset, but not when
the peripheral is re-initialized. When USB-enabled bootloader
is used, target application will not receive this event
and it needs to be generated again. This commit implements
a check against driver being enabled multiple times in case
of application without bootlader starting with cable attached
(both "fake" and "real" events are generated). Such dirty
trick allows bootloader to leave the peripheral in any state
before jumping to target application.

Fixes #15073

Signed-off-by: Paweł Zadrożniak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug platform: nRF Nordic nRFx priority: high High impact/importance bug
Projects
None yet
Development

No branches or pull requests

5 participants