User question
How to make OpenBeken firmware build with custom bkcrypt_coeffs ?
Artificial Intelligence Response
Direct answer to the question
- You don’t “compile OpenBeken with bkcrypt_coeffs” inside the C code. The 4×32‑bit bkcrypt_coeffs (aka the Beken flash/coeff key) are used by the bootloader to accept and decrypt the application image. Therefore you must build a normal, raw OpenBeken app first and then pack/re‑encrypt it with your device’s bkcrypt_coeffs (and, when producing OTA packages, with the OTA AES key) before flashing. (docs.libretiny.eu)
- Easiest workflow:
1) Build/download the raw OpenBeken app for your chip (N/T etc.). 2) Use a packer (ltchiptool CLI/GUI or bk7231tools) to generate an app image encrypted with your custom bkcrypt_coeffs. 3) Flash that image at the application offset while preserving the factory bootloader. (github.com)
Key points
- bkcrypt_coeffs are device/bootloader keys (four 32‑bit words). The common default is 510fb093 a3cbeadc 5993a17e c7adeb03; many devices still use it, but non‑standard keys are increasingly common. (docs.libretiny.eu)
- Do not overwrite the vendor bootloader. Write only the app partition (typically starts at 0x11000 on BK7231). (github.com)
- If you try to flash a default‑key image on a device with non‑standard keys, it won’t boot. Re‑encrypt/pack to your key. (docs.libretiny.eu)
Detailed problem analysis
- What bkcrypt_coeffs are and where they apply
- The Beken boot ROM/bootloader stores a 128‑bit “coeff” key (4×32‑bit). It verifies/decodes the app image (RBL/UA) using those coefficients before jumping to user code. The coefficients are not linked into the OpenBeken application; they are used by the image packer and by the bootloader during boot. (docs.libretiny.eu)
- Two different keys you will meet
- bkcrypt_coeffs (flash/coeff key): four 32‑bit words. Must match the chip to run the app. Defaults are widely known; custom values exist. (docs.libretiny.eu)
- OTA AES key (bkota.key): 16‑byte key used for OTA container encryption; often 0123456789ABCDEF, but vendors can change it. OTA packaging and in‑bootloader re‑encryption use this key; it is separate from bkcrypt_coeffs. (docs.libretiny.eu)
- Why post‑build packing is the right place to set keys
- The OpenBeken build produces a raw application binary. The last step (packing to the bootloader‑accepted format) is where coefficients and (optionally) OTA AES are applied. Changing C headers won’t help; you must supply keys to the packer and keep the factory bootloader in flash. (github.com)
- Flashing layout constraints
- On BK7231, the app partition commonly starts at 0x11000. Overwriting 0x0..0x11000 (vendor bootloader) risks a brick and won’t fix a key mismatch. Always preserve the bootloader and present a correctly keyed app at the app offset. (github.com)
Current information and trends
- Default vs custom keys
- The default 4‑word coeff key noted above is still frequent, but non‑standard keys have become more common on 2024–2026 devices (especially some Tuya/Belon/“Matter” runs). Treat mismatches as expected and plan to re‑encrypt. (docs.libretiny.eu)
- Tooling status as of January 2026 (United States)
- ltchiptool provides GUI and CLI for packaging and for UART flashing/dumping; it’s the reference toolchain in LibreTiny docs. (pypi.org)
- bk7231tools can read/write flash, dissect dumps and reconstruct RBLs; useful for extracting keys/dumps and app-only writes at 0x11000. (github.com)
- OpenBeken offers an online build system for producing raw firmware but does not, by default, take per‑device encryption inputs. Use it to get the app binary, then pack locally with your keys. (github.com)
Supporting explanations and details
- Practical meaning of the two keys
- bkcrypt_coeffs: affect acceptance and decryption of the app region by the bootloader at boot time.
- OTA AES key: affects OTA package encryption. If you deliver updates via UART (writing an app image), you don’t need OTA AES. If you deliver via OTA containers, you must also know the device’s OTA AES key or use an unencrypted OTA if the bootloader allows it. (docs.libretiny.eu)
- Why some “default-key” builds still work
- If a device happens to use the default coeff key, default OpenBeken releases will boot. If not, they will fail until you repack to the device’s coeffs. (docs.libretiny.eu)
Ethical and legal aspects
- Ensure you have the legal right to modify the device firmware and to extract keys from your own device. Respect warranty and local regulations on device modification. Back up factory firmware before any write. (github.com)
Practical guidelines
- Step‑by‑step: generate an image with custom bkcrypt_coeffs
1) Build or download the raw OpenBeken app:
- Use OpenBeken’s online builds or local build to obtain the app binary for your chip (BK7231N/T, etc.). Note: these builds are not per‑device keyed; they are raw binaries or default‑key packs. (github.com)
2) Install packaging tools:
- ltchiptool (GUI/CLI) from PyPI, or bk7231tools for advanced dump/flash workflows. (pypi.org)
3) Re‑encrypt/pack the app with your coeffs:
- Use ltchiptool’s BK72xx packer to create an RBL/app image. Provide your four 32‑bit coeff words (hex). If producing an OTA package, also provide the OTA AES key (often 0123456789ABCDEF if unchanged on your device). Consult ltchiptool --help or GUI dialogs for the exact flag names in your installed version. (pypi.org)
4) Flash only the app partition:
- Using ltchiptool or bk7231tools, write the resulting app image at 0x11000 (typical) and DO NOT overwrite the bootloader area. Example with bk7231tools (app‑only write): write_flash -s 0x11000 -S 0 app.bin. Always make and keep a full backup first. (github.com)
5) Verify:
- Power‑cycle and watch the UART logs. If the app runs, keys are correct. If it instantly resets/halts, the coeffs likely don’t match; re‑check the 4 words and repack. (docs.libretiny.eu)
- Where to get the keys
- Try ltchiptool “Get chip info” to read eFuse. If zeros (readout‑protected), use a dump‑based or bootloader‑assist method to infer/extract keys as documented by LibreTiny. (docs.libretiny.eu)
- Integrating into a repeatable build
- If you want your CI or local build to always emit a correctly keyed image, disable the default pack step and add a post‑build command that calls ltchiptool’s BK packer with your coeffs (and OTA AES if needed). This avoids modifying OBK sources and keeps keys out of the repo. (github.com)
- OTA updates with custom keys
- If your device uses custom coeffs, standard public OTA files won’t boot on it. Host your own updates packed with your coeffs, or distribute UART app images. (docs.libretiny.eu)
Possible disclaimers or additional notes
- The “online builder supports custom coeffs” claim you may have seen is misleading; online builds compile features but don’t accept per‑device encryption keys. Always repack locally for non‑default keys. (github.com)
- Offsets and formats vary slightly across BK72xx variants; confirm partitioning from your dump before writing. (github.com)
Suggestions for further research
- Read LibreTiny’s “Finding encryption keys” for background and up‑to‑date notes on defaults and exceptions. (docs.libretiny.eu)
- Check OpenBeken’s BUILDING/FLASHING docs and the GUI flasher repo for current workflows and supported chip list. (github.com)
- Keep an eye on ltchiptool release notes for new packaging flags and improved BK packers. (pypi.org)
Brief summary
- Build OpenBeken normally to get a raw app binary. Then pack it locally with your device’s bkcrypt_coeffs (and OTA AES key if making an OTA). Flash only the app partition, keeping the vendor bootloader. This is the reliable and repeatable way to “make OpenBeken build with custom bkcrypt_coeffs.” (docs.libretiny.eu)
If you share your exact chip (BK7231N or BK7231T), your four coeff words, and whether you intend to flash via UART or OTA, I can give you the exact ltchiptool command line and verify the offsets for your device.
Disclaimer: The responses provided by artificial intelligence (language model) may be inaccurate and misleading. Elektroda is not responsible for the accuracy, reliability, or completeness of the presented information. All responses should be verified by the user.