logo elektroda
logo elektroda
X
logo elektroda

How to create a custom driver for OpenBeken with online builds (no toolchain required)

p.kaczmarek2 7446 142
ADVERTISEMENT
  • #91 21252245
    divadiow
    Level 34  
    max4elektroda wrote:
    Maybe you have an example in a PR to the SDK were I can see the changes you needed?

    yep, sure.

    It's basically about making it easier to change coeff key and/or the partition addresses for the odd non-Tuya devices - eg Uascent Matter devices based on the same Beken modules Tuya uses. I think maybe only I've really played with this and I *can* do it in the SDK submodules, it would just be easier for all if the values were in the main app somewhere and then looked to by the submodule at build time.

    eg this PR changed the RF partition address https://github.com/openshwprojects/OpenBK7231...5d39bd0ceb7ca37d0b704827b372e802b27e656478330

    so this Homekit Matter device could work - https://www.elektroda.com/rtvforum/topic4074263.html


    here are some key and partition changes https://github.com/divadiow/OpenBK7231N/commit/ce8def14c48f8f4eaafbeb7da80d93ef9d2040c8

    in an attempt to get this Uascent Matter device working https://www.elektroda.com/rtvforum/topic4032988-30.html#21138630
  • ADVERTISEMENT
  • #92 21252246
    p.kaczmarek2
    Moderator Smart Home
    Maybe it would be possible to create a "patch" mechanism?
    Insert a file copy between SDK pull and App build.
    So, if Github builds a file, idk, MySdkFile.c from SDK, then in script, we check if this file already exists in platform/override folder, and if so, we copy it over. Or to be more precise - we copy blindly content of platforms/override to platforms or something, after pulling SDKs.
    Then, if you want to modify MySDKFile.c without changing SDKs, you just put the required directory tree in the platforms/overrides folder and online builds do the stuff for you.

    Added after 2 [minutes]:

    In case of @divadiow , he would create file:
    
    overrides/OpenBK7231N/platforms/bk7231n/bk7231n_os/beken378/func/user_driver/BkDriverFlash.c
    

    in the App repository,
    and then, on build, build script would first pull OpenBK7231N, and then copy "overrides/OpenBK7231N" to OpenBK7231N, so BkDriverFlash.c from divadiow would overwrite old BKDriverFlash.c

    I can explain more, but I hope you get the idea? @max4elektroda
    Helpful post? Buy me a coffee.
  • #93 21252686
    max4elektroda
    Level 20  
    I really like this discussion, we'll find a good solution :-)!

    >>21252246
    p.kaczmarek2 wrote:
    on build, build script would first pull OpenBK7231N, and then copy "overrides/OpenBK7231N" to OpenBK7231N,

    Good point, I would suggest to go one step further:
    If a script with a defined name is present in a given location ("override.sh", "pre_build.sh" or whatever name makes sense), this will be called before actual start of build process.
    The script can do "simple" task, e.g. just copy a changed file to a location inside sdk, patch a file inside sdk, set some links...
    But it's much more flexible, it could do more complex things, e.g. update sdk (or some libraries) or else do whatever you wish to be done in advance, without need to alter any file outside the app repository.

    Added after 3 [minutes]:

    Will try a PR to show the idea soon
  • #94 21252807
    divadiow
    Level 34  
    Exciting. Thank you both for entertaining the idea

    Added after 3 [minutes]:

    max4elektroda wrote:
    Enjoy your trip!

    Thank you. I'll still be glued to Elektroda. I have two OBK devices for LED strips with me. I have a vape and two epaper shop shelf edge labels to tear apart while on holiday 🤓
  • #95 21252988
    max4elektroda
    Level 20  
    Just finished PR#1381.

    Changed "Makefile" to execute script files "platforms/<platform>/pre_build.sh" if present.
    Just to show the idea, I made a simple script for all platforms, to echo the path and to show the possibilities, just "touch" a file iside every sdk.
    The scripts also could change/replace/... files inside sdk, and all done from "outside" the sdk!

    Sample output from git build details e.g. for BK7231T:
    Run make APP_VERSION=1381_merge_dc279645099b APP_NAME=OpenBK7231T OpenBK7231T
    prebuild found for OpenBK7231T
    PEBUILD-Test! Executed from platforms/BK7231T!
    make APP_NAME=OpenBK7231T TARGET_PLATFORM=bk7231t SDK_PATH=sdk/OpenBK7231T APPS_BUILD_PATH=../bk7231t_os build-BK7231
    make[1]: Entering directory '/home/runner/work/OpenBK7231T_App/OpenBK7231T_App'
    .....
    


    Local test when building with docker - searching for the files before build start, after some time and when build is done:
    
    max@max:~/LN882H/fork/move_ota_rf_net_start/OpenBK7231T_App$ find sdk -name prebuild_was_here
    max@max:~/LN882H/fork/move_ota_rf_net_start/OpenBK7231T_App$ find sdk -name prebuild_was_here
    max@max:~/LN882H/fork/move_ota_rf_net_start/OpenBK7231T_App$ find sdk -name prebuild_was_here
    sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/prebuild_was_here
    sdk/OpenBK7231T/platforms/bk7231t/bk7231t_os/prebuild_was_here
    max@max:~/LN882H/fork/move_ota_rf_net_start/OpenBK7231T_App$ find sdk -name prebuild_was_here
    sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/prebuild_was_here
    sdk/OpenW800/src/prebuild_was_here
    sdk/OpenBL602/prebuild_was_here
    sdk/OpenLN882H/prebuild_was_here
    sdk/OpenXR809/src/prebuild_was_here
    sdk/OpenW600/src/prebuild_was_here
    sdk/OpenBK7231T/platforms/bk7231t/bk7231t_os/prebuild_was_here
    max@max:~/LN882H/fork/move_ota_rf_net_start/OpenBK7231T_App$ 
    
  • ADVERTISEMENT
  • #96 21254106
    max4elektroda
    Level 20  
    To fulfill the requested "copying files to sdk before a build", this could be a script:
    
    DIRNAME=$(dirname $0);
    echo "PREBUILD script! Executed from $DIRNAME!"
    # allow whitspace in file or path, so take only newline as seperator
    OFS=$IFS
    IFS='
    '
    for X in $(find platforms/BK7231N/override/ -type f);do
       # script is executed from main app directory, so take found file and path as source
       S=${X};
       # destination is path stripped from path to override
       # so inside "override" we have the full path to the file
       # starting with "sdk/OpenBK7231N/..."
       D=${X#platforms/BK7231N/override/};
       # if file is present, we replace it, otherwise file is added ...
       [ -e $D ] && echo "PREBUILD: replacing file\n\t$D\n\twith file\n\t$S" || echo "PREBUILD: adding file\n\t$S\n\tas\n\t$D"
       cp $S $D;
    done
    # restore IFS to whatever it was before ...
    IFS=$OFS


    Test with providing the (changed) file
    platforms/BK7231N/override/sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/beken378/func/user_driver/BkDriverFlash.c
    

    and a new file
    platforms/BK7231N/override/sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/beken378/func/user_driver/this is a new file.c
    


    this is the result as expected:

    
    max@max:~/LN882H/fork/move_ota_rf_net_start/OpenBK7231T_App/docker$ docker run -it --env  TARGET_SDKS="OpenBK7231N" -v "$(pwd)/..":/OpenBK7231T_App  openbk_build  | grep -A 3 PREBUILD
    PREBUILD script! Executed from platforms/BK7231N!
    PREBUILD: adding file
       platforms/BK7231N/override/sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/beken378/func/user_driver/this is a new file.c
       as
       sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/beken378/func/user_driver/this is a new file.c
    PREBUILD: replacing file
       sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/beken378/func/user_driver/BkDriverFlash.c
       with file
       platforms/BK7231N/override/sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/beken378/func/user_driver/BkDriverFlash.c
    max@max:~/LN882H/fork/move_ota_rf_net_start/OpenBK7231T_App/docker$ 
  • ADVERTISEMENT
  • #97 21262267
    divadiow
    Level 34  
    that's cool. what are the next steps? I'm not sure what I can help with...
  • #98 21262269
    p.kaczmarek2
    Moderator Smart Home
    I think this is ready to merge?
    Helpful post? Buy me a coffee.
  • #99 21262293
    max4elektroda
    Level 20  
    p.kaczmarek2 wrote:
    I think this is ready to merge?

    Let me adjust the scripts which only demonstrate the possibility and generate an empty file.
    We could leave them empty for the moment or I could put the "copy code to SDK if present" there.
    It's a developer feature anyway.
  • #100 21262318
    p.kaczmarek2
    Moderator Smart Home
    Maybe add comments to each file? And, just maybe, create a short tutorial for forum that we can link later to from Readme?
    Helpful post? Buy me a coffee.
  • #101 21262328
    max4elektroda
    Level 20  
    I think doing a short "tuturial" will be a good idea.
    And I will just leave "empty" script files there, with some commented out sample code if you agree?

    I will give a short notice when I'm done.
  • #103 21264207
    steelincable
    Level 4  
    Can someone point me in the right direction for more info on #6 in the guide - How to debug drivers (on Windows)? I have the project cloned, opened in Visual Studio 2022, and branch set with my code updates. How do I run it so I can debug it, step into it and set breakpoints? I'm new to coding drivers, so bear with me!
  • #104 21264210
    p.kaczmarek2
    Moderator Smart Home
    Are you able to compile the project? I mean, for Windows?
    Helpful post? Buy me a coffee.
  • #105 21264263
    steelincable
    Level 4  
    Receiving the error below in vs2022 when attempting to build the solution with defaults. A quick google pointed me in this direction, does this look like the right approach to setting up the IDE? https://stackoverflow.com/questions/41695251/c-microsoft-cpp-default-props-was-not-found

    1>------ Build started: Project: openBeken_win32_mvsc2017, Configuration: Debug|Win32 ------
    1>C:\Users\steelincable\Source\Repos\OpenBK7231T_App\openBeken_win32_mvsc2017.vcxproj(18,3): error MSB4019: The imported project "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Build failed.

    Added after 8 [hours] 5 [minutes]:

    OK, I was missing some components in vs and have them added now. Looks like I need to grab some OpenGL bits.

    Screenshot of errors in Visual Studio 2022 during project compilation.
  • #106 21265030
    max4elektroda
    Level 20  
    max4elektroda wrote:
    I will just leave "empty" script files there, with some commented out sample code if you agree?

    I will give a short notice when I'm done.

    Made my changes to [url=https://github.com/openshwprojects/OpenBK7231T_App/pull/1381PR#1381[/url]
  • #107 21265130
    p.kaczmarek2
    Moderator Smart Home
    Very good @max4elektroda , I merged your changes.

    @steelincable the required libraries are here:
    https://github.com/openshwprojects/obkSimulator
    Just copy and paste..
    See:
    https://github.com/openshwprojects/obkSimulator/tree/main/simulator
    libs_for_simulator directory
    Helpful post? Buy me a coffee.
  • #108 21265240
    max4elektroda
    Level 20  
    Thanks @p.kaczmarek2!
    I also tried to make some kind of simple "tutorial" showing possible use cases here
    Comments, corrections and extensions welcomed!
  • #109 21265358
    steelincable
    Level 4  
    Thanks, I got a bit further! Looks like I'm missing glut32.lib. I'm not seeing that anywhere in the simulator files.

    A screenshot displaying a list of errors and warnings in a development environment. The main error is LNK1104 cannot open file 'glut32.lib'.
  • #110 21265391
    p.kaczmarek2
    Moderator Smart Home
    Where exactly is glut32.lib included for you? As far as I remember, there is no glut32.lib dependency, we're using freeglut.lib:
    Screenshot of source code in Microsoft Visual Studio, highlighting a line of code using freeglut.lib.
    Screenshot showing a Windows folder with files including a folder named x64 and a file freeglut.lib.
    Show me what requires glut32.lib and I'll recheck.
    Alternatively, just get glut32.lib from web and it should be okay as well.
    Helpful post? Buy me a coffee.
  • #111 21274794
    p.kaczmarek2
    Moderator Smart Home
    max4elektroda wrote:
    Did you find the issue or was it solved by magic? Release 733 is whith simulator zip again...

    The issue still persists.
    This has simulator file:
    https://github.com/openshwprojects/OpenBK7231T_App/releases/tag/1.17.755
    And here it's missing:
    https://github.com/openshwprojects/OpenBK7231T_App/releases/tag/1.17.756
    Also sometimes XR809 build is missing as well? What's wrong?
    The number of released assets varies per release. https://github.com/openshwprojects/OpenBK7231T_App/releases

    It seems like we have a problem to solve, @divadiow, @max4elektroda ...
    Helpful post? Buy me a coffee.
  • #112 21274912
    divadiow
    Level 34  
    can the logging be more verbose for the next few runs?
  • #113 21274940
    p.kaczmarek2
    Moderator Smart Home
    For now, I've only checked related commit, and it seems that 756 simulator zip is in the artifacts package, so the problem must be on the futher stages, maybe in the code that copies it for release?

    Screenshot of GitHub and file explorer window with an open ZIP archive.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #114 21275284
    max4elektroda
    Level 20  
    p.kaczmarek2 wrote:
    so the problem must be on the futher stages, maybe in the code that copies it for release?

    That would be my suspected cause, too. But I don't really understand, how this works ...
  • #115 21275584
    p.kaczmarek2
    Moderator Smart Home
    I think it's set in this file:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/.releaserc.yaml
    but I can't imagine why it would randomly skip files, I assumed this file is run once all the previous build steps are ran? Or maybe we have a race condition?
    Helpful post? Buy me a coffee.
  • #116 21278908
    max4elektroda
    Level 20  
    I tried to understand the logic, but I'm not sure if I did, but this is what I think happens:

    The files used in .releaserc.yaml were put to the folders by OpenBK7231T_App/.github/workflows/workflow.yaml if I got it right.
    Usually the files are copied to output/${{ needs.refs.outputs.version }}/... and then packed as artifacts (by actions/upload-artifact@v3).

    In case of release, the artifacts built before were copied again to output/${{ needs.refs.outputs.version }}/... (by actions/download-artifact@v3) and then finally OpenBK7231T_App/.releaserc.yaml will use the files there to publish the assets.

    What I don't know is, how the actions are called and how/if you know, the one before is completed.
    And, if the workflows are, how to say, atomic?
    Or can there be another workflow running for the same release and somehow interfere?

    Sorry if I raise more questions than providing answers...
  • Helpful post
    #117 21280901
    max4elektroda
    Level 20  
    Taking another look to the logs in

    https://github.com/openshwprojects/OpenBK7231T_App/actions/runs/11548563030/job/32140322154

    Under "Run Semantic Release" you will see:

    54 [6:33:44 AM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/github"
    55 [6:33:45 AM] [semantic-release] [@semantic-release/github] › ✘  The asset output/**/obkSimulator* cannot be read, and will be ignored.


    So maybe its just a simple case of windows binary building plus all the tests is takeing too much time?

    What caught my eye was

    A snippet of workflow.yaml configuration file with the section needs: [ refs, build ] highlighted.

    Maybe it's just as simple as add "build2" (doing the simulator build and tests) here, too?

    I opened PR #1405, but I'm not sure, if/how I can test it (it builds fine, but I'm not doing a release in the PR ...)
  • #118 21280922
    p.kaczmarek2
    Moderator Smart Home
    Nice find, docs seems to confirm:
    Quote:

    A workflow run is made up of one or more jobs, which run in parallel by default

    I will give it a go.
    Helpful post? Buy me a coffee.

Topic summary

The discussion focuses on creating a custom driver for OpenBeken (OBK) devices without the need for a toolchain, utilizing online builds. Users share insights on troubleshooting compilation issues, including missing files and incorrect paths. Key points include the importance of proper file organization, the need for specific libraries like OneWire and DS18B20, and the challenges of ensuring accurate timing for sensor readings. Participants also discuss the differences between DS1820 and DS18B20 sensors, emphasizing the need for precise timing in the OneWire protocol. Solutions involve modifying driver code, implementing a pre-build script for SDK management, and optimizing build processes to reduce overhead. The conversation highlights collaborative efforts to improve driver functionality and streamline the development workflow.
Summary generated by the language model.
ADVERTISEMENT