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
+54-45Lines changed: 54 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -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 four examples available: `gpio/gpio_config` for ST33 and `gpio/gpio_nuvoton` for NPCT75x. Once configured, a GPIO can be controlled using `gpio/gpio_set` and `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
441
+
Once configured, a GPIO can be controlled using `gpio/gpio_set` and `gpio/gpio_read`.
442
+
440
443
Demo usage is available, when no parameters are supplied. Recommended is to use carefully selected options, because GPIO interact with the physical world.
441
444
445
+
### GPIO Config
446
+
442
447
ST33 supports 6 modes, information from `gpio/gpio_config` below:
443
-
```
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,77 +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
-
NPCT75x supports 3 output modes, information from `gpio/gpio_nuvoton` below:
465
+
Example usage for configuring a GPIO to output can be found below:
462
466
463
467
```
464
-
xpected usage:
465
-
./examples/gpio/gpio_config [num] [mode]
466
-
* num is a GPIO number between 3 and 4 (default 3)
467
-
* mode is either push-pull, open-drain or open-drain with pull-up
468
-
1. pushpull - output in push pull configuration
469
-
2. opendrain - output in open drain configuration
470
-
3. pullup - output in open drain with pull-up enabled
471
-
4. unconfig - delete NV index for GPIO access
472
-
Example usage, without parameters, configures GPIO3 as push-pull output.
468
+
$ ./examples/gpio/gpio_config 0 5
469
+
GPIO num is: 0
470
+
GPIO mode is: 5
471
+
Example how to use extra GPIO on a TPM 2.0 modules
472
+
Trying to configure GPIO0...
473
+
TPM2_GPIO_Config success
474
+
NV Index for GPIO access created
473
475
```
474
476
475
-
Please note that NPCT75x GPIO numbering starts from GPIO3, while ST33 starts from GPIO0.
476
-
477
-
Example usage for configuring a GPIO to output can be found below:
477
+
Example usage for configuring a GPIO as input with a pull-up on ST33 can be found below:
478
478
479
-
- ST33
480
479
```
481
-
482
-
$ ./examples/gpio/gpio_config
480
+
$ ./examples/gpio/gpio_config 0 3
483
481
GPIO num is: 0
484
-
GPIO mode is: 5
485
-
Example how to use extra GPIO on a TPM 2.0 modules
486
-
wolfTPM2_Init: success
482
+
GPIO mode is: 3
483
+
Demo how to use extra GPIO on a TPM 2.0 modules
487
484
Trying to configure GPIO0...
488
485
TPM2_GPIO_Config success
489
486
NV Index for GPIO access created
487
+
```
490
488
491
-
$ ./examples/gpio/gpio_set
492
-
GPIO0 set to high level
489
+
### GPIO Config (NPCT75xx)
490
+
491
+
NPCT75x supports 3 output modes, information from `gpio/gpio_nuvoton` below:
493
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.
494
504
```
495
505
496
-
- NPCT75xx
506
+
Please note that NPCT75x GPIO numbering starts from GPIO3, while ST33 starts from GPIO0.
Example for GPIO configuration of a NPTC7xx TPM 2.0 module
501
511
GPIO number: 4
502
512
GPIO mode: 1
503
-
wolfTPM2_Init: success
504
-
First, the current NPCT7xx config will be read
505
-
then modified with the new GPIO configuration
506
-
Successfully read the current NPCT7xx configuration
507
-
NTC2_PreConfig success
513
+
Successfully read the current configuration
514
+
Successfully wrote new configuration
508
515
NV Index for GPIO access created
509
516
```
510
517
511
-
Switching a GPIO configuration is seamless. Because for ST33 `gpio/gpio_config` takes care of deleting existing NV Index, so a new GPIO configuration can be chosen. And for NPCT75xx `gpio/gpio_nuvoton` can reconfigure any GPIO without deleteing the creating NV index.
518
+
### GPIO Usage
512
519
513
-
Example usage for configuring a GPIO as input with a pull-up on ST33 can be found below:
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.
514
523
515
524
```
525
+
$ ./examples/gpio/gpio_set 0 -high
526
+
GPIO0 set to high level
516
527
517
-
$ ./examples/gpio/gpio_config 0 3
518
-
GPIO num is: 0
519
-
GPIO mode is: 3
520
-
Demo how to use extra GPIO on a TPM 2.0 modules
521
-
wolfTPM2_Init: success
522
-
Trying to configure GPIO0...
523
-
TPM2_GPIO_Config success
524
-
NV Index for GPIO access created
528
+
$ ./examples/gpio/gpio_set 0 -low
529
+
GPIO0 set to low level
530
+
```
525
531
532
+
```
526
533
$ ./examples/gpio/gpio_read 0
527
534
GPIO0 is Low
528
-
529
535
```
530
536
537
+
538
+
## Support
539
+
531
540
If you need more information about using these examples please contact us at support@wolfssl.com
0 commit comments