ZBOSS NCP build optimization

Hello,

I build the ZBOSS NCP sample from NCS v2.6.0 for the nRF52840 dongle.
I use the optimization flag -O2 (for speed) in the build configuration (VS Code NCS extension), and this causes the NCP to crash and reset when I send the ZDO_MGMT_NWK_UPDATE_REQ request.

Could you try this out and confirm that there is an issue with the firmware after optimization?

Best regards,
Damien

Parents Reply Children
  • Hi Damien,

    The problem can be fixed by adding NOP instructions to time-critical code in sdk-nrfxlib/nrf_802154/driver/, like this:

    diff --git a/nrf_802154/driver/src/nrf_802154_request_swi.c b/nrf_802154/driver/src/nrf_802154_request_swi.c
    index fe1b43a6..6bb8ab08 100644
    --- a/nrf_802154/driver/src/nrf_802154_request_swi.c
    +++ b/nrf_802154/driver/src/nrf_802154_request_swi.c
    @@ -292,6 +292,10 @@ static inline void assert_interrupt_status(void)
         {                                              \
             assert_interrupt_status();                 \
             func_swi(__VA_ARGS__, &result);            \
    +        __NOP();                                   \
    +        __NOP();                                   \
    +        __NOP();                                   \
    +        __NOP();                                   \
         }                                              \
                                                        \
         return result;
    @@ -307,6 +311,10 @@ static inline void assert_interrupt_status(void)
         {                                                 \
             assert_interrupt_status();                    \
             func_swi(&result);                            \
    +        __NOP();                                      \
    +        __NOP();                                      \
    +        __NOP();                                      \
    +        __NOP();                                      \
         }                                                 \
                                                           \
         return result;
    

    Let me know if this also fixes the issue on your side.

    Please note that the -O2 option is non-default, so we cannot guarantee that all nRF Connect SDK components are tested with it.

    Best regards,
    Marte

Related