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

Trimming an nRF52 BLE HID app to fit in 32KB Keil code size limit?

Folks,

Attempting to use a sample app from the 13.0.0 SDK for a pointing (mouse) device I'm prototyping, located at ...\nRF5_SDK_13.0.0_04a0bfd\examples\ble_peripheral\ble_app_hids_mouse

Loader says the code weighs in at 39KB. Sigh... Looks like my free version of the Keil MDK won't let me proceed without some serious trimming.

  • Most sample apps, including this one, appear to have a lot of excess baggage, e.g., logging, security features, etc. Any recommendations on where to start looking for candidate reductions in this app (other than the obvious approach of looking at the code sizes of the various modules)?
  • The HID protocol itself is fairly complex (i.e., fat). Any recommendations on what parts of the protocol can be stubbed out if I just want simple mouse functionality?
  • Of course, there's the option of switching to another IDE, e.g., command-line GCC. (No, a paid upgrade to the Keil MDK is not an option for this project.) Don't mean to start a flame war or ask a totally open-ended question, but any comments from people making this switch would be useful.
  • Actually was considering mbed for this application, but the mbed world seems to have gotten much more complicated lately. Don't anticipate needing the full mbed OS for this application, so mbed Client seems more appropriate. But even there, I certainly don't need the overhead of their communication protocol for IoT cloud apps. Can that be easily left out?
  • How about mbed Classic? Is that a suitable environment for building this app? Or has Nordic support for it dwindled to a level that makes this unwise as mbed moves on?

Sorry to ask such open-ended questions, but a few comments to steer me in the right direction would be very useful. Nothing like the wisdom of the crowd.

Mike

  • Hi Mike,

    • Yes, the obvious candidate is the logging module. If you open sdk_config.h and select the "Configuration Wizard" view ( just above the build output window), you can disable the logging module by unchecking NRF_LOG_ENABLED. This should result in the code weighing in at ~35kB, however, this is not enough.
    • No, can't really recommend any specific parts of the HID protocol that you can strip away.
    • I think this is your best option. I recommend switching to Segger Embedded Studio, see this blog post. You could also move to Eclipse and GCC, see this tutorial, but setting it up is not as straight-forward as Segger Embedded Studio.
    • If you plan on making an actual product that uses the HID protocol and a nRF52, then I recommend that you use the nRF5 SDK.

    Best regards

    Bjørn

Related