Repository navigation
Flash Programming 101
*A practical primer on reprogramming automotive control modules (ECUs) over the diagnostic bus. Written for technicians and calibrators using J2534 / UDS-class tooling.
⚠️ Reality check: a reflash writes to non-volatile memory the module needs to boot. Done right it's routine. Done wrong — interrupted, wrong file, dead battery — it bricks the module. Everything below exists to keep you on the right side of that line. Always have a known-good backup and a recovery plan before you erase anything.
A modern vehicle module (PCM, TCM, BCM/BEM, ABS, IPC, FDIM, RCM, etc.) is a small computer. Its flash memory typically holds three logically separate things:
| Region | What it is | Reflashed? |
|---|---|---|
| Bootloader (PBL) | Primary boot loader, masked/locked in ROM or a protected sector. Starts the module and can receive a flash kernel. | Almost never — bricking this is usually terminal. |
| Flash Driver / SBL | A small "secondary bootloader" or flash kernel the tester downloads into RAM to drive the erase/write of main flash. | Downloaded fresh each session, not permanently stored. |
| Application (strategy) | The actual operating firmware. | Yes. |
| Calibration | Tunable data (maps, VIN, options, as-built/CCF). Sometimes a separate block from the application. | Yes — often independently of the application. |
"Flashing" = replacing the Application and/or Calibration. The bootloader runs the show; your tester talks to it through a strict, standardised conversation.
Key idea: you rarely write flash directly. You put the module into a programming session, prove you're authorised (security access), hand it a flash kernel, tell it an address + size, stream the data, then tell it to validate and finish. The module does the actual NVM writing.
Hardware
- A J2534 PassThru interface (dev/shop standard — Mongoose, CarDAQ, OBDX Pro, VCM2, Tactrix, etc.) or the OEM tool. ELM327-class cables are for OBDII, not for reliable flashing.
- A stable power supply: a proper programming-grade battery maintainer/PSU (e.g. 13.5 V, ≥ 20–70 A clean output). Not a trickle charger, and not "the battery's probably fine."
Software / data
- The correct firmware file for the exact part number and hardware revision. One digit wrong = wrong module.
- The module's current contents backed up (read it out first if the module supports it).
- Vehicle as-built / configuration (CCF) data captured, especially before any coding change.
- VIN, part numbers, and current software/calibration IDs recorded.
Environment
- Engine off, ignition on (key-on-engine-off) unless the procedure says otherwise.
- All avoidable electrical loads off (lights, HVAC blower, infotainment). Doors closed/latched so the BCM doesn't keep waking things up.
- Nobody cranking, opening doors, or plugging/unplugging during the write.
Most UDS (ISO 14229) style reprogramming follows this shape. Names/service IDs below are UDS; KWP and OEM dialects differ but the stages are the same.
-
Establish comms & extended session —
10 03(extended) or10 02(programming). The module may drop other functions and go quiet to the rest of the car. -
Pre-conditions — check battery voltage, often disable DTC setting (
85 02) and normal communication (28 …) so the bus doesn't spam faults while the target is busy. -
Security Access —
27 01request seed → compute key →27 02send key. The module unlocks write access only if the key is correct. (See §6.) -
Download the flash kernel (SBL) —
34RequestDownload (address+size of RAM) →36TransferData (stream the kernel) →37RequestTransferExit. Now a smart flash driver is running in the module's RAM. -
Erase the target flash block(s) — usually a
31 01 <routine>RoutineControl, or a kernel-specific command. This is the point of no return for that block. -
Program the application/calibration —
34RequestDownload (flash address+size) → repeated36TransferData blocks →37RequestTransferExit. -
Validate — checksum/CRC/signature routine (
31 01 <checkMemory>), and often a Compatibility/ dependency check so you can't load a mismatched cal on a strategy. -
Finalize — write the fingerprint/log, re-enable comms (
28) and DTC setting (85 01), then ECU Reset (11 01). Module reboots into the new firmware. - Post-flash — clear DTCs, re-learn/relearn adaptations, re-enter configuration, verify new SW/CAL IDs.
Throughout steps 4–7 the tester sends periodic Tester Present keep-alives so the session doesn't time out. During long erases/writes the module answers
7F xx 78("response pending / busy") — that is normal, wait for it, do not treat it as an error and do not resend.
Ford FG/Falcon specifics (this project): display/audio modules (FDIM/AIM/ACM/BPM) are delivered as PHF
containers (ASCII KEY>VALUE header + binary Intel-HEX payload, flashed over the module's own loader). The
PCM (Spanish Oak) and TCM (ZF 6HP26) use byte-accurate, per-module raw routines. Ford modules want the
ISO-TP pad byte = 0x00, honour 3E 01 tester-present (and ignore 3E 80), and EEC-V/VI PCMs need +18 V
on pin 13 (FEPS) to enter bootloader.
- DO read and save the original first. A backup you took five minutes ago beats any "recovery file" you hope exists later. Store it with the VIN, date, and part number in the filename.
- DO verify the file against the target — part number, hardware rev, strategy/cal compatibility, and the file's own checksum — before you erase.
- DO lock the voltage down with a programming PSU and confirm it under load. Low/sagging voltage mid-write is the #1 cause of bricks.
- DO disable DTC setting and normal comms during the operation so the rest of the car isn't fighting you.
-
DO let
7F … 78pending responses ride. Flashing is slow; patience is a feature. - DO record before/after SW & CAL IDs, CVN, and configuration so you can prove the change and roll back.
- DO re-enter configuration / as-built and run the post-flash relearns. A flash without the follow-up coding often leaves features broken.
- DO bench-flash risky or already-suspect modules on a known rig where you control power and recovery.
- DON'T flash on the vehicle battery alone. Not even "just a quick cal."
- DON'T interrupt a write — no unplugging, no key cycles, no closing the laptop, no "I'll just check something." Once erase starts, finish.
- DON'T flash the wrong part number / hardware level. Matching "it's the same car" is not matching the module.
- DON'T flash the primary bootloader unless the OEM procedure explicitly requires it and you have JTAG/BDM recovery ready. That's the one you usually can't fix over OBD.
- DON'T ignore the compatibility/dependency NRC. If the module rejects a cal as incompatible, it's usually protecting you from a half-working or unstartable result.
- DON'T assume a failed flash is a dead module. See recovery below before you panic.
Write access is gated by a challenge-response. You ask for a seed (27 01); the module returns a random
number; you run the OEM's algorithm to turn seed → key; you send it back (27 02). Right key → unlocked;
wrong key → 7F 27 35 (invalidKey) and the attempt counter ticks. Algorithms range from simple
XOR/add/rotate and LFSRs to AES/HMAC on newer modules; some (VAG SA2) ship the algorithm as bytecode in the
ODX.
- Voltage is everything. Set the PSU a touch high (13.5–14.0 V), confirm it holds under the write load, and keep the DLC/engine-bay grounds clean. Most "random" flash failures are power.
-
Keep the session alive, correctly. Use the keep-alive the module honours (Ford =
3E 01, generic UDS =3E 80/3E 00). The wrong tester-present lets the session silently time out mid-job. -
Mind your timer resolution. On Windows, polling the bus with
Sleep(n)rounds to the ~15 ms scheduler tick; a 512 KB read that "should" take minutes drags on forever. Raise timer resolution (timeBeginPeriod(1)) or tune your poll/STminso big reads/writes run at bus speed, and log a throughput/ETA line so you can tell "slow" from "hung." -
Respect memory bounds. Read/erase/write to the actual flash extent — classic off-by-one is looping
addr <= endinstead ofaddr < endand running one block past the chip, which errors out at the top. Know where application ends and calibration begins. -
Checksums & containers. If you splice/modify an image you must fix every integrity layer: the HEX
record checksums, the container's file checksum (e.g. the PHF
FILE CHECKSUM= 16-bit additive sum of the payload bytes), and any application-internal CRC/signature the bootloader verifies at boot. Miss one and the module either rejects the file or boots to a brick. Round-trip test your packer against a known-good file (repack with zero changes → must be byte-identical) before trusting it. - Bench before car for anything experimental. On a bench harness you own the power, the bus, and the recovery, and a bad flash costs a reflash instead of a tow.
- Isolate the target. Flashing on a quiet bus (or with other modules' normal comms disabled) is faster and far less error-prone than fighting live gateway/network traffic.
- Log the raw frames. A full TX/RX capture of a successful OEM flash is the best spec you'll ever get — validate your own sequence against it byte-for-byte.
- Two modules, swap trick. When retrofitting/repairing, a second known-good module of the same part is both your reference (dump it, diff it) and your recovery (clone its known-good image).
- Don't power-cycle in a panic. Many "bricked" modules are actually sitting in the bootloader waiting for a valid download. Try to re-enter programming mode and re-flash immediately (often no security access needed to re-send the kernel once you're in the loader).
- Re-send the kernel, re-erase, re-write your known-good backup. A write that failed validation usually just needs a clean retry on stable power.
- Bench loader / forced bootloader entry — some modules have a pin/strap or a programming-voltage (FEPS) method to force the loader when the app won't boot.
- BDM/JTAG — last resort for a truly dead app or a corrupted boot region: read/write the flash chip directly. Requires opening the module and the right adapter.
- If none of that — the correct answer is a replacement + reprogram, not another gamble on power you're not sure of.
The modules that survive a bad flash are the ones you backed up and kept the voltage steady on. Those two habits prevent the large majority of unrecoverable bricks.
Reference stack this guide assumes: SAE J2534 PassThru, ISO 15765 (CAN) + ISO-TP, UDS ISO 14229-1, KWP2000, and OEM flash containers (Ford PHF/VBF, Motorola S19, Intel HEX, raw BIN). Adapt service IDs and pin maps to your target. https://testerpresent.com.au/DiagInfo
