Conversation
e2d45f9 to
4a6a4c2
Compare
bbf37b9 to
fb3e39a
Compare
There was a problem hiding this comment.
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_i2capp 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 anint32_t block_numvariable by reference/pointer (e.g. set it tomarker | block_countthen pass&block_num).
tests/system_hardware/time_write_upgrade/time_write_upgrade.c:156- There is stray text
block_countaftert_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 handlingBUS_RESET. This change switches the check toif (result.status)wherestatusis 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 overloadingstatus.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…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
d0d595b to
944830c
Compare
944830c to
927f226
Compare
ed-xmos
left a comment
There was a problem hiding this comment.
Very nice refactor, additions and optimisations. A few comments/questions - just hit re-request when you are done and need final review
ca4ce6c to
76b2338
Compare
|
Closes #71 |
76b2338 to
8369433
Compare
There was a problem hiding this comment.
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 finalblock_numargument, 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 localint32_t block_numvariable and pass it by reference (or passNULLif unused).
tests/system_hardware/time_write_upgrade/time_write_upgrade.c:156- There is stray text
block_countaftert_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 literal0here is not a valid reference/pointer and will not compile. PassNULLwhen there is no block number to provide.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8369433 to
7fb36d8
Compare
|
Marked all my comments as resolved following replies. Thanks. |
7fb36d8 to
a251bce
Compare
Updates
host/dfu_i2cRPI host exampleAdds
examples/i2c/exampleAdds 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