Skip to content

Commit 7964756

Browse files
committed
Minor code cleanups.
1 parent 1a7c490 commit 7964756

File tree

10 files changed

+81
-495
lines changed

10 files changed

+81
-495
lines changed

.github/workflows/make-test-swtpm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
wolftpm_config: --enable-st33
6969
# STMicro ST33KTPM2
7070
- name: st33ktpm2 firmware
71-
wolftpm_config: --enable-st33 --enable-firmware --enable-st
71+
wolftpm_config: --enable-st33 --enable-firmware
7272
# Microchip
7373
- name: microchip
7474
wolftpm_config: --enable-microchip

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ examples/boot/secret_seal
8484
examples/boot/secret_unseal
8585
examples/firmware/ifx_fw_extract
8686
examples/firmware/ifx_fw_update
87+
examples/firmware/st33_fw_update
8788
examples/endorsement/get_ek_certs
8889
examples/endorsement/verify_ek_cert
8990

@@ -151,6 +152,10 @@ UpgradeLog.htm
151152
*.VC.db
152153
*.filters
153154

155+
# macOS files
156+
._.DS_Store
157+
.DS_Store
158+
154159
# Backup and old files
155160
/**/*.bak
156161
/**/*.old
@@ -170,3 +175,11 @@ UpgradeLog.htm
170175
# we won't track the actual working sdkconfig files
171176
/IDE/Espressif/**/sdkconfig
172177
/IDE/Espressif/**/sdkconfig.old
178+
179+
# Firmware files
180+
examples/firmware/*.fi
181+
examples/firmware/*.BIN
182+
examples/firmware/*.DATA
183+
examples/firmware/*.MANIFEST
184+
examples/firmware/*.MANIFESTHASH
185+

examples/firmware/README.md

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Note: LMS format requirements:
153153
# Run without arguments to display the current firmware information
154154
./st33_fw_update
155155
ST33 Firmware Update Tool
156-
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 1
156+
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 1
157157
TPM2_Startup pass
158158
Mfg STM (2), Vendor ST33KTPM2X, Fw 9.257 (0x0)
159159
Firmware version details: Major=9, Minor=257, Vendor=0x0
@@ -165,7 +165,7 @@ Firmware update: Non-LMS format required
165165
ST33 Firmware Update Tool
166166
Firmware File: TPM_ST33KTPM2X_00090200_V1.fi
167167
Format: Non-LMS (V1)
168-
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 1
168+
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 1
169169
TPM2_Startup pass
170170
Mfg STM (2), Vendor ST33KTPM2X, Fw 9.257 (0x0)
171171
Firmware version details: Major=9, Minor=257, Vendor=0x0
@@ -184,7 +184,7 @@ Please reset or power cycle the TPM.
184184
ST33 Firmware Update Tool
185185
Firmware File: ST33KTPM2X_FAC_00090200_V2.fi
186186
Format: LMS (V2)
187-
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 3
187+
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 3
188188
TPM2_Startup pass
189189
Mfg STM (2), Vendor ST33KTPM2X, Fw 9.512 (0x0)
190190
Firmware version details: Major=9, Minor=512, Vendor=0x0
@@ -201,7 +201,7 @@ Please reset or power cycle the TPM.
201201
# Cancel an ongoing firmware update
202202
./st33_fw_update --abandon
203203
ST33 Firmware Update Tool
204-
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 1
204+
TPM2: Caps 0x30000415, Did 0x0003, Vid 0x104a, Rid 0x 1
205205
TPM2_Startup pass
206206
Mfg STM (2), Vendor ST33KTPM2X, Fw 9.257 (0x0)
207207
Firmware version details: Major=9, Minor=257, Vendor=0x0
@@ -211,27 +211,4 @@ Firmware Update Abandon:
211211
Success: Please reset or power cycle TPM
212212
```
213213

214-
**Note**: Firmware files cannot be made public and must be obtained separately from STMicroelectronics. Reference implementation code is available in the `examples-private` repository.
215-
216-
### Testing Firmware Updates
217-
218-
The `test_st33_firmware.sh` script can be used to test firmware update functionality:
219-
220-
```sh
221-
# Basic functionality tests (no firmware files needed)
222-
./examples/firmware/test_st33_firmware.sh
223-
224-
# Test non-LMS firmware update only
225-
NON_LMS_FW_FILE=/path/to/nonlms.fi ./examples/firmware/test_st33_firmware.sh --no-lms
226-
227-
# Test LMS firmware update only
228-
LMS_FW_FILE=/path/to/lms.fi ./examples/firmware/test_st33_firmware.sh --lms
229-
230-
# Test both (backward compatible, runs both if both files are provided)
231-
LMS_FW_FILE=/path/to/lms.fi NON_LMS_FW_FILE=/path/to/nonlms.fi ./examples/firmware/test_st33_firmware.sh
232-
233-
# Show help
234-
./examples/firmware/test_st33_firmware.sh --help
235-
```
236-
237-
**Note**: Use `--lms` or `--no-lms` flags to test a specific update path. When neither flag is specified, the script will attempt to run both tests if both firmware files are provided (backward compatible behavior).
214+
**Note**: Firmware files cannot be made public and must be obtained separately from STMicroelectronics.

examples/firmware/include.am

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,31 @@ EXTRA_DIST += examples/firmware/Makefile
88
EXTRA_DIST += examples/firmware/ifx_fw_extract.c
99

1010
if BUILD_EXAMPLES
11-
if BUILD_INFINEON
1211
if BUILD_FIRMWARE
12+
13+
if BUILD_INFINEON
1314
noinst_PROGRAMS += examples/firmware/ifx_fw_update
1415
noinst_HEADERS += examples/firmware/ifx_fw_update.h
1516
examples_firmware_ifx_fw_update_SOURCES = examples/firmware/ifx_fw_update.c \
1617
examples/tpm_test_keys.c
1718
examples_firmware_ifx_fw_update_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
1819
examples_firmware_ifx_fw_update_DEPENDENCIES = src/libwolftpm.la
1920
endif
20-
endif
21+
2122
if BUILD_ST33
22-
if BUILD_FIRMWARE
2323
noinst_PROGRAMS += examples/firmware/st33_fw_update
2424
examples_firmware_st33_fw_update_SOURCES = examples/firmware/st33_fw_update.c \
2525
examples/tpm_test_keys.c
2626
examples_firmware_st33_fw_update_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
2727
examples_firmware_st33_fw_update_DEPENDENCIES = src/libwolftpm.la
28+
2829
endif
2930
endif
3031
endif
3132

3233
example_firmwaredir = $(exampledir)/firmware
33-
dist_example_firmware_DATA = examples/firmware/ifx_fw_update.c
34+
dist_example_firmware_DATA = examples/firmware/ifx_fw_update.c \
35+
examples/firmware/st33_fw_update.c
3436

35-
DISTCLEANFILES+= examples/firmware/.libs/ifx_fw_update
37+
DISTCLEANFILES+= examples/firmware/.libs/ifx_fw_update \
38+
examples/firmware/.libs/st33_fw_update

examples/firmware/st33_fw_update.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ static int TPM2_ST33_SendFirmwareData(fw_info_t* fwinfo)
138138
return rc;
139139
}
140140

141+
/* Callback function for firmware data access
142+
* Returns the actual number of bytes copied (may be less than requested at end of buffer)
143+
* Returns BUFFER_E on error (offset out of bounds) */
141144
static int TPM2_ST33_FwData_Cb(uint8_t* data, uint32_t data_req_sz,
142145
uint32_t offset, void* cb_ctx)
143146
{
@@ -257,9 +260,9 @@ int TPM2_ST33_Firmware_Update(void* userCtx, int argc, char *argv[])
257260
rc, TPM2_GetRCString(rc));
258261
goto exit;
259262
}
260-
263+
261264
TPM2_ST33_PrintInfo(&caps);
262-
265+
263266
/* Verify this is an ST33 TPM */
264267
if (caps.mfg != TPM_MFG_STM) {
265268
printf("Error: This tool is for STMicroelectronics ST33 TPMs only!\n");

0 commit comments

Comments
 (0)