This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK 14 buttonless dfu not building with gcc

I'm using SDK 14 and trying to build the ble_app_buttonless_dfu example. I'm using Linux environment, so gcc for building. When I try to build the example I'm getting an error as below,

Compiling file: ble_dfu_unbonded.c
/tmp/cchirqL7.s: Assembler messages:
/tmp/cchirqL7.s:64: Error: cannot honor width suffix -- `ldr.w r12,=#3'
make: *** [_build/nrf52832_xxaa/ble_dfu_unbonded.c.o] Error 1

Please suggest a solution

Parents
  • The compiler is complaining about the following function in nrf_svci.h

       #define SVCI_DECL(svci_num, return_type, function_name, ...)        \
            _Pragma("GCC diagnostic push")                                  \
            _Pragma("GCC diagnostic ignored \"-Wreturn-type\"")             \
            __attribute__((naked, unused))                                  \
            static return_type svci_ ## function_name(__VA_ARGS__)          \
            {                                                               \
                /* Do the SuperVisor call by using svc instruction with     \
                   R12 containing the SVCI number */                        \
                __ASM __volatile                                            \
                (                                                           \
                    "  ldr.w r12, =%0     \n"                               \
                    "  svc %1             \n"                               \
                    "  bx lr              \n"                               \
                    "  .ltorg"                                              \
                    : /* output */                                          \
                    : /* input */                                           \
                        "X"(svci_num),                                      \
                        "I"(GCC_CAST_CPP NRF_SVCI_SVC_NUM)                  \
                    : /* clobbers */                                        \
                        "r12"                                               \
                );                                                          \
            }                                                               \
            _Pragma("GCC diagnostic pop")
    

    Specifically, its the optional instruction width specifier .w, which forces the LDR to generate a 32-bit instruction in Thumb-2 code, according to this Stack Overflow post. Removing this optional specifier, i.e. leaving it t the compiler to decide the instruction width seems to do the trick ,i.e.

    "  ldr r12, =%0     \n"                               \
    
Reply
  • The compiler is complaining about the following function in nrf_svci.h

       #define SVCI_DECL(svci_num, return_type, function_name, ...)        \
            _Pragma("GCC diagnostic push")                                  \
            _Pragma("GCC diagnostic ignored \"-Wreturn-type\"")             \
            __attribute__((naked, unused))                                  \
            static return_type svci_ ## function_name(__VA_ARGS__)          \
            {                                                               \
                /* Do the SuperVisor call by using svc instruction with     \
                   R12 containing the SVCI number */                        \
                __ASM __volatile                                            \
                (                                                           \
                    "  ldr.w r12, =%0     \n"                               \
                    "  svc %1             \n"                               \
                    "  bx lr              \n"                               \
                    "  .ltorg"                                              \
                    : /* output */                                          \
                    : /* input */                                           \
                        "X"(svci_num),                                      \
                        "I"(GCC_CAST_CPP NRF_SVCI_SVC_NUM)                  \
                    : /* clobbers */                                        \
                        "r12"                                               \
                );                                                          \
            }                                                               \
            _Pragma("GCC diagnostic pop")
    

    Specifically, its the optional instruction width specifier .w, which forces the LDR to generate a 32-bit instruction in Thumb-2 code, according to this Stack Overflow post. Removing this optional specifier, i.e. leaving it t the compiler to decide the instruction width seems to do the trick ,i.e.

    "  ldr r12, =%0     \n"                               \
    
Children
Related