Skip to content

Feature/adding example#68

Merged
humphrey-xmos merged 13 commits intoxmos:developfrom
humphrey-xmos:feature/adding-example
Mar 13, 2026
Merged

Feature/adding example#68
humphrey-xmos merged 13 commits intoxmos:developfrom
humphrey-xmos:feature/adding-example

Conversation

@humphrey-xmos
Copy link
Copy Markdown
Contributor

@humphrey-xmos humphrey-xmos commented Feb 24, 2026

Updates host/dfu_i2c RPI host example
Adds examples/i2c/ example
Adds deferred DFU task to carry out slow operations, after comms transfers compelte
Extracted the DFU flash operations sub-state-machine into own file
Made lib_dfu and lib_xua interface return type the smae
Removed API layer dfu_comamnds read/write, now uses dfu_request directly
Refactored test given the changes above

@humphrey-xmos humphrey-xmos force-pushed the feature/adding-example branch 9 times, most recently from e2d45f9 to 4a6a4c2 Compare February 26, 2026 13:53
@humphrey-xmos humphrey-xmos force-pushed the feature/adding-example branch 2 times, most recently from bbf37b9 to fb3e39a Compare March 4, 2026 10:06
@humphrey-xmos humphrey-xmos requested review from ed-xmos and removed request for ed-xmos March 5, 2026 11:21
@humphrey-xmos humphrey-xmos marked this pull request as draft March 5, 2026 11:21
@humphrey-xmos humphrey-xmos requested a review from Copilot March 11, 2026 18:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands DFU support for I2C-based control by adding new host/examples (including Raspberry Pi) and refactoring lib_dfu to use a unified dfu_request/dfu_request_with_arguments API with deferred actions for slow flash operations.

Changes:

  • Add I2C DFU examples (device + xcore host) and an RPi-focused host test/workflow.
  • Refactor lib_dfu request handling and extract the DNLOAD flash sub-state-machine into a new module with deferred actions.
  • Update host dfu_i2c app and multiple system/device-simulation tests to use the new request API and deferred behavior.

Reviewed changes

