fix: sync sensor enum when overlaying patched sensor source#815
Open
mjc wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a build-step utility to keep the Sophgo sensor header in sync by removing deprecated sensor IDs, and improves library update/backup behavior.
Changes:
- Introduced
sync_sensor_abi()to delete specific sensor enum entries fromsample_comm.hand validate removal. - Fixed
update_libto return success (exit 0) after completing. - Improved backup flow by creating the original directory with
-pand saving a copy ofsample_comm.h.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6b5011d to
6301a31
Compare
0c51204 to
105a151
Compare
105a151 to
ca38487
Compare
Author
|
this approach is much better I think. anyway, rebased. should be ready now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the SG2002 build script overlays NanoKVM's patched
sample_common_sensor.cinto MaixCDK, also synchronize MaixCDK's matchingsample_comm.hsensor enum so both sides keep the same sensor ABI.This now uses an explicit patch file:
support/sg2002/additional/sophgo-middleware/v2/sample/common/sample_comm.h.patchProblem
sample_common_sensor.candsample_comm.hform a shared sensor ABI. The enum values fromsample_comm.hare used by the sensor handling implemented insample_common_sensor.c.NanoKVM replaces MaixCDK's stock
sample_common_sensor.cduringsupport/sg2002/build, but the corresponding MaixCDK header was previously left unchanged. If the patched source removes sensor cases while the header keeps those enum entries, later sensor IDs can shift out of alignment and a rebuiltkvm_vision/ native library can select the wrong sensor branch at runtime.Fix
Add
sync_sensor_abi()tosupport/sg2002/buildand call it anywhere the patchedsample_common_sensor.cis copied into MaixCDK.The helper now:
sample_comm.h.patchagainst MaixCDK'ssample_comm.h;update_libcan be rerun safely;install_nanokvm_libs()helper;sample_comm.hduring first-time overlay setup.update_libnow exits with status0on success.中文说明
SG2002 构建脚本会把 NanoKVM 修改过的
sample_common_sensor.c覆盖到 MaixCDK 中,但之前没有同步修改对应的sample_comm.h传感器枚举。sample_common_sensor.c和sample_comm.h需要保持一致,否则重新编译kvm_vision/ native library 时,后面的传感器 ID 可能会发生偏移,导致运行时选择错误的 sensor 处理分支。这个 PR 新增一个明确的
sample_comm.h.patch,在同步 NanoKVM 的sample_common_sensor.c后,用补丁同步 MaixCDK 的sample_comm.h。补丁可以重复运行;如果 header 已经同步过会成功退出,如果 header 内容和预期不匹配则会报错停止。Testing
bash -n support/sg2002/buildgit diff --checkupdate_libsmoke test against upstreamsample_comm.hupdate_libflow twice to verify idempotencesample_comm.hpreserves mode640Sensor header patch does not match