Skip to main content

Factory vs field firmware profiles

IOTMER devices are usually flashed twice with different configuration:

  1. Factory — production line: HTTPS provision, NVS write, optional OTA
  2. Field — deployed device: reads NVS, connects MQTT, no auth code in firmware

The SDK examples map to this split:

ProfileExampleIOTMER_PROVISION_AUTH_CODEMQTT
Factory01_provisioningSet in menuconfigNo client loop
Field02_telemetryEmptyConnect + telemetry

create-app profiles

# Deployed device (NVS already provisioned)
iotmer create-app my-device --profile field

# Production line (first-time provision)
iotmer create-app my-device --profile factory

Each scaffold includes:

  • sdkconfig.defaults — active profile
  • sdkconfig.defaults.field — archived field preset
  • sdkconfig.defaults.factory — archived factory preset

Switch later:

cp sdkconfig.defaults.field sdkconfig.defaults
# or
cp sdkconfig.defaults.factory sdkconfig.defaults
idf.py fullclean build

Factory profile settings

KconfigFactoryNotes
IOTMER_PROVISION_AUTH_CODERequiredConsole API key; never ship in field images
IOTMER_WORKSPACE_IDRequiredSent in provision JSON
IOTMER_OTA_APPLY_EVEN_IF_SAME_SHAy (template default)Re-flash when server returns same SHA
IOTMER_WIFI_SSID / PASSWORDSet per line or APFactory Wi‑Fi

After successful provision, NVS holds device_id, device_key, workspace_slug, MQTT creds.

Field profile settings

KconfigFieldNotes
IOTMER_PROVISION_AUTH_CODEEmptyHTTPS provision skipped when NVS session complete
IOTMER_WORKSPACE_IDEmptyIgnored
IOTMER_OTA_APPLY_EVEN_IF_SAME_SHAnSkip redundant OTA when SHA unchanged

iotmer_init() still runs Wi‑Fi and loads NVS; provision runs only when needed.

iotmer doctor profile hints

doctor guesses the profile from merged sdkconfig / sdkconfig.defaults:

  • factory — auth code non-empty, or IOTMER_OTA_APPLY_EVEN_IF_SAME_SHA=y
  • field — empty auth code

Warnings are emitted when factory/field settings disagree (e.g. auth code set in a field build).

Same codebase, two build targets (CI)

Many teams use one repo and two sdkconfig fragments:

idf.py -DSDKCONFIG_DEFAULTS="sdkconfig.defaults.factory" build # artifact: factory.bin
idf.py -DSDKCONFIG_DEFAULTS="sdkconfig.defaults.field" build # artifact: field.bin

(Exact idf.py flags depend on your ESP-IDF version; copying to sdkconfig.defaults before build is the portable approach.)

Security

  • Do not commit production auth codes or Wi‑Fi passwords.
  • sdkconfig is gitignored in customer projects; use sdkconfig.defaults with empty placeholders.
  • Rotate console credentials if a factory image leaks.