World wide free shipping on orders over 100€ - PayPal and Stripe payments - Made in Finland

Preparing Binaries for Distribution

You have developed your program to run on RuuviTag and want to share it with the world. However, not everyone has access to Ruuvi Developer shield, and therefore you’ll need to create a DFU packet for users to install. Also, you might want to create a “full package” which contains softdevice, bootloader and your application.

The Ruuvi component
RuuviTag DevShield is an easy way to debug and flash RuuviTag units.

To create the full hex package, you’ll need to merge softdevice, bootloader and application into one. However, the bootloader needs additional adjustment: The bootloader will check CRC of the application, and application will be booted only if the CRC matches. Therefore you need to calculate the CRC of the application and merge proper CRC into the bootloader. Fortunately, Nordic Semi provides nRFutil which does most of the heavy lifting.

To generate the settings for your application, run nrfutil settings generate — family NRF52 — application test_drivers.hex — application-version 1 — bootloader-version 1 — bl-settings-version 1 settings.hex. Replace the application hex as necessary. Versioning of the application and bootloader can be anything if you’re running on default RuuviTag, as it skips checking those versions. However, bl-settings-version has to be correct. If you’re going to develop end-user application and want to have control over the firmware which gets uploaded to your tags, you’ll want to generate your own keypair, compile your own bootloader with the keys and enforce version checks. However preparing for mass production is a subject for another Dev Diary entry.

Softdevice we’re using is s132 3.1.0. Now you have the hexes ready, merge them into one package with mergehex included in nRF5x tools. mergehex -m ruuvitag_b3_bootloader.hex settings.hex -o configured_bootloader.hex and mergehex -m s132_nrf52_3.1.0_softdevice.hex configured_bootloader.hex test_drivers.hex -o test_drivers_full.hex

Then, it’s time to create the DFU package with nRFutil: nrfutil pkg generate — key-file ruuvitag_fw/keys/ruuvi_open_private.pem — application test_drivers.hex — debug-mode test_drivers_dfu.zip

It’s always a good idea to cycle the a few DFU packages to your tag after uploading your package for the first time. It’s possible to craft DFU packets with invalid settings which will lock down the bootloader making rescuing the Tag quite an operation which involves making, testing and flashing a special rescue bootloader just to be able to restore the tag.

Also you should always check the power consumption of your tag before releasing the binaries to the wild. We’ll cover power profiling in a future Dev Diary entry.

Featured Products

Find the right products for your measuring needs
  • RuuviTag sensor measures temperature, air humidity, air pressure and motionIn stock
    RuuviTag is a Bluetooth sensor that sends temperature, relative...
    Read more

    RuuviTag Sensor (4in1)

    39,90
  • Ruuvi KitIn stock
    Every Ruuvi Gateway product is shipped with...
    Read more

    Ruuvi Sensor Measurement Kit

    339,00
  • Ruuvi GatewayIn stock
    Note! Every Ruuvi Gateway product is shipped with a...
    Read more

    Ruuvi Gateway Router

    199,00
  • RuuviTag Pro 3in1 measures temperature, air humidity and motionIn stock
    Choose your model (2in1, 3in1 or 4in1) depending on...
    Read more

    RuuviTag Pro Sensor

    49,9055,90