---
title: Compile-Time Configuration (sdk_sgr_config.h)
description: Compile-Time Configuration (sdk_sgr_config.h)
---

[Skip to content](https://portal.sandgrain.eu/knowledge-base/compile-time-configuration-sdk-sgr-config.h#main-content)

English

Show submenu for translations

![SandGrain\_Logo\_RGB\_white-bijgesneden (1)](https://portal.sandgrain.eu/hs-fs/hubfs/SandGrain_Logo_RGB_white-bijgesneden%20(1).png?width=427&height=83&name=SandGrain_Logo_RGB_white-bijgesneden%20(1).png)

Open main navigation

Close main navigation

- English
  
  Show submenu for translations
- [Contact us](https://portal.sandgrain.eu/login)

[Contact us](https://portal.sandgrain.eu/login?hsLang=en)

 How can we help you?

- There are no suggestions because the search field is empty.

1. [Knowledge Base](https://portal.sandgrain.eu/knowledge-base?hsLang=en)
2. [SDK](https://portal.sandgrain.eu/knowledge-base/sdk?hsLang=en)
3. [SandGrain SDK](https://portal.sandgrain.eu/knowledge-base/sdk?hsLang=en#sandgrain-sdk)

October 6, 2026

# Compile-Time Configuration (sdk\_sgr\_config.h)

**Who this is for:** Developers who need to understand or change how the SDK is built.

**What you'll accomplish:** Understand each compile-time parameter, what it controls, and which ones you must set intentionally for production.

**These take effect at compile time.** Changing them means rebuilding (`make clean && make`). Several can also be overridden from the build system with a `-D` flag, noted below.

### Parameters in `sdk_sgr_config.h`

#### `SDK_MODE`

Selects `DEVICE_MODE` or `GATEWAY_MODE`, which functions and port implementations are compiled in. **If undefined, the build fails with a compile-time error.** See *Device Mode vs Gateway Mode*.

#### `GW_CRYPTO_ENABLED`

Whether the Gateway requires its own crypto Token via USB/SPI. Default: **not required**. Has no effect in `DEVICE_MODE` (the Token is always required there).

#### `MAX_RETRIES` / `GW_MAX_RETRIES`

Device-side and gateway-side retry limits. Validated at compile time; a minimum is enforced with a compiler warning.

#### `CW_BITFLIP_THRESHOLD` / `RW_BITFLIP_THRESHOLD`

Tolerated bit differences when comparing Challenge/Response Words. **Lower = stricter, higher = more tolerant.**

A value of `0` means any single bit difference triggers Error Management / immediate failure. That's valid, but **set it intentionally**, it's not a safe default to leave unexamined.

#### `CRC_ENABLE`

Message CRC integrity checking.

- **Disabled (`0`) by default in this branch** for local testing.
- **Mandatory outside local testing.** Enable it with `-DCRC_ENABLE=1`.
- A mismatch produces `SGR_SDK_CRC_ERROR`.

### Debug flags (six, independent)

`MW_DEBUG`, `PORT_COMM_DEBUG`, `PORT_COMM_INPUT_DEBUG`, `PORT_COMM_DEVICE_DEBUG`, `APP_GW_DEBUG`, `MW_GW_DEBUG`. Each can be overridden from the build system (e.g. `-DMW_DEBUG`).

#### **Important: don't edit the core files**

The default values live in files you should **not** edit:

- `poc_sdk_device/sdk_fw/include/sdk_sgr_config.h`
- `poc_sdk_gateway/sdk_fw/include/sdk_sgr_config.h`

More broadly, the `sdk_fw/` core directory should not be modified, with the single exception of `src/services/database/auth_db_whitelist.c` (the device whitelist). To change behavior, pass `-D` flags at build time rather than editing these headers.

### Production checklist

Before shipping a production build:

- \[   \] **Disable all debug flags.**
- \[   \] **Enable CRC** (`-DCRC_ENABLE=1`).
- \[   \] **Set bit-flip thresholds explicitly** and intentionally.
- \[   \] Keep secret keys inside the crypto chip (never exposed by the SDK).

 

- [User Documentation](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#main-content)

    - [Quick Starter Guide](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#quick-starter-guide)
    - [User Manual](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#user-manual)
    - [Whitepaper](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#whitepaper)
    - [Token Leaflet](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#token-leaflet)
    - [Claim Token Procedure](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#claim-token-procedure)
    - [Daisy Chain](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#daisy-chain)
    - [Release Note](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#release-note)
    - [Naming Convention](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#naming-convention)
    - [SandGrain SDK](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#sandgrain-sdk)
    - [TrustBridge](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#trustbridge)
- [API Documentation](https://portal.sandgrain.eu/knowledge-base/api-documentation?hsLang=en#main-content)

    - [Device API Integration](https://portal.sandgrain.eu/knowledge-base/api-documentation?hsLang=en#device-api-integration)
    - [Daisy Chain and Attestation](https://portal.sandgrain.eu/knowledge-base/api-documentation?hsLang=en#daisy-chain-and-attestation)
- [SDK](https://portal.sandgrain.eu/knowledge-base/sdk?hsLang=en#main-content)

    - [Core Functions](https://portal.sandgrain.eu/knowledge-base/sdk?hsLang=en#core-functions)
    - [SandGrain SDK](https://portal.sandgrain.eu/knowledge-base/sdk?hsLang=en#sandgrain-sdk)

[![SandGrain\_Logo\_RGB\_white-bijgesneden (1)-1](https://portal.sandgrain.eu/hs-fs/hubfs/SandGrain_Logo_RGB_white-bijgesneden%20(1)-1.png?width=427&height=83&name=SandGrain_Logo_RGB_white-bijgesneden%20(1)-1.png "SandGrain_Logo_RGB_white-bijgesneden (1)-1")](https://portal.sandgrain.eu/?hsLang=en)

<https://www.facebook.com/> <https://www.twitter.com/> <https://www.instagram.com/> <https://podcasts.apple.com/> [mailto:email@email.com](mailto:email@email.com)

Copyright © 2026, sandgrain.eu