Copilot reviewed 67 out of 68 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
tests/system_hardware/write_upgrade_boot_only/src/test_write_upgrade_boot_only.c Update system HW test to new dfu_request* API + deferred actions
tests/system_hardware/write_upgrade_boot_only/run.sh Remove legacy system HW runner script
tests/system_hardware/time_write_upgrade/time_write_upgrade.c Update timing test to new DFU request API
tests/rpi/test_rpi.py Add end-to-end RPi host DFU test
tests/rpi/status/src/main.c New status/host test app main
tests/rpi/status/CMakeLists.txt Build config for new RPi status app
tests/flash_hardware/prepare_upgrade_slot/src/test_prepare_upgrade_slot.c Minor test cleanup
tests/device_simulation/dfu_dnload/upload_start/src/test_upload_start.c Update simulation test to new DFU request API
tests/device_simulation/dfu_dnload/upload/src/test_upload.c Update simulation test to new DFU request API
tests/device_simulation/dfu_dnload/revert/src/test_revert.c New simulation test for revert-factory behavior
tests/device_simulation/dfu_dnload/revert/CMakeLists.txt Build config for new revert simulation test
tests/device_simulation/dfu_dnload/oversize_image/src/test_oversize_image.c Update oversize-image simulation test to new DFU request API
tests/device_simulation/dfu_dnload/dnload_start/src/test_dnload_start.c Update dnload-start simulation test for deferred actions
tests/device_simulation/dfu_dnload/dnload/src/test_dnload.c Update DNLOAD simulation tests; add reboot/cleanup checks
tests/device_simulation/dfu/timeout_detach/src/test_timeout_detach.c Update to new DFU request API
tests/device_simulation/dfu/getstatus/src/test_getstatus.c Update to new DFU request API
tests/device_simulation/dfu/getstate/src/test_getstate.c Update to new DFU request API
tests/device_simulation/dfu/detach/src/test_detach.c Update to new DFU request API
tests/device_simulation/dfu/clrstatus/src/test_clrstatus.c Update to new DFU request API
tests/device_simulation/dfu/bus_reset/src/test_bus_reset.c Update to new DFU request API
tests/device_simulation/dfu/abort/src/test_abort.c Update to new DFU request API
lib_dfu/src/usb/dfu_usb_requests.xc Update USB DFU request plumbing to unified response type/deferred requests
lib_dfu/src/usb/dfu_usb_descriptors.h Descriptor updates (transfer size, serial index)
lib_dfu/src/usb/dfu_interface.h Unify interface response type (dfu_cmd_response)
lib_dfu/src/dfu_sub_sm.xc New extracted flash DNLOAD/MANIFEST sub-state-machine
lib_dfu/src/dfu_sub_sm.h Header for new DFU sub-state-machine
lib_dfu/src/dfu_state_machine.h Remove obsolete state machine header
lib_dfu/src/dfu_reboot.xc Gate reboot implementation for DFU_ENABLE vs testing
lib_dfu/src/dfu_reboot.h Add configurable reboot delay constants
lib_dfu/src/dfu_flashlib_user.c Update clockblock macro usage for flashlib
lib_dfu/src/dfu_default_conf.h Add DFU_HOST/DFU_BCD_DEVICE, config cleanups, macro rename
lib_dfu/src/dfu_commands.xc Remove legacy DFU command wrapper layer
lib_dfu/src/dfu.xc Major DFU state machine refactor + deferred action support
lib_dfu/lib_build_info.cmake Build integration for new/removed DFU sources
lib_dfu/api/dfu_types.h Add descriptor payload definition + deferred action request IDs
lib_dfu/api/dfu.h Public API updated to dfu_request* + deferred_request in response
host/suffix_generator/README.txt Update example output extension/docs
host/dfu_i2c/src/operations.h Replace old ops API with upload support
host/dfu_i2c/src/operations.c Rework host DFU operations for new protocol + upload
host/dfu_i2c/src/main.c Add new operations (upload, revert_factory) and status codes
host/dfu_i2c/src/labels.h Remove deprecated host command header include
host/dfu_i2c/src/labels.c Update label mapping for new request IDs
host/dfu_i2c/src/input_reader.h Remove spispec input support; simplify inputs
host/dfu_i2c/src/input_reader.c Adjust file loading/suffix verification error handling
host/dfu_i2c/src/hal.h Expand HAL signatures for xcore I2C interface builds
host/dfu_i2c/src/hal.c Rewrite HAL to use control host APIs + header handling
host/dfu_i2c/src/dfu_utils.h Header guard rename
host/dfu_i2c/src/dfu_utils.c Add xcore sleep implementation
host/dfu_i2c/src/dfu_host_commands.h Remove deprecated host command aliases
host/dfu_i2c/src/argument_parser.h Default block size change + new operations
host/dfu_i2c/src/argument_parser.c Update CLI parsing/usage for new operations
host/dfu_i2c/src/app_types.h New app-level status code enum
host/dfu_i2c/CMakeLists.txt Switch to lib_device_control i2c host build integration + warnings
host/CMakeLists.txt Conditionally build RPi host app
examples/i2c/shared/resource.h New shared resource/addr definitions for I2C example
examples/i2c/host_xcore/src/host.xc New xcore I2C host example exercising DFU/control
examples/i2c/host_xcore/src/dfu_conf.h Host-oriented DFU config (DFU_ENABLE=0, DFU_HOST=1)
examples/i2c/host_xcore/CMakeLists.txt Build config for xcore host example
examples/i2c/device/src/xk-voice-l71.xn New device XN target for I2C example
examples/i2c/device/src/main.xc New I2C device example main wiring control + DFU
examples/i2c/device/src/control_conf.h Control config enabling I2C + DFU
examples/i2c/device/src/config.xscope xSCOPE config for example
examples/i2c/device/src/app.xc Simple control resource example app
examples/i2c/device/src/app.h Header for example app
examples/i2c/device/CMakeLists.txt Build config for device example variants (factory/update)
examples/i2c/deps.cmake Example dependency list
Jenkinsfile Enable building new examples; adjust RPi artifact handling
.gitignore Ignore generated .dfu artifacts
Comments suppressed due to low confidence (3)

tests/system_hardware/time_write_upgrade/time_write_upgrade.c:138

  • dfu_request_with_arguments(DFU_DNLOAD, ...) is called with (marker | block_count) as the 4th argument, but the API expects a nullable reference/pointer to the block number (so it can be read/written). Passing an integer here should not compile and also loses the intended block numbering (marker + count). Pass an int32_t block_num variable by reference/pointer (e.g. set it to marker | block_count then pass &block_num).
    tests/system_hardware/time_write_upgrade/time_write_upgrade.c:156
  • There is stray text block_count after t_start(8); which will cause a compilation error. Remove the extra token so this is a valid statement.
    lib_dfu/src/usb/dfu_usb_requests.xc:156
  • DFUProcessResetState() previously used a dedicated field (return_code) to infer whether the DFU state machine is in DFU mode after handling BUS_RESET. This change switches the check to if (result.status) where status is an API status code (0 == success), so the logic will almost always treat success as “not in DFU mode” and error as “in DFU mode”, which is inverted/incorrect. This should use an explicit “in DFU mode” return value (e.g. add a field back to the response, or query state via a GETSTATE-like request) rather than overloading status.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread host/dfu_i2c/src/argument_parser.c Outdated
