dfukit 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. dfukit-2.0.0/.clang-format +20 -0
  2. dfukit-2.0.0/.github/workflows/tests.yml +20 -0
  3. dfukit-2.0.0/.github/workflows/wheels.yml +93 -0
  4. dfukit-2.0.0/.gitignore +6 -0
  5. dfukit-2.0.0/.vscode/settings.json +7 -0
  6. dfukit-2.0.0/CHANGELOG.md +22 -0
  7. dfukit-2.0.0/CMakeLists.txt +73 -0
  8. dfukit-2.0.0/DESIGN.md +517 -0
  9. dfukit-2.0.0/LICENSE +202 -0
  10. dfukit-2.0.0/PKG-INFO +221 -0
  11. dfukit-2.0.0/README.md +211 -0
  12. dfukit-2.0.0/backends/ram/dfukit_ram.c +101 -0
  13. dfukit-2.0.0/backends/ram/dfukit_ram.h +44 -0
  14. dfukit-2.0.0/lib/crc32/dfukit_crc32.c +28 -0
  15. dfukit-2.0.0/lib/crc32/dfukit_crc32.h +22 -0
  16. dfukit-2.0.0/pyproject.toml +59 -0
  17. dfukit-2.0.0/python/dfukit/__init__.py +28 -0
  18. dfukit-2.0.0/python/dfukit_native.cpp +399 -0
  19. dfukit-2.0.0/src/dfukit.h +92 -0
  20. dfukit-2.0.0/src/dfukit_client.c +423 -0
  21. dfukit-2.0.0/src/dfukit_client.h +116 -0
  22. dfukit-2.0.0/src/dfukit_server.c +855 -0
  23. dfukit-2.0.0/src/dfukit_server.h +171 -0
  24. dfukit-2.0.0/src/dfukit_wire.h +148 -0
  25. dfukit-2.0.0/tests/CMakeLists.txt +6 -0
  26. dfukit-2.0.0/tests/README.md +21 -0
  27. dfukit-2.0.0/tests/conftest.py +13 -0
  28. dfukit-2.0.0/tests/simulator.py +190 -0
  29. dfukit-2.0.0/tests/test_bindings.py +46 -0
  30. dfukit-2.0.0/tests/test_boards.py +53 -0
  31. dfukit-2.0.0/tests/test_busy.py +103 -0
  32. dfukit-2.0.0/tests/test_crc32.py +22 -0
  33. dfukit-2.0.0/tests/test_lossy.py +74 -0
  34. dfukit-2.0.0/tests/test_passthrough.py +189 -0
  35. dfukit-2.0.0/tests/test_refusals.py +202 -0
  36. dfukit-2.0.0/tests/test_resume.py +109 -0
  37. dfukit-2.0.0/tests/test_update.py +57 -0
  38. dfukit-2.0.0/tests/test_wire.py +67 -0
  39. dfukit-2.0.0/uv.lock +813 -0
@@ -0,0 +1,20 @@
1
+ # Kernel style: tabs, 8 wide, 100 columns
2
+ ---
3
+ BasedOnStyle: LLVM
4
+ AlignConsecutiveMacros: AcrossComments
5
+ AllowShortBlocksOnASingleLine: Never
6
+ AllowShortCaseLabelsOnASingleLine: false
7
+ AllowShortEnumsOnASingleLine: false
8
+ AllowShortFunctionsOnASingleLine: None
9
+ AllowShortIfStatementsOnASingleLine: false
10
+ AllowShortLoopsOnASingleLine: false
11
+ BreakBeforeBraces: Linux
12
+ ColumnLimit: 100
13
+ ContinuationIndentWidth: 8
14
+ IndentCaseLabels: false
15
+ IndentGotoLabels: false
16
+ IndentWidth: 8
17
+ InsertBraces: true
18
+ InsertNewlineAtEOF: true
19
+ SortIncludes: Never
20
+ UseTab: ForContinuationAndIndentation
@@ -0,0 +1,20 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ tests:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - uses: actions/setup-python@v5
13
+ with:
14
+ python-version: "3.12"
15
+ - name: Test tools
16
+ run: pip install pytest "nanobind>=2.5"
17
+ - name: Build
18
+ run: cmake -S . -B build && cmake --build build
19
+ - name: Test
20
+ run: ctest --test-dir build --no-tests=error --output-on-failure
@@ -0,0 +1,93 @@
1
+ name: Wheels
2
+
3
+ # A version tag publishes to PyPI and creates the GitHub release. By hand it only builds
4
+ on:
5
+ workflow_dispatch:
6
+ push:
7
+ tags:
8
+ - "v[0-9]*"
9
+
10
+ jobs:
11
+ # Before anything is built: a version without a changelog entry is not released
12
+ changelog:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - name: Take the version's entry
17
+ if: github.ref_type == 'tag'
18
+ run: |
19
+ version="${GITHUB_REF_NAME#v}"
20
+ awk -v heading="## [$version]" '
21
+ /^## \[/ { found = index($0, heading) == 1; next }
22
+ /^\[[^]]+\]: / { next }
23
+ found
24
+ ' CHANGELOG.md > notes.md
25
+ if ! grep -q '[^[:space:]]' notes.md; then
26
+ echo "::error file=CHANGELOG.md::No entry for $version"
27
+ exit 1
28
+ fi
29
+ - uses: actions/upload-artifact@v4
30
+ if: github.ref_type == 'tag'
31
+ with:
32
+ name: release-notes
33
+ path: notes.md
34
+
35
+ sdist:
36
+ needs: changelog
37
+ runs-on: ubuntu-latest
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+ - name: Build
41
+ run: pipx run build --sdist
42
+ - name: Check metadata
43
+ run: pipx run twine check dist/*
44
+ - uses: actions/upload-artifact@v4
45
+ with:
46
+ name: dist-sdist
47
+ path: dist/*.tar.gz
48
+
49
+ wheels:
50
+ needs: changelog
51
+ name: Wheels on ${{ matrix.os }}
52
+ runs-on: ${{ matrix.os }}
53
+ strategy:
54
+ fail-fast: false
55
+ matrix:
56
+ os: [ubuntu-latest, macos-15-intel, macos-14, windows-latest]
57
+ steps:
58
+ - uses: actions/checkout@v4
59
+ - uses: pypa/cibuildwheel@v2.23
60
+ - uses: actions/upload-artifact@v4
61
+ with:
62
+ name: dist-${{ matrix.os }}
63
+ path: wheelhouse/*.whl
64
+
65
+ publish:
66
+ if: github.event_name == 'push'
67
+ needs: [sdist, wheels]
68
+ runs-on: ubuntu-latest
69
+ permissions:
70
+ id-token: write
71
+ steps:
72
+ - uses: actions/download-artifact@v4
73
+ with:
74
+ path: dist
75
+ pattern: dist-*
76
+ merge-multiple: true
77
+ - uses: pypa/gh-action-pypi-publish@release/v1
78
+
79
+ release:
80
+ needs: publish
81
+ runs-on: ubuntu-latest
82
+ permissions:
83
+ contents: write
84
+ steps:
85
+ - uses: actions/download-artifact@v4
86
+ with:
87
+ name: release-notes
88
+ - name: Create the release
89
+ env:
90
+ GH_TOKEN: ${{ github.token }}
91
+ run: >
92
+ gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --verify-tag
93
+ --title "$GITHUB_REF_NAME" --notes-file notes.md
@@ -0,0 +1,6 @@
1
+ build*/
2
+ __pycache__/
3
+ *.egg-info/
4
+ dist/
5
+ .coverage
6
+ .pytest_cache/
@@ -0,0 +1,7 @@
1
+ {
2
+ "python.testing.pytestArgs": [
3
+ "tests"
4
+ ],
5
+ "python.testing.unittestEnabled": false,
6
+ "python.testing.pytestEnabled": true
7
+ }
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
6
+ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.0.0] - 2026-11-04
9
+
10
+ A new protocol and library. Not compatible with dfukit 1.
11
+
12
+ ### Added
13
+
14
+ - A firmware update protocol for any link: a credit window, go-back-N, resume, a 32-bit board ID
15
+ per image target, and a CRC-32 of each image
16
+ - A server and a client in C, without threads, heap or platform code
17
+ - A RAM backend, and a pass-through that carries a session to a device further down a chain
18
+ - The CRC-32 as a small module (`lib/crc32`) that an application can replace
19
+ - A Python interface to the server and the client (`dfukit.Server`, `dfukit.Client`)
20
+ - Wheels for Linux, macOS and Windows
21
+
22
+ [2.0.0]: https://github.com/fvsolutions-dev/dfukit/releases/tag/v2.0.0
@@ -0,0 +1,73 @@
1
+ # An ESP-IDF component when ESP-IDF builds it; a plain CMake project (with the tests) otherwise
2
+ if(ESP_PLATFORM)
3
+ idf_component_register(
4
+ SRCS
5
+ src/dfukit_server.c
6
+ src/dfukit_client.c
7
+ lib/crc32/dfukit_crc32.c
8
+ backends/ram/dfukit_ram.c
9
+ INCLUDE_DIRS src lib/crc32 backends/ram
10
+ )
11
+ return()
12
+ endif()
13
+
14
+ cmake_minimum_required(VERSION 3.22)
15
+ project(dfukit C)
16
+
17
+ set(CMAKE_C_STANDARD 99)
18
+ set(CMAKE_C_STANDARD_REQUIRED ON)
19
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
20
+
21
+ set(DFUKIT_SOURCES
22
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/dfukit_server.c
23
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/dfukit_client.c
24
+ ${CMAKE_CURRENT_SOURCE_DIR}/lib/crc32/dfukit_crc32.c
25
+ )
26
+
27
+ add_library(dfukit STATIC ${DFUKIT_SOURCES})
28
+ target_include_directories(dfukit PUBLIC src lib/crc32)
29
+ if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
30
+ target_compile_options(dfukit PRIVATE -Werror=implicit-function-declaration)
31
+ target_compile_options(dfukit PRIVATE -Wall -Wextra -Wconversion -Wno-sign-conversion)
32
+ endif()
33
+
34
+ add_library(dfukit_ram STATIC backends/ram/dfukit_ram.c)
35
+ target_include_directories(dfukit_ram PUBLIC backends/ram)
36
+ target_link_libraries(dfukit_ram PUBLIC dfukit)
37
+ # Plain C99, as documented: what it does not have is an error
38
+ set_target_properties(dfukit dfukit_ram PROPERTIES C_EXTENSIONS OFF)
39
+
40
+ # The Python module (python/dfukit_native.cpp, nanobind): dfukit whole, with the ram backend. Tests
41
+ # run through it
42
+ option(DFUKIT_PYTHON "Build the Python module" ${PROJECT_IS_TOP_LEVEL})
43
+ option(DFUKIT_COVERAGE "Measure what the tests cover (tests/README.md)" OFF)
44
+ if(DFUKIT_PYTHON OR SKBUILD)
45
+ enable_language(CXX)
46
+ find_package(Python 3.10 REQUIRED COMPONENTS Interpreter Development.Module
47
+ OPTIONAL_COMPONENTS Development.SABIModule)
48
+ execute_process(COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
49
+ OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NANOBIND_DIR ERROR_QUIET)
50
+ list(APPEND CMAKE_PREFIX_PATH "${NANOBIND_DIR}")
51
+ find_package(nanobind CONFIG QUIET)
52
+ if(nanobind_FOUND)
53
+ nanobind_add_module(_dfukit STABLE_ABI NB_STATIC
54
+ ${DFUKIT_SOURCES} backends/ram/dfukit_ram.c python/dfukit_native.cpp)
55
+ target_include_directories(_dfukit PRIVATE src lib/crc32 backends/ram)
56
+ if(DFUKIT_COVERAGE)
57
+ target_compile_options(_dfukit PRIVATE --coverage -O0)
58
+ target_link_options(_dfukit PRIVATE --coverage)
59
+ endif()
60
+ if(SKBUILD)
61
+ install(TARGETS _dfukit LIBRARY DESTINATION .)
62
+ endif()
63
+ else()
64
+ message(FATAL_ERROR "No nanobind: the tests need it. Install it, or -DDFUKIT_PYTHON=OFF")
65
+ endif()
66
+ endif()
67
+
68
+ if(PROJECT_IS_TOP_LEVEL AND NOT SKBUILD)
69
+ include(CTest)
70
+ if(BUILD_TESTING)
71
+ add_subdirectory(tests)
72
+ endif()
73
+ endif()