Select ST33 field upgrade commands from the TPM command set - #586
Open
dgarske wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves ST33 firmware upgrade compatibility by selecting the correct FieldUpgradeStart/Data command-code pair per device, avoiding immediate TPM_RC_COMMAND_CODE failures on ST33 parts that don’t implement the previously hard-coded vendor ordinals.
Changes:
- Add a capability-based probe (
TPM_CAP_COMMANDS) to choose between standard TCG FieldUpgradeStart/Data and ST33KTPM vendor ordinals, with a version-based fallback heuristic. - Expose helpers to parse the target firmware version from the ST33 manifest header and to compute fallback upgrade ordinals.
- Extend ST33 firmware tooling/tests/docs to cover new part families/lines and the ordinal selection behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wolftpm/tpm2.h | Documents ST33 vendor ordinals and adds an _ex start API variant taking a caller-supplied command code. |
| wolftpm/tpm2_wrap.h | Adds wrapper/test APIs for manifest version parsing and fallback ST33 firmware-upgrade ordinal selection. |
| src/tpm2.c | Makes ST33 FieldUpgradeStart accept a supplied command code and improves vendor RC string classification for format-zero codes. |
| src/tpm2_wrap.c | Implements ST33 manifest-version parsing, command-set probing via TPM_CAP_COMMANDS, and safer manifest-size/family handling. |
| tests/unit_tests.c | Adds unit tests for manifest-version parsing and ordinal selection rules. |
| examples/firmware/st33_fw_update.c | Updates the ST33 update tool to probe command support, print diagnostics, and use selected ordinals (including retry logic on resume). |
| examples/firmware/st33_blob0.h | Refactors manifest-size selection to be family-based and explicitly handle unknown families. |
| examples/firmware/st33_blob0.c | Implements family detection and avoids asserting a manifest size when the family is unknown. |
| examples/firmware/README.md | Documents part identification and field-upgrade ordinal selection behavior. |
| README.md | Adds a new ST33TPHF2XSPI firmware-line example and notes vendor-string behavior on ST33TPHF2X. |
| hal/tpm_io_linux.c | Allows overriding I2C defaults (TPM2_I2C_*) at build time for board-specific setups. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
dgarske
force-pushed
the
st33_fu_ordinal
branch
from
August 27, 2026 20:39
5e4a941 to
ca34684
Compare
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
ST33 supports two different field-upgrade command code pairs, and wolfTPM always sent the ST33KTPM vendor pair (
0x2000030C/0x2000030D) - which some ST33 parts do not implement, so the upgrade failed at the very first command withTPM_RC_COMMAND_CODE. wolfTPM now asks the TPM which pair it implements and uses that, falling back to the standard codes (0x0000012F/0x00000141) for generation-2 images, and otherwise leaving the previous behavior unchanged.ZD 22193