Comment thread tests/rpi/test_rpi.py
Comment thread tests/rpi/test_rpi.py Outdated
Comment thread host/dfu_i2c/src/operations.c Outdated
Comment thread tests/rpi/status/src/main.c Outdated
Comment thread host/dfu_i2c/src/operations.c Outdated
Comment thread host/dfu_i2c/src/operations.c
Comment thread host/dfu_i2c/src/operations.c Outdated
Comment thread host/dfu_i2c/src/operations.c Outdated
…ests

dfu_i2c now uses device_control host_build_i2c.cmake
Making RPi DFU build use common types
Redefined mmany dfu command functions
Combing USB and non-USB return type
downalod entry refuses 0 length and call flash deinit if fifo errors
Adding deferred action types
Adding conf parameter DFU_BCD_DEVICE (+2 squashed commit)
Updating with changes to lib_device_control defines and conf
Fixing dfu_i2c return values, parameter checks and error hanlding process
dfu_i2c adding porfile data query
Upload now supported abort (not download ywt)
Adding fetch for device descriptor
@humphrey-xmos humphrey-xmos force-pushed the feature/adding-example branch 2 times, most recently from d0d595b to 944830c Compare March 12, 2026 13:56
@humphrey-xmos humphrey-xmos force-pushed the feature/adding-example branch from 944830c to 927f226 Compare March 12, 2026 14:06
Comment thread examples/i2c/host_xcore/src/host.xc
Comment thread host/dfu_i2c/src/argument_parser.c
Comment thread host/dfu_i2c/src/operations.c
Comment thread host/dfu_i2c/CMakeLists.txt
Comment thread host/libsuffix_verifier/CMakeLists.txt Outdated
Comment thread host/suffix_generator/CMakeLists.txt Outdated
Comment thread lib_dfu/src/dfu_reboot.xc Outdated
Comment thread examples/i2c/host_xcore/CMakeLists.txt
Copy link
Copy Markdown
Contributor

@ed-xmos ed-xmos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice refactor, additions and optimisations. A few comments/questions - just hit re-request when you are done and need final review

Comment thread host/dfu_i2c/src/hal.c
Comment thread host/dfu_i2c/src/hal.c Outdated
Comment thread host/dfu_i2c/src/input_reader.c
Comment thread lib_dfu/lib_build_info.cmake Outdated
@humphrey-xmos humphrey-xmos force-pushed the feature/adding-example branch from ca4ce6c to 76b2338 Compare March 12, 2026 18:17
@humphrey-xmos
Copy link
Copy Markdown
Contributor Author

Closes #71

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 71 out of 72 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (3)

tests/system_hardware/time_write_upgrade/time_write_upgrade.c:138

  • dfu_request_with_arguments() is called with (marker | block_count) for the final block_num argument, but this parameter is a (nullable) reference/pointer. Passing an expression here won’t compile and also prevents the API from updating the block number if needed; use a local int32_t block_num variable and pass it by reference (or pass NULL if unused).
    tests/system_hardware/time_write_upgrade/time_write_upgrade.c:156
  • There is stray text block_count after t_start(8); which will cause a compile error. Remove the extraneous token or split into separate statements.
    tests/system_hardware/time_write_upgrade/time_write_upgrade.c:156
  • The final argument to dfu_request_with_arguments() is the (nullable) block number reference; passing literal 0 here is not a valid reference/pointer and will not compile. Pass NULL when there is no block number to provide.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread host/dfu_i2c/src/hal.c
Comment thread host/dfu_i2c/src/argument_parser.c
Comment thread host/dfu_i2c/src/hal.c Outdated
Comment thread host/dfu_i2c/src/operations.c
Comment thread host/dfu_i2c/src/input_reader.c
Comment thread tests/system_hardware/write_upgrade_boot_only/src/test_write_upgrade_boot_only.c Outdated
Copy link
Copy Markdown
Contributor

@ed-xmos ed-xmos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@humphrey-xmos humphrey-xmos force-pushed the feature/adding-example branch from 8369433 to 7fb36d8 Compare March 13, 2026 09:29
@xross
Copy link
Copy Markdown

xross commented Mar 13, 2026

Marked all my comments as resolved following replies. Thanks.

@humphrey-xmos humphrey-xmos force-pushed the feature/adding-example branch from 7fb36d8 to a251bce Compare March 13, 2026 11:47
@humphrey-xmos humphrey-xmos merged commit 5349dba into xmos:develop Mar 13, 2026
2 checks passed
@humphrey-xmos humphrey-xmos deleted the feature/adding-example branch March 13, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants