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

bootloader_util.c does not compile with GCC without -Os option

If I try to build my project using GCC and I change the optimization flag to something other than -Os then I get the following error:

D:/Nordic/nRF51_SDK_8.1.0_b6ed55f/components/libraries/bootloader_dfu/bootloader_util.c: In function 'bootloader_util_reset': D:/Nordic/nRF51_SDK_8.1.0_b6ed55f/components/libraries/bootloader_dfu/bootloader_util.c:106:1: error: r7 cannot be used in asm here } ^ Is there any way to fix this?

Parents Reply
  • yes I skipped over the how as makefiles are not my speciality. The reason by the way is that the ARM ABI uses r7 as the frame pointer in Thumb mode (r11 in ARM mode), which is why you almost always see

    push {r7, lr}
    sub sp, sp, <some number>
    add r7, sp, #0
    

    at the start of every function in debug mode. The debugger then knows where all the local copies of the variables are kept so it can show them. So gcc stops you using r7 in debug mode unless you tell it not to use the frame pointer. if you turn it off globally that works too, but your code becomes very hard to debug.

Children
No Data
Related