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

-march flag to optimize nRF51822

I am using Nordic SDK to program an nRF51822 chip. I want to optimize power consumption as much as possible so I am looking at using the -march gcc flag. The problem is I don't know what cpu-type the nRF51822 is. When I run m make file using -march=native I get the following error:
"cc1: error: unrecognized argument in option '-march=native' cc1: note: valid arguments to '-march=' are: armv2 armv2a armv3 armv3m armv4 armv4t armv5 armv5e armv5t armv5te armv6 armv6-m armv6j armv6k armv6s-m armv6t2 armv6z armv6zk armv7 armv7-a armv7-m armv7-r armv7e-m armv8-a iwmmxt iwmmxt2 native Makefile:184: recipe for target '_build/nrf_drv_clock.o' failed make[1]: *** [_build/nrf_drv_clock.o] Error 1"

What option should I use to optimize power consumption?

  • The march flag has nothing to do with power consumption at all. You don't need to set it, just use -mcpu=cortex-m0 (in the nrf51 case) and that tells gcc what the architecture is, as well as other information about possible FPU and extensions, none of which you have on the m0. I'm sure your current makefile already sets that flag.

    So just set the -mcpu flag and that's it. There's nothing to be gained by adding the -march flag, there's only one possible architecture for the cortex-m0 and the compiler already knows what it is.

Related