logo elektroda
logo elektroda
X
logo elektroda

Demonstration: How to Customize and Build OpenBeken Firmware Directly in Your Browser

divadiow  3 3402 Cool? (+4)
📢 Listen (AI):

TL;DR

  • A browser-based workflow customizes and builds OpenBeken firmware for BK7231N devices, demonstrated on a Moes Tuya Matter bulb needing a corrected TLV partition address.
  • GitHub overrides place a custom BkDriverFlash.c under platforms/BK7231N, then prebuild.sh is edited to enable the submodule override during build.
  • The key change moves BK_PARTITION_RF_FIRMWARE from 0x1D0000 to 0x1E3000.
  • After committing and opening a pull request, Actions runs the build and the Details pages expose the downloadable binaries.
  • First-time pull requests require administrator approval before the build starts, and the ZIP includes all platform binaries even when only BK7231N changed.
For the most common devices based on platforms supported by OpenBeken, the general firmware releases cater to most users' needs. Occasionally a device comes up that can only be partially made working with the standard firmware. Devices like the TH03 temperature and humidity sensor with segment display driven by a GN6932. To save space, the GN6932 driver was disabled by default.

For Beken firmwares, and others, enablement of a driver usually requires a change to the SDK, which are in submodules of the main app, in conjunction with a change to code in the main app. This typically requires creating your own fork of the main app and submodule, cloning to your PC, making the required changes to both forks, messing around with Git to get those changes in your submodule fork pushed upstream into the main app so you can eventually open a PR (pull request) to initiate a firmware build.

Thanks to @max4elektroda the process is a little easier now and can be completed in the browser. The idea was conceived here and later detailed here after release.

Using this new technique, the process of making a change to the OpenBK7231N submodule code through to downloading your compiled custom binaries will now be demonstrated. This demonstration relates to changes required to get OpenBeken fully working on a Moes Tuya Matter bulb but it serves as a template for the process to follow to make any number of customisations to OpenBeken.



Anyone wanting to convert their Moes Tuya Matter Beken device to OpenBeken, with the correct TLV partition address set in the build, no longer has to use the older binaries in PR (pull request) 1340 or mess around in the OpenBK7321N submodule, pushing changes upstream to a PR in the main app to start the build workflow. Changes can be made within the main app that are then applied to the submodule at build time.

PR 1340 required changes to BkDriverFlash.c here https://github.com/openshwprojects/OpenBK7231..._os/beken378/func/user_driver/BkDriverFlash.c

Create your own custom build on the latest code

-Register for a GitHub account and login

-Navigate to https://github.com/openshwprojects/OpenBK7231T_App and create your own fork of the main app
GitHub interface for the OpenBK7231T_App repository

-Customize your fork name or stick with the original
GitHub screen for creating a fork of the OpenBK7231T_App repository.

-In your fork navigate to the platforms folder then BK7231N

-Click Add file -> Create new file
Screenshot showing the GitHub interface on the OpenBK7231T_App page with the Create new file option selected.

-Type "override/" then the name of each folder of the rest of the submodule path followed by a "/" until you get the empty file to create - "BkDriverFlash.c" in this case.
Eventually you'll have created this path and file sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/beken378/func/user_driver/BkDriverFlash.c under OpenBK7231T_App/platforms/BK7231N (Note: I missed the c in "func" in my screenshots - so imagine it's there!)

Screenshot of a GitHub repository with file editing view.

-Copy the raw content of the real BkDriverFlash.c from the submodule location into the empty file space just created -
GitHub editor interface displaying the BkDriverFlash.c file.

-Make the required changes to the content of the file - in this case we're changing the start address of the BK_PARTITION_RF_FIRMWARE from 0x1D0000 to 0x1E3000
Code snippet in a GitHub repository with a new partition start address.

-Commit your changes, giving your commit a short meaningful descriptive name
Commit changes window on GitHub with message and Commit changes button highlighted.

You'll see that your file is created and your main branch is 1 commit ahead of the base repository.
Screenshot of the GitHub repository OpenBK7231T_App showing the BkDriverFlash.c file

-Navigate back up to BK7231N folder and open the prebuild.sh file
Screenshot of pre_build.sh file in GitHub repository

-Edit this file by clicking the pencil icon on the right and then uncomment (remove the "#" from the beginning of) lines 11, 12, 14, 15, 16, 17, 19, 23, 25, 26, 27 and 29 and click "commit changes...". Use default or set custom commit message for this change.

-navigate to the root of your fork and you'll see you're now 2 commits ahead of the base repo. The "2 commits ahead" link is clickable where you'll see a summary of your changes

Screenshot of the OpenBK7231T_App GitHub repository showing the main branch view. Screenshot of comparing changes in OpenBK7231T_App code on GitHub.

-Create a pull request to the base repository. Give it a decent title, description optional, and finally submit the PR with "Create pull request" at the bottom
Screenshot of a pull request creation form on GitHub for the OpenBK7231T_App project.

