ble firmware development company

    BLE Firmware and OTA Update Design: Dual-Bank Flash, Power Loss Safety, and Mobile Sync

    BLE firmware & OTA guide: GATT throughput, dual-bank flash, power-loss rollback, signed images, and low-power lessons from XTELL wearable boards.

    ·XTELL Engineering Team

    Why BLE firmware looks simple until OTA hits the field

    Getting a BLE peripheral to advertise, connect to a phone, and stream sensor values takes days. Shipping a product that survives two years of firmware updates across thousands of Android and iOS handsets without bricking units on low batteries is a completely different engineering problem.

    Field failures in BLE products rarely come from the radio stack itself. They happen when flash partitioning leaves no safe rollback path, a user walks out of range halfway through an upgrade, or aggressive power-saving states conflict with GATT connection parameters.

    Choosing a flash and bootloader layout for BLE OTA

    Your OTA reliability is locked in the moment you partition flash memory. Here is how the three common bootloader layouts compare on Nordic nRF52/nRF53, ESP32/ESP32-S3, and Cortex-M4 BLE MCUs:

    OTA Flash ArchitectureMax App SizePower-Loss SafetyTypical Use Case
    Single-Slot + Bootloader DFU~90% of flashLow (old app erased before download finishes)Cost-constrained demos where re-flashing via SWD is acceptable
    Dual-Bank A/B (Ping-Pong)~45% of internal flashHigh (old app stays intact until new image boots and confirms)Production medical, industrial, and wearable devices
    External QSPI/SPI Flash Staging + Swap~85% of internal flashHigh (staging lives on external flash; bootloader swaps safely)Feature-rich BLE + GUI/audio firmware with tight internal flash

    Designing a power-loss-safe, signed OTA flow

    A production BLE OTA pipeline (such as MCUboot with swap/revert or a custom dual-bank bootloader) should treat every wireless transfer as untrusted and interruptible:

    1. Pre-flight battery and voltage check. Never start flash erase/write cycles if battery voltage is near brown-out. Gate the OTA start command on a measured ADC voltage margin above the flash programming minimum.
    2. Cryptographic image verification before swap. Check SHA-256 hash and ECDSA/Ed25519 signature over the complete staged image in secondary slot before the bootloader ever marks it bootable.
    3. Pending-confirm boot flag + hardware watchdog. After rebooting into the new firmware, keep it in a pending state. Only mark the image confirmed after the application initializes BLE, passes self-tests, and feeds the hardware watchdog. If it crashes or resets before confirming, the bootloader automatically reverts to the previous bank.
    4. Offset-based resume. Store chunk progress or expose a readable write-offset characteristic so an interrupted phone transfer resumes from the last committed flash page instead of restarting from byte zero.

    Balancing GATT throughput against battery life

    Default BLE connection settings are tuned for low standby power, not fast firmware downloads. Sending a 256 KB image over 20-byte ATT notifications at a 100 ms connection interval can take minutes and drain a coin cell or small LiPo:

    • Negotiate ATT MTU and Data Length Extension (DLE). Requesting a 247-byte ATT MTU (or higher) with 2 Mbps PHY where supported multiplies effective payload throughput several-fold with minimal extra CPU wake time.
    • Switch connection intervals dynamically by mode. Run a fast interval (for example 7.5 ms–15 ms) during active OTA or bulk log sync, then negotiate back to 200 ms–1000 ms (or peripheral latency) once idle.
    • Buffer sensor streams properly before radio bursts. In XTELL's human body posture sensor built on a BLE MCU with MPU6050/SC7A20/STK8321 accelerometers, IR/NTC sensing, RFID, and a dedicated audio processor for noise reduction and KWS, a ring buffer decoupled real-time sensor/audio capture from BLE packet bursts and WeChat mini-program sync.
    • Enforce true deep sleep outside connected windows. On XTELL's low-power smartwatch (Apollo2 Cortex-M4, Bluetooth 5.0, 240×240 touch display, heart-rate monitoring at ±2 bpm), multi-level power management kept standby consumption at 100 uA and achieved up to 7 days of battery life. Similarly, in our Apollo2 low-power IoT terminal, RTC timed wake-ups, Watchdog supervision, and flash reliability were engineered together under Keil, IAR, and GCC toolchains.

    Why BLE firmware and the mobile app must share one debugging loop

    More than half of "BLE firmware bugs" turn out to be mismatches between peripheral firmware and iOS/Android BLE stacks:

    • GATT table caching after OTA: Phones aggressively cache GATT handles across bonds. If an OTA update adds or reorders characteristics, include the standard Generic Attribute Service Changed (0x2A05) indication—otherwise Android and iOS apps write to stale handles until Bluetooth is toggled off.
    • Write-without-response pacing: Blasting notifications or write-without-response packets faster than the radio stack queue can drain causes silent packet drops on some phones. Implement application-level credit flow control or explicit page-CRC acknowledgments.

    At XTELL, the same engineering team writes both the device firmware and the companion mobile app (as in our 433MHz security linkage system with Flutter mobile apps and backend OTA/MQTT telemetry), so BLE packet framing, GATT caching, and OTA recovery are tested end-to-end on real phones before release.

    Illustrative OTA state machine checklist

    Before shipping your first BLE OTA release, verify these five test cases on the bench (an illustrative release gate):

    1. Pull battery mid-transfer at 50% download -> device boots old image cleanly.
    2. Corrupt 1 byte in staged image -> bootloader rejects signature before swap.
    3. Flash deliberately broken v+1 app (hangs before confirm) -> watchdog resets, bootloader rolls back.
    4. Change GATT characteristic UUIDs in v+1 -> mobile app receives Service Changed and rediscovers.
    5. Measure sleep current after failed/aborted OTA -> peripherals return to budgeted uA baseline.

    Need a BLE firmware and OTA engineering partner?

    Whether you are building a wearable, medical sensor, industrial node, or connected consumer device, XTELL delivers complete firmware development, mobile app integration, and end-to-end IoT development across Nordic nRF52/nRF53, ESP32/ESP32-S3, STM32, and Apollo2 platforms.

    See also our guides on battery-powered IoT sleep current budgeting and low-power wireless IoT hardware design, or send your product requirements via our contact page.

    Frequently Asked Questions

    Should a production BLE device use single-bank or dual-bank OTA?

    Production devices should use dual-bank (A/B) OTA on internal flash or stage the encrypted image on external SPI/QSPI flash before swapping. Single-bank OTA leaves the device bricked if power drops or the link breaks mid-update.

    Why does BLE OTA speed drop dramatically across different Android and iOS phones?

    Throughput depends on negotiated ATT MTU, Data Length Extension (DLE), PHY rate (1M vs 2M), and the connection interval accepted by the phone OS. Dynamic interval negotiation during DFU plus paged acknowledgments avoids buffer overflows and keeps transfers predictable.

    Does XTELL develop both the BLE firmware and the companion mobile app?

    Yes. XTELL develops BLE firmware (Nordic, ESP32/ESP32-S3, Apollo2, STM32), mobile apps (Flutter, Android, iOS), and cloud backends under one team so GATT tables, provisioning, and OTA recovery are tested end-to-end.

    Need Professional Services?

    Contact us for customized solutions and quotes