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

non-portable asm statements in SDK 8+

In SDK 8.0 the bare word asm was re-introduced in nrf_delay.h, causing failures in compilations that use strict C/C++ standard conformance flags. This was noted in earlier SDKs and had been fixed prior to 8.0.

The ARM standard toolchain abstraction for that keyword is __ASM, as defined in core_cm0.h. A recursive grep in SDK 9.0.0 suggests the following need to be fixed:

components/drivers_nrf/hal/nrf_delay.h:52:register uint32_t delay asm ("r0") = number_of_us;
components/libraries/bootloader_dfu/bootloader_util.c:110:    asm("ldr   r5, [%0]\n"                    // Get App initial MSP for bootloader.
examples/dfu/bootloader/dfu_ble_svc.c:161:    asm("movs  r0, #0x02\n"                    // Load 0x02 into R6 to prepare for exec return test.
examples/dfu/experimental/bootloader_signing/dfu_ble_svc.c:177:    asm("movs  r0, #0x02\n"                    // Load 0x02 into R6 to prepare for exec return test.
examples/dfu/experimental_ant_bootloader/libs/include/compiler_abstraction.h

There are as well several occurrences of __asm which is toolchain-specific (although all currently supported toolchains seem to support it).

Related