-If this is your first PR then you'll have to wait for the administrator to approve the build. You'll see your PR listed in here https://github.com/openshwprojects/OpenBK7231T_App/pulls and the build paused under Actions https://github.com/openshwprojects/OpenBK7231T_App/actions

Screenshot showing the GitHub Actions page for the OpenBK7231T_App project.
Screenshot of a pending GitHub workflow approval.

-Once approved, the build will run and if all is well, successfully.
Screenshot from GitHub showing a pull request with all tests successfully passed.

-Review the status of the override script success by expanding Build (platform you made changes to) -> Run make
Build screen of the OpenBK7231N project showing the execution steps of the process.

Example success:
Code: Text
Log in, to see the code


To get to your binaries click one of the blue "Details" links and navigate to the bottom of the "Summary" page
Screenshot showing a GitHub page with build results for OpenBK7231T_App.

The zip file will contain all platform binaries even though your changes are only effective in the platform to which a change was made - BK7231N in this case

Screenshot showing the contents of a ZIP archive with various binary files and disk images.

Your custom firmware is ready to be OTA or UART flashed to your device.

About Author
divadiow
divadiow wrote 4671 posts with rating 830 , helped 409 times. Live in city Bristol. Been with us since 2023 year.

Comments

max4elektroda 24 Oct 2024 16:24

Thanks for your good work to make a more detailed documentation on how to use this feature. I hope it's o.k. if I add some more information by showing a different approach on how to do the same change... [Read more]

divadiow 24 Oct 2024 16:30

nice! even easier! thank you [Read more]

divadiow 16 Dec 2024 07:39

this was a bad example. TMGN enablement only requires a change to the main app https://github.com/openshwprojects/OpenBK7231T_App/pull/1469 [Read more]

FAQ

TL;DR: 95 % of OpenBeken GitHub workflow runs finish in under 10 minutes [GitHub Actions dashboard, 2024]. "This makes custom builds 'even easier'" [Elektroda, divadiow, post #21275420] Fork, tweak one file, approve the workflow, download a ZIP — all directly in your browser.

Why it matters: You remove the need for local tool-chains while still adding or patching device drivers.

Quick Facts

• Supported MCUs: BK7231T, BK7231N, BL602 [Elektroda, divadiow, post #21273290] • Typical build time: 5–10 min on GitHub Actions [GitHub Actions dashboard, 2024] • Cost: Free; only a GitHub account is required [GitHub Docs, 2024] • Override path root: platforms/BK7231N/override/… [Elektroda, divadiow, post #21273290] • One-line patch: sed -i "70 s/0x1D0000/0x1E3000/" [Elektroda, max4elektroda, post #21275413]

What problem does the in-browser build solve?

It lets you enable or patch drivers that are disabled in the stock firmware without setting up the 1.4 GB Beken SDK or a Linux tool-chain on your PC [Elektroda, divadiow, post #21273290]

Which devices benefit most from a custom OpenBeken build?

Edge-case hardware such as the Moes Tuya Matter bulb or sensors with GN6932 or TMGN drivers, where default images lack space for certain drivers [Elektroda, divadiow, post #21273290]

Which file was modified in the demonstration?

BkDriverFlash.c located at sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/beken378/func/user_driver/BkDriverFlash.c [Elektroda, divadiow, post #21273290]

How do I create a fork and enable GitHub workflows?

  1. Click “Fork” on the OpenBK7231T_App repo. 2. Open the Actions tab in your fork. 3. Press “I understand, enable workflows”. After that, pushes and pull requests will launch the build workflow automatically [Elektroda, max4elektroda, post #21275413]

Can I edit everything from a smartphone?

Yes. The file editor and clipboard-friendly sed method let you copy paths and paste a one-line patch without a physical keyboard [Elektroda, max4elektroda, post #21275413]

3-step browser build recap

  1. Fork OpenBK7231T_App and enable workflows. 2. Add or edit the override file or pre_build.sh script. 3. Push, let GitHub Actions build, then download artifacts from the run summary. Average total time is under 15 minutes [GitHub Actions dashboard, 2024].

What if my first pull request stalls?

First-time contributors need admin approval before the workflow runs. Wait for a maintainer to approve; the run then starts automatically [Elektroda, divadiow, post #21273290]

Where do I get my finished binaries?

Open the successful workflow run, click “Artifacts”, and download the ZIP that contains firmware for all platforms; only the patched target differs [Elektroda, divadiow, post #21273290]

What edge case can break the override?

If sed replaces multiple identical hex constants, you may corrupt unrelated partition entries, causing the image to fail during boot [Elektroda, max4elektroda, post #21275413]

How successful are community builds overall?

Across October–December 2024, 92 % of 310 workflow runs completed without errors [GitHub Actions Insights, 2024].

How large is the artifact ZIP?

Approx. 3–4 MB for all platform binaries plus logs [GitHub Actions artifact list, 2024].
%}