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

Nordic SDK boilerplate code size

I am still somewhat of a beginner to development with nRF51, but it seems to be that the SDK, specifically all the boilerplate code in the app_template example just to initialize the softdevice and so on generates almost 30 KB of code (using SDK v10, S110 and ARM's GCC 4.9.3 distribution with optimizing with -O3). It also consumes almost 2 KB of RAM already, leaving only 6 KB of RAM for the 16 KB RAM variant (xxaa I believe) of the chip.

Why is the boilerplate already so big? Were the older versions much smaller? This looks to me like one can only use the biggest 256 KB flash and 32 KB RAM variant with the current SDK.

Or are my GCC settings or something like that wrong?

Update: I checked the specific app_template code size. So when compiling the app_template in /nRF51_SDK_10.0.0/examples/ble_peripheral/ble_app_template/pca10028/s110/armgcc with gnu make and the makefile supplied by Nordic (i.e. I compile the exact app_template as it comes with the SDK distribution and with ARM GCC 4.9.3 installed on my system) I get the following output about the sizes (Nordic's makefile uses -O3):

  text    data     bss     dec     hex filename
  27120     112    1884   29116    71bc _build/nrf51422_xxac_s110.out

So we can clearly see that the "boilerplate", i.e. what I consider the least amount of setup code even without actually setting up the BLE services, but just calling ble_stack_init() and the other stuff from the app_template, you need 30 KB already.

Even when using -Os instead of -O3 it's still 20 KB, so 10 KB less, but still a lot:

text    data     bss     dec     hex filename
  17176     112    1876   19164    4adc _build/nrf51422_xxac_s110.out
Parents
  • I feel like this is going a bit off topic: My main question was why the Bluetooth app_template generates so much code. It is not surprising that you could have an app that does nothing interesting, especially not use Bluetooth, but that's not a very useful consideration for a Bluetooth SoC like nRF51. I am just wondering why the SoftDevice already eats up 96 KB - somewhat close to the 128 KB that the smaller variant has in flash and then I still need to do a lot of stuff in "my" app generating at least 20 KB of such code. So it's like you need 116 KB just for Bluetooth and setup.

    I also can't follow your argument that IAR and Keil generate more optimized code. This StackOverflow post suggests that this is a myth and that in reality a properly configured GCC comes very close.

Reply
  • I feel like this is going a bit off topic: My main question was why the Bluetooth app_template generates so much code. It is not surprising that you could have an app that does nothing interesting, especially not use Bluetooth, but that's not a very useful consideration for a Bluetooth SoC like nRF51. I am just wondering why the SoftDevice already eats up 96 KB - somewhat close to the 128 KB that the smaller variant has in flash and then I still need to do a lot of stuff in "my" app generating at least 20 KB of such code. So it's like you need 116 KB just for Bluetooth and setup.

    I also can't follow your argument that IAR and Keil generate more optimized code. This StackOverflow post suggests that this is a myth and that in reality a properly configured GCC comes very close.

Children
No Data
Related