You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/README.md
+62-21Lines changed: 62 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ The PKCS #7 and TLS examples require generating CSR's and signing them using a t
8
8
9
9
To enable parameter encryption use `-aes` for AES-CFB mode or `-xor` for XOR mode. Only some TPM commands / responses support parameter encryption. If the TPM2_ API has .flags `CMD_FLAG_ENC2` or `CMD_FLAG_DEC2` set then the command will use parameter encryption / decryption.
10
10
11
-
There are some vendor specific examples, like the TPM 2.0 extra GPIO examples for ST33.
11
+
There are some vendor specific examples, like the TPM 2.0 extra GPIO examples for ST33 and NPCT75x.
12
12
13
13
## Native API Test
14
14
@@ -427,22 +427,27 @@ mySecretMessage
427
427
428
428
After a successful unsealing, the data is stored into a new file. If no filename is provided, the `unseal` tool stores the data in `unseal.bin`.
429
429
430
-
## GPIO control
430
+
431
+
## GPIO Control
431
432
432
433
Some TPM 2.0 modules have extra I/O functionalities and additional GPIO that the developer could use. This extra GPIO could be used to signal other subsystems about security events or system states.
433
434
434
-
Currently, the GPIO control examples support only ST33 TPM 2.0 modules.
435
+
Currently, the GPIO control examples support ST33 and NPCT75x TPM 2.0 modules.
435
436
436
-
There are three examples available: `gpio/gpio_config`, `gpio/gpio_set`, `gpio/gpio_read`.
437
+
There are four examples available: `gpio/gpio_config` for ST33 and `gpio/gpio_nuvoton` for NPCT75x.
437
438
438
439
Every example has a help option `-h`. Please consult with `gpio_config -h` about the various GPIO modes.
439
440
440
-
Demo usage is available, when no parameters are supplied. Then, GPIO 0 is used in output mode.
441
+
Once configured, a GPIO can be controlled using `gpio/gpio_set` and `gpio/gpio_read`.
441
442
443
+
Demo usage is available, when no parameters are supplied. Recommended is to use carefully selected options, because GPIO interact with the physical world.
442
444
443
-
```
445
+
### GPIO Config
446
+
447
+
ST33 supports 6 modes, information from `gpio/gpio_config` below:
444
448
445
-
examples/gpio/gpio_config -h
449
+
```
450
+
$ ./examples/gpio/gpio_config -h
446
451
Expected usage:
447
452
./examples/gpio/gpio_config [num] [mode]
448
453
* num is a GPIO number between 0-3 (default 0)
@@ -455,45 +460,81 @@ Expected usage:
455
460
5. pushpull - output in push pull configuration
456
461
6. unconfigure - delete the NV index for the selected GPIO
457
462
Example usage, without parameters, configures GPIO0 as input with a pull down.
458
-
459
463
```
460
464
461
465
Example usage for configuring a GPIO to output can be found below:
462
466
463
467
```
464
-
465
-
$ ./examples/gpio/gpio_config
468
+
$ ./examples/gpio/gpio_config 0 5
466
469
GPIO num is: 0
467
470
GPIO mode is: 5
468
471
Example how to use extra GPIO on a TPM 2.0 modules
469
-
wolfTPM2_Init: success
470
472
Trying to configure GPIO0...
471
473
TPM2_GPIO_Config success
472
474
NV Index for GPIO access created
473
-
474
-
$ ./examples/gpio/gpio_set
475
-
GPIO0 set to high level
476
-
477
475
```
478
476
479
-
Switching a GPIO configuration is seamless, because gpio/config takes care of deleting existing NV Index, so a new GPIO configuration can be chosen.
480
-
481
-
Example usage for configuring a GPIO as input with a pulp-up can be found below:
477
+
Example usage for configuring a GPIO as input with a pull-up on ST33 can be found below:
482
478
483
479
```
484
-
485
480
$ ./examples/gpio/gpio_config 0 3
486
481
GPIO num is: 0
487
482
GPIO mode is: 3
488
483
Demo how to use extra GPIO on a TPM 2.0 modules
489
-
wolfTPM2_Init: success
490
484
Trying to configure GPIO0...
491
485
TPM2_GPIO_Config success
492
486
NV Index for GPIO access created
487
+
```
488
+
489
+
### GPIO Config (NPCT75xx)
490
+
491
+
NPCT75x supports 3 output modes, information from `gpio/gpio_nuvoton` below:
492
+
493
+
```
494
+
$ ./examples/gpio/gpio_nuvoton -h
495
+
Expected usage:
496
+
./examples/gpio/gpio_nuvoton [num] [mode]
497
+
* num is a GPIO number between 3 and 4 (default 3)
498
+
* mode is either push-pull, open-drain or open-drain with pull-up
499
+
1. pushpull - output in push pull configuration
500
+
2. opendrain - output in open drain configuration
501
+
3. pullup - output in open drain with pull-up enabled
502
+
4. unconfig - delete NV index for GPIO access
503
+
Example usage, without parameters, configures GPIO3 as push-pull output.
504
+
```
505
+
506
+
Please note that NPCT75x GPIO numbering starts from GPIO3, while ST33 starts from GPIO0.
507
+
508
+
```
509
+
$ ./examples/gpio/gpio_nuvoton 4 1
510
+
Example for GPIO configuration of a NPTC7xx TPM 2.0 module
511
+
GPIO number: 4
512
+
GPIO mode: 1
513
+
Successfully read the current configuration
514
+
Successfully wrote new configuration
515
+
NV Index for GPIO access created
516
+
```
517
+
518
+
### GPIO Usage
519
+
520
+
Switching a GPIO configuration is seamless.
521
+
* For ST33 `gpio/gpio_config` takes care of deleting existing NV Index, so a new GPIO configuration can be chosen.
522
+
* For NPCT75xx `gpio/gpio_nuvoton` can reconfigure any GPIO without deleting the created NV index.
493
523
524
+
```
525
+
$ ./examples/gpio/gpio_set 0 -high
526
+
GPIO0 set to high level
527
+
528
+
$ ./examples/gpio/gpio_set 0 -low
529
+
GPIO0 set to low level
530
+
```
531
+
532
+
```
494
533
$ ./examples/gpio/gpio_read 0
495
534
GPIO0 is Low
496
-
497
535
```
498
536
537
+
538
+
## Support
539
+
499
540
If you need more information about using these examples please contact us at support@wolfssl.com
0 commit comments